diff options
author | Jan Schmidt <janosch@webgods.de> | 2012-11-01 17:22:59 +0100 |
---|---|---|
committer | Jan Schmidt <janosch@webgods.de> | 2012-11-01 17:43:09 +0100 |
commit | 6b4c44e85bff4ee7db6df23663ec65e5e1038343 (patch) | |
tree | 994456dde0db93aa708d45f0e9d349d6a548bf62 | |
parent | 510dc807adc2cfccdd803079f460effa1552cca4 (diff) | |
download | far-progs-6b4c44e85bff4ee7db6df23663ec65e5e1038343.tar.gz |
far-progs: clean up after running, mount points made temp dirs
We now put all our temporary files into a subdir of /tmp, which is removed
after test.pl completed. Added -k option to keep the temp files.
The mount point directories changed from /mnt/src and /mnt/dst into the
temporary directory and can no longer be set explitly with -S or -D.
Signed-off-by: Jan Schmidt <janosch@webgods.de>
-rwxr-xr-x | test.pl | 37 |
1 files changed, 27 insertions, 10 deletions
@@ -24,18 +24,17 @@ use IPC::Open3; use Symbol qw(gensym); my @fs = qw(btrfs zfs); -my %opts = (D => "/mnt/dst", S => "/mnt/src"); +my %opts = (); sub usage { print STDERR <<EO_USAGE; $0 -s source -d destination [...] -d destination type:device (required; always local) - -D destination mountpoint (default $opts{D}) + -k keep temporary files -p pedanctic mode (stop on error) -q quiet -r remote host (needs ssh root login) -s source type:device (required; remote with -r, otherwise local) - -S source mountpoint (default $opts{S}) -t test spec (e.g. "1,2,3", "1-3,6:1,7:2-4,8-12") -v verbose type must be one of: @fs @@ -155,13 +154,14 @@ sub ignore_remote { my $p_refgen = "./refgen.pl"; my $p_refgen_actions = "./actions"; my $p_fssum = "fssum"; -my $p_sumfile = "/tmp/fssum.out"; +my $p_fardir = "/tmp/far-$$"; +my $p_sumfile = "$p_fardir/fssum.out"; my $p_btrfs = "btrfs"; my $p_zfs = "zfs"; -my $p_diff_outfile = "/tmp/fartest"; +my $p_diff_outfile = "$p_fardir/send.far"; my $p_perl = "perl"; -my $allok = getopts("d:D:hpqr:s:S:t:v", \%opts); +my $allok = getopts("d:hkpqr:s:t:v", \%opts); if (!$opts{d}) { print STDERR "missing -d destination\n"; @@ -201,9 +201,10 @@ if ($dst_type eq "zfs") { print STDERR "zfs destination type not implemented\n"; $allok = 0; } -my $dst_mnt = $opts{D}; -my $src_mnt = $opts{S}; +my $dst_mnt = "$p_fardir/mnt-dst"; +my $src_mnt = "$p_fardir/mnt-src"; my $verbose = $opts{v} ? "-v" : ""; +my $keep_temp = $opts{k}; $remote_host = $opts{r}; my ($src_type_opt, @p_send, $src_send, $dst_subvol, $send_incr_opt); @@ -284,8 +285,14 @@ if ($opts{t}) { } } -ignore_local("umount", $dst_mnt); -ignore_remote("umount", $src_mnt); +mkdir($p_fardir) or die "mkdir for temp dir $p_fardir failed: $!\n"; +mkdir($dst_mnt) or die "mkdir $dst_mnt failed: $!\n"; +if ($remote_host) { + do_remote("mkdir", $p_fardir); + do_remote("mkdir", $src_mnt); +} else { + mkdir($src_mnt) or die "mkdir $src_mnt failed: $!\n"; +} my @files = split /\n/, capture_local("ls", $p_refgen_actions); my @failed_tests = (); @@ -365,4 +372,14 @@ if (@failed_tests) { } else { print "\nAll tests ok\n"; } + +if (!$keep_temp) { + do_local("umount", $dst_mnt); + do_remote("umount", $src_mnt); + do_local("rm", "-rf", $p_fardir); + if ($remote_host) { + do_remote("rm", "-rf", $p_fardir); + } +} + exit($ex_ret); |