File: syscall.exp

package info (click to toggle)
systemtap 5.1-5
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 47,964 kB
  • sloc: cpp: 80,838; ansic: 54,757; xml: 49,725; exp: 43,665; sh: 11,527; python: 5,003; perl: 2,252; tcl: 1,312; makefile: 1,006; javascript: 149; lisp: 105; awk: 101; asm: 91; java: 70; sed: 16
file content (109 lines) | stat: -rw-r--r-- 3,494 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# syscall.exp
#
# This script searches the systemtap.syscall directory for C files to
# test. See the README file for details on the C files.
#
# To restrict C files to test, set the CHECK_ONLY environment variable.
# For example, to only test the readwrite and accept C files, run:
#
#    make installcheck RUNTESTFLAGS=syscall.exp CHECK_ONLY="readwrite accept"

set test_script "sys.stp"
set test_module_name "syscall_longlonglong"
set wd [pwd]
set test_module "${wd}/${test_module_name}.ko"
set cached_module "/tmp/${test_module_name}.ko"

source $srcdir/$subdir/test.tcl

proc test_procedure {} {
    global env srcdir subdir test_script test_module test_module_name cached_module
    set flags ""

    set patterns []
    if {[info exists env(CHECK_ONLY)]} {
	foreach file $env(CHECK_ONLY) {
	    lappend patterns "$file.c"
	}
    } else {
	lappend patterns "*.c"
    }

    if {$srcdir == ""} {
	set basedir ""
    } else {
	set basedir "$srcdir/$subdir/"
    }

    set test_files []
    foreach pattern $patterns {
	set test_files [concat $test_files \
			    [glob -nocomplain "${basedir}${pattern}"]]
    }

    if {[llength $test_files] == 0} {
	# If our globbing didn't find any test files, there isn't any
	# point in proceeding.
	fail "$test_module_name: no tests found"
	return
    }

    # To speed things up, go ahead and compile the test module once
    # here, then just use it down in run_one_test(). The test script
    # uses wildcards to cover every syscall and takes time to parse.
    #
    # During test development, the module may be cached if needed
    # using REUSE_MODULE=1.
    #
    # Note that at one point we were passing '--skip-badvars' when
    # compiling the syscall module. This tends to hide errors and not
    # give errors when we expect them.
    #
    # Returning back to '--skip-badvars' after discussion.  Without it,
    # the "big" test module, having syscall.* in it, might not compile at
    # all. In such case none of the syscall tests can run.  This way
    # we can at least run the tests and possibly KFAIL the test results
    # where needed.
    set script "$srcdir/$subdir/${test_script}"
    set cmd "stap --skip-badvars -p4 -I $srcdir/$subdir/tapset -m ${test_module_name} ${script}"
    exec /bin/rm -f ${test_module}
    set output ""
    if {[info exists env(REUSE_MODULE)] && \
        ![string compare $env(REUSE_MODULE) 1] && \
        [file exists ${cached_module}]} {
        puts "ATTENTION: Reusing existing module since REUSE_MODULE was set."
        exec /bin/cp ${cached_module} ${test_module}
    } else {
        catch {eval exec $cmd} output
    }
    send_log "${output}\n"
    if {[file exists ${test_module}]} {
	exec /bin/cp ${test_module} ${cached_module}
	pass "${script} compilation"
    } else {
	# If compiling the test module failed, there isn't much point
	# in trying to run any of the real tests.
	fail "${script} compilation"
	return
    }

    for {set i 0} {$i < [arch_compile_flags]} {incr i} {
	set flags [arch_compile_flag $i]
	set arch [arch_compile_flag_name $i]
	set arch_size [arch_compile_flag_bits $i]

	foreach filename [lsort $test_files] {
	    set testname [file tail [string range $filename 0 end-2]]
	    if {![installtest_p]} {
		untested "${arch_size}-bit $testname"; continue
	    }
	    send_log "Testing ${arch_size}-bit ${testname} syscall\n"
	    run_one_test $filename $flags ${arch_size} "syscall"
	}
    }

    # Cleeanup
    exec /bin/rm -f ${test_module}
}

test_procedure