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.
21 setup_qfileinfo_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
28 rm -f $TMPDIR/setup.exp
31 # Clean up the windows environment after the test has run or failed.
32 remove_qfileinfo_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
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 test_name="RPC-WINREG / WINDOWS SERVER"
94 testit "$test_name" $SMBTORTURE_BIN_PATH \
95 -U $SMBTORTURE_USERNAME%$SMBTORTURE_PASSWORD \
96 -W $SMBTORTURE_WORKGROUP \
97 ncacn_np:$SMBTORTURE_REMOTE_HOST \
98 RPC-WINREG || all_errs=`expr $all_errs + 1`
99 if [ $old_errs -lt $all_errs ]; then
100 restore_snapshot "\n$test_name failed."
103 test_name="WINDOWS CLIENT / SAMBA SERVER SHARE"
105 cat $WINTEST_DIR/common.exp > $TMPDIR/client_test.exp
106 cat $WINTEST_DIR/wintest_client.exp >> $TMPDIR/client_test.exp
108 testit "$test_name" \
109 expect $TMPDIR/client_test.exp || all_errs=`expr $all_errs + 1`
111 if [ $old_errs -lt $all_errs ]; then
112 # Restore snapshot to ensure VM is in a known state.
113 restore_snapshot "\n$test_name failed."
114 echo "Snapshot restored."
116 rm -f $TMPDIR/client_test.exp