Update commands for moved include files
[xfstests-dev.git] / tools / interop
1 #!/usr/sbin/perl
2
3 sub setup()
4 {
5     $PATH="$PATH:/usr/local/bin/ptools:/sbin:/usr/sbin";
6     $DISPLAY="clouds:0";
7     
8     if ("$HOST" eq "bruce") {
9         $TOOLS="/home/dxm/isms/slinx-xfs/cmd/xfs/tools";
10         $SCRATCH_DEV="/dev/sdf1";
11         $SCRATCH_MNT="/mnt/xfs3";
12         $MKFS="/sbin/mkfs -t xfs -f";
13         $SUDO="/home/dxm/su -c";
14         $MOUNT="/bin/mount -t xfs";
15         $UMOUNT="/bin/umount";
16         $MKFS_EXTRA="-f";
17     } elsif ("$HOST" eq "whack") {
18         $TOOLS="/hosts/snort/build1/people/dxm/isms/slinx-xfs/cmd/xfs/tools";
19         $SCRATCH_DEV="/dev/dsk/20000080e5114459/lun2s0/c2p1";
20         $SCRATCH_MNT="/lun2";
21         $MKFS="/sbin/mkfs";
22         $SUDO="su root -c";
23         $MOUNT="/sbin/mount -t xfs";
24         $UMOUNT="/sbin/umount";
25         $MKFS_EXTRA="";
26     } else {
27         die "unconfigured host \"$HOST\"\n"
28     }
29 }
30
31 sub run_no_check(@)
32 {
33     system(@_);
34 }
35
36 sub run(@)
37 {
38     system(@_)  == 0
39         || die "ERROR \"" . join(" ",@_) . "\" returned error\n";
40 }
41
42 sub run_expect_fail(@)
43 {
44     system(@_)  == 0
45         && die "ERROR \"" . join(" ",@_) . "\" returned non-error\n";
46 }
47
48 sub umount_no_check()
49 {
50     run_no_check("umount $SCRATCH_DEV");
51 }
52
53 sub umount()
54 {
55     run("umount $SCRATCH_DEV");
56 }
57
58 sub mount($)
59 {
60     my ($ops)=@_;
61     run("mount -t xfs $ops $SCRATCH_DEV $SCRATCH_MNT");
62 }
63
64 chomp($HOST=`hostname -s`);
65
66 die "usage: $ARGV0 <operation> [parameters]\n" unless (scalar(@ARGV));
67 print "*** $HOST: Interop started\n";
68 print "    *** ", join(" ", @ARGV), "\n";
69
70 setup();
71
72 $op=shift(@ARGV);
73
74 umount_no_check();
75
76 if ($op eq "init") {
77
78     run("mkfs -t xfs $MKFS_EXTRA $SCRATCH_DEV");
79     
80 } elsif ($op eq "test") {
81
82     run("xfs_repair -n $SCRATCH_DEV");
83     
84 } elsif ($op eq "easy") {
85
86     mount("");
87     system("mount");
88     mkdir("$SCRATCH_MNT/fish",0777);
89     
90 } elsif ($op eq "check") {
91
92     mount("-o ro");
93     system("cd $SCRATCH_MNT ; $TOOLS/fs-walk .");
94
95 } else {
96     die "unknown operation \"$op\"\n";
97 }
98
99 umount_no_check();