2018-02-08 18:48:27 +07:00
|
|
|
#!/bin/sh
|
|
|
|
# SPDX-License-Identifier: GPL-2.0
|
|
|
|
|
|
|
|
export TESTNAME=test_libbpf
|
|
|
|
|
|
|
|
# Determine selftest success via shell exit code
|
|
|
|
exit_handler()
|
|
|
|
{
|
2018-10-21 04:58:44 +07:00
|
|
|
if [ $? -eq 0 ]; then
|
2018-02-08 18:48:27 +07:00
|
|
|
echo "selftests: $TESTNAME [PASS]";
|
|
|
|
else
|
|
|
|
echo "$TESTNAME: failed at file $LAST_LOADED" 1>&2
|
|
|
|
echo "selftests: $TESTNAME [FAILED]";
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
libbpf_open_file()
|
|
|
|
{
|
|
|
|
LAST_LOADED=$1
|
|
|
|
if [ -n "$VERBOSE" ]; then
|
|
|
|
./test_libbpf_open $1
|
|
|
|
else
|
|
|
|
./test_libbpf_open --quiet $1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
# Exit script immediately (well catched by trap handler) if any
|
|
|
|
# program/thing exits with a non-zero status.
|
|
|
|
set -e
|
|
|
|
|
|
|
|
# (Use 'trap -l' to list meaning of numbers)
|
|
|
|
trap exit_handler 0 2 3 6 9
|
|
|
|
|
|
|
|
libbpf_open_file test_l4lb.o
|
|
|
|
|
2018-11-07 19:28:45 +07:00
|
|
|
# Load a program with BPF-to-BPF calls
|
|
|
|
libbpf_open_file test_l4lb_noinline.o
|
2018-02-08 18:48:27 +07:00
|
|
|
|
2018-11-07 19:28:45 +07:00
|
|
|
# Load a program compiled without the "-target bpf" flag
|
|
|
|
libbpf_open_file test_xdp.o
|
2018-02-08 18:48:27 +07:00
|
|
|
|
|
|
|
# Success
|
|
|
|
exit 0
|