Debian Codegraph @

testsuite/systemtap.syscall/nd_syscall.exp

raw
1 # nd_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=nd_syscall.exp CHECK_ONLY="readwrite accept"
10
11 set test_script "nd_sys.stp"
12 set test_module_name "nd_syscall_longlonglong"
13 set wd [pwd]
14 set test_module "${wd}/${test_module_name}.ko"
15
16 source $srcdir/$subdir/test.tcl
17
18 proc test_procedure {} {
19 global env srcdir subdir test_script test_module test_module_name
20 set wd [pwd]
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 # Note that at one point we were passing '--skip-badvars' when
56 # compiling the syscall module. This tends to hide errors and not
57 # give errors when we expect them.
58 set script "$srcdir/$subdir/${test_script}"
59 set cmd "stap -p4 -m ${test_module_name} ${script}"
60 exec /bin/rm -f ${test_module}
61
62 # Remember any set value of SYSTEMTAP_DEBUGINFO_PATH
63 if {[info exists env(SYSTEMTAP_DEBUGINFO_PATH)]} {
64 set old_path $env(SYSTEMTAP_DEBUGINFO_PATH)
65 set restore_old_path 1
66 } else {
67 set restore_old_path 0
68 }
69
70 # Override SYSTEMTAP_DEBUGINFO_PATH to ensure no debuginfo could be used
71 set env(SYSTEMTAP_DEBUGINFO_PATH) ""
72 catch {eval exec $cmd} output
73
74 # Restore any previous value, otherwise unset it
75 if {$restore_old_path} {
76 set env(SYSTEMTAP_DEBUGINFO_PATH) $old_path
77 } else {
78 unset env(SYSTEMTAP_DEBUGINFO_PATH)
79 }
80
81 send_log "${output}\n"
82 if {[file exists ${test_module}]} {
83 pass "[file tail ${script}] compilation"
84 } else {
85 # If compiling the test module failed, there isn't much point
86 # in trying to run any of the real tests.
87 fail "[file tail ${script}] compilation"
88 return
89 }
90
91 for {set i 0} {$i < [arch_compile_flags]} {incr i} {
92 set flags [arch_compile_flag $i]
93 set arch [arch_compile_flag_name $i]
94 set arch_size [arch_compile_flag_bits $i]
95 verbose -log "i: $i flags: $flags arch: $arch size: $arch_size"
96
97 foreach filename [lsort $test_files] {
98 set testname [file tail [string range $filename 0 end-2]]
99 if {![installtest_p]} {
100 untested "${arch_size}-bit $testname"; continue
101 }
102 send_log "Testing ${arch_size}-bit ${testname} nd_syscall\n"
103 run_one_test $filename $flags ${arch_size} "nd_syscall"
104 }
105 }
106
107 # Cleeanup
108 exec /bin/rm -f ${test_module}
109 }
110
111 test_procedure