| 1 | # An expect script to create a temporary file, map a share, copy the file to the share,
|
|---|
| 2 | # and compare the contents of the two files.
|
|---|
| 3 | # Copyright Brad Henry <brad@samba.org> 2006
|
|---|
| 4 | # Released under the GNU GPL version 3 or later.
|
|---|
| 5 |
|
|---|
| 6 | proc run_test { remote_prompt tmp_filename share_drive host_drive buildhost_ip buildhost_share username domain password } {
|
|---|
| 7 |
|
|---|
| 8 | # Create the temp file on the windows host and connect to the samba share.
|
|---|
| 9 | set host_tmpfile "$host_drive\\$tmp_filename"
|
|---|
| 10 | set err_str [create_tmp_file $remote_prompt $host_tmpfile]
|
|---|
| 11 | if { $err_str != "OK" } {
|
|---|
| 12 | return $err_str
|
|---|
| 13 | }
|
|---|
| 14 |
|
|---|
| 15 | set buildhost_sharepoint "\\\\$buildhost_ip\\$buildhost_share"
|
|---|
| 16 | set err_str [map_share $remote_prompt $share_drive $buildhost_sharepoint $username $domain $password]
|
|---|
| 17 | if { $err_str != "OK" } {
|
|---|
| 18 | return $err_str
|
|---|
| 19 | }
|
|---|
| 20 |
|
|---|
| 21 | # Copy the temp file to the share and compare its contents with the original.
|
|---|
| 22 | set share_tmpfile "$share_drive\\$tmp_filename"
|
|---|
| 23 | set xcopy_options ""
|
|---|
| 24 | set err_str [xcopy_file $remote_prompt $host_tmpfile $share_tmpfile $xcopy_options]
|
|---|
| 25 | if { $err_str != "OK" } {
|
|---|
| 26 | return $err_str
|
|---|
| 27 | }
|
|---|
| 28 |
|
|---|
| 29 | set err_str [compare_files $remote_prompt $host_tmpfile $share_tmpfile]
|
|---|
| 30 | if { $err_str != "OK" } {
|
|---|
| 31 | return $err_str
|
|---|
| 32 | }
|
|---|
| 33 |
|
|---|
| 34 | # Remove files and unmap share.
|
|---|
| 35 | set err_str [delete_file $remote_prompt $share_tmpfile]
|
|---|
| 36 | if { $err_str != "OK" } {
|
|---|
| 37 | return $err_str
|
|---|
| 38 | }
|
|---|
| 39 | set err_str [delete_file $remote_prompt $host_tmpfile]
|
|---|
| 40 | if { $err_str != "OK" } {
|
|---|
| 41 | return $err_str
|
|---|
| 42 | }
|
|---|
| 43 |
|
|---|
| 44 | set err_str [unmap_share $remote_prompt $share_drive]
|
|---|
| 45 | if {$err_str != "OK" } {
|
|---|
| 46 | return $err_str
|
|---|
| 47 | }
|
|---|
| 48 |
|
|---|
| 49 | return $err_str
|
|---|
| 50 | }
|
|---|
| 51 |
|
|---|
| 52 | # Read parameters.
|
|---|
| 53 | set remote_prompt $env(SMBTORTURE_REMOTE_PROMPT)
|
|---|
| 54 | set remote_host $env(SMBTORTURE_REMOTE_HOST)
|
|---|
| 55 | set username $env(SMBTORTURE_USERNAME)
|
|---|
| 56 | set password $env(SMBTORTURE_PASSWORD)
|
|---|
| 57 | set timeout $env(SMBTORTURE_EXPECT_TIMEOUT)
|
|---|
| 58 |
|
|---|
| 59 | set tmp_filename $env(SMBTORTURE_TMP_FILENAME)
|
|---|
| 60 |
|
|---|
| 61 | set share_drive $env(SMBTORTURE_REMOTE_DRIVE_LETTER)
|
|---|
| 62 | set host_drive "%HOMEDRIVE%"
|
|---|
| 63 |
|
|---|
| 64 | set buildhost_ip $env(SMBTORTURE_LOCAL_IP)
|
|---|
| 65 | set buildhost_share $env(SMBTORTURE_LOCAL_SHARE_NAME)
|
|---|
| 66 | set buildhost_username $env(SMBTORTURE_LOCAL_USERNAME)
|
|---|
| 67 | set buildhost_domain $env(SMBTORTURE_LOCAL_DOMAIN)
|
|---|
| 68 | set buildhost_password $env(SMBTORTURE_LOCAL_PASSWORD)
|
|---|
| 69 |
|
|---|
| 70 | set err_val [spawn $env(SHELL)]
|
|---|
| 71 | if {$err_val == 0} {
|
|---|
| 72 | puts stderr "Expect failed while spawning a shell process."
|
|---|
| 73 | exit $err_val
|
|---|
| 74 | }
|
|---|
| 75 |
|
|---|
| 76 | set err_str [telnet_login $remote_prompt $remote_host $username $password]
|
|---|
| 77 | if {$err_str != "OK"} {
|
|---|
| 78 | puts stderr "\nFunction telnet_login failed during Samba server testing."
|
|---|
| 79 | puts stderr "Error was: $err_str."
|
|---|
| 80 | exit 1
|
|---|
| 81 | }
|
|---|
| 82 |
|
|---|
| 83 | set err_str [run_test $remote_prompt $tmp_filename $share_drive $host_drive $buildhost_ip $buildhost_share $buildhost_username $buildhost_domain $buildhost_password]
|
|---|
| 84 | if {$err_str != "OK"} {
|
|---|
| 85 | puts stderr "\nFunction run_test failed during Samba server testing."
|
|---|
| 86 | puts stderr "Error was: $err_str."
|
|---|
| 87 |
|
|---|
| 88 | # Log off from the telnet server.
|
|---|
| 89 | send "exit\r\n"
|
|---|
| 90 | exit 1
|
|---|
| 91 | }
|
|---|
| 92 |
|
|---|
| 93 | # Log off from the telnet server.
|
|---|
| 94 | send "exit\r\n"
|
|---|
| 95 | exit 0
|
|---|