diff options
author | Andrew Tridgell <tridge@samba.org> | 2006-08-24 04:14:34 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 14:16:38 -0500 |
commit | e5f7da55ef778fdd904d6ff2a54d3d5e02debc17 (patch) | |
tree | 734d71dd6dc809f14560502ba5fa82138c4d660e /source4/script/tests/test_win.sh | |
parent | b075bb842d6665be3212ddf93d4ccb98472f341a (diff) | |
download | samba-e5f7da55ef778fdd904d6ff2a54d3d5e02debc17.tar.gz samba-e5f7da55ef778fdd904d6ff2a54d3d5e02debc17.tar.xz samba-e5f7da55ef778fdd904d6ff2a54d3d5e02debc17.zip |
r17768: This merges in the current version of Brad Henry's windows testing
framework patch. There are some issues with the patch that I will
discuss in a separate email to the list, but given the low (zero?)
impact of the patch as it is, I think its better to integrate it now,
then let Brad send some minor update patches later
(This used to be commit 7232da0436ff1d84e419d268fee31a095bbb88b7)
Diffstat (limited to 'source4/script/tests/test_win.sh')
-rw-r--r-- | source4/script/tests/test_win.sh | 150 |
1 files changed, 150 insertions, 0 deletions
diff --git a/source4/script/tests/test_win.sh b/source4/script/tests/test_win.sh new file mode 100644 index 00000000000..c4d11d5bd7e --- /dev/null +++ b/source4/script/tests/test_win.sh @@ -0,0 +1,150 @@ +#!/bin/sh + +# A shell script to connect to a windows host over telnet, +# setup for a smbtorture test, +# run the test, +# and remove the previously configured directory and share. +# Copyright Brad Henry <brad@samba.org> 2006 +# Released under the GNU GPL v2 or later. + +. $WINTEST_DIR/test_win.conf + +# Setup the windows environment. +# This was the best way I could figure out including library files +# for the moment. +# I was finding that "cat common.exp wintest_setup.exp | expect -f -" +# fails to run, but exits with 0 status something like 1% of the time. + +setup_win_server_test() +{ + echo -e "\nSetting up windows environment." + cat $WINTEST_DIR/common.exp > $TMPDIR/setup.exp + cat $WINTEST_DIR/wintest_setup.exp >> $TMPDIR/setup.exp + expect $TMPDIR/setup.exp + err_rtn=$? + rm -f $TMPDIR/setup.exp +} + +# Run the smbtorture test. +run_win_server_test() +{ + echo -e "\nRunning smbtorture RAW-QFILEINFO test." + $SMBTORTURE_BIN_PATH \ + -U $SMBTORTURE_USERNAME%$SMBTORTURE_PASSWORD \ + -d 10 -W $SMBTORTURE_WORKGROUP \ + //$SMBTORTURE_REMOTE_HOST/$SMBTORTURE_REMOTE_SHARE_NAME \ + RAW-QFILEINFO + err_rtn=$? +} + +# Clean up the windows environment after the test has run or failed. +remove_win_server_test() +{ + echo -e "\nCleaning up windows environment." + cat $WINTEST_DIR/common.exp > $TMPDIR/remove.exp + cat $WINTEST_DIR/wintest_remove.exp >> $TMPDIR/remove.exp + expect $TMPDIR/remove.exp + err_rtn=$? + rm -f $TMPDIR/remove.exp +} + +# Test windows as a server against samba as a client. +win_server_test() +{ + echo -e "\nSETUP PHASE" + setup_win_server_test + if [ $err_rtn -ne 0 ]; then + echo -e "\nSamba CLIENT test setup failed." + return $err_rtn + fi + echo -e "\nSamba CLIENT test setup completed successfully." + + echo -e "\nTEST PHASE" + run_win_server_test + if [ $err_rtn -ne 0 ]; then + echo -e "\nSamba CLIENT test run failed." + return $err_rtn + fi + echo -e "\nSamba CLIENT test run completed successfully." + + echo -e "\nCLEANUP PHASE" + remove_win_server_test + if [ $err_rtn -ne 0 ]; then + echo -e "\nSamba CLIENT test removal failed." + return $err_rtn + fi + echo -e "\nSamba CLIENT test removal completed successfully." +} + +# Test windows as a client against samba as a server. +win_client_test() +{ + cat $WINTEST_DIR/common.exp > $TMPDIR/client_test.exp + cat $WINTEST_DIR/wintest_client.exp >> $TMPDIR/client_test.exp + expect $TMPDIR/client_test.exp + err_rtn=$? + rm -f $TMPDIR/client_test.exp +} + +check_error() +{ + if [ $err_rtn -ne 0 ]; then + # Restore snapshot to ensure VM is in a known state. + perl -I$WINTEST_DIR $WINTEST_DIR/vm_load_snapshot.pl + echo "Snapshot restored." + echo "==========================================" + echo $err_str + echo "==========================================" + else + echo -e "\nALL OK: $cmdline" + echo "==========================================" + echo $err_ok_str + echo "==========================================" + fi + + all_errs=`expr $all_errs + $err_rtn` +} + +get_remote_ip() +{ + export SMBTORTURE_REMOTE_HOST=`perl -I$WINTEST_DIR $WINTEST_DIR/vm_get_ip.pl` + err_rtn=$? +} + +# Index variable to count the total number of tests which fail. +all_errs=0 + +# Get ip address of windows vmware host. +err_str="Test failed to get the IP address of the windows host." +err_ok_str="Windows host IP address discovered successfully." + +get_remote_ip +check_error + +test_name="SAMBA CLIENT / WINDOWS SERVER" +echo "--==--==--==--==--==--==--==--==--==--==--" +echo "Running test $test_name (level 0 stdout)" +echo "--==--==--==--==--==--==--==--==--==--==--" +date +echo "Testing $test_name" + +err_str="TEST FAILED: $test_name" +err_ok_str="TEST PASSED: $test_name" + +win_server_test +check_error + +test_name="WINDOWS CLIENT / SAMBA SERVER" +echo "--==--==--==--==--==--==--==--==--==--==--" +echo "Running test $test_name (level 0 stdout)" +echo "--==--==--==--==--==--==--==--==--==--==--" +date +echo "Testing $test_name" + +err_str="TEST FAILED: $test_name" +err_ok_str="TEST PASSED: $test_name" + +win_client_test +check_error + +exit $all_errs |