Debian Codegraph @

testsuite/systemtap.syscall/syscall.exp

raw
1 # syscall.exp
2 #
3 # This script searches the systemtap.syscall directory for C files to
4 # test. See the README file for details on the C files.
5 #
6 # To restrict C files to test, set the CHECK_ONLY environment variable.
7 # For example, to only test the readwrite and accept C files, run:
8 #
9 # make installcheck RUNTESTFLAGS=syscall.exp CHECK_ONLY="readwrite accept"
10
11 set test_script "sys.stp"
12 set test_module_name "syscall_longlonglong"
13 set wd [pwd]
14 set test_module "${wd}/${test_module_name}.ko"
15 set cached_module "/tmp/${test_module_name}.ko"
16
17 source $srcdir/$subdir/test.tcl
18
19 proc test_procedure {} {
20 global env srcdir subdir test_script test_module test_module_name cached_module
21 set flags ""
22
23 set patterns []
24 if {[info exists env(CHECK_ONLY)]} {
25 foreach file $env(CHECK_ONLY) {
26 lappend patterns "$file.c"
27 }
28 } else {
29 lappend patterns "*.c"
30 }
31
32 if {$srcdir == ""} {
33 set basedir ""
34 } else {
35 set basedir "$srcdir/$subdir/"
36 }
37
38 set test_files []
39 foreach pattern $patterns {
40 set test_files [concat $test_files \
41 [glob -nocomplain "${basedir}${pattern}"]]
42 }
43
44 if {[llength $test_files] == 0} {
45 # If our globbing didn't find any test files, there isn't any
46 # point in proceeding.
47 fail "$test_module_name: no tests found"
48 return
49 }
50
51 # To speed things up, go ahead and compile the test module once
52 # here, then just use it down in run_one_test(). The test script
53 # uses wildcards to cover every syscall and takes time to parse.
54 #
55 # During test development, the module may be cached if needed
56 # using REUSE_MODULE=1.
57 #
58 # Note that at one point we were passing '--skip-badvars' when
59 # compiling the syscall module. This tends to hide errors and not
60 # give errors when we expect them.
61 #
62 # Returning back to '--skip-badvars' after discussion. Without it,
63 # the "big" test module, having syscall.* in it, might not compile at
64 # all. In such case none of the syscall tests can run. This way
65 # we can at least run the tests and possibly KFAIL the test results
66 # where needed.
67 set script "$srcdir/$subdir/${test_script}"
68 set cmd "stap --skip-badvars -p4 -I $srcdir/$subdir/tapset -m ${test_module_name} ${script}"
69 exec /bin/rm -f ${test_module}
70 set output ""
71 if {[info exists env(REUSE_MODULE)] && \
72 ![string compare $env(REUSE_MODULE) 1] && \
73 [file exists ${cached_module}]} {
74 puts "ATTENTION: Reusing existing module since REUSE_MODULE was set."
75 exec /bin/cp ${cached_module} ${test_module}
76 } else {
77 catch {eval exec $cmd} output
78 }
79 send_log "${output}\n"
80 if {[file exists ${test_module}]} {
81 exec /bin/cp ${test_module} ${cached_module}
82 pass "[file tail ${script}] compilation"
83 } else {
84 # If compiling the test module failed, there isn't much point
85 # in trying to run any of the real tests.
86 fail "[file tail ${script}] compilation"
87 return
88 }
89
90 for {set i 0} {$i < [arch_compile_flags]} {incr i} {
91 set flags [arch_compile_flag $i]
92 set arch [arch_compile_flag_name $i]
93 set arch_size [arch_compile_flag_bits $i]
94
95 foreach filename [lsort $test_files] {
96 set testname [file tail [string range $filename 0 end-2]]
97 if {![installtest_p]} {
98 untested "${arch_size}-bit $testname"; continue
99 }
100 send_log "Testing ${arch_size}-bit ${testname} syscall\n"
101 run_one_test $filename $flags ${arch_size} "syscall"
102 }
103 }
104
105 # Cleeanup
106 exec /bin/rm -f ${test_module}
107 }
108
109 test_procedure