]>
git.proxmox.com Git - pve-container.git/blob - src/test/run_setup_tests.pl
5 use PVE
::Tools
qw(run_command);
13 my ($exp_fn, $real_fn) = @_;
15 # replace @DAYS@ with the current correct value
16 if ($exp_fn =~ m/shadow.exp$/) {
17 my $expecteddays = int(time()/(60*60*24));
18 system ("sed -i.bak 's/\@DAYS\@/$expecteddays/' $exp_fn");
19 my $ret = system("diff -u '$exp_fn' '$real_fn'");
20 system("mv '$exp_fn.bak' '$exp_fn'");
23 return if system("diff -u '$exp_fn' '$real_fn'") == 0;
26 die "files do not match\n";
32 print "prepare $testdir\n";
34 my $rootfs = "./tmprootfs";
36 run_command
("rm -rf $rootfs");
37 run_command
("cp -a $testdir $rootfs");
39 my $config_fn = "$testdir/config";
41 my $raw = PVE
::Tools
::file_get_contents
($config_fn);
43 my $conf = PVE
::LXC
::Config
::parse_pct_config
("/lxc/100.conf", $raw);
45 $conf->{'testmode'} = 1;
47 my $lxc_setup = PVE
::LXC
::Setup-
>new($conf, $rootfs);
49 for (my $i = 0; $i < 2; $i++) {
50 # run tests twice, to make sure scripts are idempotent
53 $lxc_setup->post_create_hook('$5$SALT$PASS','ssh-rsa ABCDEFG ABC@DEF');
55 my @testfiles = qw(/etc/hostname
58 /etc/network/interfaces
62 /etc/sysconfig/network
63 /etc/sysconfig/network-scripts/ifcfg-eth0
64 /etc/sysconfig/network-scripts/route-eth0
65 /etc/sysconfig/network-scripts/route6-eth0
66 /etc/sysconfig/network-scripts/ifcfg-eth1
67 /etc/sysconfig/network-scripts/route-eth1
68 /etc/sysconfig/network-scripts/route6-eth1
69 /etc/sysconfig/network-scripts/ifcfg-eth2
70 /etc/sysconfig/network-scripts/route-eth2
71 /etc/sysconfig/network-scripts/route6-eth2
72 /etc/sysconfig/network-scripts/ifcfg-eth3
73 /etc/sysconfig/network-scripts/route-eth3
74 /etc/sysconfig/network-scripts/route6-eth3
75 /etc/sysconfig/network/ifcfg-eth0
76 /etc/sysconfig/network/ifroute-eth0
77 /etc/sysconfig/network/ifcfg-eth1
78 /etc/sysconfig/network/ifroute-eth1
79 /etc/sysconfig/network/ifcfg-eth2
80 /etc/sysconfig/network/ifroute-eth2
81 /etc/sysconfig/network/ifcfg-eth3
82 /etc/sysconfig/network/ifroute-eth3
83 /etc/init/start-ttys.conf
85 /etc/init/power-status-changed.conf
90 /root/.ssh/authorized_keys
93 /roothome/.ssh/authorized_keys);
94 foreach my $fn (@testfiles) {
95 next if !-f
"$testdir/$fn.exp";
96 test_file
("$testdir/$fn.exp", "$rootfs/$fn");
100 print "TEST $testdir => OK\n";
105 foreach my $testdir (@ARGV) {
111 foreach my $testdir (<test-
*>) {#
112 next if ! -d
$testdir;