Author: brad Date: 2006-06-24 20:32:36 +0000 (Sat, 24 Jun 2006) New Revision: 16503
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=16503 Log: wintest.conf is a config file containing parameters used by the wintest_run.sh shell script. Changed wintest_run.sh to use parameters from wintest.conf. Modularized setup, test and removal phases, as well as error handling and stdout/stderr redirection facilities. Added: branches/SOC/bnh/expect/wintest.conf Modified: branches/SOC/bnh/expect/wintest_run.sh Changeset: Added: branches/SOC/bnh/expect/wintest.conf =================================================================== --- branches/SOC/bnh/expect/wintest.conf 2006-06-24 20:29:42 UTC (rev 16502) +++ branches/SOC/bnh/expect/wintest.conf 2006-06-24 20:32:36 UTC (rev 16503) @@ -0,0 +1,40 @@ + +# Resolvable hostname or ip address of the windows host we are testing against. +export SMBTORTURE_REMOTE_HOST="192.168.100.3" + +# Command prompt that we are expecting on the windows host. +export SMBTORTURE_REMOTE_PROMPT=">" + +# The username and password we will be testing with. +# This user will have admin rights on the remote windows host. +export SMBTORTURE_USERNAME="tortureuser" +export SMBTORTURE_PASSWORD="torturepass" + +# The name of the workgroup we will be using on the remote windows host. +export SMBTORTURE_WORKGROUP="SMBTEST" + +# The name of and path to the windows share we'll be testing against. +export SMBTORTURE_REMOTE_SHARE_NAME="smbtorture_share" +export SMBTORTURE_REMOTE_SHARE_PATH="%HOMEDRIVE%\smbtorture_shared_dir" + +# Default timeout for the expect scripts to wait for a response from the remote. +export SMBTORTURE_EXPECT_TIMEOUT=30 + +# Path to the local smbtorture binary. +export SMBTORTURE_BIN_PATH="/usr/local/samba/bin/smbtorture" + +# Local system hostname and ip address we'll be adding to the remote's +# hosts file. +export SMBTORTURE_LOCAL_HOSTNAME="buttercup" +export SMBTORTURE_LOCAL_IP="192.168.100.60" + +# Filename of the windows hosts' unedited hosts file. +export REMOTE_BACKUP_HOSTS_FILENAME="hosts.smbtorture" +export REMOTE_HOSTS_FILE_PATH="%SYSTEMROOT%\\system32\\drivers\\etc" + +# These variables represent the file that STDOUT and STDERR +# are redirected to during the setup, test and removal phases of the test. +# These files are deleted when the test begins its run. +# Special files (devices, named pipes, etc) are not deleted. +STDOUT_REDIR="wintest.stdout" +STDERR_REDIR="wintest.stderr" Modified: branches/SOC/bnh/expect/wintest_run.sh =================================================================== --- branches/SOC/bnh/expect/wintest_run.sh 2006-06-24 20:29:42 UTC (rev 16502) +++ branches/SOC/bnh/expect/wintest_run.sh 2006-06-24 20:32:36 UTC (rev 16503) @@ -2,63 +2,127 @@ # A shell script to connect to a windows host over telnet, # setup for a smbtorture test, -# run the test, +# run the test, # and remove the previously configured directory and share. # Copyright Brad Henry <[EMAIL PROTECTED]> 2006 # Released under the GNU GPL v2 or later. -WINTEST_SETUP_ERROR_LOG="/tmp/wintest_setup.exp.err" -WINTEST_REMOVE_ERROR_LOG="/tmp/wintest_remove.exp.err" +. wintest.conf -export SMBTORTURE_REMOTE_HOST=192.168.0.1 -export SMBTORTURE_REMOTE_PROMPT=">" +# 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_test() +{ + echo -e "\nSetting up windows environment." >> $STDOUT_REDIR + cat common.exp > ./setup.exp + cat wintest_setup.exp >> ./setup.exp + expect ./setup.exp \ + >> $STDOUT_REDIR 2>> $STDERR_REDIR + err_rtn=$? + rm -f ./setup.exp +} -export SMBTORTURE_USERNAME="tortureuser" -export SMBTORTURE_PASSWORD="torturepass" +# Run the smbtorture test. +run_test() +{ + echo -e "\nRunning smbtorture RAW-QFILEINFO test." >> $STDOUT_REDIR + $SMBTORTURE_BIN_PATH \ + -U $SMBTORTURE_USERNAME%$SMBTORTURE_PASSWORD \ + -d 10 -W $SMBTORTURE_WORKGROUP \ + //$SMBTORTURE_REMOTE_HOST/$SMBTORTURE_REMOTE_SHARE_NAME \ + RAW-QFILEINFO \ + >> $STDOUT_REDIR 2>> $STDERR_REDIR + err_rtn=$? +} -export SMBTORTURE_SHARE_NAME="smbtorture_share" -export SMBTORTURE_SHARE_PATH="c:\torture_share" +# Clean up the windows environment after the test has run or failed. +remove_test() +{ + echo -e "\nCleaning up windows environment." >> $STDOUT_REDIR + cat common.exp > ./remove.exp + cat wintest_remove.exp >> ./remove.exp + expect ./remove.exp \ + >> $STDOUT_REDIR 2>> $STDERR_REDIR + err_rtn=$? + rm -f ./remove.exp +} -export SMBTORTURE_EXPECT_TIMEOUT=30 +display_output() +{ + cat $STDOUT_REDIR + cat $STDERR_REDIR +} -# Setup the windows environment. -# This was the best way I could figure out including library files for the moment. -cat common.exp wintest_setup.exp | expect -f - 2> $WINTEST_SETUP_ERROR_LOG -err_setup=$? +remove_files() +{ + # If these redirect to special files, we won't delete them. + for redir in $STDERR_REDIR \ + $STDOUT_REDIR + do -echo "wintest_setup.exp stderr output:" -cat $WINTEST_SETUP_ERROR_LOG -#rm -f $WINTEST_SETUP_ERROR_LOG + if [ ! -b $redir \ + -a ! -c $redir \ + -a ! -p $redir ] + then + rm -f $redir + fi + done +} -if [ $err_setup -ne 0 ] -then - exit $err_setup -fi +create_files() +{ + touch $STDOUT_REDIR + touch $STDERR_REDIR +} -# Run the smbtorture test. -/usr/local/samba/bin/smbtorture \ - -U $SMBTORTURE_USERNAME%$SMBTORTURE_PASSWORD \ - -d 10 -W SMBTEST \ - //$SMBTORTURE_REMOTE_HOST/$SMBTORTURE_SHARE_NAME \ - RAW-QFILEINFO -err_smbtorture=$? +check_error() +{ + if [ $err_rtn -ne 0 ] + then + echo -e $err_str >> $err_redir + # Run cleanup. + remove_test + # Report output recieved so far. + display_output + # Exit in error + exit $err_rtn + else + echo -e $err_ok_str >> $err_redir + fi +} -if [ $err_smbtorture -ne 0 ] -then - exit $err_smbtorture -fi +# If we crashed on a previous run, we want to know that our log files are clean. +remove_files -# Cleanup the windows environment. -cat common.exp wintest_remove.exp | expect -f - 2> $WINTEST_REMOVE_ERROR_LOG -err_remove=$? +# Create the local log files. +create_files -echo "wintest_remove.exp stderr output:" -cat $WINTEST_REMOVE_ERROR_LOG -#rm -f $WINTEST_REMOVE_ERROR_LOG +err_str="\nTest setup failed." +err_ok_str="\nTest setup completed successfully." +err_redir=$STDERR_REDIR -if [ $err_remove -ne 0 ] -then - exit $err_remove -fi +echo -e "\nSETUP PHASE" >> $STDOUT_REDIR +setup_test +check_error -exit 0 +err_str="\nTest run failed." +err_ok_str="\nTest run completed successfully." +err_redir=$STDERR_REDIR + +echo -e "\nTEST PHASE" >> $STDOUT_REDIR +run_test +check_error + +err_str="\nTest removal failed." +err_ok_str="\nTest removal completed successfully." +err_redir=$STDERR_REDIR + +echo -e "\nREMOVAL PHASE" >> $STDOUT_REDIR +remove_test +check_error + +display_output +exit $err_rtn