File: timez.t

package info (click to toggle)
systemconfigurator 2.0.10-1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 724 kB
  • ctags: 313
  • sloc: perl: 7,423; makefile: 48
file content (75 lines) | stat: -rw-r--r-- 1,328 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
use Test;
use Util::Log;
use Data::Dumper;
use Carp;

#
# This test is to
#

BEGIN {
    
    # Set up tests to run
    
    plan tests => 10;
    
    # Here is a trick to make it look like this was called with those args
    # on the command line before SCConfig runs.

    @ARGV = qw(--root /tmp/sctests --time_zone America/New_York);
}

Util::Log::start_verbose();
Util::Log::start_debug();

eval {
    use SCConfig;
    return 1;
};

ok($@,'') or croak("No point in going any further");

my $root = $config->root;

if($root !~ m{^/tmp}) {
    croak();
}

system("mkdir -p $root");
system("mkdir -p $root/etc/sysconfig/network");
system("mkdir -p $root/usr/share/zoneinfo/America");
open(OUT,">$root/usr/share/zoneinfo/America/New_York");
print OUT "test\n";
close(OUT);

eval {
    use Time;
    return 1;
};

ok($@,'') or croak("No point in going any further");

my @files = Time::setup($config);

ok($files[0],"$root/etc/localtime");
ok($files[1],"$root/etc/sysconfig/clock");

ok(scalar(@files));

ok(-e "$root/etc/localtime");

ok(-e "$root/etc/sysconfig/clock");

undef $/;
open(IN,"<$root/etc/sysconfig/clock");
my $var = <IN>;
close(IN);
ok($var,'/GMT="-u"/');
ok($var,'/DEFAULT_TIMEZONE/');

my $rc = system("cmp $root/etc/localtime $root/usr/share/zoneinfo/America/New_York");

ok(!$rc);

system("rm -rf $root");