# z/OS: moving data between the shell and MVS data sets. # # Needs tso(1) (TSO/E from the shell) and a high-level qualifier the user # may create data sets under: ZASH_TEST_HLQ, else the user ID. Skipped # (status 77) when tso is not available. Everything created is deleted # at the end, also when the test fails part way. # # zash does not open data sets itself; this checks that data flows # correctly between the shell and the z/OS utilities that do: quoting of # //'DSN(MEMBER)' names, exit statuses, pipes, here-documents, and large # amounts of data. # # VERIFY: written from the z/OS UNIX Command Reference and not yet run. # In particular: cp -T into and out of fixed-length records (trailing # blanks), cp reading /dev/fd/0, and the exact LISTDS output. command -v tso >/dev/null 2>&1 || exit 77 hlq=${ZASH_TEST_HLQ:-$(id -un | tr '[:lower:]' '[:upper:]')} q=Z$(($$ % 9999999)) pds=$hlq.ZASHTEST.$q seq=$hlq.ZASHTEST.$q.SEQ cleanup() { tso -t "DELETE '$pds'" >/dev/null 2>&1 tso -t "DELETE '$seq'" >/dev/null 2>&1 } trap cleanup EXIT # Allocate a PDS of 80-byte records and a sequential data set. tso -t "ALLOCATE DATASET('$pds') NEW CATALOG TRACKS SPACE(5,5) DIR(10) RECFM(F,B) LRECL(80) BLKSIZE(3120) DSORG(PO)" >/dev/null 2>&1 echo "allocate pds: $?" tso -t "FREE DATASET('$pds')" >/dev/null 2>&1 tso -t "ALLOCATE DATASET('$seq') NEW CATALOG TRACKS SPACE(5,5) RECFM(V,B) LRECL(255) BLKSIZE(3120) DSORG(PS)" >/dev/null 2>&1 echo "allocate seq: $?" tso -t "FREE DATASET('$seq')" >/dev/null 2>&1 # 1. A file into a member and back. Fixed records come back padded to # 80 bytes, so trailing blanks are stripped before comparing. printf 'line one\nline two\n' >src cp -T src "//'$pds(MEM1)'" echo "cp file to member: $?" cp -T "//'$pds(MEM1)'" back echo "cp member to file: $?" sed 's/ *$//' back # 2. The data set name in a variable, with the quotes inside the value. dsn="//'$pds(MEM2)'" printf 'from a variable\n' >src2 cp -T src2 "$dsn" && cp -T "$dsn" back2 && sed 's/ *$//' back2 # 3. Piping into a member: a pipeline feeds cp through /dev/fd/0. printf 'piped %s\n' a b c | tr a-z A-Z | cp -T /dev/fd/0 "//'$pds(PIPED)'" echo "pipe to member: $?" cp -T "//'$pds(PIPED)'" /dev/fd/1 | sed 's/ *$//' # 4. A here-document into a member, then the member into a pipeline. cp -T /dev/fd/0 "//'$pds(HERE)'" </dev/null && echo "$m" done | wc -l | tr -d ' ' # 8. Failures come back as non-zero statuses. cp -T "//'$pds(NOSUCH)'" x 2>/dev/null [ $? -ne 0 ] && echo "missing member fails" cp -T src "//'$hlq.ZASHTEST.NOT.ALLOCATED.$q'" 2>/dev/null tso -t "DELETE '$hlq.ZASHTEST.NOT.ALLOCATED.$q'" >/dev/null 2>&1 tso -t "LISTDS 'NO.SUCH.DATASET.$q'" >/dev/null 2>&1 [ $? -ne 0 ] && echo "tso failure status" # 9. A shell redirection from a data set name is an ordinary path to # zash (native data set redirection is not implemented yet): it fails # cleanly. Reading, not writing, so that a superuser running the test # cannot create a stray file in /. (cat <"//'$pds(MEM1)'") 2>/dev/null echo "redirection from a data set name: $?"