gpio: rcar: Fix runtime PM imbalance on error
[linux/fpc-iii.git] / tools / bootconfig / test-bootconfig.sh
blob81b350ffd03fb1cf2a7f57bf9635abc72857b8ea
1 #!/bin/sh
2 # SPDX-License-Identifier: GPL-2.0-only
4 echo "Boot config test script"
6 if [ -d "$1" ]; then
7 TESTDIR=$1
8 else
9 TESTDIR=.
11 BOOTCONF=${TESTDIR}/bootconfig
13 INITRD=`mktemp ${TESTDIR}/initrd-XXXX`
14 TEMPCONF=`mktemp ${TESTDIR}/temp-XXXX.bconf`
15 OUTFILE=`mktemp ${TESTDIR}/tempout-XXXX`
16 NG=0
18 cleanup() {
19 rm -f $INITRD $TEMPCONF $OUTFILE
20 exit $NG
23 trap cleanup EXIT TERM
25 NO=1
27 xpass() { # pass test command
28 echo "test case $NO ($3)... "
29 if ! ($@ && echo "\t\t[OK]"); then
30 echo "\t\t[NG]"; NG=$((NG + 1))
32 NO=$((NO + 1))
35 xfail() { # fail test command
36 echo "test case $NO ($3)... "
37 if ! (! $@ && echo "\t\t[OK]"); then
38 echo "\t\t[NG]"; NG=$((NG + 1))
40 NO=$((NO + 1))
43 echo "Basic command test"
44 xpass $BOOTCONF $INITRD
46 echo "Delete command should success without bootconfig"
47 xpass $BOOTCONF -d $INITRD
49 dd if=/dev/zero of=$INITRD bs=4096 count=1
50 echo "key = value;" > $TEMPCONF
51 bconf_size=$(stat -c %s $TEMPCONF)
52 initrd_size=$(stat -c %s $INITRD)
54 echo "Apply command test"
55 xpass $BOOTCONF -a $TEMPCONF $INITRD
56 new_size=$(stat -c %s $INITRD)
58 echo "File size check"
59 xpass test $new_size -eq $(expr $bconf_size + $initrd_size + 9 + 12)
61 echo "Apply command repeat test"
62 xpass $BOOTCONF -a $TEMPCONF $INITRD
64 echo "File size check"
65 xpass test $new_size -eq $(stat -c %s $INITRD)
67 echo "Delete command check"
68 xpass $BOOTCONF -d $INITRD
70 echo "File size check"
71 new_size=$(stat -c %s $INITRD)
72 xpass test $new_size -eq $initrd_size
74 echo "No error messge while applying"
75 dd if=/dev/zero of=$INITRD bs=4096 count=1
76 printf " \0\0\0 \0\0\0" >> $INITRD
77 $BOOTCONF -a $TEMPCONF $INITRD > $OUTFILE 2>&1
78 xfail grep -i "failed" $OUTFILE
79 xfail grep -i "error" $OUTFILE
81 echo "Max node number check"
83 echo -n > $TEMPCONF
84 for i in `seq 1 1024` ; do
85 echo "node$i" >> $TEMPCONF
86 done
87 xpass $BOOTCONF -a $TEMPCONF $INITRD
89 echo "badnode" >> $TEMPCONF
90 xfail $BOOTCONF -a $TEMPCONF $INITRD
92 echo "Max filesize check"
94 # Max size is 32767 (including terminal byte)
95 echo -n "data = \"" > $TEMPCONF
96 dd if=/dev/urandom bs=768 count=32 | base64 -w0 >> $TEMPCONF
97 echo "\"" >> $TEMPCONF
98 xfail $BOOTCONF -a $TEMPCONF $INITRD
100 truncate -s 32764 $TEMPCONF
101 echo "\"" >> $TEMPCONF # add 2 bytes + terminal ('\"\n\0')
102 xpass $BOOTCONF -a $TEMPCONF $INITRD
104 echo "Adding same-key values"
105 cat > $TEMPCONF << EOF
106 key = bar, baz
107 key += qux
109 echo > $INITRD
111 xpass $BOOTCONF -a $TEMPCONF $INITRD
112 $BOOTCONF $INITRD > $OUTFILE
113 xpass grep -q "bar" $OUTFILE
114 xpass grep -q "baz" $OUTFILE
115 xpass grep -q "qux" $OUTFILE
117 echo "=== expected failure cases ==="
118 for i in samples/bad-* ; do
119 xfail $BOOTCONF -a $i $INITRD
120 done
122 echo "=== expected success cases ==="
123 for i in samples/good-* ; do
124 xpass $BOOTCONF -a $i $INITRD
125 done
127 echo
128 if [ $NG -eq 0 ]; then
129 echo "All tests passed"
130 else
131 echo "$NG tests failed"