From 820735a85dbc2c9d19e948ea37945306ed7bc997 Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Thu, 9 May 2019 08:33:34 -0400 Subject: tests: Add some more --sudo tests https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=912180#17 pointed out that d_ino is not trustworthy on mount points either. Make sure we don't use it. --- tests.sh | 54 +++++++++++++++++++++++++++++++++++++---- tests/test_inum_bind_mount.out | 2 ++ tests/test_inum_mount.out | 1 + tests/test_xtype_bind_mount.out | 2 ++ 4 files changed, 54 insertions(+), 5 deletions(-) create mode 100644 tests/test_inum_bind_mount.out create mode 100644 tests/test_inum_mount.out create mode 100644 tests/test_xtype_bind_mount.out diff --git a/tests.sh b/tests.sh index b9d0a89..93ac03c 100755 --- a/tests.sh +++ b/tests.sh @@ -645,7 +645,10 @@ sudo_tests=( test_mount test_xdev + test_inum_mount + test_inum_bind_mount test_type_bind_mount + test_xtype_bind_mount ) if [ "$DEFAULT" ]; then @@ -940,6 +943,11 @@ function closefrom() { done } +function inum() { + ls -id "$@" | awk '{ print $1 }' +} + + cd "$TMP" # Test cases @@ -1753,8 +1761,7 @@ function test_quit_implicit_print() { } function test_inum() { - local inode="$(ls -id basic/k/foo/bar | awk '{ print $1 }')" - bfs_diff basic -inum "$inode" + bfs_diff basic -inum "$(inum basic/k/foo/bar)" } function test_nogroup() { @@ -2219,7 +2226,7 @@ function test_L_unique_depth() { function test_mount() { rm -rf scratch/* - mkdir scratch/foo scratch/mnt + mkdir scratch/{foo,mnt} sudo mount -t tmpfs tmpfs scratch/mnt touch scratch/foo/bar scratch/mnt/baz @@ -2232,7 +2239,7 @@ function test_mount() { function test_xdev() { rm -rf scratch/* - mkdir scratch/foo scratch/mnt + mkdir scratch/{foo,mnt} sudo mount -t tmpfs tmpfs scratch/mnt touch scratch/foo/bar scratch/mnt/baz @@ -2243,9 +2250,33 @@ function test_xdev() { return $ret } +function test_inum_mount() { + rm -rf scratch/* + mkdir scratch/{foo,mnt} + sudo mount -t tmpfs tmpfs scratch/mnt + + bfs_diff scratch -inum "$(inum scratch/mnt)" + local ret=$? + + sudo umount scratch/mnt + return $ret +} + +function test_inum_bind_mount() { + rm -rf scratch/* + touch scratch/{foo,bar} + sudo mount --bind scratch/{foo,bar} + + bfs_diff scratch -inum "$(inum scratch/bar)" + local ret=$? + + sudo umount scratch/bar + return $ret +} + function test_type_bind_mount() { rm -rf scratch/* - touch scratch/file scratch/null + touch scratch/{file,null} sudo mount --bind /dev/null scratch/null bfs_diff scratch -type c @@ -2255,6 +2286,19 @@ function test_type_bind_mount() { return $ret } +function test_xtype_bind_mount() { + rm -rf scratch/* + touch scratch/{file,null} + sudo mount --bind /dev/null scratch/null + ln -s /dev/null scratch/link + + bfs_diff -L scratch -type c + local ret=$? + + sudo umount scratch/null + return $ret +} + BOL= EOL='\n' diff --git a/tests/test_inum_bind_mount.out b/tests/test_inum_bind_mount.out new file mode 100644 index 0000000..a520de3 --- /dev/null +++ b/tests/test_inum_bind_mount.out @@ -0,0 +1,2 @@ +scratch/bar +scratch/foo diff --git a/tests/test_inum_mount.out b/tests/test_inum_mount.out new file mode 100644 index 0000000..99c7511 --- /dev/null +++ b/tests/test_inum_mount.out @@ -0,0 +1 @@ +scratch/mnt diff --git a/tests/test_xtype_bind_mount.out b/tests/test_xtype_bind_mount.out new file mode 100644 index 0000000..16804ea --- /dev/null +++ b/tests/test_xtype_bind_mount.out @@ -0,0 +1,2 @@ +scratch/link +scratch/null -- cgit v1.2.3