diff options
author | Tavian Barnes <tavianator@tavianator.com> | 2019-04-24 23:37:56 -0400 |
---|---|---|
committer | Tavian Barnes <tavianator@tavianator.com> | 2019-04-24 23:37:56 -0400 |
commit | 0b9bf589a2762267fedf7321ba03968ebc3abfcd (patch) | |
tree | aa479f35f68ce83aaae88581e07739f02d911ec6 /tests.sh | |
parent | 3857f41551b2ad3e5288828163afb6f67c7cc6f1 (diff) | |
download | bfs-0b9bf589a2762267fedf7321ba03968ebc3abfcd.tar.xz |
tests: Add some tests that require sudo
Diffstat (limited to 'tests.sh')
-rwxr-xr-x | tests.sh | 90 |
1 files changed, 77 insertions, 13 deletions
@@ -44,16 +44,19 @@ fi function usage() { local pad=$(printf "%*s" ${#0} "") cat <<EOF -Usage: ${GRN}$0${RST} [${BLU}--bfs${RST}=${MAG}path/to/bfs${RST}] [${BLU}--posix${RST}|${BLU}--bsd${RST}|${BLU}--gnu${RST}|${BLU}--all${RST}] +Usage: ${GRN}$0${RST} [${BLU}--bfs${RST}=${MAG}path/to/bfs${RST}] [${BLU}--posix${RST}] [${BLU}--bsd${RST}] [${BLU}--gnu${RST}] [${BLU}--all${RST}] [${BLU}--sudo${RST}] $pad [${BLU}--noclean${RST}] [${BLU}--update${RST}] [${BLU}--verbose${RST}] [${BLU}--help${RST}] $pad [${BLD}test_*${RST} [${BLD}test_*${RST} ...]] ${BLU}--bfs${RST}=${MAG}path/to/bfs${RST} Set the path to the bfs executable to test (default: ${MAG}./bfs${RST}) - ${BLU}--posix${RST}|${BLU}--bsd${RST}|${BLU}--gnu${RST}|${BLU}--all${RST} + ${BLU}--posix${RST}, ${BLU}--bsd${RST}, ${BLU}--gnu${RST}, ${BLU}--all${RST} Choose which test cases to run (default: ${BLU}--all${RST}) + ${BLU}--sudo${RST} + Run tests that require root (not included in ${BLU}--all${RST}) + ${BLU}--noclean${RST} Keep the test directories around after the run @@ -81,9 +84,12 @@ function _realpath() { BFS="$(_realpath ./bfs)" TESTS="$(_realpath ./tests)" -BSD=yes -GNU=yes -ALL=yes +DEFAULT=yes +POSIX= +BSD= +GNU= +ALL= +SUDO= CLEAN=yes UPDATE= VERBOSE= @@ -101,25 +107,30 @@ for arg; do BFS="${arg#*=}" ;; --posix) - BSD= - GNU= - ALL= + DEFAULT= + POSIX=yes ;; --bsd) + DEFAULT= + POSIX=yes BSD=yes - GNU= - ALL= ;; --gnu) - BSD= + DEFAULT= + POSIX=yes GNU=yes - ALL= ;; --all) + DEFAULT= + POSIX=yes BSD=yes GNU=yes ALL=yes ;; + --sudo) + DEFAULT= + SUDO=yes + ;; --noclean) CLEAN= ;; @@ -626,11 +637,26 @@ bfs_tests=( test_deep_strict ) +sudo_tests=( + test_mount + test_xdev + + test_type_bind_mount +) + +if [ "$DEFAULT" ]; then + POSIX=yes + BSD=yes + GNU=yes + ALL=yes +fi + if [ ! "$EXPLICIT" ]; then - enable_tests "${posix_tests[@]}" + [ "$POSIX" ] && enable_tests "${posix_tests[@]}" [ "$BSD" ] && enable_tests "${bsd_tests[@]}" [ "$GNU" ] && enable_tests "${gnu_tests[@]}" [ "$ALL" ] && enable_tests "${bfs_tests[@]}" + [ "$SUDO" ] && enable_tests "${sudo_tests[@]}" fi # The temporary directory that will hold our test data @@ -2171,6 +2197,44 @@ function test_L_unique_depth() { bfs_diff -L loops/deeply/nested -unique -depth } +function test_mount() { + rm -rf scratch/* + mkdir scratch/foo scratch/mnt + sudo mount -t tmpfs tmpfs scratch/mnt + touch scratch/foo/bar scratch/mnt/baz + + bfs_diff scratch -mount + local ret=$? + + sudo umount scratch/mnt + return $ret +} + +function test_xdev() { + rm -rf scratch/* + mkdir scratch/foo scratch/mnt + sudo mount -t tmpfs tmpfs scratch/mnt + touch scratch/foo/bar scratch/mnt/baz + + bfs_diff scratch -xdev + local ret=$? + + sudo umount scratch/mnt + return $ret +} + +function test_type_bind_mount() { + rm -rf scratch/* + touch scratch/file scratch/null + sudo mount --bind /dev/null scratch/null + + bfs_diff scratch -type c + local ret=$? + + sudo umount scratch/null + return $ret +} + BOL= EOL='\n' |