From ddb476bcd224f8c262d24981af48da2fc649f43d Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Sat, 14 Oct 2023 08:55:57 -0400 Subject: tests: Move closed_std* tests out of the POSIX group POSIX actually says > If the utility would be executed with file descriptor 0, 1, or 2 > closed, implementations may execute the utility with the file > descriptor open to an unspecified file. So we're not guaranteed to be able to detect the situation in the first place. Add a best-effort check for these platforms and skip the test. Link: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_09_01_01 --- tests/bfs/closed_stderr.sh | 4 ++++ tests/bfs/closed_stdin.out | 19 +++++++++++++++++++ tests/bfs/closed_stdin.sh | 1 + tests/bfs/closed_stdout.sh | 4 ++++ tests/posix/closed_stderr.sh | 1 - tests/posix/closed_stdin.out | 19 ------------------- tests/posix/closed_stdin.sh | 1 - tests/posix/closed_stdout.sh | 1 - 8 files changed, 28 insertions(+), 22 deletions(-) create mode 100644 tests/bfs/closed_stderr.sh create mode 100644 tests/bfs/closed_stdin.out create mode 100644 tests/bfs/closed_stdin.sh create mode 100644 tests/bfs/closed_stdout.sh delete mode 100644 tests/posix/closed_stderr.sh delete mode 100644 tests/posix/closed_stdin.out delete mode 100644 tests/posix/closed_stdin.sh delete mode 100644 tests/posix/closed_stdout.sh (limited to 'tests') diff --git a/tests/bfs/closed_stderr.sh b/tests/bfs/closed_stderr.sh new file mode 100644 index 0000000..26abd85 --- /dev/null +++ b/tests/bfs/closed_stderr.sh @@ -0,0 +1,4 @@ +# Check if the platform automatically re-opens stderr before we can +(bash -c 'echo >&2' 2>&-) && skip + +! invoke_bfs basic >&- 2>&- diff --git a/tests/bfs/closed_stdin.out b/tests/bfs/closed_stdin.out new file mode 100644 index 0000000..a7ccfe4 --- /dev/null +++ b/tests/bfs/closed_stdin.out @@ -0,0 +1,19 @@ +basic +basic/a +basic/b +basic/c +basic/c/d +basic/e +basic/e/f +basic/g +basic/g/h +basic/i +basic/j +basic/j/foo +basic/k +basic/k/foo +basic/k/foo/bar +basic/l +basic/l/foo +basic/l/foo/bar +basic/l/foo/bar/baz diff --git a/tests/bfs/closed_stdin.sh b/tests/bfs/closed_stdin.sh new file mode 100644 index 0000000..6932be8 --- /dev/null +++ b/tests/bfs/closed_stdin.sh @@ -0,0 +1 @@ +bfs_diff basic <&- diff --git a/tests/bfs/closed_stdout.sh b/tests/bfs/closed_stdout.sh new file mode 100644 index 0000000..5b6f7c3 --- /dev/null +++ b/tests/bfs/closed_stdout.sh @@ -0,0 +1,4 @@ +# Check if the platform automatically re-opens stdout before we can +(bash -c echo >&-) && skip + +! invoke_bfs basic >&- diff --git a/tests/posix/closed_stderr.sh b/tests/posix/closed_stderr.sh deleted file mode 100644 index 570d5bb..0000000 --- a/tests/posix/closed_stderr.sh +++ /dev/null @@ -1 +0,0 @@ -! invoke_bfs basic >&- 2>&- diff --git a/tests/posix/closed_stdin.out b/tests/posix/closed_stdin.out deleted file mode 100644 index a7ccfe4..0000000 --- a/tests/posix/closed_stdin.out +++ /dev/null @@ -1,19 +0,0 @@ -basic -basic/a -basic/b -basic/c -basic/c/d -basic/e -basic/e/f -basic/g -basic/g/h -basic/i -basic/j -basic/j/foo -basic/k -basic/k/foo -basic/k/foo/bar -basic/l -basic/l/foo -basic/l/foo/bar -basic/l/foo/bar/baz diff --git a/tests/posix/closed_stdin.sh b/tests/posix/closed_stdin.sh deleted file mode 100644 index 6932be8..0000000 --- a/tests/posix/closed_stdin.sh +++ /dev/null @@ -1 +0,0 @@ -bfs_diff basic <&- diff --git a/tests/posix/closed_stdout.sh b/tests/posix/closed_stdout.sh deleted file mode 100644 index 25c060d..0000000 --- a/tests/posix/closed_stdout.sh +++ /dev/null @@ -1 +0,0 @@ -! invoke_bfs basic >&- -- cgit v1.2.3