--- /dev/null
+# stap_run_exact.exp
+#
+# Simple script for testing multiple lines of exact output.
+
+# stap_run_exact TEST_NAME filename args
+# TEST_NAME is the name printed
+# filename is path to the current test
+# Additional arguments are passed to stap as-is.
+#
+# global result_string must be set to the expected output
+
+proc stap_run_exact { TEST_NAME test_file_name args } {
+ if {[info procs installtest_p] != "" && ![installtest_p]} { untested $TEST_NAME; return }
+
+ 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"
+}
--- /dev/null
+# test elision of zero buckets in histograms
+
+set myresults(-1) {value |-------------------------------------------------- count
+ 300 | 0
+ 350 | 0
+ 400 |@ 1
+ 450 | 0
+ 500 | 0
+ 550 | 0
+ 600 | 0
+ 650 | 0
+ 700 | 0
+ 750 | 0
+ 800 | 0
+ 850 | 0
+ 900 | 0
+ 950 |@ 1
+ 1000 | 0
+ 1050 | 0
+
+value |-------------------------------------------------- count
+ 300 | 0
+ 350 | 0
+ 400 |@ 1
+ 450 | 0
+ 500 |@ 1
+ 550 | 0
+ 600 | 0
+
+value |-------------------------------------------------- count
+ 0 |@ 1
+ 50 | 0
+ 100 | 0
+
+value |-------------------------------------------------- count
+ 0 | 0
+ 50 |@ 1
+ 100 | 0
+ 150 | 0
+
+value |-------------------------------------------------- count
+ 1350 | 0
+ 1400 | 0
+ 1450 |@ 1
+ 1500 | 0
+
+value |-------------------------------------------------- count
+ 1400 | 0
+ 1450 | 0
+ 1500 |@ 1
+
+value |-------------------------------------------------- count
+ -30 | 0
+ -20 | 0
+ -10 |@ 1
+ 0 | 0
+ 10 | 0
+
+value |-------------------------------------------------- count
+ -20 | 0
+ -10 | 0
+ 0 |@ 1
+ 10 | 0
+ 20 | 0
+
+value |-------------------------------------------------- count
+ 32 | 0
+ 64 | 0
+ 128 |@ 1
+ 256 | 0
+ 512 | 0
+
+value |-------------------------------------------------- count
+ 0 |@ 1
+ 1 | 0
+ 2 | 0
+
+ value |-------------------------------------------------- count
+-16384 | 0
+ -8192 | 0
+ -4096 |@ 1
+ -2048 | 0
+ -1024 | 0
+ -512 | 0
+ -256 | 0
+ -128 | 0
+ -64 | 0
+ -32 | 0
+ -16 | 0
+ -8 | 0
+ -4 | 0
+ -2 |@ 1
+ -1 | 0
+ 0 | 0
+
+}
+set myresults(0) {value |-------------------------------------------------- count
+ ~
+ 400 |@ 1
+ ~
+ 950 |@ 1
+
+value |-------------------------------------------------- count
+ ~
+ 400 |@ 1
+ ~
+ 500 |@ 1
+
+value |-------------------------------------------------- count
+ 0 |@ 1
+
+value |-------------------------------------------------- count
+ ~
+ 50 |@ 1
+
+value |-------------------------------------------------- count
+ ~
+ 1450 |@ 1
+
+value |-------------------------------------------------- count
+ ~
+ 1500 |@ 1
+
+value |-------------------------------------------------- count
+ ~
+ -10 |@ 1
+
+value |-------------------------------------------------- count
+ ~
+ 0 |@ 1
+
+value |-------------------------------------------------- count
+ ~
+ 128 |@ 1
+
+value |-------------------------------------------------- count
+ 0 |@ 1
+
+ value |-------------------------------------------------- count
+ ~
+ -4096 |@ 1
+ ~
+ -2 |@ 1
+
+}
+set myresults(1) {value |-------------------------------------------------- count
+ ~
+ 350 | 0
+ 400 |@ 1
+ 450 | 0
+ ~
+ 900 | 0
+ 950 |@ 1
+ 1000 | 0
+
+value |-------------------------------------------------- count
+ ~
+ 350 | 0
+ 400 |@ 1
+ 450 | 0
+ 500 |@ 1
+ 550 | 0
+
+value |-------------------------------------------------- count
+ 0 |@ 1
+ 50 | 0
+
+value |-------------------------------------------------- count
+ 0 | 0
+ 50 |@ 1
+ 100 | 0
+
+value |-------------------------------------------------- count
+ ~
+ 1400 | 0
+ 1450 |@ 1
+ 1500 | 0
+
+value |-------------------------------------------------- count
+ ~
+ 1450 | 0
+ 1500 |@ 1
+
+value |-------------------------------------------------- count
+ ~
+ -20 | 0
+ -10 |@ 1
+ 0 | 0
+
+value |-------------------------------------------------- count
+ ~
+ -10 | 0
+ 0 |@ 1
+ 10 | 0
+
+value |-------------------------------------------------- count
+ ~
+ 64 | 0
+ 128 |@ 1
+ 256 | 0
+
+value |-------------------------------------------------- count
+ 0 |@ 1
+ 1 | 0
+
+ value |-------------------------------------------------- count
+ ~
+ -8192 | 0
+ -4096 |@ 1
+ -2048 | 0
+ ~
+ -4 | 0
+ -2 |@ 1
+ -1 | 0
+
+}
+set myresults(2) {value |-------------------------------------------------- count
+ 300 | 0
+ 350 | 0
+ 400 |@ 1
+ 450 | 0
+ 500 | 0
+ ~
+ 850 | 0
+ 900 | 0
+ 950 |@ 1
+ 1000 | 0
+ 1050 | 0
+
+value |-------------------------------------------------- count
+ 300 | 0
+ 350 | 0
+ 400 |@ 1
+ 450 | 0
+ 500 |@ 1
+ 550 | 0
+ 600 | 0
+
+value |-------------------------------------------------- count
+ 0 |@ 1
+ 50 | 0
+ 100 | 0
+
+value |-------------------------------------------------- count
+ 0 | 0
+ 50 |@ 1
+ 100 | 0
+ 150 | 0
+
+value |-------------------------------------------------- count
+ 1350 | 0
+ 1400 | 0
+ 1450 |@ 1
+ 1500 | 0
+
+value |-------------------------------------------------- count
+ 1400 | 0
+ 1450 | 0
+ 1500 |@ 1
+
+value |-------------------------------------------------- count
+ -30 | 0
+ -20 | 0
+ -10 |@ 1
+ 0 | 0
+ 10 | 0
+
+value |-------------------------------------------------- count
+ -20 | 0
+ -10 | 0
+ 0 |@ 1
+ 10 | 0
+ 20 | 0
+
+value |-------------------------------------------------- count
+ 32 | 0
+ 64 | 0
+ 128 |@ 1
+ 256 | 0
+ 512 | 0
+
+value |-------------------------------------------------- count
+ 0 |@ 1
+ 1 | 0
+ 2 | 0
+
+ value |-------------------------------------------------- count
+-16384 | 0
+ -8192 | 0
+ -4096 |@ 1
+ -2048 | 0
+ -1024 | 0
+ ~
+ -8 | 0
+ -4 | 0
+ -2 |@ 1
+ -1 | 0
+ 0 | 0
+
+}
+set myresults(3) {value |-------------------------------------------------- count
+ 300 | 0
+ 350 | 0
+ 400 |@ 1
+ 450 | 0
+ 500 | 0
+ 550 | 0
+ ~
+ 800 | 0
+ 850 | 0
+ 900 | 0
+ 950 |@ 1
+ 1000 | 0
+ 1050 | 0
+
+value |-------------------------------------------------- count
+ 300 | 0
+ 350 | 0
+ 400 |@ 1
+ 450 | 0
+ 500 |@ 1
+ 550 | 0
+ 600 | 0
+
+value |-------------------------------------------------- count
+ 0 |@ 1
+ 50 | 0
+ 100 | 0
+
+value |-------------------------------------------------- count
+ 0 | 0
+ 50 |@ 1
+ 100 | 0
+ 150 | 0
+
+value |-------------------------------------------------- count
+ 1350 | 0
+ 1400 | 0
+ 1450 |@ 1
+ 1500 | 0
+
+value |-------------------------------------------------- count
+ 1400 | 0
+ 1450 | 0
+ 1500 |@ 1
+
+value |-------------------------------------------------- count
+ -30 | 0
+ -20 | 0
+ -10 |@ 1
+ 0 | 0
+ 10 | 0
+
+value |-------------------------------------------------- count
+ -20 | 0
+ -10 | 0
+ 0 |@ 1
+ 10 | 0
+ 20 | 0
+
+value |-------------------------------------------------- count
+ 32 | 0
+ 64 | 0
+ 128 |@ 1
+ 256 | 0
+ 512 | 0
+
+value |-------------------------------------------------- count
+ 0 |@ 1
+ 1 | 0
+ 2 | 0
+
+ value |-------------------------------------------------- count
+-16384 | 0
+ -8192 | 0
+ -4096 |@ 1
+ -2048 | 0
+ -1024 | 0
+ -512 | 0
+ ~
+ -16 | 0
+ -8 | 0
+ -4 | 0
+ -2 |@ 1
+ -1 | 0
+ 0 | 0
+
+}
+
+
+for {set i -1} { $i < 4} {incr i} {
+ set test "elision-$i"
+ set ::result_string $myresults($i)
+ stap_run_exact "elision$i" $srcdir/$subdir/elision.stp -DHIST_ELISION=$i
+}
+
+
--- /dev/null
+# test that we can check the count of an empty array
+
+global a,b,c
+
+probe begin
+{
+ a <<< 444
+ a <<< 999
+ print(@hist_linear(a, 0, 1500, 50))
+ delete a
+
+ a <<< 444
+ a <<< 500
+ print(@hist_linear(a, 0, 1500, 50))
+ delete a
+
+ a <<< 0
+ print(@hist_linear(a, 0, 1500, 50))
+ delete a
+
+ a <<< 50
+ print(@hist_linear(a, 0, 1500, 50))
+ delete a
+
+ a <<< 1450
+ print(@hist_linear(a, 0, 1500, 50))
+ delete a
+
+ a <<< 1500
+ print(@hist_linear(a, 0, 1500, 50))
+ delete a
+
+ b <<< -10
+ print(@hist_linear(b, -100, 100, 10))
+ delete b
+
+ b <<< 0
+ print(@hist_linear(b, -100, 100, 10))
+ delete b
+
+ c <<< 128
+ print(@hist_log(c))
+ delete c
+
+ c <<< 0
+ print(@hist_log(c))
+ delete c
+
+ c <<< -2
+ c <<< -4096
+ print(@hist_log(c))
+
+ exit()
+}