File: stdin.t

package info (click to toggle)
speedy-cgi-perl 2.22-4
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 1,128 kB
  • ctags: 890
  • sloc: ansic: 4,487; sh: 1,105; perl: 945; makefile: 89
file content (25 lines) | stat: -rw-r--r-- 621 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25

# Our test script consume only one line from stdin, and leaves the
# second line in the buffer.  If the buffer isn't cleared between
# perl runs, we'll see the buffered line on the second run.

print "1..1\n";

my $sp = "$ENV{SPEEDY} t/scripts/stdin";

# Send two lines to script on stdin.
open(S, "| $sp >/dev/null");
print S "line1\nline2\n";
close(S);

# See if we get the correct output next time, or if stdin was buffered.
open(S, "| $sp >/tmp/stdin.$$");
print S "line3\n";
close(S);

open(F, "</tmp/stdin.$$");
my $line = <F>;
print ($line eq "line3\n" ? "ok\n" : "not ok\n");
close(F);

unlink("/tmp/stdin.$$");