summaryrefslogtreecommitdiffstats
path: root/tests/unixSend.test
blob: aa140d20d5847561c3079bfc54198b5ace193e92 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
# This file is a Tcl script to test out the "send" command and the
# other procedures in the file tkSend.c.  It is organized in the
# standard fashion for Tcl tests.
#
# Copyright (c) 1994 Sun Microsystems, Inc.
# Copyright (c) 1994-1996 Sun Microsystems, Inc.
# Copyright (c) 1998-1999 by Scriptics Corporation.
# All rights reserved.
#
# RCS: @(#) $Id: unixSend.test,v 1.1.2.3 1999/03/11 18:51:17 hershey Exp $

if {$tcl_platform(platform) == "macintosh"} {
    puts "send is not available on the Mac - skipping tests"
    return
}
if {$tcl_platform(platform) == "windows"} {
    puts "skipping: Unix only tests..."
    return
}
if {[auto_execok xhost] == ""} {
    puts "xhost application isn't available - skipping tests"
    return
}

if {[lsearch [namespace children] ::test] == -1} {
    source [file join [pwd] [file dirname [info script]] defs.tcl]
}

if {[info commands testsend] == "testsend"} {
    set gotTestCmds 1
} else {
    set gotTestCmds 0
}

foreach i [winfo children .] {
    destroy $i
}
wm geometry . {}
raise .

# If send is disabled because of inadequate security, don't run any
# of these tests at all.

setupbg
set app [dobg {tk appname}]
if {[catch {send $app set a 0} msg] == 1} {
    if [string match "X server insecure *" $msg] {
	puts -nonewline "Your X server is insecure, so \"send\" can't be used;"
	puts " skipping \"send\" tests."
	cleanupbg
	return
    }
}
cleanupbg

# Compute a script that will load Tk into a child interpreter.

foreach pkg [info loaded] {
    if {[lindex $pkg 1] == "Tk"} {
	set loadTk "load $pkg"
	break
    }
}

# Procedure to create a new application with a given name and class.

proc newApp {screen name class} {
    global loadTk
    interp create $name
    $name eval [list set argv [list -display $screen -name $name -class $class]]
    eval $loadTk $name
}

set name [tk appname]
if $gotTestCmds {
    set registry [testsend prop root InterpRegistry]
    set commId [lindex [testsend prop root InterpRegistry] 0]
}
tk appname tktest
catch {send t_s_1 destroy .}
catch {send t_s_2 destroy .}

if $gotTestCmds {
    test unixSend-1.1 {RegOpen procedure, bogus property} {
	testsend bogus
	set result [winfo interps]
	tk appname tktest
	list $result [winfo interps]
    } {{} tktest}
    test unixSend-1.2 {RegOpen procedure, bogus property} {
	testsend prop root InterpRegistry {}
	set result [winfo interps]
	tk appname tktest
	list $result [winfo interps]
    } {{} tktest}
    test unixSend-1.3 {RegOpen procedure, bogus property} {
	testsend prop root InterpRegistry abcdefg
	tk appname tktest
	set x [testsend prop root InterpRegistry]
	string range $x [string first " " $x] end
    } " tktest\nabcdefg\n"

    frame .f -width 1 -height 1
    set id [string range [winfo id .f] 2 end]
    test unixSend-2.1 {RegFindName procedure} {
	testsend prop root InterpRegistry {}
	list [catch {send foo bar} msg] $msg
    } {1 {no application named "foo"}}
    test unixSend-2.2 {RegFindName procedure} {
	testsend prop root InterpRegistry " abc\n def\nghi\n\n$id foo\n"
	tk appname foo
    } {foo #2}
    test unixSend-2.3 {RegFindName procedure} {
	testsend prop root InterpRegistry "gyz foo\n"
	tk appname foo
    } {foo}
    test unixSend-2.4 {RegFindName procedure} {
	testsend prop root InterpRegistry "${id}z foo\n"
	tk appname foo
    } {foo}

    test unixSend-3.1 {RegDeleteName procedure} {
	tk appname tktest
	testsend prop root InterpRegistry "012345 gorp\n12345 foo\n12345 tktest"
	tk appname x
	set x [testsend prop root InterpRegistry]
	string range $x [string first " " $x] end
    } " x\n012345 gorp\n12345 foo\n"
    test unixSend-3.2 {RegDeleteName procedure} {
	tk appname tktest
	testsend prop root InterpRegistry "012345 gorp\n12345 tktest\n23456 tktest"
	tk appname x
	set x [testsend prop root InterpRegistry]
	string range $x [string first " " $x] end
    } " x\n012345 gorp\n23456 tktest\n"
    test unixSend-3.3 {RegDeleteName procedure} {
	tk appname tktest
	testsend prop root InterpRegistry "012345 tktest\n12345 bar\n23456 tktest"
	tk appname x
	set x [testsend prop root InterpRegistry]
	string range $x [string first " " $x] end
    } " x\n12345 bar\n23456 tktest\n"
    test unixSend-3.4 {RegDeleteName procedure} {
	tk appname tktest
	testsend prop root InterpRegistry "foo"
	tk appname x
	set x [testsend prop root InterpRegistry]
	string range $x [string first " " $x] end
    } " x\nfoo\n"
    test unixSend-3.5 {RegDeleteName procedure} {
	tk appname tktest
	testsend prop root InterpRegistry ""
	tk appname x
	set x [testsend prop root InterpRegistry]
	string range $x [string first " " $x] end
    } " x\n"

    test unixSend-4.1 {RegAddName procedure} {
	testsend prop root InterpRegistry ""
	tk appname bar
	testsend prop root InterpRegistry
    } "$commId bar\n"
    test unixSend-4.2 {RegAddName procedure} {
	testsend prop root InterpRegistry "abc def"
	tk appname bar
	tk appname foo
	testsend prop root InterpRegistry
    } "$commId foo\nabc def\n"

    # Previous checks should already cover the Regclose procedure.

    test unixSend-5.1 {ValidateName procedure} {
	testsend prop root InterpRegistry "123 abc\n"
	winfo interps
    } {}
    test unixSend-5.2 {ValidateName procedure} {
	testsend prop root InterpRegistry "$id Hi there"
	winfo interps
    } {{Hi there}}
    test unixSend-5.3 {ValidateName procedure} {
	testsend prop root InterpRegistry "$id Bogus"
	list [catch {send Bogus set a 44} msg] $msg
    } {1 {target application died or uses a Tk version before 4.0}}
    test unixSend-5.4 {ValidateName procedure} {
	tk appname test
	testsend prop root InterpRegistry "$commId Bogus\n$commId test\n"
	winfo interps
    } {test}
}

winfo interps
tk appname tktest
update
setupbg
set x [split [exec xhost] \n]
foreach i [lrange $x 1 end]  {
    exec xhost - $i
}
test unixSend-6.1 {ServerSecure procedure} {nonPortable} {
    set a 44
    list [dobg [list send [tk appname] set a 55]] $a
} {55 55}
test unixSend-6.2 {ServerSecure procedure} {nonPortable} {
    set a 22
    exec xhost [exec hostname]
    list [catch {dobg [list send [tk appname] set a 33]} msg] $a $msg
} {0 22 {X server insecure (must use xauth-style authorization); command ignored}}
test unixSend-6.3 {ServerSecure procedure} {nonPortable} {
    set a abc
    exec xhost - [exec hostname]
    list [dobg [list send [tk appname] set a new]] $a
} {new new}
cleanupbg

if $gotTestCmds {
    test unixSend-7.1 {Tk_SetAppName procedure} {
	testsend prop root InterpRegistry ""
	tk appname newName
	list [tk appname oldName] [testsend prop root InterpRegistry]
    } "oldName {$commId oldName\n}"
    test unixSend-7.2 {Tk_SetAppName procedure, name not in use} {
	testsend prop root InterpRegistry ""
	list [tk appname gorp] [testsend prop root InterpRegistry]
    } "gorp {$commId gorp\n}"
    test unixSend-7.3 {Tk_SetAppName procedure, name in use by us} {
	tk appname name1
	testsend prop root InterpRegistry "$commId name2\n"
	list [tk appname name2] [testsend prop root InterpRegistry]
    } "name2 {$commId name2\n}"
    test unixSend-7.4 {Tk_SetAppName procedure, name in use} {
	tk appname name1
	testsend prop root InterpRegistry "$id foo\n$id foo #2\n$id foo #3\n"
	list [tk appname foo] [testsend prop root InterpRegistry]
    } "{foo #4} {$commId foo #4\n$id foo\n$id foo #2\n$id foo #3\n}"
}

test unixSend-8.1 {Tk_SendCmd procedure, options} {
    setupbg
    set app [dobg {tk appname}]
    set a 66
    send -async $app [list send [tk appname] set a 77]
    set result $a
    after 200 set x 40
    tkwait variable x
    cleanupbg
    lappend result $a
} {66 77}
if [info exists env(TK_ALT_DISPLAY)] {
    test unixSend-8.2 {Tk_SendCmd procedure, options} {
	setupbg -display $env(TK_ALT_DISPLAY)
	tk appname xyzgorp
	set a homeDisplay
	set result [dobg "
	    toplevel .t -screen [winfo screen .]
	    wm geometry .t +0+0
	    set a altDisplay
	    tk appname xyzgorp
	    list \[send xyzgorp set a\] \[send -displayof .t xyzgorp set a\]
	"]
	cleanupbg
	set result
    } {altDisplay homeDisplay}
}
test unixSend-8.3 {Tk_SendCmd procedure, options} {
    list [catch {send -- -async foo bar baz} msg] $msg
} {1 {no application named "-async"}}
test unixSend-8.4 {Tk_SendCmd procedure, options} {
    list [catch {send -gorp foo bar baz} msg] $msg
} {1 {bad option "-gorp": must be -async, -displayof, or --}}
test unixSend-8.5 {Tk_SendCmd procedure, options} {
    list [catch {send -async foo} msg] $msg
} {1 {wrong # args: should be "send ?options? interpName arg ?arg ...?"}}
test unixSend-8.6 {Tk_SendCmd procedure, options} {
    list [catch {send foo} msg] $msg
} {1 {wrong # args: should be "send ?options? interpName arg ?arg ...?"}}
test unixSend-8.7 {Tk_SendCmd procedure, local execution} {
    set a initial
    send [tk appname] {set a new}
    set a
} {new}
test unixSend-8.8 {Tk_SendCmd procedure, local execution} {
    set a initial
    send [tk appname] set a new
    set a
} {new}
test unixSend-8.9 {Tk_SendCmd procedure, local execution} {
    set a initial
    string tolower [list [catch {send [tk appname] open bad_file} msg] \
	    $msg $errorInfo $errorCode]
} {1 {couldn't open "bad_file": no such file or directory} {couldn't open "bad_file": no such file or directory
    while executing
"open bad_file"
    invoked from within
"send [tk appname] open bad_file"} {posix enoent {no such file or directory}}}
test unixSend-8.10 {Tk_SendCmd procedure, no such interpreter} {
    list [catch {send bogus_name bogus_command} msg] $msg
} {1 {no application named "bogus_name"}}
if $gotTestCmds {
    newApp "" t_s_1 Test
    t_s_1 eval wm withdraw .
    test unixSend-8.11 {Tk_SendCmd procedure, local execution, different interp} {
	set a us
	send t_s_1 set a them
	list $a [send t_s_1 set a]
    } {us them}
    test unixSend-8.12 {Tk_SendCmd procedure, local execution, different interp} {
	set a us
	send t_s_1 {set a them}
	list $a [send t_s_1 {set a}]
    } {us them}
    test unixSend-8.13 {Tk_SendCmd procedure, local execution, different interp} {
	set a us
	send t_s_1 {set a them}
	list $a [send t_s_1 {set a}]
    } {us them}
    test unixSend-8.14 {Tk_SendCmd procedure, local interp killed by send} {
	newApp "" t_s_2 Test
	list [catch {send t_s_2 {destroy .; concat result}} msg] $msg
    } {0 result}
    interp delete t_s_2
    test unixSend-8.15 {Tk_SendCmd procedure, local interp, error info} {
	catch {error foo}
	list [catch {send t_s_1 {if 1 {open bogus_file_name}}} msg] $msg $errorInfo $errorCode
    } {1 {couldn't open "bogus_file_name": no such file or directory} {couldn't open "bogus_file_name": no such file or directory
    while executing
"open bogus_file_name"
    invoked from within
"if 1 {open bogus_file_name}"
    invoked from within
"send t_s_1 {if 1 {open bogus_file_name}}"} {POSIX ENOENT {no such file or directory}}}
    test unixSend-8.16 {Tk_SendCmd procedure, bogusCommWindow} {
	testsend prop root InterpRegistry "10234 bogus\n"
	set result [list [catch {send bogus bogus command} msg] $msg]
	winfo interps
	tk appname tktest
	set result
    } {1 {no application named "bogus"}}
    interp delete t_s_1
}
test unixSend-8.17 {Tk_SendCmd procedure, deferring events} {nonPortable} {
    # Non-portable because some window managers ignore "raise"
    # requests so can't guarantee that new app's window won't
    # obscure .f, thereby masking the Expose event.

    setupbg
    set app [dobg {tk appname}]
    raise .		; # Don't want new app obscuring .f
    catch {destroy .f}
    frame .f
    place .f -x 0 -y 0
    bind .f <Expose> {set a exposed}
    set a {no event yet}
    set result ""
    lappend result [send $app send [list [tk appname]] set a]
    lappend result $a
    update
    cleanupbg
    lappend result $a
} {{no event yet} {no event yet} exposed}
test unixSend-8.18 {Tk_SendCmd procedure, error in remote app} {
    setupbg
    set app [dobg {tk appname}]
    set result [string tolower [list [catch {send $app open bad_name} msg] \
	    $msg $errorInfo $errorCode]]
    cleanupbg
    set result
} {1 {couldn't open "bad_name": no such file or directory} {couldn't open "bad_name": no such file or directory
    while executing
"open bad_name"
    invoked from within
"send $app open bad_name"} {posix enoent {no such file or directory}}}
test unixSend-8.19 {Tk_SendCmd, using modal timeouts} {
    setupbg
    set app [dobg {tk appname}]
    set x no
    set result ""
    after 0 {set x yes}
    lappend result [send $app {concat x y z}]
    lappend result $x
    update
    cleanupbg
    lappend result $x
} {{x y z} no yes}

tk appname tktest
catch {destroy .f}
frame .f
set id [string range [winfo id .f] 2 end]
if $gotTestCmds {
    test unixSend-9.1 {Tk_GetInterpNames procedure} {
	testsend prop root InterpRegistry \
		"$commId tktest\nfoo bar\n$commId tktest\n$id frame .f\n\n\n"
	list [winfo interps] [testsend prop root InterpRegistry]
    } "{tktest tktest {frame .f}} {$commId tktest\n$commId tktest\n$id frame .f
}"
    test unixSend-9.2 {Tk_GetInterpNames procedure} {
	testsend prop root InterpRegistry \
		"$commId tktest\nfoobar\n$commId gorp\n"
	list [winfo interps] [testsend prop root InterpRegistry]
    } "tktest {$commId tktest\n}"
    test unixSend-9.3 {Tk_GetInterpNames procedure} {
	testsend prop root InterpRegistry {}
	list [winfo interps] [testsend prop root InterpRegistry]
    } {{} {}}

    testsend prop root InterpRegistry "$commId tktest\n$id dummy\n"
    test unixSend-10.1 {SendEventProc procedure, bogus comm property} {
	testsend prop comm Comm {abc def}
	testsend prop comm Comm {}
	update
    } {}
    test unixSend-10.2 {SendEventProc procedure, simultaneous messages} {
	testsend prop comm Comm \
		"c\n-n tktest\n-s set a 44\nc\n-n tktest\n-s set b 45\n"
	set a null
	set b xyzzy
	update
	list $a $b
    } {44 45}
    test unixSend-10.3 {SendEventProc procedure, simultaneous messages} {
	testsend prop comm Comm \
		"c\n-n tktest\n-s set a newA\nr\n-s [testsend serial]\n-r 12345\nc\n-n tktest\n-s set b newB\n"
	set a null
	set b xyzzy
	set x [send dummy bogus]
	list $x $a $b
    } {12345 newA newB}
    test unixSend-10.4 {SendEventProc procedure, leading nulls, bogus commands} {
	testsend prop comm Comm \
		"\n\nx\n-bogus\n\nc\n-n tktest\n-s set a 44\n"
	set a null
	update
	set a
    } {44}
    test unixSend-10.5 {SendEventProc procedure, extraneous command options} {
	testsend prop comm Comm \
		"c\n-n tktest\n-x miscellanous\n-y who knows?\n-s set a new\n"
	set a null
	update
	set a
    } {new}
    test unixSend-10.6 {SendEventProc procedure, unknown interpreter} {
	testsend prop [winfo id .f] Comm {}
	testsend prop comm Comm \
		"c\n-n unknown\n-r $id 44\n-s set a new\n"
	set a null
	update
	list [testsend prop [winfo id .f] Comm] $a
    } "{\nr\n-s 44\n-r receiver never heard of interpreter \"unknown\"\n-c 1\n} null"
    test unixSend-10.7 {SendEventProc procedure, error in script} {
	testsend prop [winfo id .f] Comm {}
	testsend prop comm Comm \
		"c\n-n tktest\n-r $id 62\n-s foreach i {1 2 3} {error {test error} {Initial errorInfo} {test code}}\n"
	update
	testsend prop [winfo id .f] Comm
    } {
r
-s 62
-r test error
-i Initial errorInfo
    ("foreach" body line 1)
    invoked from within
"foreach i {1 2 3} {error {test error} {Initial errorInfo} {test code}}"
-e test code
-c 1
}
    test unixSend-10.8 {SendEventProc procedure, exceptional return} {
	testsend prop [winfo id .f] Comm {}
	testsend prop comm Comm \
		"c\n-n tktest\n-r $id 62\n-s break\n"
	update
	testsend prop [winfo id .f] Comm
    } {
r
-s 62
-r 
-c 3
}
    test unixSend-10.9 {SendEventProc procedure, empty return} {
	testsend prop [winfo id .f] Comm {}
	testsend prop comm Comm \
		"c\n-n tktest\n-r $id 62\n-s concat\n"
	update
	testsend prop [winfo id .f] Comm
    } {
r
-s 62
-r 
}
    test unixSend-10.10 {SendEventProc procedure, asynchronous calls} {
	testsend prop [winfo id .f] Comm {}
	testsend prop comm Comm \
		"c\n-n tktest\n-s foreach i {1 2 3} {error {test error} {Initial errorInfo} {test code}}\n"
	update
	testsend prop [winfo id .f] Comm
    } {}
    test unixSend-10.11 {SendEventProc procedure, exceptional return} {
	testsend prop [winfo id .f] Comm {}
	testsend prop comm Comm \
		"c\n-n tktest\n-s break\n"
	update
	testsend prop [winfo id .f] Comm
    } {}
    test unixSend-10.12 {SendEventProc procedure, empty return} {
	testsend prop [winfo id .f] Comm {}
	testsend prop comm Comm \
		"c\n-n tktest\n-s concat\n"
	update
	testsend prop [winfo id .f] Comm
    } {}
    test unixSend-10.13 {SendEventProc procedure, return processing} {
	testsend prop comm Comm \
		"r\n-c 1\n-e test1\n-i test2\n-r test3\n-s [testsend serial]\n"
	list [catch {send dummy foo} msg] $msg $errorInfo $errorCode
    } {1 test3 {test2
    invoked from within
"send dummy foo"} test1}
    test unixSend-10.14 {SendEventProc procedure, extraneous return options} {
	testsend prop comm Comm \
		"r\n-x test1\n-y test2\n-r result\n-s [testsend serial]\n"
	list [catch {send dummy foo} msg] $msg
    } {0 result}
    test unixSend-10.15 {SendEventProc procedure, serial number} {
	testsend prop comm Comm \
		"r\n-r response\n"
	list [catch {send dummy foo} msg] $msg
    } {1 {target application died or uses a Tk version before 4.0}}
    test unixSend-10.16 {SendEventProc procedure, serial number} {
	testsend prop comm Comm \
		"r\n-r response\n\n-s 0"
	list [catch {send dummy foo} msg] $msg
    } {1 {target application died or uses a Tk version before 4.0}}
    test unixSend-10.17 {SendEventProc procedure, errorCode and errorInfo} {
	testsend prop comm Comm \
		"r\n-i test1\n-e test2\n-c 4\n-s [testsend serial]\n"
	set errorCode oldErrorCode
	set errorInfo oldErrorInfo
	list [catch {send dummy foo} msg] $msg $errorInfo $errorCode
    } {4 {} oldErrorInfo oldErrorCode}
    test unixSend-10.18 {SendEventProc procedure, send kills application} {
	setupbg
	dobg {tk appname t_s_3}
	set x [list [catch {send t_s_3 destroy .} msg] $msg]
	cleanupbg
	set x
    } {0 {}}
    test unixSend-10.19 {SendEventProc procedure, send exits} {
	setupbg
	dobg {tk appname t_s_3}
	set x [list [catch {send t_s_3 exit} msg] $msg]
	close $fd
	set x
    } {1 {target application died}}

    test unixSend-11.1 {AppendPropCarefully and AppendErrorProc procedures} {
	testsend prop root InterpRegistry "0x21447 dummy\n"
	list [catch {send dummy foo} msg] $msg
    } {1 {no application named "dummy"}}
    test unixSend-11.2 {AppendPropCarefully and AppendErrorProc procedures} {
	testsend prop comm Comm "c\n-r0x123 44\n-n tktest\n-s concat a b c\n"
	update
    } {}
}

winfo interps
tk appname tktest
catch {destroy .f}
frame .f
set id [string range [winfo id .f] 2 end]
if $gotTestCmds {
    test unixSend-12.1 {TimeoutProc procedure} {
        testsend prop root InterpRegistry "$id dummy\n"
        list [catch {send dummy foo} msg] $msg
    } {1 {target application died or uses a Tk version before 4.0}}
    testsend prop root InterpRegistry ""
}
test unixSend-12.2 {TimeoutProc procedure} {
    winfo interps
    tk appname tktest
    update
    setupbg
    puts $fd {after 10 {after 5000; exit}; puts [tk appname]; puts **DONE**; flush stdout}
    set ::test::bgDone 0
    set ::test::bgData {}
    flush $fd
    tkwait variable ::test::bgDone
    set app $::test::bgData
    after 200
    set result [list [catch {send $app foo} msg] $msg]
    close $fd
    set result
} {1 {target application died}}

winfo interps
tk appname tktest
test unixSend-13.1 {DeleteProc procedure} {
    setupbg
    set app [dobg {rename send {}; tk appname}]
    set result [list [catch {send $app foo} msg] $msg [winfo interps]]
    cleanupbg
    set result
} {1 {no application named "tktest #2"} tktest}
test unixSend-13.2 {DeleteProc procedure} {
    winfo interps
    tk appname tktest
    rename send {}
    set result {}
    lappend result [winfo interps] [info commands send]
    tk appname foo
    lappend result [winfo interps] [info commands send]
} {{} {} foo send}

if [info exists env(TK_ALT_DISPLAY)] {
    test unixSend-14.1 {SendRestrictProc procedure, sends crossing from different displays} {
	setupbg -display $env(TK_ALT_DISPLAY)
	set result [dobg "
	    toplevel .t -screen [winfo screen .]
	    wm geometry .t +0+0
	    tk appname xyzgorp1
	    set x child
	"]
	toplevel .t -screen $env(TK_ALT_DISPLAY)
	wm geometry .t +0+0
	tk appname xyzgorp2
	update
	set y parent
	set result [send -displayof .t xyzgorp1 {list $x [send -displayof .t xyzgorp2 set y]}]
	destroy .t
	cleanupbg
	set result
    } {child parent}
}

if $gotTestCmds {
    testsend prop root InterpRegister $registry
    tk appname tktest
    test unixSend-15.1 {UpdateCommWindow procedure} {
	set x [list [testsend prop comm TK_APPLICATION]]
	newApp "" t_s_1 Test
	send t_s_1 wm withdraw .
	newApp "" t_s_2 Test
	send t_s_2 wm withdraw .
	lappend x [testsend prop comm TK_APPLICATION]
	interp delete t_s_1
	lappend x [testsend prop comm TK_APPLICATION]
	interp delete t_s_2
	lappend x [testsend prop comm TK_APPLICATION]
    } {tktest {t_s_2 t_s_1 tktest} {t_s_2 tktest} tktest}
}

tk appname $name
if $gotTestCmds {
    testsend prop root InterpRegistry $registry
}
if $gotTestCmds {
    testdeleteapps
}
rename newApp {}

# cleanup
::test::cleanupTests
return