Debian Codegraph @

gcc/testsuite/gm2/projects/pim/run/pass/tower/projects-pim-run-pass-tower.exp

raw
1 # Expect driver script for GCC Regression Tests
2 # Copyright (C) 2023-2025 Free Software Foundation, Inc.
3
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 3 of the License, or
7 # (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with GCC; see the file COPYING3. If not see
16 # <http://www.gnu.org/licenses/>.
17
18 # This file was written by Gaius Mulley ([email protected])
19 # for GNU Modula-2.
20
21 if $tracelevel then {
22 strace $tracelevel
23 }
24
25 # load support procs
26 # load_lib gm2-torture.exp
27 load_lib gm2-simple.exp
28
29 gm2_init_cor "${srcdir}/${subdir}" -g
30 gm2_link_obj "advflex.o AdvCmd.o AdvIntroduction.o AdvMap.o AdvMath.o AdvParse.o AdvSound.o AdvSystem.o AdvTreasure.o AdvUtil.o DrawG.o DrawL.o Lock.o ProcArgs.o Screen.o Window.o SocketControl.o"
31
32 set gm2_run_tower_test 0
33
34 proc gm2-local-exec { testcase execname mapfile } {
35 global tool;
36 # puts stderr "about to run: ${execname} ${mapfile}"
37
38 set pid [fork]
39 switch $pid {
40 -1 {
41 puts stderr "fork failed."
42 }
43 0 {
44 # puts stderr "child running ${execname} ${mapfile}"
45 set result [gm2_load "$execname" "$mapfile" ""];
46 exit 0
47 }
48 default {
49 # puts stderr "parent attempting to connect to the child"
50 set port 7000;
51 # wait for 3 seconds before attempting to connect.
52 sleep 3
53 # verbose "parent attempting to connect to ${execname} ${mapfile}" 1
54 if {[catch {set chan [socket 127.0.0.1 ${port}]
55 puts ${chan} "quit\r"
56 flush ${chan}
57 close ${chan} }]} {
58 verbose "parent unable to connect to ${execname} ${mapfile}" 1
59 puts stderr "parent unable to connect to ${execname} ${mapfile}"
60 ${tool}_fail ${testcase} ${mapfile}
61 } else {
62 # verbose "parent successfully able to connect to ${execname} ${mapfile}" 1
63 # puts stderr "parent successfully connected to ${execname} ${mapfile}"
64 ${tool}_pass ${testcase} ${mapfile}
65 }
66 remote_file build delete $execname;
67 # verbose "killing off child after successful test" 1
68 puts stderr "parent successfully connected to child"
69 puts stderr "now tidying up by killing the child"
70 puts stderr "ignore next warning about sig term"
71 set res [exec kill ${pid}];
72 }
73 }
74 }
75
76 # If we want these to be re-built for each torture option we need some different
77 # logic.
78 gm2_target_compile $srcdir/$subdir/AdvCmd.mod AdvCmd.o object "-c -g -I$srcdir/$subdir/"
79 gm2_target_compile $srcdir/$subdir/AdvIntroduction.mod AdvIntroduction.o object "-c -g -I$srcdir/$subdir/"
80 gm2_target_compile $srcdir/$subdir/AdvMap.mod AdvMap.o object "-c -g -I$srcdir/$subdir/"
81 gm2_target_compile $srcdir/$subdir/AdvMath.mod AdvMath.o object "-c -g -I$srcdir/$subdir/"
82 gm2_target_compile $srcdir/$subdir/AdvParse.mod AdvParse.o object "-c -g -I$srcdir/$subdir/"
83 gm2_target_compile $srcdir/$subdir/AdvSound.mod AdvSound.o object "-c -g -I$srcdir/$subdir/"
84 gm2_target_compile $srcdir/$subdir/AdvSystem.mod AdvSystem.o object "-c -g -I$srcdir/$subdir/"
85 gm2_target_compile $srcdir/$subdir/AdvTreasure.mod AdvTreasure.o object "-c -g -I$srcdir/$subdir/"
86 gm2_target_compile $srcdir/$subdir/AdvUtil.mod AdvUtil.o object "-c -g -I$srcdir/$subdir/"
87 gm2_target_compile $srcdir/$subdir/DrawG.mod DrawG.o object "-c -g -I$srcdir/$subdir/"
88 gm2_target_compile $srcdir/$subdir/DrawL.mod DrawL.o object "-c -g -I$srcdir/$subdir/"
89 gm2_target_compile $srcdir/$subdir/Lock.mod Lock.o object "-c -g -I$srcdir/$subdir/"
90 gm2_target_compile $srcdir/$subdir/ProcArgs.mod ProcArgs.o object "-c -g -I$srcdir/$subdir/"
91 gm2_target_compile $srcdir/$subdir/Screen.mod Screen.o object "-c -g -I$srcdir/$subdir/"
92 gm2_target_compile $srcdir/$subdir/Window.mod Window.o object "-c -g -I$srcdir/$subdir/"
93
94 set output [target_compile $srcdir/$subdir/SocketControl.c SocketControl.o object "-g"]
95 set output [target_compile $srcdir/$subdir/advflex.c advflex.o object "-g"]
96
97 foreach testcase [lsort [glob -nocomplain $srcdir/$subdir/Dungeon.mod]] {
98 # If we're only testing specific files and this isn't one of them, skip it.
99 if ![runtest_file_p $runtests $testcase] then {
100 continue
101 }
102 set gm2_keep_executable 1
103 if { ${gm2_run_tower_test} } then {
104 gm2-simple-execute $testcase "" ""
105 } else {
106 verbose "not running simple tower execute test (with no map)" 1
107 }
108 set gm2_keep_executable 0
109
110 global tmpdir;
111 set executable $tmpdir/[file tail [file rootname $testcase].x];
112
113 if { ${gm2_run_tower_test} } then {
114 gm2-local-exec ${testcase} ${executable} $srcdir/$subdir/star
115 } else {
116 verbose "not running tower socket test" 1
117 }
118 remote_file build delete ${executable};
119 }