#!/usr/bin/perl use warnings; use strict; # Live tests. # # These tests need to be run as simba_ca and it needs to be able to # connect to simba_da@localhost. use Test::More tests => 8; use File::stat; BEGIN { use_ok( 'Simba::CA' ); } my $ca = Simba::CA->new({ dbi_file => $ENV{SIMBA_DB_CONN} || "$ENV{HOME}/.dbi/simba_test"}); ok($ca, 'new CA'); # make sure filesets contains test data then connect again: $ca->{dbh}->do("delete from filesets"); $ca->{dbh}->do("insert into filesets(host, dir) values('localhost', '/var/tmp/simba_test')"); $ca = Simba::CA->new({ dbi_file => $ENV{SIMBA_DB_CONN} || "$ENV{HOME}/.dbi/simba_test"}); ok($ca, 'new CA 2'); SKIP: { skip "not running as root", 5 unless $> == 0; mkdir "/var/tmp/simba_test"; mkdir "/var/tmp/simba_test/d1"; mkdir "/var/tmp/simba_test/d2"; open my $fh, '>:raw', '/var/tmp/simba_test/d1/f1'; print $fh "test\n"; close($fh); open $fh, '>:raw', '/var/tmp/simba_test/d2/f2'; print $fh "test\n"; close($fh); open $fh, '>:raw', '/var/tmp/simba_test/d2/f3'; print $fh "#!/bin/sh\n"; chmod(04511, $fh); close($fh); $ca->run(); my $this_backup = $ca->{this_backup}; my $st1 = lstat("$this_backup/d1/f1"); ok($st1, "file 1 exists"); is($st1->nlink, 2, "file 1 has 2 links"); my $st2 = lstat("$this_backup/d2/f2"); ok($st2, "file 2 exists"); is($st2->nlink, 2, "file 2 has 2 links"); is($st1->ino, $st2->ino, , "file 1 and 2 are the same"); my $st3 = lstat("$this_backup/d2/f3"); ok($st3, "file 3 exists"); cmp_ok($st3->mode & 07777, '==', 04511, , "mode of file 3 is correct"); # cleanup system("rm", "-rf", $this_backup); $ca->{dbh}->do("delete from versions"); $ca->{dbh}->do("delete from files"); $ca->{dbh}->do("delete from filesets"); }