diff options
author | Tavian Barnes <tavianator@tavianator.com> | 2019-05-09 08:33:34 -0400 |
---|---|---|
committer | Tavian Barnes <tavianator@tavianator.com> | 2019-05-09 08:33:34 -0400 |
commit | 820735a85dbc2c9d19e948ea37945306ed7bc997 (patch) | |
tree | 61278c543f4629ae049e409c1990c5a9865ef6be /tests.sh | |
parent | 50d395b356b3ffc73ab97101c5434bda06141cc4 (diff) | |
download | bfs-820735a85dbc2c9d19e948ea37945306ed7bc997.tar.xz |
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.
Diffstat (limited to 'tests.sh')
-rwxr-xr-x | tests.sh | 54 |
1 files changed, 49 insertions, 5 deletions
@@ -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' |