summaryrefslogtreecommitdiffstats
path: root/testsuite/systemtap.base/optim_arridx.exp
diff options
context:
space:
mode:
Diffstat (limited to 'testsuite/systemtap.base/optim_arridx.exp')
-rw-r--r--testsuite/systemtap.base/optim_arridx.exp77
1 files changed, 77 insertions, 0 deletions
diff --git a/testsuite/systemtap.base/optim_arridx.exp b/testsuite/systemtap.base/optim_arridx.exp
new file mode 100644
index 00000000..0987dec6
--- /dev/null
+++ b/testsuite/systemtap.base/optim_arridx.exp
@@ -0,0 +1,77 @@
+# test integer limits. Set and print variables and print constants.
+
+set test "optim_arridx"
+set ::result_string {# globals
+arr1:long [long, long]
+arr2:long [long]
+arr3:long [long]
+# functions
+fna:long (a:long)
+return a
+fnb:long (a:long, b:long)
+return (a) + (b)
+exit:unknown ()
+%{
+ atomic_set (&session_state, STAP_SESSION_STOPPING);
+ _stp_exit ();
+%}
+# probes
+begin /* <- begin */
+ # locals
+ idx2:long
+ j:long
+ k:long
+ b:long
+ m:long
+ arr1:long [long]
+ arr2:long [long, long]
+ aa:long
+ bb:long
+ cc:long
+ dd:long
+ ee:long
+{
+(arr2[(idx2) = (2)]) = (20)
+(arr2[(j) = (4)]) = (40)
+(arr1[fna((k) = (0)), k]) = (1)
+(arr1[(b) = (1), b]) = (2)
+fnb((arr3[0]) = (4), arr3[0])
+(m) = (1)
+for (2; (m) <= (10); (m)++) ;
+printf("%d %d %d %d\\n", arr1[0], arr2[0, 0], idx2, j)
+(aa) = (fna(1))
+(bb) = (fnb((cc) = (1), 2))
+for (1; (bb) < (10); (bb)++) (cc) += (bb)
+for ((dd) = (1); (dd) < (10); 1) (dd) += (1)
+if (1) (ee) = (1)
+
+(cc) = ((dd) = (5))
+(cc) = ((4) + ((cc) = (1)))
+printf("%d %d %d %d %d", aa, bb, cc, dd, ee)
+exit()
+}
+}
+
+proc optim_arridx_run { TEST_NAME args } {
+ # zap the srcdir prefix
+ set test_file_name $TEST_NAME
+ set TEST_NAME [regsub {.*/testsuite/} $TEST_NAME ""]
+
+ set cmd [concat stap $args $test_file_name]
+ catch {eval exec $cmd} res
+
+ set n 0
+ set expected [split $::result_string "\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]\"\n"
+ send_log "Got \"$line\"\n"
+ return
+ }
+ incr n
+ }
+ pass "$TEST_NAME"
+}
+
+optim_arridx_run $srcdir/$subdir/$test.stp -p2 -v 2>/dev/null