summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorSean Kurtz <seankurtz75@gmail.com>2026-11-28 16:34:52 -0600
committerSean Kurtz <seankurtz75@gmail.com>2026-11-28 16:34:52 -0600
commit648125a5ef1a98519c5d2cd66c4f015bcb8b5b1f (patch)
tree70f802e577c24b23eb3a96098b4500a913bab399
parent3f24ca27250ade07c34a98fb792e6ca64e54c21b (diff)
downloadzash-648125a5ef1a98519c5d2cd66c4f015bcb8b5b1f.tar.gz
tests: cover the review fixes that landed without one
The 2026-11-28 review merge (#46) and the in-process `( cd dir )` merge (#31) left four changes with no test of their own. Three of the eighteen commits cannot have one, see below. - tests/posix/glob-edge.sh: `deep/*` where `deep` holds a file, a subdirectory, a symlink and a dangling symlink. This is the path the glob change takes when the last component has no literal tail left: it adds what readdir() named without an lstat(), so a directory and a broken link must still appear. Replacing `sb_cstr(&g->path)` with the unterminated buffer in that call makes this test fail. - tests/posix/charset.sh: a reversed range `[z-a]` matches nothing, which is what dash and bash do; the ASCII fast path compares bytes where the EBCDIC path looks up a table, so the two must agree on the edge. - tests/posix/printf-ext.sh: a 5000-character `%s`. The bare `%s` fast path writes the argument straight to the output instead of through the format buffer, so length is now the output's business. - tests/zash/heredoc-tmpdir.sh: a TMPDIR longer than PATH_MAX still produces the here-document, through the pipe fallback. - .exp files regenerated with dash (posix) and ./zash (zash), then reviewed: only the added lines differ. The three commits with no test: - 270ac66 `signal()` to `sigaction()` for SIG_DFL: the disposition set is the same, so no test can tell the two apart. - 06e1dd5 the arena size guard: reaching it needs a SIZE_MAX/2 allocation. - de0d26a the TMPDIR length check itself: a truncated temp name has no `XXXXXX` left, so mkstemp() already failed and the pipe fallback already ran. heredoc-tmpdir.sh pins that fallback, not the check. Verified on Linux (7.3.4-300.fc45.x86_64, 2026-11-28): make check 128 passed, 1 skipped, the known linux/i-dscomplete failure; make asan the same with no sanitizer report; the new posix tests pass against dash too.
-rw-r--r--tests/posix/charset.exp1
-rw-r--r--tests/posix/charset.sh1
-rw-r--r--tests/posix/glob-edge.exp1
-rw-r--r--tests/posix/glob-edge.sh2
-rw-r--r--tests/posix/printf-ext.expbin338 -> 343 bytes
-rw-r--r--tests/posix/printf-ext.sh1
-rw-r--r--tests/zash/heredoc-tmpdir.exp3
-rw-r--r--tests/zash/heredoc-tmpdir.sh8
8 files changed, 17 insertions, 0 deletions
diff --git a/tests/posix/charset.exp b/tests/posix/charset.exp
index b930bec..209df77 100644
--- a/tests/posix/charset.exp
+++ b/tests/posix/charset.exp
@@ -10,6 +10,7 @@ z in s-z
j in i-j
k not in a-j
case sensitive
+reversed range matches nothing
punct class
alpha class
digit class
diff --git a/tests/posix/charset.sh b/tests/posix/charset.sh
index e5d875d..53e519a 100644
--- a/tests/posix/charset.sh
+++ b/tests/posix/charset.sh
@@ -27,6 +27,7 @@ for c in a i j r s z; do case $c in [a-i]) echo "$c in a-i" ;; [j-r]) echo "$c i
case j in [i-j]) echo "j in i-j" ;; esac
case k in [!a-j]) echo "k not in a-j" ;; esac
case B in [a-z]) echo "B wrongly lower" ;; *) echo "case sensitive" ;; esac
+case m in [z-a]) echo "reversed range matched: $m" ;; *) echo "reversed range matches nothing" ;; esac
case _ in [[:alpha:]]) echo no ;; [[:punct:]]) echo "punct class" ;; esac
case x in [[:alpha:]]) echo "alpha class" ;; esac
case 5 in [[:digit:]]) echo "digit class" ;; esac
diff --git a/tests/posix/glob-edge.exp b/tests/posix/glob-edge.exp
index 5c5bb34..28ccf97 100644
--- a/tests/posix/glob-edge.exp
+++ b/tests/posix/glob-edge.exp
@@ -1,3 +1,4 @@
+deep/a deep/broken deep/link deep/sub
a1 a2
a1 b1
a1 b1
diff --git a/tests/posix/glob-edge.sh b/tests/posix/glob-edge.sh
index 006e948..98caf8f 100644
--- a/tests/posix/glob-edge.sh
+++ b/tests/posix/glob-edge.sh
@@ -1,5 +1,7 @@
# Pathname expansion.
mkdir sub; touch a1 a2 b1 .hidden 'sp ace' sub/x sub/y '[x]' 'q?'
+mkdir deep; mkdir deep/sub; ln -s a deep/link; ln -s nowhere deep/broken; touch deep/a
+echo deep/* | tr ' ' '\n' | sort | tr '\n' ' '; echo
echo a*
echo *1
echo ?1 | tr ' ' '\n' | sort | tr '\n' ' '; echo
diff --git a/tests/posix/printf-ext.exp b/tests/posix/printf-ext.exp
index 8ddaab7..83299d0 100644
--- a/tests/posix/printf-ext.exp
+++ b/tests/posix/printf-ext.exp
Binary files differ
diff --git a/tests/posix/printf-ext.sh b/tests/posix/printf-ext.sh
index 066aa2e..cace68f 100644
--- a/tests/posix/printf-ext.sh
+++ b/tests/posix/printf-ext.sh
@@ -19,6 +19,7 @@ printf '%d\n' abc 2>/dev/null; echo "nan=$?"
printf '%f\n' xyz 2>/dev/null; echo "nanf=$?"
printf '%d\n' 0x1f 010 -0
printf '%.3s|%10.4s|\n' abcdef abcdef
+long=$(awk 'BEGIN { for (i = 0; i < 5000; i++) printf "x" }'); printf '%s' "$long" | wc -c
printf '%s\n' -n
printf -- '--\n'
printf '\101\102\n'
diff --git a/tests/zash/heredoc-tmpdir.exp b/tests/zash/heredoc-tmpdir.exp
new file mode 100644
index 0000000..1b97303
--- /dev/null
+++ b/tests/zash/heredoc-tmpdir.exp
@@ -0,0 +1,3 @@
+hi
+status=0
+[status 0]
diff --git a/tests/zash/heredoc-tmpdir.sh b/tests/zash/heredoc-tmpdir.sh
new file mode 100644
index 0000000..437c5e7
--- /dev/null
+++ b/tests/zash/heredoc-tmpdir.sh
@@ -0,0 +1,8 @@
+# A TMPDIR too long for the here-document temp path falls back to a pipe
+# instead of writing a truncated name.
+long=$(awk 'BEGIN { for (i = 0; i < 5000; i++) printf "x" }')
+TMPDIR=/$long
+cat <<TXT
+hi
+TXT
+echo "status=$?"