Skip to content

Commit bfed3dd

Browse files
committed
tools/bootconfig: Improve portability
Since 'stat' command and 'truncate' command are GNU extension, use 'wc' and 'dd' commands instead. Link: https://lore.kernel.org/all/175211424184.2591046.3523297993175066026.stgit@mhiramat.tok.corp.google.com/ Signed-off-by: Masami Hiramatsu (Google) <[email protected]>
1 parent 63989c7 commit bfed3dd

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

tools/bootconfig/test-bootconfig.sh

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,12 @@ xpass $BOOTCONF -d $INITRD
4949

5050
dd if=/dev/zero of=$INITRD bs=4096 count=1
5151
echo "key = value;" > $TEMPCONF
52-
bconf_size=$(stat -c %s $TEMPCONF)
53-
initrd_size=$(stat -c %s $INITRD)
52+
bconf_size=$(wc -c < $TEMPCONF)
53+
initrd_size=$(wc -c < $INITRD)
5454

5555
echo "Apply command test"
5656
xpass $BOOTCONF -a $TEMPCONF $INITRD
57-
new_size=$(stat -c %s $INITRD)
57+
new_size=$(wc -c < $INITRD)
5858

5959
echo "Show command test"
6060
xpass $BOOTCONF $INITRD
@@ -69,13 +69,13 @@ echo "Apply command repeat test"
6969
xpass $BOOTCONF -a $TEMPCONF $INITRD
7070

7171
echo "File size check"
72-
xpass test $new_size -eq $(stat -c %s $INITRD)
72+
xpass test $new_size -eq $(wc -c < $INITRD)
7373

7474
echo "Delete command check"
7575
xpass $BOOTCONF -d $INITRD
7676

7777
echo "File size check"
78-
new_size=$(stat -c %s $INITRD)
78+
new_size=$(wc -c < $INITRD)
7979
xpass test $new_size -eq $initrd_size
8080

8181
echo "No error messge while applying"
@@ -108,7 +108,8 @@ dd if=/dev/urandom bs=768 count=32 | base64 -w0 >> $TEMPCONF
108108
echo "\"" >> $TEMPCONF
109109
xfail $BOOTCONF -a $TEMPCONF $INITRD
110110

111-
truncate -s 32764 $TEMPCONF
111+
dd if=$TEMPCONF of=$OUTFILE bs=1 count=32764
112+
cp $OUTFILE $TEMPCONF
112113
echo "\"" >> $TEMPCONF # add 2 bytes + terminal ('\"\n\0')
113114
xpass $BOOTCONF -a $TEMPCONF $INITRD
114115

0 commit comments

Comments
 (0)