diff options
Diffstat (limited to 'tests/tools')
| -rw-r--r-- | tests/tools/zos-shim/zos_shim.h | 9 | ||||
| -rw-r--r-- | tests/tools/zos-sleep.c | 35 |
2 files changed, 44 insertions, 0 deletions
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; +} |
