File: stdio.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 (35 lines) | stat: -rw-r--r-- 734 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
26
27
28
29
30
31
32
33
34
35

# Basic stdio test.  Pass a list of numbers through our script which
# does a "cat", and we should get back the same list.

my $do_stderr	= 1;
my $num		= 10000;
my $tmp		= "/tmp/speedy_stdio.$$";
my $max		= $do_stderr ? 4 : 2;
my @redirects	= $do_stderr ? (">$tmp", "1 2>$tmp") : (">$tmp");

print "1..$max\n";

for (my $j = 0; $j < 2; ++$j) {
    foreach my $redirect (@redirects) {
	open(F, "| $ENV{SPEEDY} t/scripts/stdio $redirect");
	for (my $i = 1; $i < $num; ++$i) {
	    print F "$i\n";
	}
	close(F);

	my $ok = 1;
	open(F, "<$tmp");
	for (my $i = 1; $i < $num; ++$i) {
	    $_ = <F>;
	    #print "Got: $_";
	    if ($_ != $i) {
		$ok = 0; last;
	    }
	}
	close(F);
	print $ok ? "ok\n" : "not ok\n";

	unlink($tmp);
    }
}