fsx: Add fallocate collapse range operation
[xfstests-dev.git] / tools / interop
1 #!/usr/sbin/perl
2 #
3 # Copyright (c) 2001 Silicon Graphics, Inc.  All Rights Reserved.
4 #
5 # This program is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU General Public License as
7 # published by the Free Software Foundation.
8 #
9 # This program is distributed in the hope that it would be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write the Free Software Foundation,
16 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
17 #
18
19 sub setup()
20 {
21     $PATH="$PATH:/usr/local/bin/ptools:/sbin:/usr/sbin";
22     $DISPLAY="clouds:0";
23     
24     if ("$HOST" eq "bruce") {
25         $TOOLS="/home/dxm/isms/slinx-xfs/cmd/xfs/tools";
26         $SCRATCH_DEV="/dev/sdf1";
27         $SCRATCH_MNT="/mnt/xfs3";
28         $MKFS="/sbin/mkfs -t xfs -f";
29         $SUDO="/home/dxm/su -c";
30         $MOUNT="/bin/mount -t xfs";
31         $UMOUNT="/bin/umount";
32         $MKFS_EXTRA="-f";
33     } elsif ("$HOST" eq "whack") {
34         $TOOLS="/hosts/snort/build1/people/dxm/isms/slinx-xfs/cmd/xfs/tools";
35         $SCRATCH_DEV="/dev/dsk/20000080e5114459/lun2s0/c2p1";
36         $SCRATCH_MNT="/lun2";
37         $MKFS="/sbin/mkfs";
38         $SUDO="su root -c";
39         $MOUNT="/sbin/mount -t xfs";
40         $UMOUNT="/sbin/umount";
41         $MKFS_EXTRA="";
42     } else {
43         die "unconfigured host \"$HOST\"\n"
44     }
45 }
46
47 sub run_no_check(@)
48 {
49     system(@_);
50 }
51
52 sub run(@)
53 {
54     system(@_)  == 0
55         || die "ERROR \"" . join(" ",@_) . "\" returned error\n";
56 }
57
58 sub run_expect_fail(@)
59 {
60     system(@_)  == 0
61         && die "ERROR \"" . join(" ",@_) . "\" returned non-error\n";
62 }
63
64 sub umount_no_check()
65 {
66     run_no_check("umount $SCRATCH_DEV");
67 }
68
69 sub umount()
70 {
71     run("umount $SCRATCH_DEV");
72 }
73
74 sub mount($)
75 {
76     my ($ops)=@_;
77     run("mount -t xfs $ops $SCRATCH_DEV $SCRATCH_MNT");
78 }
79
80 chomp($HOST=`hostname -s`);
81
82 die "usage: $ARGV0 <operation> [parameters]\n" unless (scalar(@ARGV));
83 print "*** $HOST: Interop started\n";
84 print "    *** ", join(" ", @ARGV), "\n";
85
86 setup();
87
88 $op=shift(@ARGV);
89
90 umount_no_check();
91
92 if ($op eq "init") {
93
94     run("mkfs -t xfs $MKFS_EXTRA $SCRATCH_DEV");
95     
96 } elsif ($op eq "test") {
97
98     run("xfs_repair -n $SCRATCH_DEV");
99     
100 } elsif ($op eq "easy") {
101
102     mount("");
103     system("mount");
104     mkdir("$SCRATCH_MNT/fish",0777);
105     
106 } elsif ($op eq "check") {
107
108     mount("-o ro");
109     system("cd $SCRATCH_MNT ; $TOOLS/fs-walk .");
110
111 } else {
112     die "unknown operation \"$op\"\n";
113 }
114
115 umount_no_check();