diff options
author | Dave Brolley <brolley@redhat.com> | 2009-11-23 19:08:51 -0500 |
---|---|---|
committer | Dave Brolley <brolley@redhat.com> | 2009-11-23 19:08:51 -0500 |
commit | 5d1c958ce2dcc0f28c1bd13b8e005c0c2ad1cdba (patch) | |
tree | e44ad8807e0b5b2e1bb85682f677d492f1195dbf /testsuite/systemtap.base | |
parent | 562d60b004e3d7ae73c1c7508be529006bd6430f (diff) | |
parent | 90bba7158de040705a101ba1fdf6062866b4b4e9 (diff) | |
download | systemtap-steved-5d1c958ce2dcc0f28c1bd13b8e005c0c2ad1cdba.tar.gz systemtap-steved-5d1c958ce2dcc0f28c1bd13b8e005c0c2ad1cdba.tar.xz systemtap-steved-5d1c958ce2dcc0f28c1bd13b8e005c0c2ad1cdba.zip |
Merge branch 'master' of ssh://sources.redhat.com/git/systemtap
Conflicts:
configure
Diffstat (limited to 'testsuite/systemtap.base')
-rw-r--r-- | testsuite/systemtap.base/cu-decl-1.c | 17 | ||||
-rw-r--r-- | testsuite/systemtap.base/cu-decl-2.c | 10 | ||||
-rw-r--r-- | testsuite/systemtap.base/cu-decl.exp | 25 | ||||
-rw-r--r-- | testsuite/systemtap.base/externalvar.c | 52 | ||||
-rw-r--r-- | testsuite/systemtap.base/externalvar.exp | 70 | ||||
-rw-r--r-- | testsuite/systemtap.base/externalvar.stp | 39 | ||||
-rw-r--r-- | testsuite/systemtap.base/externalvar_lib.c | 43 |
7 files changed, 256 insertions, 0 deletions
diff --git a/testsuite/systemtap.base/cu-decl-1.c b/testsuite/systemtap.base/cu-decl-1.c new file mode 100644 index 00000000..9743d298 --- /dev/null +++ b/testsuite/systemtap.base/cu-decl-1.c @@ -0,0 +1,17 @@ +#include <stdio.h> + +struct foo; +struct foo* get_foo(void); + +void +print(struct foo* f) +{ + printf("%p\n", f); +} + +int +main() +{ + print(get_foo()); + return 0; +} diff --git a/testsuite/systemtap.base/cu-decl-2.c b/testsuite/systemtap.base/cu-decl-2.c new file mode 100644 index 00000000..46503251 --- /dev/null +++ b/testsuite/systemtap.base/cu-decl-2.c @@ -0,0 +1,10 @@ +struct foo { + int x, y; +}; + +struct foo* +get_foo() +{ + static struct foo f = { 6, 7 }; + return &f; +} diff --git a/testsuite/systemtap.base/cu-decl.exp b/testsuite/systemtap.base/cu-decl.exp new file mode 100644 index 00000000..ae06ad85 --- /dev/null +++ b/testsuite/systemtap.base/cu-decl.exp @@ -0,0 +1,25 @@ +# Check that we can dereference a type declaration that is +# defined in a separate CU from the function. +set test "cu-decl" + +set script { + probe process("cu-decl").function("print") { + println($f->x * $f->y) + } +} + +set sources "$srcdir/$subdir/$test-1.c $srcdir/$subdir/$test-2.c" +set res [target_compile $sources $test executable "additional_flags=-g"] +if { $res != "" } { + verbose "target_compile failed: $res" 2 + fail "$test target compilation" + untested "$test" +} else { + pass "$test target compilation" +} +if {![utrace_p]} { + untested "$test : no kernel utrace support found" +} else { + stap_compile $test 1 "{$script}" +} +catch {exec rm $test} diff --git a/testsuite/systemtap.base/externalvar.c b/testsuite/systemtap.base/externalvar.c new file mode 100644 index 00000000..a7716029 --- /dev/null +++ b/testsuite/systemtap.base/externalvar.c @@ -0,0 +1,52 @@ +/* externalvar test case + * Copyright (C) 2009, Red Hat Inc. + * + * This file is part of systemtap, and is free software. You can + * redistribute it and/or modify it under the terms of the GNU General + * Public License (GPL); either version 2, or (at your option) any + * later version. + * + * Tests that an external exported variable can be accessed. + */ + +#include <stdlib.h> + +// function from our library +int lib_main (void); + +struct exestruct +{ + char c; + int i; + long l; + struct exestruct *s1; + struct exestruct *s2; +}; + +char exevar_c; +int exevar_i; +long exevar_l; +struct exestruct *exe_s; + +static void +main_call () +{ + asm (""); // dummy method, just to probe and extract and jump into lib. + lib_main (); +} + +int +main () +{ + exevar_c = 42; + exevar_i = 2; + exevar_l = 21; + exe_s = (struct exestruct *) malloc(sizeof(struct exestruct)); + exe_s->i =1; + exe_s->l =2; + exe_s->c =3; + exe_s->s1 = NULL; + exe_s->s2 = exe_s; + main_call (); + return 0; +} diff --git a/testsuite/systemtap.base/externalvar.exp b/testsuite/systemtap.base/externalvar.exp new file mode 100644 index 00000000..668dec55 --- /dev/null +++ b/testsuite/systemtap.base/externalvar.exp @@ -0,0 +1,70 @@ +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 additional_flags=-O0" +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" + +# Only run on make installcheck and utrace present. +if {! [installtest_p]} { untested "$test"; return } +if {! [utrace_p]} { untested "$test"; return } + +# Compile our test program and library. +set res [target_compile $testsrclib $testso executable $testlibflags] +if { $res != "" } { + verbose "target_compile for $testso failed: $res" 2 + fail "unable to compile $testsrclib" + return +} +set res [target_compile $testsrc $testexe executable $maintestflags] +if { $res != "" } { + verbose "target_compile failed: $res" 2 + fail "unable to compile $testsrc" + return +} + +set output {exevar_c = 42 +exevar_i = 2 +exevar_l = 21 +exe_s->i = 1 +exe_s->l = 2 +exe_s->c = 3 +exe_s->s1 = 0x0 +exe_s == exe_s->s2 +libvar = 42 +lib_s->i = 1 +lib_s->l = 2 +lib_s->c = 3 +lib_s == lib_s->s1 +lib_s->s2 = 0x0} + +# 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] +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 + send_log "line [expr $n + 1]: expected \"[lindex $expected $n]\", " + send_log "Got \"$line\"\n" + return + } + incr n +} +if { $n != $m } { + fail $test + send_log "Got \"$n\" lines, expected \"$m\" lines\n" +} else { + pass $test +} +# exec rm -f $testexe $testso diff --git a/testsuite/systemtap.base/externalvar.stp b/testsuite/systemtap.base/externalvar.stp new file mode 100644 index 00000000..7d4b69bb --- /dev/null +++ b/testsuite/systemtap.base/externalvar.stp @@ -0,0 +1,39 @@ +probe process("externalvar").function("main_call") +{ + printf("exevar_c = %d\n", $exevar_c); + printf("exevar_i = %d\n", $exevar_i); + printf("exevar_l = %d\n", $exevar_l); + + printf("exe_s->i = %d\n", $exe_s->i); + printf("exe_s->l = %d\n", $exe_s->l); + printf("exe_s->c = %d\n", $exe_s->c); + + printf("exe_s->s1 = 0x%x\n", $exe_s->s1); + if ($exe_s == $exe_s->s2) + { + printf("exe_s == exe_s->s2\n"); + } + else + { + printf("exe_s != exe_s->s2\n"); + } +} + +probe process("libexternalvar.so").function("lib_call") +{ + printf("libvar = %d\n", $libvar); + + printf("lib_s->i = %d\n", $lib_s->i); + printf("lib_s->l = %d\n", $lib_s->l); + printf("lib_s->c = %d\n", $lib_s->c); + + if ($lib_s == $lib_s->s1) + { + printf("lib_s == lib_s->s1\n"); + } + else + { + printf("lib_s != lib_s->s2\n"); + } + printf("lib_s->s2 = 0x%x\n", $lib_s->s2); +} diff --git a/testsuite/systemtap.base/externalvar_lib.c b/testsuite/systemtap.base/externalvar_lib.c new file mode 100644 index 00000000..9017e798 --- /dev/null +++ b/testsuite/systemtap.base/externalvar_lib.c @@ -0,0 +1,43 @@ +/* external var test case - library helper + * Copyright (C) 2009, Red Hat Inc. + * + * This file is part of systemtap, and is free software. You can + * redistribute it and/or modify it under the terms of the GNU General + * Public License (GPL); either version 2, or (at your option) any + * later version. + * + * Tests that an external exported variable can be accessed. + */ + +#include <stdlib.h> + +struct libstruct +{ + int i; + long l; + char c; + struct libstruct *s1; + struct libstruct *s2; +}; + +int libvar; +struct libstruct *lib_s; + +static void +lib_call () +{ + asm(""); // dummy method, just to probe and extract. +} + +void +lib_main () +{ + libvar = 42; + lib_s = (struct libstruct *) malloc(sizeof(struct libstruct)); + lib_s->i = 1; + lib_s->l = 2; + lib_s->c = 3; + lib_s->s1 = lib_s; + lib_s->s2 = NULL; + lib_call (); +} |