Debian Codegraph @

tests/ts/lsfd/mkfds-bpf-prog

raw
1 #!/bin/bash
2 #
3 # Copyright (C) 2023 Masatake YAMATO <[email protected]>
4 #
5 # This file is part of util-linux.
6 #
7 # This file is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
11 #
12 # This file is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
16 #
17 TS_TOPDIR="${0%/*}/../.."
18 TS_DESC="bpf-prog files"
19
20 . "$TS_TOPDIR"/functions.sh
21 ts_init "$*"
22 ts_skip_nonroot
23 ts_skip_docker
24
25 . "$TS_SELF/lsfd-functions.bash"
26 ts_check_test_command "$TS_CMD_LSFD"
27 ts_check_test_command "$TS_HELPER_MKFDS"
28
29 ts_cd "$TS_OUTDIR"
30
31 PID=
32 ID=
33 TAG=
34 FD=3
35 NAME=mkdfs_prog
36 RC=
37
38 {
39 coproc MKFDS { "$TS_HELPER_MKFDS" bpf-prog "$FD" prog-type-id=2 name="$NAME"; }
40 if read -r -u "${MKFDS[0]}" PID ID TAG; then
41 "${TS_CMD_LSFD}" -r -n -oBPF-PROG.TYPE,BPF-PROG.TYPE.RAW,BPF.NAME -p "${PID}" -Q "(FD == $FD)"
42 echo "BPF-PROG.TYPE,BPF-PROG.TYPE.RAW,BPF.NAME": $?
43
44 ID_0=$("${TS_CMD_LSFD}" -r -n -oBPF-PROG.ID -p "${PID}" -Q "(FD == $FD)")
45 if [[ "${ID_0}" == "${ID}" ]]; then
46 echo "comparing ids": OK
47 else
48 echo "comparing ids": FAILED "ID_0:${ID_0} == ID:${ID}"
49 fi
50
51 TAG_0=$("${TS_CMD_LSFD}" -r -n -oBPF-PROG.TAG -p "${PID}" -Q "(FD == $FD)")
52 if [[ "${TAG_0}" == "${TAG}" ]]; then
53 echo "comparing tags": OK
54 else
55 echo "comparing tags": FAILED "TAG_0:${TAG_0} == TAG:${TAG}"
56 fi
57
58 echo DONE >&"${MKFDS[1]}"
59 fi
60 wait "${MKFDS_PID}"
61 RC=$?
62 } > "$TS_OUTPUT" 2>&1
63
64 if [ "$RC" == "$TS_EXIT_NOTSUPP" ]; then
65 ts_skip "bpf(2) is not available"
66 fi
67
68 ts_finalize