bsd-jail-object/t/BSD-Jail-Object.t
author mahlon
Fri, 05 Sep 2008 05:15:48 +0000
branchperl-modules
changeset 0 315eb12b224b
permissions -rw-r--r--
Reorganizing for Trac.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
315eb12b224b Reorganizing for Trac.
mahlon
parents:
diff changeset
     1
315eb12b224b Reorganizing for Trac.
mahlon
parents:
diff changeset
     2
use Test::More;
315eb12b224b Reorganizing for Trac.
mahlon
parents:
diff changeset
     3
315eb12b224b Reorganizing for Trac.
mahlon
parents:
diff changeset
     4
BEGIN
315eb12b224b Reorganizing for Trac.
mahlon
parents:
diff changeset
     5
{
315eb12b224b Reorganizing for Trac.
mahlon
parents:
diff changeset
     6
    if ( $^O !~ /^freebsd$/i ) {
315eb12b224b Reorganizing for Trac.
mahlon
parents:
diff changeset
     7
        plan skip_all => 'Module only usable under FreeBSD operating system';
315eb12b224b Reorganizing for Trac.
mahlon
parents:
diff changeset
     8
    }
315eb12b224b Reorganizing for Trac.
mahlon
parents:
diff changeset
     9
    else {
315eb12b224b Reorganizing for Trac.
mahlon
parents:
diff changeset
    10
        if ( $< ) {
315eb12b224b Reorganizing for Trac.
mahlon
parents:
diff changeset
    11
            plan skip_all => 'Must be root to run tests';
315eb12b224b Reorganizing for Trac.
mahlon
parents:
diff changeset
    12
        }
315eb12b224b Reorganizing for Trac.
mahlon
parents:
diff changeset
    13
        else {
315eb12b224b Reorganizing for Trac.
mahlon
parents:
diff changeset
    14
            plan tests => 7;
315eb12b224b Reorganizing for Trac.
mahlon
parents:
diff changeset
    15
            use_ok('BSD::Jail::Object');
315eb12b224b Reorganizing for Trac.
mahlon
parents:
diff changeset
    16
        }
315eb12b224b Reorganizing for Trac.
mahlon
parents:
diff changeset
    17
    }
315eb12b224b Reorganizing for Trac.
mahlon
parents:
diff changeset
    18
}
315eb12b224b Reorganizing for Trac.
mahlon
parents:
diff changeset
    19
315eb12b224b Reorganizing for Trac.
mahlon
parents:
diff changeset
    20
# jail identifier we'll do our tests on
315eb12b224b Reorganizing for Trac.
mahlon
parents:
diff changeset
    21
my $jid;
315eb12b224b Reorganizing for Trac.
mahlon
parents:
diff changeset
    22
315eb12b224b Reorganizing for Trac.
mahlon
parents:
diff changeset
    23
# all methods, public and private
315eb12b224b Reorganizing for Trac.
mahlon
parents:
diff changeset
    24
can_ok( 'BSD::Jail::Object', qw/
315eb12b224b Reorganizing for Trac.
mahlon
parents:
diff changeset
    25
    new _init 
315eb12b224b Reorganizing for Trac.
mahlon
parents:
diff changeset
    26
    jid ip hostname path
315eb12b224b Reorganizing for Trac.
mahlon
parents:
diff changeset
    27
    attach jids
315eb12b224b Reorganizing for Trac.
mahlon
parents:
diff changeset
    28
315eb12b224b Reorganizing for Trac.
mahlon
parents:
diff changeset
    29
    sysctl_len _find_jail
315eb12b224b Reorganizing for Trac.
mahlon
parents:
diff changeset
    30
    _find_jids _attach _create
315eb12b224b Reorganizing for Trac.
mahlon
parents:
diff changeset
    31
/);
315eb12b224b Reorganizing for Trac.
mahlon
parents:
diff changeset
    32
315eb12b224b Reorganizing for Trac.
mahlon
parents:
diff changeset
    33
# create
315eb12b224b Reorganizing for Trac.
mahlon
parents:
diff changeset
    34
my $j = BSD::Jail::Object->new({
315eb12b224b Reorganizing for Trac.
mahlon
parents:
diff changeset
    35
        path => '/tmp',
315eb12b224b Reorganizing for Trac.
mahlon
parents:
diff changeset
    36
        hostname => 'bsd-jail-object-tester',
315eb12b224b Reorganizing for Trac.
mahlon
parents:
diff changeset
    37
        ip => '127.0.0.1'
315eb12b224b Reorganizing for Trac.
mahlon
parents:
diff changeset
    38
});
315eb12b224b Reorganizing for Trac.
mahlon
parents:
diff changeset
    39
315eb12b224b Reorganizing for Trac.
mahlon
parents:
diff changeset
    40
is( ref $j, 'BSD::Jail::Object', 'Object namespace' );
315eb12b224b Reorganizing for Trac.
mahlon
parents:
diff changeset
    41
is( $j->path, '/tmp', "path verify" );
315eb12b224b Reorganizing for Trac.
mahlon
parents:
diff changeset
    42
is( $j->ip, '127.0.0.1', "ip verify" );
315eb12b224b Reorganizing for Trac.
mahlon
parents:
diff changeset
    43
is( $j->hostname, 'bsd-jail-object-tester', "hostname verify" );
315eb12b224b Reorganizing for Trac.
mahlon
parents:
diff changeset
    44
like( $j->jid, qr/^\d+$/, 'jid is integer (' . $j->jid . ')' );
315eb12b224b Reorganizing for Trac.
mahlon
parents:
diff changeset
    45
315eb12b224b Reorganizing for Trac.
mahlon
parents:
diff changeset
    46
# can't easily test attach()
315eb12b224b Reorganizing for Trac.
mahlon
parents:
diff changeset
    47
        
315eb12b224b Reorganizing for Trac.
mahlon
parents:
diff changeset
    48
# end of tests
315eb12b224b Reorganizing for Trac.
mahlon
parents:
diff changeset
    49
315eb12b224b Reorganizing for Trac.
mahlon
parents:
diff changeset
    50
315eb12b224b Reorganizing for Trac.
mahlon
parents:
diff changeset
    51
315eb12b224b Reorganizing for Trac.
mahlon
parents:
diff changeset
    52