forked from aya-rs/aya-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.sh
executable file
·57 lines (52 loc) · 1.34 KB
/
test.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/bin/bash
set -ex
TEMPLATE_DIR=$1
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
TMP_DIR=$(mktemp -d)
clean_up() {
rm -rf "${TMP_DIR}"
}
trap clean_up EXIT
pushd $TMP_DIR
case "$PROG_TYPE" in
"cgroup_sockopt")
ADDITIONAL_ARGS="-d sockopt_target=getsockopt"
;;
"classifier"|"cgroup_skb")
ADDITIONAL_ARGS="-d direction=Ingress"
;;
"fentry"|"fexit")
ADDITIONAL_ARGS="-d fn_name=try_to_wake_up"
;;
"kprobe"|"kretprobe")
ADDITIONAL_ARGS="-d kprobe=test"
;;
"lsm")
ADDITIONAL_ARGS="-d lsm_hook=file_open"
;;
"raw_tracepoint")
ADDITIONAL_ARGS="-d tracepoint_name=sys_enter"
;;
"sk_msg")
ADDITIONAL_ARGS="-d sock_map=TEST"
;;
"tp_btf")
ADDITIONAL_ARGS="-d tracepoint_name=net_dev_queue"
;;
"tracepoint")
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=''
esac
cargo generate --path "${TEMPLATE_DIR}" -n test -d program_type="${PROG_TYPE}" ${ADDITIONAL_ARGS}
pushd test
cargo xtask build-ebpf
cargo build
popd
exit 0