File: testlib.pl

package info (click to toggle)
libnet-traceroute-perl 1.15-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 276 kB
  • sloc: perl: 957; sh: 25; makefile: 4
file content (39 lines) | stat: -rw-r--r-- 885 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
36
37
38
39
use strict;
use warnings;

# Library routines used in multiple tests.

use Test::More;
use Net::Traceroute;

# parsetext(text) - return a Net::Traceroute object with the given
# text already parsed.
sub parsetext {
    my $text = shift;
    my $tr = Net::Traceroute->new();
    $tr->text($text);
    $tr->parse();
    return($tr);
}

# parsefh(filehandle) - slurp all text in from filehandle, and offer
# it to parsetext above.  Returns a Net::Traceroute object with the
# text parsed.
sub parsefh {
    my $fh = shift;
    my $text;
    { local $/ = undef; $text = <$fh>; }
    close($fh);
    parsetext($text);
}

# os_must_unixexec() - test requires the OS has a unix style exec.
# Test must use Test::More::plan().
sub os_must_unixexec {
    my @oses = qw(MSWin32 cygwin);
    my %oses = map { $_ => 1, } @oses;
    plan skip_all => "OS unsupported"
	if(exists($oses{$^O}));
}

1;