| 1 |
# arg_write.exp |
| 2 |
# |
| 3 |
# This script searches the systemtap.syscall/arg_write directory for |
| 4 |
# C files to 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=arg_write.exp CHECK_ONLY="readwrite accept" |
| 10 |
|
| 11 |
set test_script "arg_write.stp" |
| 12 |
set test_module_name "arg_write_longlonglong" |
| 13 |
set wd [pwd] |
| 14 |
set test_module "${wd}/${test_module_name}.ko" |
| 15 |
|
| 16 |
source $srcdir/$subdir/test.tcl |
| 17 |
|
| 18 |
if { ![expr { [string equal $tcl_platform(machine) "x86_64"] |
| 19 |
&& [string compare $tcl_platform(osVersion) "4.17"] >= 0 }] |
| 20 |
&& ![expr { [string equal $tcl_platform(machine) "aarch64"] |
| 21 |
&& [string compare $tcl_platform(osVersion) "4.19"] >= 0 }] } { |
| 22 |
untested $test_script |
| 23 |
return |
| 24 |
} |
| 25 |
|
| 26 |
proc test_procedure {} { |
| 27 |
global env srcdir subdir test_script test_module test_module_name |
| 28 |
set wd [pwd] |
| 29 |
set flags "" |
| 30 |
|
| 31 |
set patterns [] |
| 32 |
if {[info exists env(CHECK_ONLY)]} { |
| 33 |
foreach file $env(CHECK_ONLY) { |
| 34 |
lappend patterns "$file.c" |
| 35 |
} |
| 36 |
} else { |
| 37 |
lappend patterns "*.c" |
| 38 |
} |
| 39 |
|
| 40 |
if {$srcdir == ""} { |
| 41 |
set basedir "arg_write/" |
| 42 |
} else { |
| 43 |
set basedir "$srcdir/$subdir/arg_write/" |
| 44 |
} |
| 45 |
|
| 46 |
set test_files [] |
| 47 |
foreach pattern $patterns { |
| 48 |
set test_files [concat $test_files \ |
| 49 |
[glob -nocomplain "${basedir}${pattern}"]] |
| 50 |
} |
| 51 |
|
| 52 |
if {[llength $test_files] == 0} { |
| 53 |
# If our globbing didn't find any test files, there isn't any |
| 54 |
# point in proceeding. |
| 55 |
fail "$test_module_name: no tests found" |
| 56 |
return |
| 57 |
} |
| 58 |
|
| 59 |
# To speed things up, go ahead and compile the test module once |
| 60 |
# here, then just use it down in run_one_test(). The test script |
| 61 |
# uses wildcards to cover every syscall and takes time to parse. |
| 62 |
# |
| 63 |
# Note that at one point we were passing '--skip-badvars' when |
| 64 |
# compiling the syscall module. This tends to hide errors and not |
| 65 |
# give errors when we expect them. |
| 66 |
set script "$srcdir/$subdir/${test_script}" |
| 67 |
set cmd "stap -p4 -m ${test_module_name} ${script}" |
| 68 |
exec /bin/rm -f ${test_module} |
| 69 |
|
| 70 |
# Remember any set value of SYSTEMTAP_DEBUGINFO_PATH |
| 71 |
if {[info exists env(SYSTEMTAP_DEBUGINFO_PATH)]} { |
| 72 |
set old_path $env(SYSTEMTAP_DEBUGINFO_PATH) |
| 73 |
set restore_old_path 1 |
| 74 |
} else { |
| 75 |
set restore_old_path 0 |
| 76 |
} |
| 77 |
|
| 78 |
# Override SYSTEMTAP_DEBUGINFO_PATH to ensure no debuginfo could be used |
| 79 |
set env(SYSTEMTAP_DEBUGINFO_PATH) "" |
| 80 |
catch {eval exec $cmd} output |
| 81 |
|
| 82 |
# Restore any previous value, otherwise unset it |
| 83 |
if {$restore_old_path} { |
| 84 |
set env(SYSTEMTAP_DEBUGINFO_PATH) $old_path |
| 85 |
} else { |
| 86 |
unset env(SYSTEMTAP_DEBUGINFO_PATH) |
| 87 |
} |
| 88 |
|
| 89 |
send_log "${output}\n" |
| 90 |
if {[file exists ${test_module}]} { |
| 91 |
pass "[file tail ${script}] compilation" |
| 92 |
} else { |
| 93 |
# If compiling the test module failed, there isn't much point |
| 94 |
# in trying to run any of the real tests. |
| 95 |
fail "[file tail ${script}] compilation" |
| 96 |
return |
| 97 |
} |
| 98 |
|
| 99 |
for {set i 0} {$i < [arch_compile_flags]} {incr i} { |
| 100 |
set flags [arch_compile_flag $i] |
| 101 |
set arch [arch_compile_flag_name $i] |
| 102 |
set arch_size [arch_compile_flag_bits $i] |
| 103 |
verbose -log "i: $i flags: $flags arch: $arch size: $arch_size" |
| 104 |
|
| 105 |
foreach filename [lsort $test_files] { |
| 106 |
set testname [file tail [string range $filename 0 end-2]] |
| 107 |
if {![installtest_p]} { |
| 108 |
untested "${arch_size}-bit $testname"; continue |
| 109 |
} |
| 110 |
send_log "Testing ${arch_size}-bit ${testname} nd_syscall\n" |
| 111 |
run_one_test $filename $flags ${arch_size} "nd_syscall" |
| 112 |
} |
| 113 |
} |
| 114 |
|
| 115 |
# Cleeanup |
| 116 |
exec /bin/rm -f ${test_module} |
| 117 |
} |
| 118 |
|
| 119 |
test_procedure |