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

TOMOYO Linux Cross Reference
Linux/tools/bootconfig/test-bootconfig.sh

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ 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.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /tools/bootconfig/test-bootconfig.sh (Architecture m68k) and /tools/bootconfig/test-bootconfig.sh (Architecture alpha)


  1 #!/bin/sh                                           1 #!/bin/sh
  2 # SPDX-License-Identifier: GPL-2.0-only             2 # SPDX-License-Identifier: GPL-2.0-only
  3                                                     3 
  4 echo "Boot config test script"                      4 echo "Boot config test script"
  5                                                     5 
  6 if [ -d "$1" ]; then                                6 if [ -d "$1" ]; then
  7   TESTDIR=$1                                        7   TESTDIR=$1
  8 else                                                8 else
  9   TESTDIR=.                                         9   TESTDIR=.
 10 fi                                                 10 fi
 11 BOOTCONF=${TESTDIR}/bootconfig                     11 BOOTCONF=${TESTDIR}/bootconfig
 12 ALIGN=4                                            12 ALIGN=4
 13                                                    13 
 14 INITRD=`mktemp ${TESTDIR}/initrd-XXXX`             14 INITRD=`mktemp ${TESTDIR}/initrd-XXXX`
 15 TEMPCONF=`mktemp ${TESTDIR}/temp-XXXX.bconf`       15 TEMPCONF=`mktemp ${TESTDIR}/temp-XXXX.bconf`
 16 OUTFILE=`mktemp ${TESTDIR}/tempout-XXXX`           16 OUTFILE=`mktemp ${TESTDIR}/tempout-XXXX`
 17 NG=0                                               17 NG=0
 18                                                    18 
 19 cleanup() {                                        19 cleanup() {
 20   rm -f $INITRD $TEMPCONF $OUTFILE                 20   rm -f $INITRD $TEMPCONF $OUTFILE
 21   exit $NG                                         21   exit $NG
 22 }                                                  22 }
 23                                                    23 
 24 trap cleanup EXIT TERM                             24 trap cleanup EXIT TERM
 25                                                    25 
 26 NO=1                                               26 NO=1
 27                                                    27 
 28 xpass() { # pass test command                      28 xpass() { # pass test command
 29   echo "test case $NO ($*)... "                    29   echo "test case $NO ($*)... "
 30   if ! ($@ && echo "\t\t[OK]"); then               30   if ! ($@ && echo "\t\t[OK]"); then
 31      echo "\t\t[NG]"; NG=$((NG + 1))               31      echo "\t\t[NG]"; NG=$((NG + 1))
 32   fi                                               32   fi
 33   NO=$((NO + 1))                                   33   NO=$((NO + 1))
 34 }                                                  34 }
 35                                                    35 
 36 xfail() { # fail test command                      36 xfail() { # fail test command
 37   echo "test case $NO ($*)... "                    37   echo "test case $NO ($*)... "
 38   if ! (! $@ && echo "\t\t[OK]"); then             38   if ! (! $@ && echo "\t\t[OK]"); then
 39      echo "\t\t[NG]"; NG=$((NG + 1))               39      echo "\t\t[NG]"; NG=$((NG + 1))
 40   fi                                               40   fi
 41   NO=$((NO + 1))                                   41   NO=$((NO + 1))
 42 }                                                  42 }
 43                                                    43 
 44 echo "Basic command test"                          44 echo "Basic command test"
 45 xpass $BOOTCONF $INITRD                            45 xpass $BOOTCONF $INITRD
 46                                                    46 
 47 echo "Delete command should success without bo     47 echo "Delete command should success without bootconfig"
 48 xpass $BOOTCONF -d $INITRD                         48 xpass $BOOTCONF -d $INITRD
 49                                                    49 
 50 dd if=/dev/zero of=$INITRD bs=4096 count=1         50 dd if=/dev/zero of=$INITRD bs=4096 count=1
 51 echo "key = value;" > $TEMPCONF                    51 echo "key = value;" > $TEMPCONF
 52 bconf_size=$(stat -c %s $TEMPCONF)                 52 bconf_size=$(stat -c %s $TEMPCONF)
 53 initrd_size=$(stat -c %s $INITRD)                  53 initrd_size=$(stat -c %s $INITRD)
 54                                                    54 
 55 echo "Apply command test"                          55 echo "Apply command test"
 56 xpass $BOOTCONF -a $TEMPCONF $INITRD               56 xpass $BOOTCONF -a $TEMPCONF $INITRD
 57 new_size=$(stat -c %s $INITRD)                     57 new_size=$(stat -c %s $INITRD)
 58                                                    58 
 59 echo "Show command test"                           59 echo "Show command test"
 60 xpass $BOOTCONF $INITRD                            60 xpass $BOOTCONF $INITRD
 61                                                    61 
 62 echo "File size check"                             62 echo "File size check"
 63 total_size=$(expr $bconf_size + $initrd_size +     63 total_size=$(expr $bconf_size + $initrd_size + 9 + 12 + $ALIGN - 1 )
 64 total_size=$(expr $total_size / $ALIGN)            64 total_size=$(expr $total_size / $ALIGN)
 65 total_size=$(expr $total_size \* $ALIGN)           65 total_size=$(expr $total_size \* $ALIGN)
 66 xpass test $new_size -eq $total_size               66 xpass test $new_size -eq $total_size
 67                                                    67 
 68 echo "Apply command repeat test"                   68 echo "Apply command repeat test"
 69 xpass $BOOTCONF -a $TEMPCONF $INITRD               69 xpass $BOOTCONF -a $TEMPCONF $INITRD
 70                                                    70 
 71 echo "File size check"                             71 echo "File size check"
 72 xpass test $new_size -eq $(stat -c %s $INITRD)     72 xpass test $new_size -eq $(stat -c %s $INITRD)
 73                                                    73 
 74 echo "Delete command check"                        74 echo "Delete command check"
 75 xpass $BOOTCONF -d $INITRD                         75 xpass $BOOTCONF -d $INITRD
 76                                                    76 
 77 echo "File size check"                             77 echo "File size check"
 78 new_size=$(stat -c %s $INITRD)                     78 new_size=$(stat -c %s $INITRD)
 79 xpass test $new_size -eq $initrd_size              79 xpass test $new_size -eq $initrd_size
 80                                                    80 
 81 echo "No error messge while applying"              81 echo "No error messge while applying"
 82 dd if=/dev/zero of=$INITRD bs=4096 count=1         82 dd if=/dev/zero of=$INITRD bs=4096 count=1
 83 printf " \0\0\0 \0\0\0" >> $INITRD                 83 printf " \0\0\0 \0\0\0" >> $INITRD
 84 $BOOTCONF -a $TEMPCONF $INITRD > $OUTFILE 2>&1     84 $BOOTCONF -a $TEMPCONF $INITRD > $OUTFILE 2>&1
 85 xfail grep -i "failed" $OUTFILE                    85 xfail grep -i "failed" $OUTFILE
 86 xfail grep -i "error" $OUTFILE                     86 xfail grep -i "error" $OUTFILE
 87                                                    87 
 88 echo "Max node number check"                       88 echo "Max node number check"
 89                                                    89 
 90 awk '                                              90 awk '
 91 BEGIN {                                            91 BEGIN {
 92   for (i = 0; i < 26; i += 1)                      92   for (i = 0; i < 26; i += 1)
 93       printf("%c\n", 65 + i % 26)                  93       printf("%c\n", 65 + i % 26)
 94   for (i = 26; i < 8192; i += 1)                   94   for (i = 26; i < 8192; i += 1)
 95       printf("%c%c%c\n", 65 + i % 26, 65 + (i      95       printf("%c%c%c\n", 65 + i % 26, 65 + (i / 26) % 26, 65 + (i / 26 / 26))
 96 }                                                  96 }
 97 ' > $TEMPCONF                                      97 ' > $TEMPCONF
 98 xpass $BOOTCONF -a $TEMPCONF $INITRD               98 xpass $BOOTCONF -a $TEMPCONF $INITRD
 99                                                    99 
100 echo "badnode" >> $TEMPCONF                       100 echo "badnode" >> $TEMPCONF
101 xfail $BOOTCONF -a $TEMPCONF $INITRD              101 xfail $BOOTCONF -a $TEMPCONF $INITRD
102                                                   102 
103 echo "Max filesize check"                         103 echo "Max filesize check"
104                                                   104 
105 # Max size is 32767 (including terminal byte)     105 # Max size is 32767 (including terminal byte)
106 echo -n "data = \"" > $TEMPCONF                   106 echo -n "data = \"" > $TEMPCONF
107 dd if=/dev/urandom bs=768 count=32 | base64 -w    107 dd if=/dev/urandom bs=768 count=32 | base64 -w0 >> $TEMPCONF
108 echo "\"" >> $TEMPCONF                            108 echo "\"" >> $TEMPCONF
109 xfail $BOOTCONF -a $TEMPCONF $INITRD              109 xfail $BOOTCONF -a $TEMPCONF $INITRD
110                                                   110 
111 truncate -s 32764 $TEMPCONF                       111 truncate -s 32764 $TEMPCONF
112 echo "\"" >> $TEMPCONF  # add 2 bytes + termin    112 echo "\"" >> $TEMPCONF  # add 2 bytes + terminal ('\"\n\0')
113 xpass $BOOTCONF -a $TEMPCONF $INITRD              113 xpass $BOOTCONF -a $TEMPCONF $INITRD
114                                                   114 
115 echo "Adding same-key values"                     115 echo "Adding same-key values"
116 cat > $TEMPCONF << EOF                            116 cat > $TEMPCONF << EOF
117 key = bar, baz                                    117 key = bar, baz
118 key += qux                                        118 key += qux
119 EOF                                               119 EOF
120 echo > $INITRD                                    120 echo > $INITRD
121                                                   121 
122 xpass $BOOTCONF -a $TEMPCONF $INITRD              122 xpass $BOOTCONF -a $TEMPCONF $INITRD
123 $BOOTCONF $INITRD > $OUTFILE                      123 $BOOTCONF $INITRD > $OUTFILE
124 xpass grep -q "bar" $OUTFILE                      124 xpass grep -q "bar" $OUTFILE
125 xpass grep -q "baz" $OUTFILE                      125 xpass grep -q "baz" $OUTFILE
126 xpass grep -q "qux" $OUTFILE                      126 xpass grep -q "qux" $OUTFILE
127                                                   127 
128 echo "Override same-key values"                   128 echo "Override same-key values"
129 cat > $TEMPCONF << EOF                            129 cat > $TEMPCONF << EOF
130 key = bar, baz                                    130 key = bar, baz
131 key := qux                                        131 key := qux
132 EOF                                               132 EOF
133 echo > $INITRD                                    133 echo > $INITRD
134                                                   134 
135 xpass $BOOTCONF -a $TEMPCONF $INITRD              135 xpass $BOOTCONF -a $TEMPCONF $INITRD
136 $BOOTCONF $INITRD > $OUTFILE                      136 $BOOTCONF $INITRD > $OUTFILE
137 xfail grep -q "bar" $OUTFILE                      137 xfail grep -q "bar" $OUTFILE
138 xfail grep -q "baz" $OUTFILE                      138 xfail grep -q "baz" $OUTFILE
139 xpass grep -q "qux" $OUTFILE                      139 xpass grep -q "qux" $OUTFILE
140                                                   140 
141 echo "Double/single quotes test"                  141 echo "Double/single quotes test"
142 echo "key = '\"string\"';" > $TEMPCONF            142 echo "key = '\"string\"';" > $TEMPCONF
143 $BOOTCONF -a $TEMPCONF $INITRD                    143 $BOOTCONF -a $TEMPCONF $INITRD
144 $BOOTCONF $INITRD > $TEMPCONF                     144 $BOOTCONF $INITRD > $TEMPCONF
145 cat $TEMPCONF                                     145 cat $TEMPCONF
146 xpass grep \'\"string\"\' $TEMPCONF               146 xpass grep \'\"string\"\' $TEMPCONF
147                                                   147 
148 echo "Repeat same-key tree"                       148 echo "Repeat same-key tree"
149 cat > $TEMPCONF << EOF                            149 cat > $TEMPCONF << EOF
150 foo                                               150 foo
151 bar                                               151 bar
152 foo { buz }                                       152 foo { buz }
153 EOF                                               153 EOF
154 echo > $INITRD                                    154 echo > $INITRD
155                                                   155 
156 xpass $BOOTCONF -a $TEMPCONF $INITRD              156 xpass $BOOTCONF -a $TEMPCONF $INITRD
157 $BOOTCONF $INITRD > $OUTFILE                      157 $BOOTCONF $INITRD > $OUTFILE
158 xpass grep -q "bar" $OUTFILE                      158 xpass grep -q "bar" $OUTFILE
159                                                   159 
160                                                   160 
161 echo "Remove/keep tailing spaces"                 161 echo "Remove/keep tailing spaces"
162 cat > $TEMPCONF << EOF                            162 cat > $TEMPCONF << EOF
163 foo = val     # comment                           163 foo = val     # comment
164 bar = "val2 " # comment                           164 bar = "val2 " # comment
165 EOF                                               165 EOF
166 echo > $INITRD                                    166 echo > $INITRD
167                                                   167 
168 xpass $BOOTCONF -a $TEMPCONF $INITRD              168 xpass $BOOTCONF -a $TEMPCONF $INITRD
169 $BOOTCONF $INITRD > $OUTFILE                      169 $BOOTCONF $INITRD > $OUTFILE
170 xfail grep -q val[[:space:]] $OUTFILE             170 xfail grep -q val[[:space:]] $OUTFILE
171 xpass grep -q val2[[:space:]] $OUTFILE            171 xpass grep -q val2[[:space:]] $OUTFILE
172                                                   172 
173 echo "=== expected failure cases ==="             173 echo "=== expected failure cases ==="
174 for i in samples/bad-* ; do                       174 for i in samples/bad-* ; do
175   xfail $BOOTCONF -a $i $INITRD                   175   xfail $BOOTCONF -a $i $INITRD
176 done                                              176 done
177                                                   177 
178 echo "=== expected success cases ==="             178 echo "=== expected success cases ==="
179 for i in samples/good-* ; do                      179 for i in samples/good-* ; do
180   xpass $BOOTCONF -a $i $INITRD                   180   xpass $BOOTCONF -a $i $INITRD
181 done                                              181 done
182                                                   182 
183                                                   183 
184 echo                                              184 echo
185 echo "=== Summary ==="                            185 echo "=== Summary ==="
186 echo "# of Passed: $(expr $NO - $NG - 1)"         186 echo "# of Passed: $(expr $NO - $NG - 1)"
187 echo "# of Failed: $NG"                           187 echo "# of Failed: $NG"
188                                                   188 
189 echo                                              189 echo
190 if [ $NG -eq 0 ]; then                            190 if [ $NG -eq 0 ]; then
191         echo "All tests passed"                   191         echo "All tests passed"
192 else                                              192 else
193         echo "$NG tests failed"                   193         echo "$NG tests failed"
194         exit 1                                    194         exit 1
195 fi                                                195 fi
                                                      

~ [ 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