Denis Vlasenko | 2e157dd | 2008-07-19 09:27:19 +0000 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
| 3 | # Copyright 2008 by Denys Vlasenko <vda.linux@googlemail.com> |
| 4 | # Licensed under GPL v2, see file LICENSE for details. |
| 5 | |
| 6 | . testing.sh |
| 7 | |
| 8 | NO_REDUCE=65536 |
| 9 | NO_TRIM=131072 |
| 10 | GREEDY=262144 |
| 11 | |
| 12 | # testing "description" "command" "result" "infile" "stdin" |
| 13 | |
| 14 | testing "mdev.conf" \ |
| 15 | "parse -n 4 -m 3 -f $GREEDY -" \ |
| 16 | "[sda][0:0][644][@echo @echo TEST]\n" \ |
| 17 | "-" \ |
| 18 | " sda 0:0 644 @echo @echo TEST # echo trap\n" |
| 19 | |
| 20 | testing "notrim" \ |
| 21 | "parse -n 4 -m 3 -f $(($GREEDY+$NO_TRIM)) -" \ |
| 22 | "[][sda][0:0][644 @echo @echo TEST ]\n" \ |
| 23 | "-" \ |
| 24 | " sda 0:0 644 @echo @echo TEST \n" |
| 25 | |
Denis Vlasenko | 9b366f4 | 2008-07-20 17:50:58 +0000 | [diff] [blame] | 26 | FILE=__parse |
Denis Vlasenko | 2e157dd | 2008-07-19 09:27:19 +0000 | [diff] [blame] | 27 | cat >$FILE <<EOF |
| 28 | # |
| 29 | # Device Point System Options |
| 30 | #_______________________________________________________________ |
| 31 | /dev/hdb3 / ext2 defaults 1 0 |
| 32 | /dev/hdb1 /dosc hpfs ro 1 0 |
| 33 | /dev/fd0 /dosa vfat rw,user,noauto,nohide 0 0 |
| 34 | /dev/fd1 /dosb vfat rw,user,noauto,nohide 0 0 |
| 35 | # |
| 36 | /dev/cdrom /cdrom iso9660 ro,user,noauto,nohide 0 0 |
| 37 | /dev/hdb5 /redhat ext2 rw,root,noauto,nohide 0 0 #sssd |
| 38 | /dev/hdb6 /win2home ntfs rw,root,noauto,nohide 0 0# ssdsd |
| 39 | /dev/hdb7 /win2skul ntfs rw,root,noauto,nohide none 0 0 |
| 40 | none /dev/pts devpts gid=5,mode=620 0 0 |
| 41 | none /proc proc defaults 0 0 |
| 42 | EOF |
| 43 | |
| 44 | cat >$FILE.res <<EOF |
| 45 | [/dev/hdb3][/][ext2][defaults][1][0] |
| 46 | [/dev/hdb1][/dosc][hpfs][ro][1][0] |
| 47 | [/dev/fd0][/dosa][vfat][rw,user,noauto,nohide][0][0] |
| 48 | [/dev/fd1][/dosb][vfat][rw,user,noauto,nohide][0][0] |
| 49 | [/dev/cdrom][/cdrom][iso9660][ro,user,noauto,nohide][0][0] |
| 50 | [/dev/hdb5][/redhat][ext2][rw,root,noauto,nohide][0][0] |
| 51 | [/dev/hdb6][/win2home][ntfs][rw,root,noauto,nohide][0][0] |
| 52 | [/dev/hdb7][/win2skul][ntfs][rw,root,noauto,nohide][none][0] |
| 53 | [none][/dev/pts][devpts][gid=5,mode=620][0][0] |
| 54 | [none][/proc][proc][defaults][0][0] |
| 55 | EOF |
| 56 | |
| 57 | testing "polluted fstab" \ |
| 58 | "parse -n 6 -m 6 $FILE" \ |
| 59 | "`cat $FILE.res`\n" \ |
| 60 | "" \ |
| 61 | "" |
Denis Vlasenko | 9b366f4 | 2008-07-20 17:50:58 +0000 | [diff] [blame] | 62 | cp ../examples/inittab $FILE |
| 63 | cat >$FILE.res <<EOF |
| 64 | [][][sysinit][/etc/init.d/rcS] |
| 65 | [][][askfirst][-/bin/sh] |
| 66 | [tty2][][askfirst][-/bin/sh] |
| 67 | [tty3][][askfirst][-/bin/sh] |
| 68 | [tty4][][askfirst][-/bin/sh] |
| 69 | [tty4][][respawn][/sbin/getty 38400 tty5] |
| 70 | [tty5][][respawn][/sbin/getty 38400 tty6] |
| 71 | [][][restart][/sbin/init] |
| 72 | [][][ctrlaltdel][/sbin/reboot] |
| 73 | [][][shutdown][/bin/umount -a -r] |
| 74 | [][][shutdown][/sbin/swapoff -a] |
| 75 | EOF |
| 76 | |
| 77 | testing "inittab from examples" \ |
| 78 | "parse -n 4 -m 4 -f $(($GREEDY+$NO_TRIM)) -d'#:' $FILE" \ |
| 79 | "`cat $FILE.res`\n" \ |
| 80 | "" \ |
| 81 | "" |
| 82 | |
| 83 | cp ../examples/udhcp/udhcpd.conf $FILE |
| 84 | cat >$FILE.res <<EOF |
| 85 | [start][192.168.0.20] |
| 86 | [end][192.168.0.254] |
| 87 | [interface][eth0] |
| 88 | [opt][dns][192.168.10.2][192.168.10.10] |
| 89 | [option][subnet][255.255.255.0] |
| 90 | [opt][router][192.168.10.2] |
| 91 | [opt][wins][192.168.10.10] |
| 92 | [option][dns][129.219.13.81] |
| 93 | [option][domain][local] |
| 94 | [option][lease][864000] |
| 95 | EOF |
| 96 | |
| 97 | testing "udhcpd.conf from examples" \ |
| 98 | "parse -n 127 $FILE" \ |
| 99 | "`cat $FILE.res`\n" \ |
| 100 | "" \ |
| 101 | "" |
| 102 | |
Denis Vlasenko | 2e157dd | 2008-07-19 09:27:19 +0000 | [diff] [blame] | 103 | rm -f $FILE $FILE.res |
| 104 | |
| 105 | exit $FAILCOUNT |