3 # A shell script to connect to a windows host over telnet,
4 # setup for a smbtorture 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.
15 # Setup the windows environment.
16 # This was the best way I could figure out including library files
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.
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
28 rm -f $TMPDIR/setup.exp
31 # Clean up the windows environment after the test has run or failed.
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
39 rm -f $TMPDIR/remove.exp
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.
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."
59 test_name
="RAW-QFILEINFO / WINDOWS SERVER"
60 echo -e "\n$test_name SETUP PHASE"
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."
68 echo -e "\n$test_name setup completed successfully."
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."
80 echo -e "\n$test_name CLEANUP PHASE"
82 if [ $err_rtn -ne 0 ]; then
83 # If cleanup fails, restore VM snapshot.
84 restore_snapshot
"\n$test_name removal failed."
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"
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."
109 test_name
="WINDOWS CLIENT / SAMBA SERVER SHARE"
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