mdev: plug a few memory and fd leaks; simplify code a bit
[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 user, group, and date
10 FILTER_LS="sed -e 's/,  */,/g' -e 's/  */ /g' | cut -d' ' -f 1,2,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/dev
20 mkdir -p mdev.testdir/sys/block/sda
21 echo "8:0" >mdev.testdir/sys/block/sda/dev
22
23 testing "mdev add /block/sda" \
24         "env - ACTION=add DEVPATH=/block/sda chroot mdev.testdir /mdev 2>&1;
25         ls -ln mdev.testdir/dev | $FILTER_LS" \
26 "\
27 mdev: /etc/mdev.conf: No such file or directory
28 brw-rw---- 1 8,0 sda
29 " \
30         "" ""
31
32 # clean up
33 rm -rf mdev.testdir
34
35 exit $FAILCOUNT