summaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
authorSean Kurtz <seankurtz75@gmail.com>2026-11-23 11:50:17 -0600
committerSean Kurtz <seankurtz75@gmail.com>2026-11-23 11:50:17 -0600
commitb6574b2f3cb86d33d7e55985c7914dfce6dbf296 (patch)
tree22449ab76bbe49bed35b5e6c54019d2802301d6a /tests
parent2161b3c2de4eec4cc5f28cbf683f25acd3c7dbef (diff)
parenta847b938b372995762c8ab581c0be521fd2e8bcb (diff)
downloadzash-docs/logo-and-clean.tar.gz
Merge origin/main into docs/logo-and-cleandocs/logo-and-clean
Resolutions: README.md and DESIGN.md keep the new colour logo (packaging/zash-logo.svg) at width 220; the Makefile keeps main's newer shellcheck header, lists `make docs` in the usage block, and `clean` removes docs, cov and $(ZTOOLS) along with the branch's new tools.
Diffstat (limited to 'tests')
-rw-r--r--tests/posix/expand-edge.sh4
-rw-r--r--tests/posix/glob-edge.sh2
-rw-r--r--tests/scripts/bigdata.sh4
-rw-r--r--tests/scripts/wordfreq.sh6
-rw-r--r--tests/tools/zos-shim/zos_shim.h9
-rw-r--r--tests/tools/zos-sleep.c35
-rw-r--r--tests/zos/fdmap.exp1
-rw-r--r--tests/zos/fdmap.sh5
-rw-r--r--tests/zos/tagging.sh2
9 files changed, 61 insertions, 7 deletions
diff --git a/tests/posix/expand-edge.sh b/tests/posix/expand-edge.sh
index d8d1e7c..230578e 100644
--- a/tests/posix/expand-edge.sh
+++ b/tests/posix/expand-edge.sh
@@ -25,7 +25,7 @@ x=abcabc; echo "${x#*b}" "${x##*b}" "${x%b*}" "${x%%b*}" "${#x}"
x='a*b'; echo "${x#a\*}" "${x#"a*"}" "${x%'*b'}"
x=/usr/local/bin/sh; echo "${x##*/}" "${x%/*}"
echo "${#}" "${#@}" 2>/dev/null
-echo ${x:+"quoted alt"} | wc -w
+echo ${x:+"quoted alt"} | wc -w | tr -d ' '
a=1; b='$a'; echo "$b" ${b}
echo "$(echo "nested $(echo "deeper")")"
echo `echo \`echo inner\``
@@ -37,6 +37,6 @@ y=a:~:b; echo "$y" | sed "s|$HOME|HOME|g"
echo $((1+2))$((3)) "$((4*5))"
echo ${x+$(echo sub)}
echo "${u-$(echo default)}"
-unset u; echo "${u-"a b"}" | wc -w
+unset u; echo "${u-"a b"}" | wc -w | tr -d ' '
f() { echo "$#"; }; f "$@"; f $u; f "$u"; f ''
set -- 1 2 3 4 5 6 7 8 9 10 11; echo "$10" "${10}" "${11}"
diff --git a/tests/posix/glob-edge.sh b/tests/posix/glob-edge.sh
index ea3f0ee..006e948 100644
--- a/tests/posix/glob-edge.sh
+++ b/tests/posix/glob-edge.sh
@@ -18,7 +18,7 @@ echo q?
x='a*'; echo $x "$x"
for f in sp*; do echo "<$f>"; done
echo [a-b]1
-echo [[:digit:]]* | wc -w
+echo [[:digit:]]* | wc -w | tr -d ' '
echo [[:alpha:]]1
echo a[
echo sub/../a1
diff --git a/tests/scripts/bigdata.sh b/tests/scripts/bigdata.sh
index 0b012d9..58410e1 100644
--- a/tests/scripts/bigdata.sh
+++ b/tests/scripts/bigdata.sh
@@ -10,8 +10,8 @@ printf '%s\n' "$big" | cksum | cut -d' ' -f1 >sum3
cmp -s sum1 sum3 && echo "command substitution intact"
n=0; while read -r a b c; do n=$((n + c)); done <data; echo "sum: $n"
printf '%s\n' "$big" | while read -r a b c; do :; done; echo "read loop: $a"
-x=$(printf '%070000d' 0 | wc -c); echo "70000 bytes: $x" | tr -s ' '
-y=$(printf '%070000d' 0 | tr 0 x | tr x y | wc -c); echo "through tr: $y" | tr -s ' '
+x=$(printf '%070000d' 0 | wc -c | tr -d ' '); echo "70000 bytes: $x" | tr -s ' '
+y=$(printf '%070000d' 0 | tr 0 x | tr x y | wc -c | tr -d ' '); echo "through tr: $y" | tr -s ' '
printf '%0100000d\n' 0 | { read -r l; echo "${#l}"; }
cat <<EOF2 | wc -c | tr -d ' '
$big
diff --git a/tests/scripts/wordfreq.sh b/tests/scripts/wordfreq.sh
index 31c5eb0..5637c0e 100644
--- a/tests/scripts/wordfreq.sh
+++ b/tests/scripts/wordfreq.sh
@@ -4,7 +4,11 @@ The quick brown fox jumps over the lazy dog.
The dog barks; the fox runs. A quick, quick fox!
TXT
normalize() {
- tr 'A-Z' 'a-z' | tr -c 'a-z\n' ' ' | tr -s ' ' '\n' | sed '/^$/d'
+ # tr's ranges and -c follow the code page's collating order, which on
+ # z/OS (EBCDIC) makes 'A-Z' 'a-z' a mapping into punctuation and
+ # leaves ';' alone. sed and the [:upper:]/[:lower:] classes do not.
+ sed 's/[^a-zA-Z]/ /g' | tr '[:upper:]' '[:lower:]' | tr -s ' ' '\n' |
+ sed '/^$/d'
}
total=0
while read -r w; do
diff --git a/tests/tools/zos-shim/zos_shim.h b/tests/tools/zos-shim/zos_shim.h
index 5c4bac3..54f5fe9 100644
--- a/tests/tools/zos-shim/zos_shim.h
+++ b/tests/tools/zos-shim/zos_shim.h
@@ -11,6 +11,9 @@
*/
#ifndef ZOS_SHIM_H
#define ZOS_SHIM_H
+/* Tell the sources they are being checked, not built: this is 64-bit
+ * Linux, and sys_zos.c asserts the real build is 31-bit. */
+#define ZASH_ZOS_SHIM 1
#include <fcntl.h>
#include <signal.h>
#include <spawn.h>
@@ -85,6 +88,12 @@ int __osname(struct utsname *);
/* <stdlib.h> fetch() */
typedef int (*__fetch_t)(void);
__fetch_t fetch(const char *);
+int release(void (*)(void));
+
+/* <signal.h>: LE's abend signal. The value is from EDC4H023. */
+#ifndef SIGABND
+#define SIGABND 18
+#endif
/* <spawn.h> (z/OS spawn(), not posix_spawn) */
struct inheritance {
diff --git a/tests/tools/zos-sleep.c b/tests/tools/zos-sleep.c
new file mode 100644
index 0000000..f6272ab
--- /dev/null
+++ b/tests/tools/zos-sleep.c
@@ -0,0 +1,35 @@
+/**
+ * @file zos-sleep.c
+ * @brief A `sleep` that takes fractions, for the z/OS test runs.
+ *
+ * /bin/sleep on z/OS rejects "0.3" ("Improper sleep interval
+ * specification"), and tests/zash/jobs.sh and tests/scripts/parallel.sh
+ * order background jobs with sub-second sleeps. `make zos-check` builds
+ * this and puts its directory in front of PATH; Linux never builds it,
+ * because its own sleep is already fine.
+ */
+#include <errno.h>
+#include <stdlib.h>
+#include <time.h>
+
+int main(int argc, char **argv) {
+ struct timespec ts = {0, 0};
+ if (argc < 2)
+ return 1;
+ for (int i = 1; i < argc; i++) {
+ char *end = NULL;
+ double seconds = strtod(argv[i], &end);
+ if (end == argv[i] || *end != '\0' || seconds < 0)
+ return 1;
+ long whole = (long)seconds;
+ ts.tv_sec += (time_t)whole;
+ ts.tv_nsec += (long)((seconds - (double)whole) * 1e9);
+ }
+ ts.tv_sec += (time_t)(ts.tv_nsec / 1000000000L);
+ ts.tv_nsec %= 1000000000L;
+ while (nanosleep(&ts, &ts) < 0) {
+ if (errno != EINTR)
+ return 1;
+ }
+ return 0;
+}
diff --git a/tests/zos/fdmap.exp b/tests/zos/fdmap.exp
index cd47308..62f83ce 100644
--- a/tests/zos/fdmap.exp
+++ b/tests/zos/fdmap.exp
@@ -7,4 +7,5 @@ piped
captured
script descriptors ok
and closed again
+survives exec
[status 0]
diff --git a/tests/zos/fdmap.sh b/tests/zos/fdmap.sh
index c4f1679..b63a199 100644
--- a/tests/zos/fdmap.sh
+++ b/tests/zos/fdmap.sh
@@ -26,3 +26,8 @@ while [ $i -le 9 ]; do
i=$((i + 1))
done
/bin/sh -c 'echo "and closed again"'
+# The map hands the child the shell's own pipe descriptors. They are
+# close-on-exec (sys_pipe()), and spawn() keeps the flag, so a grandchild
+# that execs would lose the pipe -- ps printed EDC5113I Bad file
+# descriptor. The map must pass a duplicate without the flag.
+/bin/sh -c 'exec /bin/echo survives exec' | /bin/cat
diff --git a/tests/zos/tagging.sh b/tests/zos/tagging.sh
index 5f3c3bb..5ef4a3d 100644
--- a/tests/zos/tagging.sh
+++ b/tests/zos/tagging.sh
@@ -69,7 +69,7 @@ _TAG_REDIR_OUT=BIN printf 'hello\n' >in819 # ASCII bytes in an ASCII build
[ "$self" = IBM-1047 ] && _TAG_REDIR_OUT=BIN printf '\150\145\154\154\157\012' >in819
chtag -tc ISO8859-1 in819
_TAG_REDIR_IN=TXT cat <in819
-_TAG_REDIR_IN=BIN od -An -tx1 <in819 | tr -d ' \n'
+_TAG_REDIR_IN=BIN od -An -tx1 <in819 | tr -d ' \n' | tr '[:upper:]' '[:lower:]'
echo
echo "-- pipeline stage tagged by _TAG_REDIR_OUT"