#!/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 <mount point prefix> <mount count> <iterations>\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)) {