File: 04-distribution.t

package info (click to toggle)
libsys-info-driver-linux-perl 0.7908-1
  • links: PTS, VCS
  • area: main
  • in suites: forky
  • size: 244 kB
  • sloc: perl: 1,120; makefile: 2
file content (41 lines) | stat: -rw-r--r-- 937 bytes parent folder | download | duplicates (5)
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
40
41
#!/usr/bin/env perl -w
use strict;
use warnings;
use Carp       qw( croak   );
use Test::More qw( no_plan );
use Data::Dumper;

use Sys::Info::Driver::Linux::OS::Distribution;

ok( my $distro  = Sys::Info::Driver::Linux::OS::Distribution->new, 'Got the object' );
ok( my $name    = $distro->name,    'Got a name'    );
ok( my $version = $distro->version, 'Got a version' );

diag Dumper {
    distro  => $distro,
    name    => $name,
    version => $version,
};

dump_if_exists( '/etc/lsb-release' );

sub dump_if_exists {
    my $file = shift;
    return if ! -e $file;
    diag('DEBUG');
    diag("[DUMPING] $file");
    diag( slurp( $file ) );
    return;
}

sub slurp {
    my $file = shift || croak 'File parameter is missing';
    require IO::File;
    my $FH = IO::File->new;
    $FH->open( $file, '<' ) or croak "Can't open FH ($file) for reading: $!";
    my $rv = do { local $/; <$FH> };
    $FH->close;
    return $rv;
}

1;