s4:nbt_server: simulate nmbd and provide unexpected handling
[Samba.git] / source4 / selftest / win / wintest_client.exp
blobccf5d06ea9ee0c86d4dff1f7663114daf60e2b8b
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.
6 proc run_test { remote_prompt tmp_filename share_drive host_drive buildhost_ip buildhost_share username domain password } {
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
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
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
29 set err_str [compare_files $remote_prompt $host_tmpfile $share_tmpfile]
30 if { $err_str != "OK" } {
31 return $err_str
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
39 set err_str [delete_file $remote_prompt $host_tmpfile]
40 if { $err_str != "OK" } {
41 return $err_str
44 set err_str [unmap_share $remote_prompt $share_drive]
45 if {$err_str != "OK" } {
46 return $err_str
49 return $err_str
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)
59 set tmp_filename $env(SMBTORTURE_TMP_FILENAME)
61 set share_drive $env(SMBTORTURE_REMOTE_DRIVE_LETTER)
62 set host_drive "%HOMEDRIVE%"
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)
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
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
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."
88 # Log off from the telnet server.
89 send "exit\r\n"
90 exit 1
93 # Log off from the telnet server.
94 send "exit\r\n"
95 exit 0