~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/tools/testing/selftests/bpf/test_bpftool_metadata.sh

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /tools/testing/selftests/bpf/test_bpftool_metadata.sh (Architecture i386) and /tools/testing/selftests/bpf/test_bpftool_metadata.sh (Architecture sparc64)


  1 #!/bin/sh                                           1 #!/bin/sh
  2 # SPDX-License-Identifier: GPL-2.0                  2 # SPDX-License-Identifier: GPL-2.0
  3                                                     3 
  4 # Kselftest framework requirement - SKIP code       4 # Kselftest framework requirement - SKIP code is 4.
  5 ksft_skip=4                                         5 ksft_skip=4
  6                                                     6 
  7 BPF_FILE_USED="metadata_used.bpf.o"                 7 BPF_FILE_USED="metadata_used.bpf.o"
  8 BPF_FILE_UNUSED="metadata_unused.bpf.o"             8 BPF_FILE_UNUSED="metadata_unused.bpf.o"
  9                                                     9 
 10 TESTNAME=bpftool_metadata                          10 TESTNAME=bpftool_metadata
 11 BPF_FS=$(awk '$3 == "bpf" {print $2; exit}' /p     11 BPF_FS=$(awk '$3 == "bpf" {print $2; exit}' /proc/mounts)
 12 BPF_DIR=$BPF_FS/test_$TESTNAME                     12 BPF_DIR=$BPF_FS/test_$TESTNAME
 13                                                    13 
 14 _cleanup()                                         14 _cleanup()
 15 {                                                  15 {
 16         set +e                                     16         set +e
 17         rm -rf $BPF_DIR 2> /dev/null               17         rm -rf $BPF_DIR 2> /dev/null
 18 }                                                  18 }
 19                                                    19 
 20 cleanup_skip()                                     20 cleanup_skip()
 21 {                                                  21 {
 22         echo "selftests: $TESTNAME [SKIP]"         22         echo "selftests: $TESTNAME [SKIP]"
 23         _cleanup                                   23         _cleanup
 24                                                    24 
 25         exit $ksft_skip                            25         exit $ksft_skip
 26 }                                                  26 }
 27                                                    27 
 28 cleanup()                                          28 cleanup()
 29 {                                                  29 {
 30         if [ "$?" = 0 ]; then                      30         if [ "$?" = 0 ]; then
 31                 echo "selftests: $TESTNAME [PA     31                 echo "selftests: $TESTNAME [PASS]"
 32         else                                       32         else
 33                 echo "selftests: $TESTNAME [FA     33                 echo "selftests: $TESTNAME [FAILED]"
 34         fi                                         34         fi
 35         _cleanup                                   35         _cleanup
 36 }                                                  36 }
 37                                                    37 
 38 if [ $(id -u) -ne 0 ]; then                        38 if [ $(id -u) -ne 0 ]; then
 39         echo "selftests: $TESTNAME [SKIP] Need     39         echo "selftests: $TESTNAME [SKIP] Need root privileges"
 40         exit $ksft_skip                            40         exit $ksft_skip
 41 fi                                                 41 fi
 42                                                    42 
 43 if [ -z "$BPF_FS" ]; then                          43 if [ -z "$BPF_FS" ]; then
 44         echo "selftests: $TESTNAME [SKIP] Coul     44         echo "selftests: $TESTNAME [SKIP] Could not run test without bpffs mounted"
 45         exit $ksft_skip                            45         exit $ksft_skip
 46 fi                                                 46 fi
 47                                                    47 
 48 if ! bpftool version > /dev/null 2>&1; then        48 if ! bpftool version > /dev/null 2>&1; then
 49         echo "selftests: $TESTNAME [SKIP] Coul     49         echo "selftests: $TESTNAME [SKIP] Could not run test without bpftool"
 50         exit $ksft_skip                            50         exit $ksft_skip
 51 fi                                                 51 fi
 52                                                    52 
 53 set -e                                             53 set -e
 54                                                    54 
 55 trap cleanup_skip EXIT                             55 trap cleanup_skip EXIT
 56                                                    56 
 57 mkdir $BPF_DIR                                     57 mkdir $BPF_DIR
 58                                                    58 
 59 trap cleanup EXIT                                  59 trap cleanup EXIT
 60                                                    60 
 61 bpftool prog load $BPF_FILE_UNUSED $BPF_DIR/un     61 bpftool prog load $BPF_FILE_UNUSED $BPF_DIR/unused
 62                                                    62 
 63 METADATA_PLAIN="$(bpftool prog)"                   63 METADATA_PLAIN="$(bpftool prog)"
 64 echo "$METADATA_PLAIN" | grep 'a = "foo"' > /d     64 echo "$METADATA_PLAIN" | grep 'a = "foo"' > /dev/null
 65 echo "$METADATA_PLAIN" | grep 'b = 1' > /dev/n     65 echo "$METADATA_PLAIN" | grep 'b = 1' > /dev/null
 66                                                    66 
 67 bpftool prog --json | grep '"metadata":{"a":"f     67 bpftool prog --json | grep '"metadata":{"a":"foo","b":1}' > /dev/null
 68                                                    68 
 69 bpftool map | grep 'metadata.rodata' > /dev/nu     69 bpftool map | grep 'metadata.rodata' > /dev/null
 70                                                    70 
 71 rm $BPF_DIR/unused                                 71 rm $BPF_DIR/unused
 72                                                    72 
 73 bpftool prog load $BPF_FILE_USED $BPF_DIR/used     73 bpftool prog load $BPF_FILE_USED $BPF_DIR/used
 74                                                    74 
 75 METADATA_PLAIN="$(bpftool prog)"                   75 METADATA_PLAIN="$(bpftool prog)"
 76 echo "$METADATA_PLAIN" | grep 'a = "bar"' > /d     76 echo "$METADATA_PLAIN" | grep 'a = "bar"' > /dev/null
 77 echo "$METADATA_PLAIN" | grep 'b = 2' > /dev/n     77 echo "$METADATA_PLAIN" | grep 'b = 2' > /dev/null
 78                                                    78 
 79 bpftool prog --json | grep '"metadata":{"a":"b     79 bpftool prog --json | grep '"metadata":{"a":"bar","b":2}' > /dev/null
 80                                                    80 
 81 bpftool map | grep 'metadata.rodata' > /dev/nu     81 bpftool map | grep 'metadata.rodata' > /dev/null
 82                                                    82 
 83 rm $BPF_DIR/used                                   83 rm $BPF_DIR/used
 84                                                    84 
 85 exit 0                                             85 exit 0
                                                      

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php