Whamcloud - gitweb
- Added match_or_enqueue helper function
[fs/lustre-release.git] / lustre / tests / create.pl
1 #!/usr/bin/perl
2
3 sub usage () {
4     print "Usage: $0 <mount point prefix> <mount count> <iterations>\n";
5     print "example: $0 /mnt/lustre 2 50\n";
6     print "         will test in /mnt/lustre1 and /mnt/lustre2\n";
7     exit;
8 }
9
10 sub unused() {
11     my $tmp = `./mcreate $path`;
12     if ($tmp) {
13         $tmp =~ /.*error: (.*)\n/;
14         print "Created  $path: $1\n";
15     } else {
16         print "Created  $path: Success\n";
17     }
18 }
19
20 my $mtpt = shift || usage();
21 my $mount_count = shift || usage();
22 my $i = shift || usage();
23 my $files = 2;
24
25 while ($i--) {
26     $which = int(rand() * $mount_count) + 1;
27     $d = int(rand() * $files);
28     $path = "$mtpt$which/$d";
29     open(FH, ">$path") || die "open($PATH): $!";
30     print "Opened   $path: Success\n";
31     close(FH) || die;
32
33     $which = int(rand() * $mount_count) + 1;
34     $d = int(rand() * $files);
35     $path = "$mtpt$which/$d";
36     if (unlink($path)) {
37         print "Unlinked $path: Success\n";
38     } else {
39         print "Unlinked $path: $!\n";
40     }
41 }
42 print "Done.\n";