From d568c8e1c5012569e74f44bfd8491cf099aeac2a Mon Sep 17 00:00:00 2001 From: pschwan Date: Thu, 18 Jul 2002 06:26:43 +0000 Subject: [PATCH] small cleanup --- lustre/tests/create.pl | 47 ++++++++++++++++++++++++++++++----------------- 1 file changed, 30 insertions(+), 17 deletions(-) diff --git a/lustre/tests/create.pl b/lustre/tests/create.pl index debdcd1..71b4f95 100644 --- a/lustre/tests/create.pl +++ b/lustre/tests/create.pl @@ -1,36 +1,49 @@ #!/usr/bin/perl +my $mtpt = shift || usage(); +my $mount_count = shift || usage(); +my $i = shift || usage(); +my $files = 5; +my $mcreate = 1; # should we use mcreate or open? + sub usage () { print "Usage: $0 \n"; print "example: $0 /mnt/lustre 2 50\n"; print " will test in /mnt/lustre1 and /mnt/lustre2\n"; + print " $0 /mnt/lustre -1 50\n"; + print " will test in /mnt/lustre only\n"; exit; } -sub unused() { - my $tmp = `./mcreate $path`; - if ($tmp) { - $tmp =~ /.*error: (.*)\n/; - print "Created $path: $1\n"; +sub do_open($) { + my $path = shift; + + if ($mcreate) { + my $tmp = `./mcreate $path`; + if ($tmp) { + $tmp =~ /.*error: (.*)\n/; + print "Created $path: $1\n"; + } else { + print "Created $path: Success\n"; + } } else { - print "Created $path: Success\n"; + open(FH, ">$path") || die "open($PATH): $!"; + print "Opened $path: Success\n"; + close(FH) || die; } } -my $mtpt = shift || usage(); -my $mount_count = shift || usage(); -my $i = shift || usage(); -my $files = 2; - while ($i--) { - $which = int(rand() * $mount_count) + 1; + my $which = ""; + if ($mount_count > 0) { + $which = int(rand() * $mount_count) + 1; + } $d = int(rand() * $files); - $path = "$mtpt$which/$d"; - open(FH, ">$path") || die "open($PATH): $!"; - print "Opened $path: Success\n"; - close(FH) || die; + do_open("$mtpt$which/$d"); - $which = int(rand() * $mount_count) + 1; + if ($mount_count > 0) { + $which = int(rand() * $mount_count) + 1; + } $d = int(rand() * $files); $path = "$mtpt$which/$d"; if (unlink($path)) { -- 1.8.3.1