Whamcloud - gitweb
7217ba0b60aefed9efe9fc521db0575e60a4a073
[fs/lustre-release.git] / libsysio / tests / test_copy.bash
1 #!/bin/bash
2 #############################################################################
3 #
4 #     This Cplant(TM) source code is the property of Sandia National
5 #     Laboratories.
6 #
7 #     This Cplant(TM) source code is copyrighted by Sandia National
8 #     Laboratories.
9 #
10 #     The redistribution of this Cplant(TM) source code is subject to the
11 #     terms of the GNU Lesser General Public License
12 #     (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html)
13 #
14 #     Cplant(TM) Copyright 1998-2003 Sandia Corporation. 
15 #     Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive
16 #     license for use of this work by or on behalf of the US Government.
17 #     Export of this program may require a license from the United States
18 #     Government.
19 #
20 #############################################################################
21
22
23 # This library is free software; you can redistribute it and/or
24 # modify it under the terms of the GNU Lesser General Public
25 # License as published by the Free Software Foundation; either
26 # version 2.1 of the License, or (at your option) any later version.
27
28 # This library is distributed in the hope that it will be useful,
29 # but WITHOUT ANY WARRANTY; without even the implied warranty of
30 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
31 # Lesser General Public License for more details.
32
33 # You should have received a copy of the GNU Lesser General Public
34 # License along with this library; if not, write to the Free Software
35 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
36 #
37 # Questions or comments about this library should be sent to:
38 #
39 # Lee Ward
40 # Sandia National Laboratories, New Mexico
41 # P.O. Box 5800
42 # Albuquerque, NM 87185-1110
43 #
44 # lee@sandia.gov
45
46 ############################################################################
47 #
48 #   File:  test_copy.bash
49 #
50 #   Description:  Script to exercise the sysio library.
51 #
52 #   Usage:  
53 #   test_copy.bash 
54
55 #   Limitations:
56 #   1.  Doesn't exercise all of sysio.
57 #   2.  Uses hardcoded /native prefix for file names which may not be the
58 #       final solution.
59 #
60 ############################################################################
61
62 # defaults - change as necessary for local system
63 SCRATCH=test_copy.$$
64 CWD=`pwd`
65 SRC=${CWD}/test_copy.src
66 DEST=${CWD}/test_copy.dest
67 PREFIX=/native
68
69 # main processing logic follows
70 cp /dev/null $SCRATCH
71 rm -f $SRC $DEST
72 if [ -f $SRC ] 
73 then 
74   echo "Could not remove $SRC - test INDETERMINATE" >> $SCRATCH
75   exit 5
76 fi
77 if [ -f $DEST ] 
78 then 
79   echo "Could not remove $DEST - test INDETERMINATE" >> $SCRATCH
80   exit 5
81 fi
82
83 if ( ! cp /usr/include/stdio.h $SRC )  # just picked something handy
84 then
85   echo "Could not create source file - test INDETERMINATE" >> $SCRATCH
86   exit 5
87 fi
88
89
90 #
91 #  Run the test
92 #
93 ./test_copy ${PREFIX}/${SRC} ${PREFIX}/${DEST}
94 SRC_VERF=`cksum $SRC | awk '{ print $1 }'`
95 DEST_VERF=`cksum $DEST | awk '{ print $1 }'`
96 if [ "$SRC_VERF" -ne "$DEST_VERF" ]
97 then
98     echo "The source and destination files did not match; test FAILED" >> $SCRATCH 2>&1
99 else
100     echo "The source and destination files matched; test PASSED" >> $SCRATCH 2>&1
101 fi
102
103 #
104 #  Report test results
105 #
106 echo ""
107 PASSCNT=1
108 if grep "FAILED" $SCRATCH > /dev/null
109 then
110         echo "TEST $0 FAILED - found failed"
111         cat $SCRATCH
112         RC=8
113 elif test `grep -c "PASSED" $SCRATCH` -ne $PASSCNT > /dev/null
114 then
115         echo "TEST $0 FAILED - wrong pass count"
116         cat $SCRATCH
117         RC=4
118 else
119         echo "TEST $0 PASSED"
120         RC=0
121
122 fi
123
124 if [ -z "$NOCLEANUP" ]
125 then
126   rm -f $SCRATCH $SRC $DEST
127 fi
128
129 exit $RC