blob: 904e1a17a2b50babeefd3f1befb53dbf7d66cfda [file] [log] [blame]
Denis Vlasenko2e157dd2008-07-19 09:27:19 +00001#!/bin/sh
2
3# Copyright 2008 by Denys Vlasenko <vda.linux@googlemail.com>
Denys Vlasenko0ef64bd2010-08-16 20:14:46 +02004# Licensed under GPLv2, see file LICENSE in this source tree.
Denis Vlasenko2e157dd2008-07-19 09:27:19 +00005
Mike Frysingercaa79402009-11-04 18:41:22 -05006. ./testing.sh
Denis Vlasenko2e157dd2008-07-19 09:27:19 +00007
Denis Vlasenko084266e2008-07-26 23:08:31 +00008COLLAPSE=$(( 0x00010000))
9TRIM=$(( 0x00020000))
10GREEDY=$(( 0x00040000))
11MIN_DIE=$(( 0x00100000))
12KEEP_COPY=$((0x00200000))
13ESCAPE=$(( 0x00400000))
14NORMAL=$(( COLLAPSE | TRIM | GREEDY))
Denis Vlasenko2e157dd2008-07-19 09:27:19 +000015
16# testing "description" "command" "result" "infile" "stdin"
17
Denis Vlasenko084266e2008-07-26 23:08:31 +000018testing "parse mdev.conf" \
19 "parse -n 4 -m 3 -f $((NORMAL)) -" \
Denis Vlasenko2e157dd2008-07-19 09:27:19 +000020 "[sda][0:0][644][@echo @echo TEST]\n" \
21 "-" \
22 " sda 0:0 644 @echo @echo TEST # echo trap\n"
23
Denis Vlasenko084266e2008-07-26 23:08:31 +000024testing "parse notrim" \
25 "parse -n 4 -m 3 -f $((NORMAL - TRIM - COLLAPSE)) -" \
Denis Vlasenko2e157dd2008-07-19 09:27:19 +000026 "[][sda][0:0][644 @echo @echo TEST ]\n" \
27 "-" \
28 " sda 0:0 644 @echo @echo TEST \n"
29
Denis Vlasenko9b366f42008-07-20 17:50:58 +000030FILE=__parse
Denis Vlasenko2e157dd2008-07-19 09:27:19 +000031cat >$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
44none /dev/pts devpts gid=5,mode=620 0 0
45 none /proc proc defaults 0 0
46EOF
47
48cat >$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 Vlasenko084266e2008-07-26 23:08:31 +000056[/dev/hdb7][/win2skul][ntfs][rw,root,noauto,nohide][none][0 0]
Denis Vlasenko2e157dd2008-07-19 09:27:19 +000057[none][/dev/pts][devpts][gid=5,mode=620][0][0]
58[none][/proc][proc][defaults][0][0]
59EOF
60
Denis Vlasenko084266e2008-07-26 23:08:31 +000061testing "parse polluted fstab" \
Denis Vlasenko2e157dd2008-07-19 09:27:19 +000062 "parse -n 6 -m 6 $FILE" \
63 "`cat $FILE.res`\n" \
64 "" \
65 ""
Denis Vlasenko9b366f42008-07-20 17:50:58 +000066cp ../examples/inittab $FILE
67cat >$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]
79EOF
80
Denis Vlasenko084266e2008-07-26 23:08:31 +000081testing "parse inittab from examples" \
82 "parse -n 4 -m 4 -f $((NORMAL - TRIM - COLLAPSE)) -d'#:' $FILE" \
Denis Vlasenko9b366f42008-07-20 17:50:58 +000083 "`cat $FILE.res`\n" \
84 "" \
85 ""
86
87cp ../examples/udhcp/udhcpd.conf $FILE
88cat >$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]
Denys Vlasenkoda947602011-06-18 09:29:21 +020099[option][0x08][01020304]
Denis Vlasenko9b366f42008-07-20 17:50:58 +0000100EOF
101
Denis Vlasenko084266e2008-07-26 23:08:31 +0000102testing "parse udhcpd.conf from examples" \
Denis Vlasenko9b366f42008-07-20 17:50:58 +0000103 "parse -n 127 $FILE" \
104 "`cat $FILE.res`\n" \
105 "" \
106 ""
107
Denis Vlasenko2e157dd2008-07-19 09:27:19 +0000108rm -f $FILE $FILE.res
109
110exit $FAILCOUNT