File: externalvar.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 (118 lines) | stat: -rw-r--r-- 3,316 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
set test "externalvar"
set testpath "$srcdir/$subdir"
set testsrc  "$testpath/$test.c"
set testsrclib  "$testpath/${test}_lib.c"
set testexe  "[pwd]/$test"
set testlibname  "$test"
set testlibdir "[pwd]"
set testso  "$testlibdir/lib${testlibname}.so"
set testflags "additional_flags=-g"
set testlibflags "$testflags additional_flags=-fPIC additional_flags=-shared"
set maintestflags "$testflags additional_flags=-L$testlibdir additional_flags=-l$testlibname additional_flags=-Wl,-rpath,$testlibdir"

set output {exevar_c = 42
exevar_i = 2
exevar_l = 21
stat_exevar_c = 42
stat_exevar_i = 2
stat_exevar_l = 21
exe_s->i = 1
exe_s->l = 2
exe_s->c = 3
stat_exe_s->i = 1
stat_exe_s->l = 2
stat_exe_s->c = 3
exe_s->s1 = 0x0
exe_s == exe_s->s2
stat_exe_s->s1 = 0x0
stat_exe_s == exe_s->s2
libvar = 42
stat_libvar = 42
lib_s->i = 1
lib_s->l = 2
lib_s->c = 3
stat_lib_s->i = 1
stat_lib_s->l = 2
stat_lib_s->c = 3
lib_s == lib_s->s1
lib_s->s2 = 0x0
stat_lib_s == lib_s->s1
stat_lib_s->s2 = 0x0}

# Only run on make installcheck and utrace present.
if {! [installtest_p]} { untested "$test"; return }

proc dyninst_kfails {index} {
  # The dyninst runtime isn't multi-arch, it only works on the
  # native architecture. PR14490.
  if {! [all_compile_flag_native_p $index]} {
    setup_kfail 14490 "*-*-*"
  }
}

for {set i 0} {$i < [all_compile_flags]} {incr i} {
  set extra_flag [all_compile_flag $i]
  set extra_name [all_compile_flag_name $i]

  # Compile our test program and library.
  set res [target_compile $testsrclib $testso executable \
	       "$testlibflags $extra_flag"]
  if { $res != "" } {
    verbose "target_compile for $testso failed: $res" 2
    fail "unable to compile $testsrclib $extra_name"
    continue
  }
  set res [target_compile $testsrc $testexe executable \
	       "$maintestflags $extra_flag"]
  if { $res != "" } {
    verbose "target_compile failed: $res" 2
    fail "unable to compile $testsrc $extra_name"
    continue
  }

  foreach runtime [get_runtime_list] {
    set test_name "$test-$extra_name"
    if {$runtime != ""} {
      # Got to run stap with both the exe and the libraries used as -d
      # args.
      if {[info procs ${runtime}_kfails] ne ""} { ${runtime}_kfails $i }
      set test_name "$test_name-$runtime"
      set cmd [concat stap --runtime=$runtime -d $testso \
		   -d $testexe -c $testexe $testpath/$test.stp]
    } elseif {[utrace_p] && [uprobes_p]} {
      # Got to run stap with both the exe and the libraries used as -d
      # args.
      set cmd [concat stap -d $testso -d $testexe -c $testexe \
		   $testpath/$test.stp]
    } else {
      untested "$test_name"
      continue
    }
    send_log "cmd: $cmd\n"
    catch {eval exec $cmd} res
    send_log "cmd output: $res\n"
      
    set n 0
    set m [llength [split $output "\n"]]
    set expected [split $output "\n"]
    foreach line [split $res "\n"] {
      if {![string equal $line [lindex $expected $n]]} {
	fail "$test_name"
	send_log "line [expr $n + 1]: expected \"[lindex $expected $n]\", "
	send_log "Got \"$line\"\n"
	set n -1
	break
      }
      incr n
    }
    if { $n < 0 } { continue }
      
    if { $n != $m } {
      fail "$test_name"
      send_log "Got \"$n\" lines, expected \"$m\" lines\n"
    } else {
      pass $test_name
    }
  }
  catch {exec rm -f $testexe $testso}
}