mdev: fix a bug where it was not stopping on first matching rule
[oweals/busybox.git] / testsuite / mdev.tests
1 #!/bin/sh
2 # Copyright 2008 by Denys Vlasenko
3 # Licensed under GPL v2, see file LICENSE for details.
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
10 FILTER_LS="sed -e 's/,  */,/g' -e 's/  */ /g' | cut -d' ' -f 1-5,9-"
11
12 # testing "test name" "options" "expected result" "file input" "stdin"
13
14 rm -rf mdev.testdir
15 mkdir mdev.testdir
16 # We need mdev executable to be in chroot jail!
17 # (will still fail with dynamically linked one, though...)
18 cp ../busybox mdev.testdir/mdev
19 mkdir mdev.testdir/etc
20 mkdir mdev.testdir/dev
21 mkdir -p mdev.testdir/sys/block/sda
22 echo "8:0" >mdev.testdir/sys/block/sda/dev
23
24 testing "mdev add /block/sda" \
25         "env - ACTION=add DEVPATH=/block/sda chroot mdev.testdir /mdev 2>&1;
26         ls -ln mdev.testdir/dev | $FILTER_LS" \
27 "\
28 mdev: /etc/mdev.conf: No such file or directory
29 brw-rw---- 1 0 0 8,0 sda
30 " \
31         "" ""
32
33 # continuing to use directory structure from prev test
34 rm mdev.testdir/dev/sda
35 echo ".* 1:1 666" >mdev.testdir/etc/mdev.conf
36 echo "sda 2:2 444" >>mdev.testdir/etc/mdev.conf
37 testing "mdev stops on first rule" \
38         "env - ACTION=add DEVPATH=/block/sda chroot mdev.testdir /mdev 2>&1;
39         ls -ln mdev.testdir/dev | $FILTER_LS" \
40 "\
41 brw-rw-rw- 1 1 1 8,0 sda
42 " \
43         "" ""
44
45 # clean up
46 rm -rf mdev.testdir
47
48 exit $FAILCOUNT