This is the mail archive of the systemtap@sourceware.org mailing list for the systemtap project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCHv2 2/2] Test for: Fix sematic error: empty struct


From: James Bottomley <James.Bottomley@HansenPartnership.com>
Date: Tue, 8 Jul 2008 12:38:58 -0500
Subject: Add test suite for declaration resolution

This adds the test declaration.exp which checks that specific named
declarations inside the kernel both fail and succeed.  We get the
failure by only using a single compile unit which is currently known
to have the structure stubbed.  We get exactly the same declaration to
succeed by adding a CU that is known to have the declaration.

Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
---
 testsuite/config/unix.exp                |    1 +
 testsuite/lib/stap_compile.exp           |   39 +++++++++++++++++++++++++++++
 testsuite/systemtap.base/declaration.exp |   19 ++++++++++++++
 testsuite/systemtap.base/marker.exp      |   40 ------------------------------
 4 files changed, 59 insertions(+), 40 deletions(-)
 create mode 100644 testsuite/lib/stap_compile.exp
 create mode 100644 testsuite/systemtap.base/declaration.exp

diff --git a/testsuite/config/unix.exp b/testsuite/config/unix.exp
index 625c560..52560ca 100644
--- a/testsuite/config/unix.exp
+++ b/testsuite/config/unix.exp
@@ -3,3 +3,4 @@ load_lib "stap_run2.exp"
 load_lib "stap_run_exact.exp"
 load_lib "stap_run_binary.exp"
 load_lib "stap_run.exp"
+load_lib "stap_compile.exp"
diff --git a/testsuite/lib/stap_compile.exp b/testsuite/lib/stap_compile.exp
new file mode 100644
index 0000000..8c6df0e
--- /dev/null
+++ b/testsuite/lib/stap_compile.exp
@@ -0,0 +1,39 @@
+# stap_compile TEST_NAME flags script args
+# - TEST_NAME is the name of the current test
+# - compile indicates whether the script is supposed to compile
+# - script is the script to compile
+# Additional arguments are passed to stap as-is.
+proc stap_compile { TEST_NAME compile script args } {
+    set cmd [concat {stap -v -p4 -e} $script $args]
+
+    verbose -log "running $cmd" 
+    eval spawn $cmd
+    set compile_errors 0
+    expect {
+	-re {^Pass\ [1234]:[^\r]*\ in\ .*\ ms.\r\n} {exp_continue}
+	-re {^Pass\ [34]: using cached [^\r\n]+\r\n} {exp_continue}
+        # pass-4 output
+	-re {^/[^\r\n]+.ko\r\n} {exp_continue}
+	-re "parse error" { incr compile_errors 1; exp_continue}
+	-re "compilation failed" {incr compile_errors 1; exp_continue}
+	-re "semantic error:" {incr compile_errors 1; exp_continue}
+    }
+    catch close
+    wait
+
+    # If we've got compile errors and the script was supposed to
+    # compile, fail.
+    if {$compile_errors > 0} {
+	if {$compile == 1} {
+	    fail "$TEST_NAME compilation failed"
+	} else {
+	    pass "$TEST_NAME compilation failed correctly"
+	}
+    } else {
+	if {$compile == 1} {
+	    pass "$TEST_NAME compilation succeeded"
+	} else {
+	    fail "$TEST_NAME compilation succeeded unexpectedly"
+	}
+    }
+}
diff --git a/testsuite/systemtap.base/declaration.exp b/testsuite/systemtap.base/declaration.exp
new file mode 100644
index 0000000..1649881
--- /dev/null
+++ b/testsuite/systemtap.base/declaration.exp
@@ -0,0 +1,19 @@
+# Declaration tests.  Specifically looking for resolution of
+# DW_AT_declaration from another module
+
+set TEST_NAME "RESOLVE_FAIL"
+
+# this test just makes sure $device is still stubbed with DW_AT_declaration
+set failscript {
+    probe\ module(\"libata\").function(\"ata_qc_issue\")\ \{\ print(\$qc->\$scsicmd->\$device->\$host->\$host_no)\ \};
+}
+
+stap_compile $TEST_NAME 0 $failscript
+
+set TEST_NAME "RESOLVE_PASS"
+
+set passscript {
+    probe\ module(\"scsi_mod\").function(\"scsi_request_fn\")\ \{print(\$q)\}
+}
+
+stap_compile $TEST_NAME 1 [concat $passscript $failscript ]
\ No newline at end of file
diff --git a/testsuite/systemtap.base/marker.exp b/testsuite/systemtap.base/marker.exp
index 857fa5d..89c0b8c 100644
--- a/testsuite/systemtap.base/marker.exp
+++ b/testsuite/systemtap.base/marker.exp
@@ -3,46 +3,6 @@
 # trigger a specific marker).  So, we'll try to compile lots of tests
 # to do as much as we can.
 
-# stap_compile TEST_NAME flags script args
-# - TEST_NAME is the name of the current test
-# - compile indicates whether the script is supposed to compile
-# - script is the script to compile
-# Additional arguments are passed to stap as-is.
-proc stap_compile { TEST_NAME compile script args } {
-    set cmd [concat {stap -v -p4 -e} $script $args]
-    
-    verbose -log "running $cmd" 
-    eval spawn $cmd
-    set compile_errors 0
-    expect {
-	-re {^Pass\ [1234]:[^\r]*\ in\ .*\ ms.\r\n} {exp_continue}
-	-re {^Pass\ [34]: using cached [^\r\n]+\r\n} {exp_continue}
-        # pass-4 output
-	-re {^/[^\r\n]+.ko\r\n} {exp_continue}
-	-re "parse error" { incr compile_errors 1; exp_continue}
-	-re "compilation failed" {incr compile_errors 1; exp_continue}
-	-re "semantic error:" {incr compile_errors 1; exp_continue}
-    }
-    catch close
-    wait
-
-    # If we've got compile errors and the script was supposed to
-    # compile, fail.
-    if {$compile_errors > 0} {
-	if {$compile == 1} {
-	    fail "$TEST_NAME compilation failed"
-	} else {
-	    pass "$TEST_NAME compilation failed correctly"
-	}
-    } else {
-	if {$compile == 1} {
-	    pass "$TEST_NAME compilation succeeded"
-	} else {
-	    fail "$TEST_NAME compilation succeeded unexpectedly"
-	}
-    }
-}
-
 # Initialize variables
 set kernel_markers_found 0
 set kernel_marker_names {}
-- 
1.5.6




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]