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