source: branches/3.2/mindi-busybox/testsuite/mdev.tests @ 3232

Last change on this file since 3232 was 3232, checked in by bruno, 5 years ago
  • Update mindi-busybox to 1.21.1
  • Property svn:executable set to *
File size: 8.2 KB
Line 
1#!/bin/sh
2# Copyright 2008 by Denys Vlasenko
3# Licensed under GPLv2, see file LICENSE in this source tree.
4
5. ./testing.sh
6
7# ls -ln is showing date. Need to remove that, it's variable
8# sed: (1) "maj, min" -> "maj,min" (2) coalesce spaces
9# cut: remove date
10FILTER_LS="grep -v '^total ' | sed -e 's/,  */,/g' -e 's/  */ /g' | cut -d' ' -f 1-5,9-"
11# cut: remove size+date
12FILTER_LS2="grep -v '^total ' | sed -e 's/,  */,/g' -e 's/  */ /g' | cut -d' ' -f 1-4,9-"
13
14# testing "test name" "commands" "expected result" "file input" "stdin"
15
16rm -rf mdev.testdir
17mkdir mdev.testdir
18# We need mdev executable to be in chroot jail!
19# (will still fail with dynamically linked one, though...)
20cp ../busybox mdev.testdir/mdev
21mkdir mdev.testdir/bin
22cp ../busybox mdev.testdir/bin/sh 2>/dev/null # for testing cmd feature
23mkdir mdev.testdir/etc
24mkdir mdev.testdir/dev
25mkdir -p mdev.testdir/sys/block/sda
26echo "8:0" >mdev.testdir/sys/block/sda/dev
27
28# env - PATH=$PATH: on some systems chroot binary won't otherwise be found
29
30optional STATIC FEATURE_LS_TIMESTAMPS FEATURE_LS_USERNAME
31testing "mdev add /block/sda" \
32    "env - PATH=$PATH ACTION=add DEVPATH=/block/sda chroot mdev.testdir /mdev 2>&1;
33    ls -ln mdev.testdir/dev | $FILTER_LS" \
34"\
35brw-rw---- 1 0 0 8,0 sda
36" \
37    "" ""
38SKIP=
39
40# continuing to use directory structure from prev test
41optional STATIC FEATURE_MDEV_CONF FEATURE_LS_TIMESTAMPS FEATURE_LS_USERNAME
42testing "mdev deletes /block/sda" \
43    "env - PATH=$PATH ACTION=remove DEVPATH=/block/sda chroot mdev.testdir /mdev 2>&1;
44    ls -ln mdev.testdir/dev | $FILTER_LS" \
45"\
46" \
47    "" ""
48SKIP=
49
50# continuing to use directory structure from prev test
51rm -rf mdev.testdir/dev/*
52echo ".* 1:1 666" >mdev.testdir/etc/mdev.conf
53echo "sda 2:2 444" >>mdev.testdir/etc/mdev.conf
54optional STATIC FEATURE_MDEV_CONF FEATURE_LS_TIMESTAMPS FEATURE_LS_USERNAME
55testing "mdev stops on first rule" \
56    "env - PATH=$PATH ACTION=add DEVPATH=/block/sda chroot mdev.testdir /mdev 2>&1;
57    ls -ln mdev.testdir/dev | $FILTER_LS" \
58"\
59brw-rw-rw- 1 1 1 8,0 sda
60" \
61    "" ""
62SKIP=
63
64# continuing to use directory structure from prev test
65rm -rf mdev.testdir/dev/*
66echo "-.* 1:1 666" >mdev.testdir/etc/mdev.conf
67echo "sda 2:2 444" >>mdev.testdir/etc/mdev.conf
68optional STATIC FEATURE_MDEV_CONF FEATURE_LS_TIMESTAMPS FEATURE_LS_USERNAME
69testing "mdev does not stop on dash-rule" \
70    "env - PATH=$PATH ACTION=add DEVPATH=/block/sda chroot mdev.testdir /mdev 2>&1;
71    ls -ln mdev.testdir/dev | $FILTER_LS" \
72"\
73br--r--r-- 1 2 2 8,0 sda
74" \
75    "" ""
76SKIP=
77
78# continuing to use directory structure from prev test
79rm -rf mdev.testdir/dev/*
80echo "\$MODALIAS=qw  1:1 666" >mdev.testdir/etc/mdev.conf
81echo "\$MODALIAS=qw. 2:2 444" >>mdev.testdir/etc/mdev.conf
82echo "\$MODALIAS=qw. 3:3 400" >>mdev.testdir/etc/mdev.conf
83optional STATIC FEATURE_MDEV_CONF FEATURE_LS_TIMESTAMPS FEATURE_LS_USERNAME
84testing "mdev \$ENVVAR=regex match" \
85    "env - PATH=$PATH ACTION=add DEVPATH=/block/sda MODALIAS=qwe chroot mdev.testdir /mdev 2>&1;
86    ls -ln mdev.testdir/dev | $FILTER_LS" \
87"\
88br--r--r-- 1 2 2 8,0 sda
89" \
90    "" ""
91SKIP=
92
93# continuing to use directory structure from prev test
94rm -rf mdev.testdir/dev/*
95echo "sda 0:0 444 >disk/scsiA" >mdev.testdir/etc/mdev.conf
96optional STATIC FEATURE_MDEV_CONF FEATURE_MDEV_RENAME FEATURE_LS_RECURSIVE FEATURE_LS_TIMESTAMPS FEATURE_LS_USERNAME
97testing "mdev move/symlink rule '>bar/baz'" \
98    "env - PATH=$PATH ACTION=add DEVPATH=/block/sda chroot mdev.testdir /mdev 2>&1;
99    ls -lnR mdev.testdir/dev | $FILTER_LS2" \
100"\
101mdev.testdir/dev:
102drwxr-xr-x 2 0 0 disk
103lrwxrwxrwx 1 0 0 sda -> disk/scsiA
104
105mdev.testdir/dev/disk:
106br--r--r-- 1 0 0 scsiA
107" \
108    "" ""
109SKIP=
110
111# continuing to use directory structure from prev test
112rm -rf mdev.testdir/dev/*
113echo "sda 0:0 444 >disk/" >mdev.testdir/etc/mdev.conf
114optional STATIC FEATURE_MDEV_CONF FEATURE_MDEV_RENAME FEATURE_LS_RECURSIVE FEATURE_LS_TIMESTAMPS FEATURE_LS_USERNAME
115testing "mdev move/symlink rule '>bar/'" \
116    "env - PATH=$PATH ACTION=add DEVPATH=/block/sda chroot mdev.testdir /mdev 2>&1;
117    ls -lnR mdev.testdir/dev | $FILTER_LS2" \
118"\
119mdev.testdir/dev:
120drwxr-xr-x 2 0 0 disk
121lrwxrwxrwx 1 0 0 sda -> disk/sda
122
123mdev.testdir/dev/disk:
124br--r--r-- 1 0 0 sda
125" \
126    "" ""
127SKIP=
128
129# continuing to use directory structure from prev test
130rm -rf mdev.testdir/dev/*
131echo "sda 0:0 444 =disk/sd/a" >mdev.testdir/etc/mdev.conf
132optional STATIC FEATURE_MDEV_CONF FEATURE_MDEV_RENAME FEATURE_LS_RECURSIVE FEATURE_LS_TIMESTAMPS FEATURE_LS_USERNAME
133testing "mdev move rule '=bar/baz/fname'" \
134    "env - PATH=$PATH ACTION=add DEVPATH=/block/sda chroot mdev.testdir /mdev 2>&1;
135    ls -lnR mdev.testdir/dev | $FILTER_LS2" \
136"\
137mdev.testdir/dev:
138drwxr-xr-x 3 0 0 disk
139
140mdev.testdir/dev/disk:
141drwxr-xr-x 2 0 0 sd
142
143mdev.testdir/dev/disk/sd:
144br--r--r-- 1 0 0 a
145" \
146    "" ""
147SKIP=
148
149# continuing to use directory structure from prev test
150rm -rf mdev.testdir/dev/*
151# here we complicate things by having non-matching group 1 and using %0
152echo "s([0-9])*d([a-z]+) 0:0 644 >sd/%2_%0" >mdev.testdir/etc/mdev.conf
153optional STATIC FEATURE_MDEV_CONF FEATURE_MDEV_RENAME FEATURE_MDEV_RENAME_REGEXP FEATURE_LS_RECURSIVE FEATURE_LS_TIMESTAMPS FEATURE_LS_USERNAME FEATURE_LS_SORTFILES
154testing "mdev regexp substring match + replace" \
155    "env - PATH=$PATH ACTION=add DEVPATH=/block/sda chroot mdev.testdir /mdev 2>&1;
156    ls -lnR mdev.testdir/dev | $FILTER_LS2" \
157"\
158mdev.testdir/dev:
159drwxr-xr-x 2 0 0 sd
160lrwxrwxrwx 1 0 0 sda -> sd/a_sda
161
162mdev.testdir/dev/sd:
163brw-r--r-- 1 0 0 a_sda
164" \
165    "" ""
166SKIP=
167
168# continuing to use directory structure from prev test
169rm -rf mdev.testdir/dev/*
170echo "sda 0:0 644 @echo @echo TEST" >mdev.testdir/etc/mdev.conf
171optional STATIC FEATURE_MDEV_CONF FEATURE_MDEV_EXEC FEATURE_LS_RECURSIVE FEATURE_LS_TIMESTAMPS FEATURE_LS_USERNAME FEATURE_SH_IS_ASH
172testing "mdev command" \
173    "env - PATH=$PATH ACTION=add DEVPATH=/block/sda chroot mdev.testdir /mdev 2>&1;
174    ls -lnR mdev.testdir/dev | $FILTER_LS" \
175"\
176@echo TEST
177mdev.testdir/dev:
178brw-r--r-- 1 0 0 8,0 sda
179" \
180    "" ""
181SKIP=
182
183# continuing to use directory structure from prev test
184rm -rf mdev.testdir/dev/*
185echo "sda 0:0 644 =block/ @echo @echo TEST:\$MDEV" >mdev.testdir/etc/mdev.conf
186optional STATIC FEATURE_MDEV_CONF FEATURE_MDEV_RENAME FEATURE_MDEV_EXEC FEATURE_LS_RECURSIVE FEATURE_LS_TIMESTAMPS FEATURE_LS_USERNAME FEATURE_SH_IS_ASH
187testing "mdev move and command" \
188    "env - PATH=$PATH ACTION=add DEVPATH=/block/sda chroot mdev.testdir /mdev 2>&1;
189    ls -lnR mdev.testdir/dev | $FILTER_LS2" \
190"\
191@echo TEST:block/sda
192mdev.testdir/dev:
193drwxr-xr-x 2 0 0 block
194
195mdev.testdir/dev/block:
196brw-r--r-- 1 0 0 sda
197" \
198    "" ""
199SKIP=
200
201# continuing to use directory structure from prev test
202rm -rf mdev.testdir/dev/*
203echo "@8,0 0:1 644" >mdev.testdir/etc/mdev.conf
204optional STATIC FEATURE_MDEV_CONF FEATURE_MDEV_RENAME FEATURE_MDEV_RENAME_REGEXP FEATURE_LS_RECURSIVE FEATURE_LS_TIMESTAMPS FEATURE_LS_USERNAME
205testing "mdev #maj,min and no explicit uid" \
206    "env - PATH=$PATH ACTION=add DEVPATH=/block/sda chroot mdev.testdir /mdev 2>&1;
207    ls -lnR mdev.testdir/dev | $FILTER_LS" \
208"\
209mdev.testdir/dev:
210brw-r--r-- 1 0 1 8,0 sda
211" \
212    "" ""
213SKIP=
214
215# continuing to use directory structure from prev test
216rm -rf mdev.testdir/dev/*
217mkdir -p mdev.testdir/sys/class/tty/capi
218echo "191:0" >mdev.testdir/sys/class/tty/capi/dev
219mkdir -p mdev.testdir/sys/class/tty/capi1
220echo "191:1" >mdev.testdir/sys/class/tty/capi1/dev
221mkdir -p mdev.testdir/sys/class/tty/capi20
222echo "191:20" >mdev.testdir/sys/class/tty/capi20/dev
223echo "capi            0:0 0660 =capi20"      >mdev.testdir/etc/mdev.conf
224echo "capi([0-9])     0:0 0660 =capi20.0%1" >>mdev.testdir/etc/mdev.conf
225echo "capi([0-9]*)    0:0 0660 =capi20.%1"  >>mdev.testdir/etc/mdev.conf
226# mdev invocation with DEVPATH=/class/tty/capi20 was deleting /dev/capi20
227optional STATIC FEATURE_MDEV_CONF FEATURE_MDEV_RENAME FEATURE_MDEV_RENAME_REGEXP FEATURE_LS_RECURSIVE FEATURE_LS_TIMESTAMPS FEATURE_LS_USERNAME FEATURE_LS_SORTFILES
228testing "move rule does not delete node with name == device_name" \
229    "\
230    env - PATH=$PATH ACTION=add DEVPATH=/class/tty/capi chroot mdev.testdir /mdev 2>&1;
231    env - PATH=$PATH ACTION=add DEVPATH=/class/tty/capi1 chroot mdev.testdir /mdev 2>&1;
232    env - PATH=$PATH ACTION=add DEVPATH=/class/tty/capi20 chroot mdev.testdir /mdev 2>&1;
233    ls -lnR mdev.testdir/dev | $FILTER_LS" \
234"\
235mdev.testdir/dev:
236crw-rw---- 1 0 0 191,0 capi20
237crw-rw---- 1 0 0 191,1 capi20.01
238crw-rw---- 1 0 0 191,20 capi20.20
239" \
240    "" ""
241SKIP=
242
243# clean up
244rm -rf mdev.testdir
245
246exit $FAILCOUNT
Note: See TracBrowser for help on using the repository browser.