1
1
import os
2
2
3
3
const vexe = @VEXE
4
+ const gcc_path = os.find_abs_path_of_executable ('gcc' ) or { '' }
5
+ const cdefs_h_32bit_exists = os.exists ('/usr/include/i386-linux-gnu/sys/cdefs.h' )
4
6
5
7
fn test_tracing () {
6
8
os.chdir (@VROOT)!
@@ -12,28 +14,39 @@ fn test_tracing() {
12
14
eprintln ('> skipping ${fpath} , because ${should_match_fpath} does not exist.' )
13
15
continue
14
16
}
15
- res := os.execute ('${os.quoted_path(vexe)} -trace-calls run ${os.quoted_path(fpath)} ' )
16
- if res.exit_code != 0 {
17
- eprintln ('> compilation output:\n ${res.output} ' )
18
- assert res.exit_code == 0 , 'compilation of ${fpath} failed'
17
+ run_single_program (fpath, should_match_fpath, '' , '64bit' )
18
+ if cdefs_h_32 bit_exists && gcc_path != '' {
19
+ // try running the same programs, compiled in 32bit mode too, if gcc is available:
20
+ run_single_program (fpath, should_match_fpath, '-cc gcc -m32 -gc none' , '32bit' )
21
+ } else {
22
+ eprintln ('> skipping -m32 compilation since either 32bit headers are not installed, or you do not have gcc installed' )
19
23
}
20
- lines := os.read_lines (should_match_fpath) or {
21
- assert false , '${fpath} should be readable'
22
- return
23
- }
24
- if lines.len == 0 {
25
- assert false , '${should_match_fpath} should contain at least one line/glob match pattern'
26
- }
27
- mut matched := false
28
- for line in lines {
29
- if res.output.match_glob (line) {
30
- matched = true
31
- println ('> trace output of ${fpath} matches line pattern: ${line} ' )
32
- continue
33
- } else {
34
- eprintln (res.output)
35
- assert false , '> trace output of ${fpath} DID NOT match the line pattern: ${line} '
36
- }
24
+ eprintln ('-' .repeat (30 ))
25
+ }
26
+ }
27
+
28
+ fn run_single_program (fpath string , should_match_fpath string , compiler_opts string , label string ) {
29
+ res := os.execute ('${os.quoted_path(vexe)} ${compiler_opts} -trace-calls run ${os.quoted_path(fpath)} ' )
30
+ if res.exit_code != 0 {
31
+ eprintln ('> ${label} compilation output:\n ${res.output} ' )
32
+ assert res.exit_code == 0 , 'compilation of ${fpath} failed'
33
+ }
34
+ lines := os.read_lines (should_match_fpath) or {
35
+ assert false , '${fpath} should be readable'
36
+ return
37
+ }
38
+ if lines.len == 0 {
39
+ assert false , '${should_match_fpath} should contain at least one line/glob match pattern'
40
+ }
41
+ mut matched := false
42
+ for line in lines {
43
+ if res.output.match_glob (line) {
44
+ matched = true
45
+ println ('> ${label} trace output of ${fpath} matches line pattern: ${line} ' )
46
+ continue
47
+ } else {
48
+ eprintln (res.output)
49
+ assert false , '> trace output of ${fpath} DID NOT match the line pattern: ${line} '
37
50
}
38
51
}
39
52
}
0 commit comments