Skip to content

Commit

Permalink
Appease shellcheck
Browse files Browse the repository at this point in the history
  • Loading branch information
tamird committed Oct 11, 2024
1 parent 5d645df commit 9661423
Showing 1 changed file with 17 additions and 16 deletions.
33 changes: 17 additions & 16 deletions test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,53 +3,54 @@
set -ex

TEMPLATE_DIR=$1
if [ -z "$TEMPLATE_DIR" ]; then echo "template dir required"; exit 1; fi
if [ -z "${TEMPLATE_DIR}" ]; then echo "template dir required"; exit 1; fi
PROG_TYPE=$2
if [ -z "$PROG_TYPE" ]; then echo "program type required"; exit 1; fi
if [ -z "${PROG_TYPE}" ]; then echo "program type required"; exit 1; fi

TMP_DIR=$(mktemp -d)
clean_up() {
# shellcheck disable=SC2317
rm -rf "${TMP_DIR}"
}
trap clean_up EXIT

pushd $TMP_DIR
case "$PROG_TYPE" in
pushd "${TMP_DIR}"
case "${PROG_TYPE}" in
"cgroup_sockopt")
ADDITIONAL_ARGS="-d sockopt_target=getsockopt"
ADDITIONAL_ARGS=(-d sockopt_target=getsockopt)
;;
"classifier"|"cgroup_skb")
ADDITIONAL_ARGS="-d direction=Ingress"
ADDITIONAL_ARGS=(-d direction=Ingress)
;;
"fentry"|"fexit")
ADDITIONAL_ARGS="-d fn_name=try_to_wake_up"
ADDITIONAL_ARGS=(-d fn_name=try_to_wake_up)
;;
"kprobe"|"kretprobe")
ADDITIONAL_ARGS="-d kprobe=test"
ADDITIONAL_ARGS=(-d kprobe=test)
;;
"lsm")
ADDITIONAL_ARGS="-d lsm_hook=file_open"
ADDITIONAL_ARGS=(-d lsm_hook=file_open)
;;
"raw_tracepoint")
ADDITIONAL_ARGS="-d tracepoint_name=sys_enter"
ADDITIONAL_ARGS=(-d tracepoint_name=sys_enter)
;;
"sk_msg")
ADDITIONAL_ARGS="-d sock_map=SOCK_MAP"
ADDITIONAL_ARGS=(-d sock_map=SOCK_MAP)
;;
"tp_btf")
ADDITIONAL_ARGS="-d tracepoint_name=net_dev_queue"
ADDITIONAL_ARGS=(-d tracepoint_name=net_dev_queue)
;;
"tracepoint")
ADDITIONAL_ARGS="-d tracepoint_category=net -d tracepoint_name=net_dev_queue"
ADDITIONAL_ARGS=(-d tracepoint_category=net -d tracepoint_name=net_dev_queue)
;;
"uprobe"|"uretprobe")
ADDITIONAL_ARGS="-d uprobe_target=testlib -d uprobe_fn_name=testfn"
ADDITIONAL_ARGS=(-d uprobe_target=testlib -d uprobe_fn_name=testfn)
;;
*)
ADDITIONAL_ARGS=''
ADDITIONAL_ARGS=()
esac

cargo generate --path "${TEMPLATE_DIR}" -n test -d program_type="${PROG_TYPE}" ${ADDITIONAL_ARGS}
cargo generate --path "${TEMPLATE_DIR}" -n test -d program_type="${PROG_TYPE}" "${ADDITIONAL_ARGS[@]}"
pushd test
cargo +nightly fmt --all -- --check
cargo build --package test
Expand Down

0 comments on commit 9661423

Please sign in to comment.