mirror of
https://github.com/topjohnwu/ndk-busybox.git
synced 2024-11-30 15:10:36 +00:00
f2f3868e0d
+142 bytes.
100 lines
2.7 KiB
Bash
Executable File
100 lines
2.7 KiB
Bash
Executable File
#!/bin/sh
|
|
# Copyright 2008 by Denys Vlasenko
|
|
# Licensed under GPL v2, see file LICENSE for details.
|
|
|
|
. testing.sh
|
|
|
|
# ls -ln is showing date. Need to remove that, it's variable
|
|
# sed: (1) "maj, min" -> "maj,min" (2) coalesce spaces
|
|
# cut: remove date
|
|
FILTER_LS="sed -e 's/, */,/g' -e 's/ */ /g' | cut -d' ' -f 1-5,9-"
|
|
# cut: remove size+date
|
|
FILTER_LS2="sed -e 's/, */,/g' -e 's/ */ /g' | cut -d' ' -f 1-4,9-"
|
|
|
|
# testing "test name" "options" "expected result" "file input" "stdin"
|
|
|
|
rm -rf mdev.testdir
|
|
mkdir mdev.testdir
|
|
# We need mdev executable to be in chroot jail!
|
|
# (will still fail with dynamically linked one, though...)
|
|
cp ../busybox mdev.testdir/mdev
|
|
mkdir mdev.testdir/etc
|
|
mkdir mdev.testdir/dev
|
|
mkdir -p mdev.testdir/sys/block/sda
|
|
echo "8:0" >mdev.testdir/sys/block/sda/dev
|
|
|
|
testing "mdev add /block/sda" \
|
|
"env - ACTION=add DEVPATH=/block/sda chroot mdev.testdir /mdev 2>&1;
|
|
ls -ln mdev.testdir/dev | $FILTER_LS" \
|
|
"\
|
|
mdev: /etc/mdev.conf: No such file or directory
|
|
brw-rw---- 1 0 0 8,0 sda
|
|
" \
|
|
"" ""
|
|
|
|
# continuing to use directory structure from prev test
|
|
rm -rf mdev.testdir/dev/*
|
|
echo ".* 1:1 666" >mdev.testdir/etc/mdev.conf
|
|
echo "sda 2:2 444" >>mdev.testdir/etc/mdev.conf
|
|
testing "mdev stops on first rule" \
|
|
"env - ACTION=add DEVPATH=/block/sda chroot mdev.testdir /mdev 2>&1;
|
|
ls -ln mdev.testdir/dev | $FILTER_LS" \
|
|
"\
|
|
brw-rw-rw- 1 1 1 8,0 sda
|
|
" \
|
|
"" ""
|
|
|
|
# continuing to use directory structure from prev test
|
|
rm -rf mdev.testdir/dev/*
|
|
echo "sda 0:0 444 >disk/scsiA" >mdev.testdir/etc/mdev.conf
|
|
testing "mdev move/symlink rule '>bar/baz'" \
|
|
"env - ACTION=add DEVPATH=/block/sda chroot mdev.testdir /mdev 2>&1;
|
|
ls -lnR mdev.testdir/dev | $FILTER_LS2" \
|
|
"\
|
|
mdev.testdir/dev:
|
|
drwxr-xr-x 2 0 0 disk
|
|
lrwxrwxrwx 1 0 0 sda -> disk/scsiA
|
|
|
|
mdev.testdir/dev/disk:
|
|
br--r--r-- 1 0 0 scsiA
|
|
" \
|
|
"" ""
|
|
|
|
# continuing to use directory structure from prev test
|
|
rm -rf mdev.testdir/dev/*
|
|
echo "sda 0:0 444 >disk/" >mdev.testdir/etc/mdev.conf
|
|
testing "mdev move/symlink rule '>bar/'" \
|
|
"env - ACTION=add DEVPATH=/block/sda chroot mdev.testdir /mdev 2>&1;
|
|
ls -lnR mdev.testdir/dev | $FILTER_LS2" \
|
|
"\
|
|
mdev.testdir/dev:
|
|
drwxr-xr-x 2 0 0 disk
|
|
lrwxrwxrwx 1 0 0 sda -> disk/sda
|
|
|
|
mdev.testdir/dev/disk:
|
|
br--r--r-- 1 0 0 sda
|
|
" \
|
|
"" ""
|
|
|
|
# continuing to use directory structure from prev test
|
|
rm -rf mdev.testdir/dev/*
|
|
# here we complicate things by having non-matching group 1 and using %0
|
|
echo "s([0-9])*d([a-z]+) 0:0 644 >sd/%2_%0" >mdev.testdir/etc/mdev.conf
|
|
testing "mdev regexp substring match + replace" \
|
|
"env - ACTION=add DEVPATH=/block/sda chroot mdev.testdir /mdev 2>&1;
|
|
ls -lnR mdev.testdir/dev | $FILTER_LS2" \
|
|
"\
|
|
mdev.testdir/dev:
|
|
drwxr-xr-x 2 0 0 sd
|
|
lrwxrwxrwx 1 0 0 sda -> sd/a_sda
|
|
|
|
mdev.testdir/dev/sd:
|
|
brw-r--r-- 1 0 0 a_sda
|
|
" \
|
|
"" ""
|
|
|
|
# clean up
|
|
rm -rf mdev.testdir
|
|
|
|
exit $FAILCOUNT
|