2008-03-28 02:19:26 +05:30
|
|
|
#!/bin/sh
|
|
|
|
# Copyright 2008 by Denys Vlasenko
|
2010-08-16 23:44:46 +05:30
|
|
|
# Licensed under GPLv2, see file LICENSE in this source tree.
|
2008-03-28 02:19:26 +05:30
|
|
|
|
2009-11-05 05:11:22 +05:30
|
|
|
. ./testing.sh
|
2008-03-28 02:19:26 +05:30
|
|
|
|
|
|
|
# ls -ln is showing date. Need to remove that, it's variable
|
|
|
|
# sed: (1) "maj, min" -> "maj,min" (2) coalesce spaces
|
2008-03-29 18:40:57 +05:30
|
|
|
# cut: remove date
|
2010-01-25 06:30:16 +05:30
|
|
|
FILTER_LS="grep -v '^total ' | sed -e 's/, */,/g' -e 's/ */ /g' | cut -d' ' -f 1-5,9-"
|
2008-03-29 20:41:07 +05:30
|
|
|
# cut: remove size+date
|
2010-01-25 06:30:16 +05:30
|
|
|
FILTER_LS2="grep -v '^total ' | sed -e 's/, */,/g' -e 's/ */ /g' | cut -d' ' -f 1-4,9-"
|
2008-03-28 02:19:26 +05:30
|
|
|
|
2013-01-21 05:52:12 +05:30
|
|
|
# testing "test name" "commands" "expected result" "file input" "stdin"
|
2008-03-28 02:19:26 +05:30
|
|
|
|
|
|
|
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
|
2008-05-02 18:51:24 +05:30
|
|
|
mkdir mdev.testdir/bin
|
|
|
|
cp ../busybox mdev.testdir/bin/sh 2>/dev/null # for testing cmd feature
|
2008-03-29 18:40:57 +05:30
|
|
|
mkdir mdev.testdir/etc
|
2008-03-28 02:19:26 +05:30
|
|
|
mkdir mdev.testdir/dev
|
|
|
|
mkdir -p mdev.testdir/sys/block/sda
|
|
|
|
echo "8:0" >mdev.testdir/sys/block/sda/dev
|
|
|
|
|
2008-08-04 20:10:58 +05:30
|
|
|
# env - PATH=$PATH: on some systems chroot binary won't otherwise be found
|
|
|
|
|
2010-05-11 07:23:57 +05:30
|
|
|
optional STATIC FEATURE_LS_TIMESTAMPS FEATURE_LS_USERNAME
|
2008-03-28 02:19:26 +05:30
|
|
|
testing "mdev add /block/sda" \
|
2008-08-04 20:10:58 +05:30
|
|
|
"env - PATH=$PATH ACTION=add DEVPATH=/block/sda chroot mdev.testdir /mdev 2>&1;
|
2008-03-28 02:19:26 +05:30
|
|
|
ls -ln mdev.testdir/dev | $FILTER_LS" \
|
|
|
|
"\
|
2008-03-29 18:40:57 +05:30
|
|
|
brw-rw---- 1 0 0 8,0 sda
|
|
|
|
" \
|
|
|
|
"" ""
|
2010-05-10 14:30:11 +05:30
|
|
|
SKIP=
|
2008-03-29 18:40:57 +05:30
|
|
|
|
2010-08-16 17:56:15 +05:30
|
|
|
# continuing to use directory structure from prev test
|
|
|
|
optional STATIC FEATURE_MDEV_CONF FEATURE_LS_TIMESTAMPS FEATURE_LS_USERNAME
|
|
|
|
testing "mdev deletes /block/sda" \
|
|
|
|
"env - PATH=$PATH ACTION=remove DEVPATH=/block/sda chroot mdev.testdir /mdev 2>&1;
|
|
|
|
ls -ln mdev.testdir/dev | $FILTER_LS" \
|
|
|
|
"\
|
|
|
|
" \
|
|
|
|
"" ""
|
|
|
|
SKIP=
|
|
|
|
|
2008-03-29 18:40:57 +05:30
|
|
|
# continuing to use directory structure from prev test
|
2008-03-29 20:41:07 +05:30
|
|
|
rm -rf mdev.testdir/dev/*
|
2008-03-29 18:40:57 +05:30
|
|
|
echo ".* 1:1 666" >mdev.testdir/etc/mdev.conf
|
|
|
|
echo "sda 2:2 444" >>mdev.testdir/etc/mdev.conf
|
2010-05-11 07:23:57 +05:30
|
|
|
optional STATIC FEATURE_MDEV_CONF FEATURE_LS_TIMESTAMPS FEATURE_LS_USERNAME
|
2008-03-29 18:40:57 +05:30
|
|
|
testing "mdev stops on first rule" \
|
2008-08-04 20:10:58 +05:30
|
|
|
"env - PATH=$PATH ACTION=add DEVPATH=/block/sda chroot mdev.testdir /mdev 2>&1;
|
2008-03-29 18:40:57 +05:30
|
|
|
ls -ln mdev.testdir/dev | $FILTER_LS" \
|
|
|
|
"\
|
|
|
|
brw-rw-rw- 1 1 1 8,0 sda
|
2008-03-28 02:19:26 +05:30
|
|
|
" \
|
|
|
|
"" ""
|
2010-05-10 14:30:11 +05:30
|
|
|
SKIP=
|
2008-03-28 02:19:26 +05:30
|
|
|
|
2009-04-17 04:12:01 +05:30
|
|
|
# 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
|
2010-05-11 07:23:57 +05:30
|
|
|
optional STATIC FEATURE_MDEV_CONF FEATURE_LS_TIMESTAMPS FEATURE_LS_USERNAME
|
2009-04-17 04:12:01 +05:30
|
|
|
testing "mdev does not stop on dash-rule" \
|
|
|
|
"env - PATH=$PATH ACTION=add DEVPATH=/block/sda chroot mdev.testdir /mdev 2>&1;
|
|
|
|
ls -ln mdev.testdir/dev | $FILTER_LS" \
|
|
|
|
"\
|
|
|
|
br--r--r-- 1 2 2 8,0 sda
|
|
|
|
" \
|
|
|
|
"" ""
|
2010-05-10 14:30:11 +05:30
|
|
|
SKIP=
|
2009-04-17 04:12:01 +05:30
|
|
|
|
2009-04-20 03:07:07 +05:30
|
|
|
# continuing to use directory structure from prev test
|
|
|
|
rm -rf mdev.testdir/dev/*
|
|
|
|
echo "\$MODALIAS=qw 1:1 666" >mdev.testdir/etc/mdev.conf
|
|
|
|
echo "\$MODALIAS=qw. 2:2 444" >>mdev.testdir/etc/mdev.conf
|
|
|
|
echo "\$MODALIAS=qw. 3:3 400" >>mdev.testdir/etc/mdev.conf
|
2010-05-11 07:23:57 +05:30
|
|
|
optional STATIC FEATURE_MDEV_CONF FEATURE_LS_TIMESTAMPS FEATURE_LS_USERNAME
|
2009-04-20 03:07:07 +05:30
|
|
|
testing "mdev \$ENVVAR=regex match" \
|
|
|
|
"env - PATH=$PATH ACTION=add DEVPATH=/block/sda MODALIAS=qwe chroot mdev.testdir /mdev 2>&1;
|
|
|
|
ls -ln mdev.testdir/dev | $FILTER_LS" \
|
|
|
|
"\
|
|
|
|
br--r--r-- 1 2 2 8,0 sda
|
|
|
|
" \
|
|
|
|
"" ""
|
2010-05-10 14:30:11 +05:30
|
|
|
SKIP=
|
2009-04-20 03:07:07 +05:30
|
|
|
|
2008-03-29 20:41:07 +05:30
|
|
|
# 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
|
2020-06-24 03:57:37 +05:30
|
|
|
optional STATIC FEATURE_MDEV_CONF FEATURE_MDEV_RENAME FEATURE_LS_RECURSIVE FEATURE_LS_TIMESTAMPS FEATURE_LS_USERNAME FEATURE_LS_SORTFILES
|
2008-03-29 20:41:07 +05:30
|
|
|
testing "mdev move/symlink rule '>bar/baz'" \
|
2008-08-04 20:10:58 +05:30
|
|
|
"env - PATH=$PATH ACTION=add DEVPATH=/block/sda chroot mdev.testdir /mdev 2>&1;
|
2008-03-29 20:41:07 +05:30
|
|
|
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
|
|
|
|
" \
|
|
|
|
"" ""
|
2010-05-10 09:23:16 +05:30
|
|
|
SKIP=
|
2008-03-29 20:41:07 +05:30
|
|
|
|
|
|
|
# continuing to use directory structure from prev test
|
|
|
|
rm -rf mdev.testdir/dev/*
|
|
|
|
echo "sda 0:0 444 >disk/" >mdev.testdir/etc/mdev.conf
|
2020-06-24 03:57:37 +05:30
|
|
|
optional STATIC FEATURE_MDEV_CONF FEATURE_MDEV_RENAME FEATURE_LS_RECURSIVE FEATURE_LS_TIMESTAMPS FEATURE_LS_USERNAME FEATURE_LS_SORTFILES
|
2008-03-29 20:41:07 +05:30
|
|
|
testing "mdev move/symlink rule '>bar/'" \
|
2008-08-04 20:10:58 +05:30
|
|
|
"env - PATH=$PATH ACTION=add DEVPATH=/block/sda chroot mdev.testdir /mdev 2>&1;
|
2008-03-29 20:41:07 +05:30
|
|
|
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
|
|
|
|
" \
|
|
|
|
"" ""
|
2010-05-10 09:23:16 +05:30
|
|
|
SKIP=
|
2008-03-29 20:41:07 +05:30
|
|
|
|
2013-01-21 05:52:12 +05:30
|
|
|
# continuing to use directory structure from prev test
|
|
|
|
rm -rf mdev.testdir/dev/*
|
|
|
|
echo "sda 0:0 444 =disk/sd/a" >mdev.testdir/etc/mdev.conf
|
|
|
|
optional STATIC FEATURE_MDEV_CONF FEATURE_MDEV_RENAME FEATURE_LS_RECURSIVE FEATURE_LS_TIMESTAMPS FEATURE_LS_USERNAME
|
|
|
|
testing "mdev move rule '=bar/baz/fname'" \
|
|
|
|
"env - PATH=$PATH ACTION=add DEVPATH=/block/sda chroot mdev.testdir /mdev 2>&1;
|
|
|
|
ls -lnR mdev.testdir/dev | $FILTER_LS2" \
|
|
|
|
"\
|
|
|
|
mdev.testdir/dev:
|
|
|
|
drwxr-xr-x 3 0 0 disk
|
|
|
|
|
|
|
|
mdev.testdir/dev/disk:
|
|
|
|
drwxr-xr-x 2 0 0 sd
|
|
|
|
|
|
|
|
mdev.testdir/dev/disk/sd:
|
|
|
|
br--r--r-- 1 0 0 a
|
|
|
|
" \
|
|
|
|
"" ""
|
|
|
|
SKIP=
|
|
|
|
|
2008-03-29 22:56:10 +05:30
|
|
|
# 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
|
2010-05-11 15:32:48 +05:30
|
|
|
optional STATIC FEATURE_MDEV_CONF FEATURE_MDEV_RENAME FEATURE_MDEV_RENAME_REGEXP FEATURE_LS_RECURSIVE FEATURE_LS_TIMESTAMPS FEATURE_LS_USERNAME FEATURE_LS_SORTFILES
|
2008-03-29 22:56:10 +05:30
|
|
|
testing "mdev regexp substring match + replace" \
|
2008-08-04 20:10:58 +05:30
|
|
|
"env - PATH=$PATH ACTION=add DEVPATH=/block/sda chroot mdev.testdir /mdev 2>&1;
|
2008-03-29 22:56:10 +05:30
|
|
|
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
|
|
|
|
" \
|
|
|
|
"" ""
|
2010-05-10 09:23:16 +05:30
|
|
|
SKIP=
|
2008-03-29 22:56:10 +05:30
|
|
|
|
2008-05-02 18:51:24 +05:30
|
|
|
# continuing to use directory structure from prev test
|
|
|
|
rm -rf mdev.testdir/dev/*
|
|
|
|
echo "sda 0:0 644 @echo @echo TEST" >mdev.testdir/etc/mdev.conf
|
2017-08-05 17:15:22 +05:30
|
|
|
optional STATIC FEATURE_MDEV_CONF FEATURE_MDEV_EXEC FEATURE_LS_RECURSIVE FEATURE_LS_TIMESTAMPS FEATURE_LS_USERNAME SH_IS_ASH ASH_ECHO
|
2008-05-02 18:51:24 +05:30
|
|
|
testing "mdev command" \
|
2008-08-04 20:10:58 +05:30
|
|
|
"env - PATH=$PATH ACTION=add DEVPATH=/block/sda chroot mdev.testdir /mdev 2>&1;
|
2008-05-02 18:51:24 +05:30
|
|
|
ls -lnR mdev.testdir/dev | $FILTER_LS" \
|
|
|
|
"\
|
|
|
|
@echo TEST
|
|
|
|
mdev.testdir/dev:
|
|
|
|
brw-r--r-- 1 0 0 8,0 sda
|
|
|
|
" \
|
|
|
|
"" ""
|
2010-05-10 09:23:16 +05:30
|
|
|
SKIP=
|
2008-05-02 18:51:24 +05:30
|
|
|
|
2009-01-12 13:27:52 +05:30
|
|
|
# continuing to use directory structure from prev test
|
|
|
|
rm -rf mdev.testdir/dev/*
|
2009-07-02 16:37:11 +05:30
|
|
|
echo "sda 0:0 644 =block/ @echo @echo TEST:\$MDEV" >mdev.testdir/etc/mdev.conf
|
2017-08-05 17:15:22 +05:30
|
|
|
optional STATIC FEATURE_MDEV_CONF FEATURE_MDEV_RENAME FEATURE_MDEV_EXEC FEATURE_LS_RECURSIVE FEATURE_LS_TIMESTAMPS FEATURE_LS_USERNAME SH_IS_ASH
|
2009-01-12 13:27:52 +05:30
|
|
|
testing "mdev move and command" \
|
|
|
|
"env - PATH=$PATH ACTION=add DEVPATH=/block/sda chroot mdev.testdir /mdev 2>&1;
|
|
|
|
ls -lnR mdev.testdir/dev | $FILTER_LS2" \
|
|
|
|
"\
|
2009-07-02 16:37:11 +05:30
|
|
|
@echo TEST:block/sda
|
2009-01-12 13:27:52 +05:30
|
|
|
mdev.testdir/dev:
|
|
|
|
drwxr-xr-x 2 0 0 block
|
|
|
|
|
|
|
|
mdev.testdir/dev/block:
|
|
|
|
brw-r--r-- 1 0 0 sda
|
|
|
|
" \
|
|
|
|
"" ""
|
2010-05-10 09:23:16 +05:30
|
|
|
SKIP=
|
2009-01-12 13:27:52 +05:30
|
|
|
|
2008-09-08 04:52:08 +05:30
|
|
|
# continuing to use directory structure from prev test
|
|
|
|
rm -rf mdev.testdir/dev/*
|
2009-06-14 03:11:57 +05:30
|
|
|
echo "@8,0 0:1 644" >mdev.testdir/etc/mdev.conf
|
2010-05-11 07:23:57 +05:30
|
|
|
optional STATIC FEATURE_MDEV_CONF FEATURE_MDEV_RENAME FEATURE_MDEV_RENAME_REGEXP FEATURE_LS_RECURSIVE FEATURE_LS_TIMESTAMPS FEATURE_LS_USERNAME
|
2008-09-08 04:52:08 +05:30
|
|
|
testing "mdev #maj,min and no explicit uid" \
|
|
|
|
"env - PATH=$PATH ACTION=add DEVPATH=/block/sda chroot mdev.testdir /mdev 2>&1;
|
|
|
|
ls -lnR mdev.testdir/dev | $FILTER_LS" \
|
|
|
|
"\
|
|
|
|
mdev.testdir/dev:
|
|
|
|
brw-r--r-- 1 0 1 8,0 sda
|
|
|
|
" \
|
|
|
|
"" ""
|
2010-05-10 09:23:16 +05:30
|
|
|
SKIP=
|
2008-09-08 04:52:08 +05:30
|
|
|
|
2009-06-22 05:01:12 +05:30
|
|
|
# continuing to use directory structure from prev test
|
|
|
|
rm -rf mdev.testdir/dev/*
|
|
|
|
mkdir -p mdev.testdir/sys/class/tty/capi
|
|
|
|
echo "191:0" >mdev.testdir/sys/class/tty/capi/dev
|
|
|
|
mkdir -p mdev.testdir/sys/class/tty/capi1
|
|
|
|
echo "191:1" >mdev.testdir/sys/class/tty/capi1/dev
|
|
|
|
mkdir -p mdev.testdir/sys/class/tty/capi20
|
|
|
|
echo "191:20" >mdev.testdir/sys/class/tty/capi20/dev
|
|
|
|
echo "capi 0:0 0660 =capi20" >mdev.testdir/etc/mdev.conf
|
|
|
|
echo "capi([0-9]) 0:0 0660 =capi20.0%1" >>mdev.testdir/etc/mdev.conf
|
|
|
|
echo "capi([0-9]*) 0:0 0660 =capi20.%1" >>mdev.testdir/etc/mdev.conf
|
|
|
|
# mdev invocation with DEVPATH=/class/tty/capi20 was deleting /dev/capi20
|
2010-05-11 15:32:48 +05:30
|
|
|
optional STATIC FEATURE_MDEV_CONF FEATURE_MDEV_RENAME FEATURE_MDEV_RENAME_REGEXP FEATURE_LS_RECURSIVE FEATURE_LS_TIMESTAMPS FEATURE_LS_USERNAME FEATURE_LS_SORTFILES
|
2009-06-22 05:01:12 +05:30
|
|
|
testing "move rule does not delete node with name == device_name" \
|
|
|
|
"\
|
|
|
|
env - PATH=$PATH ACTION=add DEVPATH=/class/tty/capi chroot mdev.testdir /mdev 2>&1;
|
|
|
|
env - PATH=$PATH ACTION=add DEVPATH=/class/tty/capi1 chroot mdev.testdir /mdev 2>&1;
|
|
|
|
env - PATH=$PATH ACTION=add DEVPATH=/class/tty/capi20 chroot mdev.testdir /mdev 2>&1;
|
|
|
|
ls -lnR mdev.testdir/dev | $FILTER_LS" \
|
|
|
|
"\
|
|
|
|
mdev.testdir/dev:
|
|
|
|
crw-rw---- 1 0 0 191,0 capi20
|
|
|
|
crw-rw---- 1 0 0 191,1 capi20.01
|
|
|
|
crw-rw---- 1 0 0 191,20 capi20.20
|
|
|
|
" \
|
|
|
|
"" ""
|
2010-05-10 09:23:16 +05:30
|
|
|
SKIP=
|
2009-06-22 05:01:12 +05:30
|
|
|
|
2008-03-28 02:19:26 +05:30
|
|
|
# clean up
|
|
|
|
rm -rf mdev.testdir
|
|
|
|
|
|
|
|
exit $FAILCOUNT
|