blob: 06be8d2b9a859561ef6cc7792ae64be0076e1f54 [file] [log] [blame]
Denis Vlasenko2e157dd2008-07-19 09:27:19 +00001#!/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
8NO_REDUCE=65536
9NO_TRIM=131072
10GREEDY=262144
11
12# testing "description" "command" "result" "infile" "stdin"
13
14testing "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
20testing "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 Vlasenko9b366f42008-07-20 17:50:58 +000026FILE=__parse
Denis Vlasenko2e157dd2008-07-19 09:27:19 +000027cat >$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
40none /dev/pts devpts gid=5,mode=620 0 0
41 none /proc proc defaults 0 0
42EOF
43
44cat >$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]
55EOF
56
57testing "polluted fstab" \
58 "parse -n 6 -m 6 $FILE" \
59 "`cat $FILE.res`\n" \
60 "" \
61 ""
Denis Vlasenko9b366f42008-07-20 17:50:58 +000062cp ../examples/inittab $FILE
63cat >$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]
75EOF
76
77testing "inittab from examples" \
78 "parse -n 4 -m 4 -f $(($GREEDY+$NO_TRIM)) -d'#:' $FILE" \
79 "`cat $FILE.res`\n" \
80 "" \
81 ""
82
83cp ../examples/udhcp/udhcpd.conf $FILE
84cat >$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]
95EOF
96
97testing "udhcpd.conf from examples" \
98 "parse -n 127 $FILE" \
99 "`cat $FILE.res`\n" \
100 "" \
101 ""
102
Denis Vlasenko2e157dd2008-07-19 09:27:19 +0000103rm -f $FILE $FILE.res
104
105exit $FAILCOUNT