mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-14 15:54:15 +08:00
selftests, bpftool: Set EXIT trap after usage function
The trap on EXIT is used to clean up any temporary directory left by the build attempts. It is not needed when the user simply calls the script with its --help option, and may not be needed either if we add checks (e.g. on the availability of bpftool files) before the build attempts. Let's move this trap and related variables lower down in the code, so that we don't accidentally change the value returned from the script on early exits at pre-checks. Signed-off-by: Quentin Monnet <quentin.monnet@netronome.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Reviewed-by: Jakub Kicinski <jakub.kicinski@netronome.com> Link: https://lore.kernel.org/bpf/20191119105010.19189-2-quentin.monnet@netronome.com
This commit is contained in:
parent
a89b2cbf71
commit
31f8b8295b
@ -1,6 +1,26 @@
|
||||
#!/bin/bash
|
||||
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
|
||||
|
||||
case $1 in
|
||||
-h|--help)
|
||||
echo -e "$0 [-j <n>]"
|
||||
echo -e "\tTest the different ways of building bpftool."
|
||||
echo -e ""
|
||||
echo -e "\tOptions:"
|
||||
echo -e "\t\t-j <n>:\tPass -j flag to 'make'."
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
|
||||
J=$*
|
||||
|
||||
# Assume script is located under tools/testing/selftests/bpf/. We want to start
|
||||
# build attempts from the top of kernel repository.
|
||||
SCRIPT_REL_PATH=$(realpath --relative-to=$PWD $0)
|
||||
SCRIPT_REL_DIR=$(dirname $SCRIPT_REL_PATH)
|
||||
KDIR_ROOT_DIR=$(realpath $PWD/$SCRIPT_REL_DIR/../../../../)
|
||||
cd $KDIR_ROOT_DIR
|
||||
|
||||
ERROR=0
|
||||
TMPDIR=
|
||||
|
||||
@ -13,26 +33,6 @@ return_value() {
|
||||
}
|
||||
trap return_value EXIT
|
||||
|
||||
case $1 in
|
||||
-h|--help)
|
||||
echo -e "$0 [-j <n>]"
|
||||
echo -e "\tTest the different ways of building bpftool."
|
||||
echo -e ""
|
||||
echo -e "\tOptions:"
|
||||
echo -e "\t\t-j <n>:\tPass -j flag to 'make'."
|
||||
exit
|
||||
;;
|
||||
esac
|
||||
|
||||
J=$*
|
||||
|
||||
# Assume script is located under tools/testing/selftests/bpf/. We want to start
|
||||
# build attempts from the top of kernel repository.
|
||||
SCRIPT_REL_PATH=$(realpath --relative-to=$PWD $0)
|
||||
SCRIPT_REL_DIR=$(dirname $SCRIPT_REL_PATH)
|
||||
KDIR_ROOT_DIR=$(realpath $PWD/$SCRIPT_REL_DIR/../../../../)
|
||||
cd $KDIR_ROOT_DIR
|
||||
|
||||
check() {
|
||||
local dir=$(realpath $1)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user