zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: Zsh hackers list <zsh-workers@zsh.org>
Subject: [PATCH] Test for 50101
Date: Sun, 1 May 2022 11:09:18 -0700	[thread overview]
Message-ID: <CAH+w=7a8W-OE9BBvcoaW=mhFn7adhNxBmB6=sAbL+Bru1xbc3Q@mail.gmail.com> (raw)
In-Reply-To: <CAH+w=7bby1GiKxTL9Y3M6Xuhe56EQdRHDsabbShfWNLkdkxhsg@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 984 bytes --]

I included tests for all return values of sysread except "error in parameters".

That includes a couple of Xfail tests for the $REPLY value.  The doc says:

     ... The result of the read is stored in PARAM or
     REPLY if that is not given. ...
     If OUTFD is given, an attempt is made to write all the bytes just
     read to the file descriptor OUTFD.  If this fails, ...
     the bytes read but not written are stored in
     the parameter named by PARAM if supplied ....  If it was
     successful, COUNTVAR contains the full number of bytes transferred,
     as usual, and PARAM is not set.

This doesn't really specify what happens when $REPLY (or the PARAM)
already has a value before sysread is called.  As currently
implemented, the value (or unset-ness) is unchanged when the return
status does not require that anything be assigned, so it's necessary
to either carefully (un)set these parameters before calling sysread,
or to test the return status before using them.

[-- Attachment #2: test_sysread.txt --]
[-- Type: text/plain, Size: 1952 bytes --]

diff --git a/Test/V14system.ztst b/Test/V14system.ztst
index ffdb730a4..81253324f 100644
--- a/Test/V14system.ztst
+++ b/Test/V14system.ztst
@@ -147,3 +147,69 @@ F:This timing test might fail due to process scheduling issues unrelated to zsh.
 0:zsystem flock successful wait test, fractional seconds
 ?elapsed time seems OK
 F:This timing test might fail due to process scheduling issues unrelated to zsh.
+
+  unset chars REPLY
+  print -n a few words | sysread -i 0 -c chars
+  ret=$?
+  print -- $chars x${REPLY}x
+  return ret
+0:sysread default
+>11 xa few wordsx
+
+  unset chars REPLY
+  sysread -i 9 -c chars
+  ret=$?
+  print -- $chars x${REPLY}x
+  return ret
+2:sysread read error
+>-1 xx
+
+  REPLY="say nothing"
+  sysread -i 9 -c chars
+  ret=$?
+  print -- $chars x${REPLY}x
+  return ret
+2f:sysread read error
+F:The value of $REPLY should be empty or unset when nothing is read?
+>-1 xx
+
+  unset chars REPLY
+  print -n a few words | sysread -i 0 -o 9 -c chars
+  ret=$?
+  print -- $chars x${REPLY}x
+  return ret
+3:sysread write error
+>11 xx
+
+  sleep 3 | sysread -i 0 -t 1
+4:sysread timeout
+
+  sysread -i 0 </dev/null
+5:sysread end of file
+
+  unset chars oration
+  print -n a few words | sysread -i 0 -o 9 -c chars oration
+  ret=$?
+  print $chars x${oration}x $REPLY
+  return ret
+3:regression test: sysread write error with both -o and a parameter
+>11 xa few wordsx
+
+  unset chars oration
+  print a few words | sysread -i 0 -o 1 -c chars oration
+  ret=$?
+  print -- $chars x${oration}x $REPLY
+  return ret
+0:regression test: sucessful sysread with both -o and a parameter
+>a few words
+>12 xx
+
+  oration="do not say these words"
+  print a few words | sysread -i 0 -o 1 -c chars oration
+  ret=$?
+  print -- $chars x${oration}x $REPLY
+  return ret
+0f:successful sysread with both -o and a parameter
+F:The value of $oration should be empty or unset when everything is written?
+>a few words
+>12 xx

  parent reply	other threads:[~2022-05-01 18:10 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-30 18:31 A second test release before 5.9 final? Bart Schaefer
2022-04-30 21:41 ` dana
2022-05-01 14:52 ` Daniel Shahaf
2022-05-01 16:50   ` Bart Schaefer
2022-05-01 17:38     ` Daniel Shahaf
2022-05-02  2:24       ` Jun T
2022-05-02  3:10         ` Bart Schaefer
2022-05-02  4:09           ` Jun T
2022-05-02 12:58           ` Daniel Shahaf
2022-05-01 17:49     ` Peter Stephenson
2022-05-01 18:09     ` Bart Schaefer [this message]
2022-05-01 19:09     ` [PATCH] Tests for 50126, 50136, and 50149 Bart Schaefer
2022-05-02  4:59       ` Jun T
2022-05-02  5:15         ` Bart Schaefer
2022-05-02  5:46           ` Jun T
2022-05-02 13:14         ` Jun. T
2022-05-02 16:26           ` Bart Schaefer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAH+w=7a8W-OE9BBvcoaW=mhFn7adhNxBmB6=sAbL+Bru1xbc3Q@mail.gmail.com' \
    --to=schaefer@brasslantern.com \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).