summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2018-11-14 00:08:11 -0500
committerTavian Barnes <tavianator@tavianator.com>2018-11-14 00:08:11 -0500
commita8f7b6dbd743bc224e2a8616993c373e82072956 (patch)
tree4f1485d9ebea1bca3e8105f9a049169aa45f0aab
parent4b60aafc1185164cf48a0627bc3b092c6a79b3bc (diff)
downloadbfs-a8f7b6dbd743bc224e2a8616993c373e82072956.tar.xz
tests: Don't assume find continues after filesystem loops
POSIX says > When it detects an infinite loop, find shall write a diagnostic > message to standard error and shall either recover its position in the > hierarchy or terminate. So make the 'links' folder not have any loops, and add a new 'loops' folder for testing the GNU/bfs behaviour.
-rwxr-xr-xtests.sh58
-rw-r--r--tests/test_H_loops.out4
-rw-r--r--tests/test_L.out5
-rw-r--r--tests/test_L_depth.out5
-rw-r--r--tests/test_L_loops_continue.out11
-rw-r--r--tests/test_L_xtype_f.out2
-rw-r--r--tests/test_L_xtype_l.out3
-rw-r--r--tests/test_colors.out4
-rw-r--r--tests/test_expr_flag_path.out2
-rw-r--r--tests/test_expr_path_flag.out2
-rw-r--r--tests/test_flag_expr_path.out2
-rw-r--r--tests/test_follow.out5
-rw-r--r--tests/test_links_minus.out1
-rw-r--r--tests/test_path_expr_flag.out2
-rw-r--r--tests/test_path_flag_expr.out2
-rw-r--r--tests/test_printf_types.out23
-rw-r--r--tests/test_type_multi.out1
-rw-r--r--tests/test_xtype_f.out2
-rw-r--r--tests/test_xtype_multi.out3
19 files changed, 100 insertions, 37 deletions
diff --git a/tests.sh b/tests.sh
index 88c3206..2930f86 100755
--- a/tests.sh
+++ b/tests.sh
@@ -90,12 +90,25 @@ function make_links() {
ln "$1/file" "$1/hardlink"
ln -s nowhere "$1/broken"
ln -s symlink/file "$1/notdir"
+ mkdir -p "$1/deeply/nested/dir"
+ touchp "$1/deeply/nested/file"
+ ln -s file "$1/deeply/nested/link"
+ ln -s deeply/nested "$1/skip"
+}
+make_links "$TMP/links"
+
+# Creates a file+directory structure with symbolic link loops
+function make_loops() {
+ touchp "$1/file"
+ ln -s file "$1/symlink"
+ ln -s nowhere "$1/broken"
+ ln -s symlink/file "$1/notdir"
ln -s loop "$1/loop"
mkdir -p "$1/deeply/nested/dir"
ln -s ../../deeply "$1/deeply/nested/loop"
ln -s deeply/nested/loop/nested "$1/skip"
}
-make_links "$TMP/links"
+make_loops "$TMP/loops"
# Creates a file+directory structure with varying timestamps
function make_times() {
@@ -185,10 +198,12 @@ posix_tests=(
test_H_slash
test_H_broken
test_H_notdir
+ test_H_loops
test_L
test_L_broken
test_L_notdir
+ test_L_loops
test_flag_weird_names
test_flag_comma
@@ -401,6 +416,8 @@ gnu_tests=(
test_P
test_P_slash
+ test_L_loops_continue
+
test_double_dash
test_flag_double_dash
@@ -931,8 +948,12 @@ function test_H_newer() {
bfs_diff -H times -newer times/l
}
+function test_H_loops() {
+ bfs_diff -H loops/deeply/nested/loop
+}
+
function test_L() {
- bfs_diff -L links 2>/dev/null
+ bfs_diff -L links
}
function test_L_broken() {
@@ -943,16 +964,27 @@ function test_L_notdir() {
bfs_diff -H links/notdir
}
+function test_L_loops() {
+ # POSIX says it's okay to either stop of keep going on seeing a filesystem
+ # loop, as long as a diagnostic is printed
+ local errors="$(invoke_bfs -L loops 2>&1 >/dev/null)"
+ [ -n "$errors" ]
+}
+
+function test_L_loops_continue() {
+ bfs_diff -L loops 2>/dev/null
+}
+
function test_X() {
bfs_diff -X weirdnames 2>/dev/null
}
function test_follow() {
- bfs_diff links -follow 2>/dev/null
+ bfs_diff links -follow
}
function test_L_depth() {
- bfs_diff -L links -depth 2>/dev/null
+ bfs_diff -L links -depth
}
function test_samefile() {
@@ -968,7 +1000,7 @@ function test_H_samefile_symlink() {
}
function test_L_samefile_symlink() {
- bfs_diff -L links -samefile links/symlink 2>/dev/null
+ bfs_diff -L links -samefile links/symlink
}
function test_samefile_broken() {
@@ -980,7 +1012,7 @@ function test_H_samefile_broken() {
}
function test_L_samefile_broken() {
- bfs_diff -L links -samefile links/broken 2>/dev/null
+ bfs_diff -L links -samefile links/broken
}
function test_samefile_notdir() {
@@ -992,27 +1024,27 @@ function test_H_samefile_notdir() {
}
function test_L_samefile_notdir() {
- bfs_diff -L links -samefile links/notdir 2>/dev/null
+ bfs_diff -L links -samefile links/notdir
}
function test_xtype_l() {
- bfs_diff links -xtype l 2>/dev/null
+ bfs_diff links -xtype l
}
function test_xtype_f() {
- bfs_diff links -xtype f 2>/dev/null
+ bfs_diff links -xtype f
}
function test_L_xtype_l() {
- bfs_diff -L links -xtype l 2>/dev/null
+ bfs_diff -L links -xtype l
}
function test_L_xtype_f() {
- bfs_diff -L links -xtype f 2>/dev/null
+ bfs_diff -L links -xtype f
}
function test_xtype_multi() {
- bfs_diff links -xtype f,d,c 2>/dev/null
+ bfs_diff links -xtype f,d,c
}
function test_xtype_reorder() {
@@ -1544,7 +1576,7 @@ function test_printf_flags() {
}
function test_printf_types() {
- bfs_diff links -printf '(%p) (%l) %y %Y\n'
+ bfs_diff loops -printf '(%p) (%l) %y %Y\n'
}
function test_printf_escapes() {
diff --git a/tests/test_H_loops.out b/tests/test_H_loops.out
new file mode 100644
index 0000000..1fc8f8f
--- /dev/null
+++ b/tests/test_H_loops.out
@@ -0,0 +1,4 @@
+loops/deeply/nested/loop
+loops/deeply/nested/loop/nested
+loops/deeply/nested/loop/nested/dir
+loops/deeply/nested/loop/nested/loop
diff --git a/tests/test_L.out b/tests/test_L.out
index dc88380..cf21a44 100644
--- a/tests/test_L.out
+++ b/tests/test_L.out
@@ -8,5 +8,8 @@ links/skip
links/symlink
links/deeply/nested
links/skip/dir
-links/skip/loop
+links/skip/file
+links/skip/link
links/deeply/nested/dir
+links/deeply/nested/file
+links/deeply/nested/link
diff --git a/tests/test_L_depth.out b/tests/test_L_depth.out
index dc88380..cf21a44 100644
--- a/tests/test_L_depth.out
+++ b/tests/test_L_depth.out
@@ -8,5 +8,8 @@ links/skip
links/symlink
links/deeply/nested
links/skip/dir
-links/skip/loop
+links/skip/file
+links/skip/link
links/deeply/nested/dir
+links/deeply/nested/file
+links/deeply/nested/link
diff --git a/tests/test_L_loops_continue.out b/tests/test_L_loops_continue.out
new file mode 100644
index 0000000..fbe0cac
--- /dev/null
+++ b/tests/test_L_loops_continue.out
@@ -0,0 +1,11 @@
+loops
+loops/broken
+loops/deeply
+loops/file
+loops/notdir
+loops/skip
+loops/symlink
+loops/deeply/nested
+loops/skip/dir
+loops/skip/loop
+loops/deeply/nested/dir
diff --git a/tests/test_L_xtype_f.out b/tests/test_L_xtype_f.out
index 996ffc8..78953d1 100644
--- a/tests/test_L_xtype_f.out
+++ b/tests/test_L_xtype_f.out
@@ -1,2 +1,4 @@
links/file
links/hardlink
+links/skip/file
+links/deeply/nested/file
diff --git a/tests/test_L_xtype_l.out b/tests/test_L_xtype_l.out
index 5773878..1cb0e19 100644
--- a/tests/test_L_xtype_l.out
+++ b/tests/test_L_xtype_l.out
@@ -2,4 +2,5 @@ links/broken
links/notdir
links/skip
links/symlink
-links/skip/loop
+links/skip/link
+links/deeply/nested/link
diff --git a/tests/test_colors.out b/tests/test_colors.out
index 6f8c534..8f09546 100644
--- a/tests/test_colors.out
+++ b/tests/test_colors.out
@@ -3,10 +3,10 @@
links/skip
links/symlink
links/broken
-links/loop
links/notdir
links/file
links/hardlink
links/deeply/nested
links/deeply/nested/dir
-links/deeply/nested/loop
+links/deeply/nested/link
+links/deeply/nested/file
diff --git a/tests/test_expr_flag_path.out b/tests/test_expr_flag_path.out
index c37a541..3112cd2 100644
--- a/tests/test_expr_flag_path.out
+++ b/tests/test_expr_flag_path.out
@@ -1 +1 @@
-links/skip/loop
+links/skip/link
diff --git a/tests/test_expr_path_flag.out b/tests/test_expr_path_flag.out
index c37a541..3112cd2 100644
--- a/tests/test_expr_path_flag.out
+++ b/tests/test_expr_path_flag.out
@@ -1 +1 @@
-links/skip/loop
+links/skip/link
diff --git a/tests/test_flag_expr_path.out b/tests/test_flag_expr_path.out
index c37a541..3112cd2 100644
--- a/tests/test_flag_expr_path.out
+++ b/tests/test_flag_expr_path.out
@@ -1 +1 @@
-links/skip/loop
+links/skip/link
diff --git a/tests/test_follow.out b/tests/test_follow.out
index dc88380..cf21a44 100644
--- a/tests/test_follow.out
+++ b/tests/test_follow.out
@@ -8,5 +8,8 @@ links/skip
links/symlink
links/deeply/nested
links/skip/dir
-links/skip/loop
+links/skip/file
+links/skip/link
links/deeply/nested/dir
+links/deeply/nested/file
+links/deeply/nested/link
diff --git a/tests/test_links_minus.out b/tests/test_links_minus.out
index e69de29..eda26f1 100644
--- a/tests/test_links_minus.out
+++ b/tests/test_links_minus.out
@@ -0,0 +1 @@
+links/deeply/nested/file
diff --git a/tests/test_path_expr_flag.out b/tests/test_path_expr_flag.out
index c37a541..3112cd2 100644
--- a/tests/test_path_expr_flag.out
+++ b/tests/test_path_expr_flag.out
@@ -1 +1 @@
-links/skip/loop
+links/skip/link
diff --git a/tests/test_path_flag_expr.out b/tests/test_path_flag_expr.out
index c37a541..3112cd2 100644
--- a/tests/test_path_flag_expr.out
+++ b/tests/test_path_flag_expr.out
@@ -1 +1 @@
-links/skip/loop
+links/skip/link
diff --git a/tests/test_printf_types.out b/tests/test_printf_types.out
index b548b10..9cfe347 100644
--- a/tests/test_printf_types.out
+++ b/tests/test_printf_types.out
@@ -1,12 +1,11 @@
-(links) () d d
-(links/broken) (nowhere) l N
-(links/deeply) () d d
-(links/file) () f f
-(links/hardlink) () f f
-(links/loop) (loop) l L
-(links/symlink) (file) l f
-(links/deeply/nested) () d d
-(links/notdir) (symlink/file) l N
-(links/deeply/nested/dir) () d d
-(links/skip) (deeply/nested/loop/nested) l d
-(links/deeply/nested/loop) (../../deeply) l d
+(loops) () d d
+(loops/broken) (nowhere) l N
+(loops/deeply) () d d
+(loops/file) () f f
+(loops/loop) (loop) l L
+(loops/symlink) (file) l f
+(loops/deeply/nested) () d d
+(loops/notdir) (symlink/file) l N
+(loops/deeply/nested/dir) () d d
+(loops/skip) (deeply/nested/loop/nested) l d
+(loops/deeply/nested/loop) (../../deeply) l d
diff --git a/tests/test_type_multi.out b/tests/test_type_multi.out
index 316ab7f..d22ed9f 100644
--- a/tests/test_type_multi.out
+++ b/tests/test_type_multi.out
@@ -4,3 +4,4 @@ links/file
links/hardlink
links/deeply/nested
links/deeply/nested/dir
+links/deeply/nested/file
diff --git a/tests/test_xtype_f.out b/tests/test_xtype_f.out
index 222ac78..dbe0c3f 100644
--- a/tests/test_xtype_f.out
+++ b/tests/test_xtype_f.out
@@ -1,3 +1,5 @@
links/file
links/hardlink
links/symlink
+links/deeply/nested/file
+links/deeply/nested/link
diff --git a/tests/test_xtype_multi.out b/tests/test_xtype_multi.out
index f9847db..171c580 100644
--- a/tests/test_xtype_multi.out
+++ b/tests/test_xtype_multi.out
@@ -6,4 +6,5 @@ links/skip
links/symlink
links/deeply/nested
links/deeply/nested/dir
-links/deeply/nested/loop
+links/deeply/nested/file
+links/deeply/nested/link