3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 2 of the License, or
6 # (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program. If not, see <http://www.gnu.org/licenses/>.
16 use Test::More tests => 8;
20 use File::Temp qw(tempfile);
26 my ($tmp_fh, $tmp_name) = tempfile;
27 my ($tmp2_fh, $tmp2_name) = tempfile;
29 my $string = "foo\nbar\n";
32 open TMP, '>', $tmp_name;
36 my $pid = spawn(exec => "cat",
37 from_string => \$string,
38 to_string => \$string2);
42 is($string2, $string, "{from,to}_string");
44 $pid = spawn(exec => "cat",
45 from_handle => $tmp_fh,
46 to_handle => $tmp2_fh);
52 open TMP, '<', $tmp2_name;
56 is($string2, $string, "{from,to}_handle");
58 $pid = spawn(exec => "cat",
59 from_file => $tmp_name,
60 to_file => $tmp2_name,
66 open TMP, '<', $tmp2_name;
70 is($string2, $string, "{from,to}_file");
73 $pid = spawn(exec => ["sleep", "10"],
77 ok($@, "fails on timeout");