From 3a29a2eef30f191afbc1bc117b6e5a2812dfe91b Mon Sep 17 00:00:00 2001 From: Martin Cermak Date: Tue, 8 Jan 2019 17:06:41 +0100 Subject: [PATCH] Make testcase at_var.exp work with stap-4.1+ and kernel-4.17+ This testcase update tries to reflect following changes: - 4.17 breaks syscalls tapset https://sourceware.org/bugzilla/show_bug.cgi?id=23160 - $foo->bar differs from @var("foo")->bar https://bugzilla.redhat.com/show_bug.cgi?id=1660889#c4 . --- testsuite/systemtap.base/at_var.exp | 28 +++++++++++++++++++++++++++- testsuite/systemtap.base/at_var.stp | 10 +++++----- 2 files changed, 32 insertions(+), 6 deletions(-) diff --git a/testsuite/systemtap.base/at_var.exp b/testsuite/systemtap.base/at_var.exp index 890d2563d..875d01dc8 100644 --- a/testsuite/systemtap.base/at_var.exp +++ b/testsuite/systemtap.base/at_var.exp @@ -21,8 +21,10 @@ $utimes[1]$$: {.tv_sec=3, .tv_usec=4} set result_string3 {user_int(&$foo->bar): 40 user_int(&@var("foo")->bar): 40 &@cast($foo->bar, "struct foo")->bar: 42 +$foo->bar == @entry($foo->bar): true} + +set result_string4 { &@cast(@var("foo")->bar, "struct foo")->bar: 42 -$foo->bar == @entry($foo->bar): true @var("foo")->bar == @entry(@var("foo")->bar): true} # s390x machines can't do $utimes$$, since all syscall args are @@ -37,6 +39,8 @@ if {[istarget s390x-*-*]} { if {! [installtest_p]} { untested "$test"; return } if {! [uretprobes_p]} { untested "$test"; return } +# A) Test the "current" (post-4a8652800d4dc7d57d3e2ac5463c1d292b9742a8) version behavior: + set res [target_compile ${testpath}/${test}.c ${test} executable "additional_flags=-O2 additional_flags=-g"] if { $res != "" } { verbose "target_compile failed: $res" 2 @@ -55,5 +59,27 @@ if { $res != "" } { stap_run3 $test_name $srcdir/$subdir/$test.stp -c ./${test} -w } +# B) Test the legacy/--compatible=4.0 (pre-4a8652800d4dc7d57d3e2ac5463c1d292b9742a8) behavior: + +set ::result_string "${::result_string}$result_string4" + +set res [target_compile ${testpath}/${test}.c ${test} executable "additional_flags=-O2 additional_flags=-g"] +if { $res != "" } { + verbose "target_compile failed: $res" 2 + fail "${test}: unable to compile ${test}.c" +} else { + stap_run3 $test $srcdir/$subdir/$test.stp -c ./${test} -w --compatible=4.0 +} + +# Test for target program compiled without optimization +set test_name "${test} (non-optimized)" +set res [target_compile ${testpath}/${test}.c ${test} executable "additional_flags=-g"] +if { $res != "" } { + verbose "target_compile failed: $res" 2 + fail "${test_name}: unable to compile ${test}.c" +} else { + stap_run3 $test_name $srcdir/$subdir/$test.stp -c ./${test} -w --compatible=4.0 +} + # Cleanup if { $verbose == 0 } { catch { exec rm -f $test } } diff --git a/testsuite/systemtap.base/at_var.stp b/testsuite/systemtap.base/at_var.stp index fb76868da..e74436d80 100644 --- a/testsuite/systemtap.base/at_var.stp +++ b/testsuite/systemtap.base/at_var.stp @@ -19,7 +19,7 @@ probe process.function("sub") %(arch != "s390" %? // On s390x, the utimes() wrapper and function both just get longs, // so we'll have to use @cast(). -probe kernel.function("SYSC_utimes")!, kernel.function("sys_utimes") +probe kernel.function("SYSC_utimes")!, kernel.function("sys_utimes")!, kernel.function("do_futimesat") { printf("$utimes$$: %s\n", $utimes$$); printf("$utimes[1]$$: %s\n", $utimes[1]$$); @@ -38,12 +38,12 @@ probe process.function("sub").return so taking the address of that field is 42 again. */ printf("&@cast($foo->bar, \"struct foo\")->bar: %d\n", &@cast($foo->bar, "struct foo")->bar); - printf("&@cast(@var(\"foo\")->bar, \"struct foo\")->bar: %d\n", - &@cast(@var("foo")->bar, "struct foo")->bar); - - /* Note that variables are taken at entry in both cases. */ printf("$foo->bar == @entry($foo->bar): %s\n", $foo->bar == @entry($foo->bar) ? "true" : "false"); +%( systemtap_v <= "4.0" %? + printf("&@cast(@var(\"foo\")->bar, \"struct foo\")->bar: %d\n", + &@cast(@var("foo")->bar, "struct foo")->bar); printf("@var(\"foo\")->bar == @entry(@var(\"foo\")->bar): %s\n", @var("foo")->bar == @entry(@var("foo")->bar) ? "true" : "false"); +%) } -- 2.43.5