File: tls.exp

package info (click to toggle)
systemtap 5.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 47,556 kB
  • sloc: cpp: 81,117; ansic: 54,933; xml: 49,795; exp: 43,595; sh: 11,526; 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 (152 lines) | stat: -rw-r--r-- 4,435 bytes parent folder | download | duplicates (3)
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
set test "tls"
set stap_path $env(SYSTEMTAP_PATH)/stap

# exp_internal 1

# tls not supported on aarch64: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97344
set arch [exec uname -i]
if {$arch eq "aarch64"} { untested $test; return }

set so_flags "additional_flags=-shared"
set so_flags "$so_flags additional_flags=-g"
set so_flags "$so_flags additional_flags=-fPIC"
set x_flags "additional_flags=-Wl,-rpath,[pwd]"
set x_flags "$x_flags additional_flags=-g"
set x_flags "$x_flags additional_flags=-fPIC"
set x_flags "$x_flags additional_flags=-lpthread"

# static tls variables setup

set so1_sopath "[pwd]/libtls1.so"
set res0 [target_compile $srcdir/$subdir/tls1_.c $so1_sopath \
	      executable $so_flags ]
set x1_flags "$x_flags additional_flags=-L[pwd] additional_flags=-ltls1"
set x1_exepath "[pwd]/tls1.x"
set res [target_compile $srcdir/$subdir/tls1.c $x1_exepath \
	     executable $x1_flags ]
if {$res0 != "" || $res != ""} {
    fail "$test compiling tls1"
    return
} else {
    pass "$test compiling tls1"
}

# extern tls variables setup

set so2_sopath "[pwd]/libtls2.so"
set so3_sopath "[pwd]/libtls3.so"
set so2_flags "$so_flags additional_flags=-DEXTERN_TLS"

set res0 [target_compile $srcdir/$subdir/tls1_.c $so2_sopath \
	      executable $so2_flags ]
set res1 [target_compile $srcdir/$subdir/tls2_.c $so3_sopath \
	      executable $so2_flags ]
set x2_flags "$x_flags additional_flags=-L[pwd] additional_flags=-ltls2"
set x2_flags "$x2_flags additional_flags=-ltls3"
set x2_flags "$x2_flags additional_flags=-DEXTERN_TLS"
set x2_exepath "[pwd]/tls2.x"
set res [target_compile $srcdir/$subdir/tls1.c $x2_exepath \
	 executable $x2_flags ]
if { $res0 != "" || $res != "" } {
    fail "$test compiling -shared"
    return
} else {
    pass "$test compiling -shared"
}

# errno setup

set errno_exepath "[pwd]/tlserrno.x"
set res [target_compile $srcdir/$subdir/tlserrno.c $errno_exepath \
	     executable $x_flags ]
if {$res != ""} {
    fail "$test compiling tlserrno"
    return
} else {
    pass "$test compiling tls1errno"
}
set libc_path [exec sh -c "ldd tlserrno.x | grep libc.so | awk '{print \$3}'"]

foreach runtime [get_runtime_list] {
    if {$runtime != ""} {
	set test_type "$test ($runtime)"
    } else {
	set runtime "kernel"
	set test_type $test
    }

    set ok 0
    set nodb 0
    spawn $stap_path --runtime=$runtime -g -c $x1_exepath $srcdir/$subdir/tls1.stp $so1_sopath IGNORE
    expect {
	-timeout 180
	-re {WARNING:.*No DWARF information found} { incr nodb }
	-re {In Stap(()| increase_tls): (tls1=0x[23] tls2=0x[34]|tls=99)} { incr ok; exp_continue }
	eof { }
    }
    catch {close}; catch {wait}
    if {$nodb != 0} {
	untested "$test_type (missing debuginfo)"
	return
    }
    if {$ok == 3} {
	pass "$test_type local tls vars"
    } else {
	fail "$test_type local tls vars ($ok/3)"
    }

    # extern tls variables

    set ok 0
    spawn $stap_path --runtime=$runtime -g -c $x2_exepath $srcdir/$subdir/tls1.stp $so2_sopath $so3_sopath
    expect {
	-timeout 180
	-re {In Stap (worker|increase_tls): tls1=0x[23] tls2=0x[34]\r\n} { incr ok; exp_continue }
	eof { }
    }
    catch {close}; catch {wait}
    if {$ok == 4} {
	pass "$test_type ext tls vars"
    } else {
	fail "$test_type ext tls vars ($ok/4)"
    }

    # Check errno

    set ok 0
    set nodb 0
    spawn $stap_path --runtime=$runtime  -e "probe process(\"$libc_path\").function(\"*stat*\").return { printf(\"errno=%d %s\\n\", @var(\"errno@errno.c\"),errno_str(@var(\"errno@errno.c\"))) }" -c "/usr/bin/ls /file/does/not/exist"
    expect {
	-timeout 180
	-re {Missing separate debuginfos} { incr nodb }
	-re {errno=2 (ENOENT)} { incr ok; exp_continue }
	eof { }
    }
    catch {close}; catch {wait}
    if {$ok >= 1} {
	pass "$test_type errno"
    } elseif {$nodb > 0} {
	xfail "$test_type errno (no glibc debuginfo)"
    } else {
	fail "$test_type errno ($ok/>=1)"
    }

    set ok 0
    set nodb 0
    spawn $stap_path --runtime=$runtime -e "probe process(\"$errno_exepath\").function(\"main\").return {println (\"In Stap errno=\",@errno) }" -c "$errno_exepath"

    expect {
	-timeout 180
	-re {Missing separate debuginfos} { incr nodb }
	-re {In Stap errno=2} { incr ok; exp_continue }
	eof { }
    }
    catch {close}; catch {wait}
    if {$ok >= 1} {
	pass "$test_type @errno"
    } elseif {$nodb > 0} {
	xfail "$test_type errno (no glibc debuginfo)"
    } else {
	fail "$test_type @errno ($ok/>=1)"
    }
}