Staging: remove wusbcore and UWB from the kernel tree.
[linux/fpc-iii.git] / tools / bootconfig / test-bootconfig.sh
blob87725e8723f87c74f5f1b5340f2e08ce47b3e160
1 #!/bin/sh
2 # SPDX-License-Identifier: GPL-2.0-only
4 echo "Boot config test script"
6 BOOTCONF=./bootconfig
7 INITRD=`mktemp initrd-XXXX`
8 TEMPCONF=`mktemp temp-XXXX.bconf`
9 NG=0
11 cleanup() {
12 rm -f $INITRD $TEMPCONF
13 exit $NG
16 trap cleanup EXIT TERM
18 NO=1
20 xpass() { # pass test command
21 echo "test case $NO ($3)... "
22 if ! ($@ && echo "\t\t[OK]"); then
23 echo "\t\t[NG]"; NG=$((NG + 1))
25 NO=$((NO + 1))
28 xfail() { # fail test command
29 echo "test case $NO ($3)... "
30 if ! (! $@ && echo "\t\t[OK]"); then
31 echo "\t\t[NG]"; NG=$((NG + 1))
33 NO=$((NO + 1))
36 echo "Basic command test"
37 xpass $BOOTCONF $INITRD
39 echo "Delete command should success without bootconfig"
40 xpass $BOOTCONF -d $INITRD
42 dd if=/dev/zero of=$INITRD bs=4096 count=1
43 echo "key = value;" > $TEMPCONF
44 bconf_size=$(stat -c %s $TEMPCONF)
45 initrd_size=$(stat -c %s $INITRD)
47 echo "Apply command test"
48 xpass $BOOTCONF -a $TEMPCONF $INITRD
49 new_size=$(stat -c %s $INITRD)
51 echo "File size check"
52 xpass test $new_size -eq $(expr $bconf_size + $initrd_size + 9)
54 echo "Apply command repeat test"
55 xpass $BOOTCONF -a $TEMPCONF $INITRD
57 echo "File size check"
58 xpass test $new_size -eq $(stat -c %s $INITRD)
60 echo "Delete command check"
61 xpass $BOOTCONF -d $INITRD
63 echo "File size check"
64 new_size=$(stat -c %s $INITRD)
65 xpass test $new_size -eq $initrd_size
67 echo "Max node number check"
69 echo -n > $TEMPCONF
70 for i in `seq 1 1024` ; do
71 echo "node$i" >> $TEMPCONF
72 done
73 xpass $BOOTCONF -a $TEMPCONF $INITRD
75 echo "badnode" >> $TEMPCONF
76 xfail $BOOTCONF -a $TEMPCONF $INITRD
78 echo "Max filesize check"
80 # Max size is 32767 (including terminal byte)
81 echo -n "data = \"" > $TEMPCONF
82 dd if=/dev/urandom bs=768 count=32 | base64 -w0 >> $TEMPCONF
83 echo "\"" >> $TEMPCONF
84 xfail $BOOTCONF -a $TEMPCONF $INITRD
86 truncate -s 32764 $TEMPCONF
87 echo "\"" >> $TEMPCONF # add 2 bytes + terminal ('\"\n\0')
88 xpass $BOOTCONF -a $TEMPCONF $INITRD
90 echo "=== expected failure cases ==="
91 for i in samples/bad-* ; do
92 xfail $BOOTCONF -a $i $INITRD
93 done
95 echo "=== expected success cases ==="
96 for i in samples/good-* ; do
97 xpass $BOOTCONF -a $i $INITRD
98 done
100 echo
101 if [ $NG -eq 0 ]; then
102 echo "All tests passed"
103 else
104 echo "$NG tests failed"