r19280: Missed renaming a remove_qfileinfo_test() function call.
[Samba/ekacnet.git] / source4 / script / tests / test_win.sh
blobe61b924aeabeccfc824438a55331f50477b642f4
1 #!/bin/sh
3 # A shell script to connect to a windows host over telnet,
4 # setup for a smbtorture test,
5 # run the test,
6 # and remove the previously configured directory and share.
7 # Copyright Brad Henry <brad@samba.org> 2006
8 # Released under the GNU GPL v2 or later.
10 . script/tests/test_functions.sh
12 # This variable is defined in the per-hosts .fns file.
13 . $WINTESTCONF
15 # Setup the windows environment.
16 # This was the best way I could figure out including library files
17 # for the moment.
18 # I was finding that "cat common.exp wintest_setup.exp | expect -f -"
19 # fails to run, but exits with 0 status something like 1% of the time.
21 setup_share_test()
23 echo -e "\nSetting up windows environment."
24 cat $WINTEST_DIR/common.exp > $TMPDIR/setup.exp
25 cat $WINTEST_DIR/wintest_setup.exp >> $TMPDIR/setup.exp
26 expect $TMPDIR/setup.exp
27 err_rtn=$?
28 rm -f $TMPDIR/setup.exp
31 # Clean up the windows environment after the test has run or failed.
32 remove_share_test()
34 echo -e "\nCleaning up windows environment."
35 cat $WINTEST_DIR/common.exp > $TMPDIR/remove.exp
36 cat $WINTEST_DIR/wintest_remove.exp >> $TMPDIR/remove.exp
37 expect $TMPDIR/remove.exp
38 err_rtn=$?
39 rm -f $TMPDIR/remove.exp
42 restore_snapshot()
44 echo -e $1
45 perl -I$WINTEST_DIR $WINTEST_DIR/vm_load_snapshot.pl
46 echo "Snapshot restored."
49 # Index variable to count the total number of tests which fail.
50 all_errs=0
52 export SMBTORTURE_REMOTE_HOST=`perl -I$WINTEST_DIR $WINTEST_DIR/vm_get_ip.pl`
53 if [ -z $SMBTORTURE_REMOTE_HOST ]; then
54 # Restore snapshot to ensure VM is in a known state, then exit.
55 restore_snapshot "Test failed to get the IP address of the windows host."
56 exit 1
59 test_name="RAW-QFILEINFO / WINDOWS SERVER"
60 echo -e "\n$test_name SETUP PHASE"
62 setup_share_test
64 if [ $err_rtn -ne 0 ]; then
65 # If test setup fails, load VM snapshot and skip test.
66 restore_snapshot "\n$test_name setup failed, skipping test."
67 else
68 echo -e "\n$test_name setup completed successfully."
69 old_errs=$all_errs
71 testit "$test_name" $SMBTORTURE_BIN_PATH \
72 -U $SMBTORTURE_USERNAME%$SMBTORTURE_PASSWORD \
73 -d 10 -W $SMBTORTURE_WORKGROUP \
74 //$SMBTORTURE_REMOTE_HOST/$SMBTORTURE_REMOTE_SHARE_NAME \
75 RAW-QFILEINFO || all_errs=`expr $all_errs + 1`
76 if [ $old_errs -lt $all_errs ]; then
77 # If test fails, load VM snapshot and skip cleanup.
78 restore_snapshot "\n$test_name failed."
79 else
80 echo -e "\n$test_name CLEANUP PHASE"
81 remove_share_test
82 if [ $err_rtn -ne 0 ]; then
83 # If cleanup fails, restore VM snapshot.
84 restore_snapshot "\n$test_name removal failed."
85 else
86 echo -e "\n$test_name removal completed successfully."
91 rpc_tests="RPC-WINREG RPC-ASYNCBIND RPC-ATSVC RPC-DSSETUP RPC-EPMAPPER"
92 rpc_tests="$rpc_tests RPC-INITSHUTDOWN RPC-LSA-GETUSER RPC-MULTIBIND RPC-ROT"
93 rpc_tests="$rpc_tests RPC-SECRETS RPC-SRVSVC RPC-SVCCTL RPC-WKSSVC"
95 for t in $rpc_tests; do
96 test_name="$t / WINDOWS SERVER"
97 old_errs=$all_errs
99 testit "$test_name" $SMBTORTURE_BIN_PATH \
100 -U $SMBTORTURE_USERNAME%$SMBTORTURE_PASSWORD \
101 -W $SMBTORTURE_WORKGROUP \
102 ncacn_np:$SMBTORTURE_REMOTE_HOST \
103 $t || all_errs=`expr $all_errs + 1`
104 if [ $old_errs -lt $all_errs ]; then
105 restore_snapshot "\n$test_name failed."
107 done
109 test_name="WINDOWS CLIENT / SAMBA SERVER SHARE"
110 old_errs=$all_errs
111 cat $WINTEST_DIR/common.exp > $TMPDIR/client_test.exp
112 cat $WINTEST_DIR/wintest_client.exp >> $TMPDIR/client_test.exp
114 testit "$test_name" \
115 expect $TMPDIR/client_test.exp || all_errs=`expr $all_errs + 1`
117 if [ $old_errs -lt $all_errs ]; then
118 # Restore snapshot to ensure VM is in a known state.
119 restore_snapshot "\n$test_name failed."
120 echo "Snapshot restored."
122 rm -f $TMPDIR/client_test.exp
124 testok $0 $all_errs