summaryrefslogtreecommitdiffstats
path: root/runtime
diff options
context:
space:
mode:
authorhunt <hunt>2005-06-18 07:12:41 +0000
committerhunt <hunt>2005-06-18 07:12:41 +0000
commitef0e92b0335077884edd5ac9997a203bec1839b0 (patch)
tree8247b545c18d83a3b580744b8689a3227a1a364d /runtime
parent96124157d812d71cbdfd018e984dc42bed17d072 (diff)
downloadsystemtap-steved-ef0e92b0335077884edd5ac9997a203bec1839b0.tar.gz
systemtap-steved-ef0e92b0335077884edd5ac9997a203bec1839b0.tar.xz
systemtap-steved-ef0e92b0335077884edd5ac9997a203bec1839b0.zip
Added aggregation tests. Fixed other for latest runtime changes.
Diffstat (limited to 'runtime')
-rw-r--r--runtime/tests/README4
-rw-r--r--runtime/tests/agg/Makefile5
-rw-r--r--runtime/tests/agg/agg.test209
-rw-r--r--runtime/tests/agg/all.tcl4
-rw-r--r--runtime/tests/agg/count.c72
-rw-r--r--runtime/tests/agg/stats.c59
-rw-r--r--runtime/tests/maps/all.tcl7
-rw-r--r--runtime/tests/maps/ii.c5
-rw-r--r--runtime/tests/maps/iiss.c5
-rw-r--r--runtime/tests/maps/is.c5
-rw-r--r--runtime/tests/maps/ist.c16
-rw-r--r--runtime/tests/maps/map_format.c18
-rw-r--r--runtime/tests/maps/si.c6
-rw-r--r--runtime/tests/maps/test_list_int64.c5
-rw-r--r--runtime/tests/maps/test_list_string.c6
-rw-r--r--runtime/tests/string/all.tcl8
16 files changed, 369 insertions, 65 deletions
diff --git a/runtime/tests/README b/runtime/tests/README
index 795d8a02..b38eb212 100644
--- a/runtime/tests/README
+++ b/runtime/tests/README
@@ -1,2 +1,2 @@
-
-maps/ tests for associative arrays (maps) and lists
+This directory contains the user-levels tests.
+To run, just type "make".
diff --git a/runtime/tests/agg/Makefile b/runtime/tests/agg/Makefile
new file mode 100644
index 00000000..c396c132
--- /dev/null
+++ b/runtime/tests/agg/Makefile
@@ -0,0 +1,5 @@
+default: tests
+
+tests:
+ tclsh all.tcl
+
diff --git a/runtime/tests/agg/agg.test b/runtime/tests/agg/agg.test
new file mode 100644
index 00000000..58db3714
--- /dev/null
+++ b/runtime/tests/agg/agg.test
@@ -0,0 +1,209 @@
+package require tcltest
+namespace import -force tcltest::*
+
+cd $tcltest::testsDirectory
+
+set CFLAGS "-Os"
+set KPATH "/lib/modules/[exec uname -r]/build/include"
+set MPATH "/lib/modules/[exec uname -r]/build/include/asm/mach-default"
+set PATH "../../user"
+
+test Counter {Counter Test} -setup {
+ exec gcc $CFLAGS -I $KPATH -I $PATH -I $MPATH -o test count.c
+} -body {
+ exec ./test
+} -result {cnt1[0] = 1
+cnt2[0] = 10
+cnt1[1] = 2
+cnt2[1] = 11
+cnt1[2] = 3
+cnt2[2] = 12
+cnt1[3] = 4
+cnt2[3] = 13
+cnt1[4] = 5
+cnt2[4] = 14
+cnt1[5] = 6
+cnt2[5] = 15
+cnt1[6] = 7
+cnt2[6] = 16
+cnt1[7] = 8
+cnt2[7] = 17
+cnt1 = 36
+cnt2 = 108
+--------------------
+cnt1[0] = 2
+cnt2[0] = 20
+cnt1[1] = 4
+cnt2[1] = 22
+cnt1[2] = 6
+cnt2[2] = 24
+cnt1[3] = 8
+cnt2[3] = 26
+cnt1[4] = 10
+cnt2[4] = 28
+cnt1[5] = 12
+cnt2[5] = 30
+cnt1[6] = 14
+cnt2[6] = 32
+cnt1[7] = 16
+cnt2[7] = 34
+cnt1 = 72
+cnt2 = 216
+--------------------
+cnt1 = 140
+cnt2 = 784
+cnt1 = 0
+cnt2 = 0
+--------------------
+cnt1[0] = 0
+cnt2[0] = 0
+cnt1[1] = 1
+cnt2[1] = 1
+cnt1[2] = 4
+cnt2[2] = 8
+cnt1[3] = 9
+cnt2[3] = 27
+cnt1[4] = 16
+cnt2[4] = 64
+cnt1[5] = 25
+cnt2[5] = 125
+cnt1[6] = 36
+cnt2[6] = 216
+cnt1[7] = 49
+cnt2[7] = 343
+cnt1 = 140
+cnt2 = 784}
+
+test Stats {Stats Test} -setup {
+ exec gcc $CFLAGS -I $KPATH -I $PATH -I $MPATH -o test stats.c
+} -body {
+ exec ./test
+} -result {st1[0] = count: 1 sum:1
+st2[0] = count: 1 sum:10
+st3[0] = count: 1 sum:100
+st1[1] = count: 1 sum:2
+st2[1] = count: 1 sum:11
+st3[1] = count: 1 sum:101
+st1[2] = count: 1 sum:3
+st2[2] = count: 1 sum:12
+st3[2] = count: 1 sum:102
+st1[3] = count: 1 sum:4
+st2[3] = count: 1 sum:13
+st3[3] = count: 1 sum:103
+st1[4] = count: 1 sum:5
+st2[4] = count: 1 sum:14
+st3[4] = count: 1 sum:104
+st1[5] = count: 1 sum:6
+st2[5] = count: 1 sum:15
+st3[5] = count: 1 sum:105
+st1[6] = count: 1 sum:7
+st2[6] = count: 1 sum:16
+st3[6] = count: 1 sum:106
+st1[7] = count: 1 sum:8
+st2[7] = count: 1 sum:17
+st3[7] = count: 1 sum:107
+--------------------
+CPU: 0 Count: 1 Sum: 1
+CPU: 1 Count: 1 Sum: 2
+CPU: 2 Count: 1 Sum: 3
+CPU: 3 Count: 1 Sum: 4
+CPU: 4 Count: 1 Sum: 5
+CPU: 5 Count: 1 Sum: 6
+CPU: 6 Count: 1 Sum: 7
+CPU: 7 Count: 1 Sum: 8
+CPU: 0 Count: 1 Sum: 10
+CPU: 1 Count: 1 Sum: 11
+CPU: 2 Count: 1 Sum: 12
+CPU: 3 Count: 1 Sum: 13
+CPU: 4 Count: 1 Sum: 14
+CPU: 5 Count: 1 Sum: 15
+CPU: 6 Count: 1 Sum: 16
+CPU: 7 Count: 1 Sum: 17
+CPU: 0 Count: 1 Sum: 100
+CPU: 1 Count: 1 Sum: 101
+CPU: 2 Count: 1 Sum: 102
+CPU: 3 Count: 1 Sum: 103
+CPU: 4 Count: 1 Sum: 104
+CPU: 5 Count: 1 Sum: 105
+CPU: 6 Count: 1 Sum: 106
+CPU: 7 Count: 1 Sum: 107
+--------------------
+Count: 8 Sum: 36
+Count: 8 Sum: 108
+Count: 8 Sum: 828
+--------------------
+count:8 sum:36 avg:4 min:1 max:8
+
+count:8 sum:108 avg:13 min:10 max:17
+value |-------------------------------------------------- count
+ 0 | 0
+ 1 | 0
+ 2 | 0
+ 4 | 0
+ 8 |@@@@@@ 6
+ 16 |@@ 2
+ 32 | 0
+
+count:8 sum:828 avg:103 min:100 max:107
+value |-------------------------------------------------- count
+ 0 | 0
+ 5 | 0
+ 10 | 0
+ 15 | 0
+ 20 | 0
+ 25 | 0
+ 30 | 0
+ 35 | 0
+ 40 | 0
+ 45 | 0
+ 50 | 0
+ 55 | 0
+ 60 | 0
+ 65 | 0
+ 70 | 0
+ 75 | 0
+ 80 | 0
+ 85 | 0
+ 90 | 0
+ 95 |@@@@@@@@ 8
+
+count:0 sum:0 avg:0 min:0 max:0
+
+count:0 sum:0 avg:0 min:0 max:0
+value |-------------------------------------------------- count
+ 0 | 0
+ 1 | 0
+ 2 | 0
+ 4 | 0
+ 8 | 0
+ 16 | 0
+ 32 | 0
+
+count:0 sum:0 avg:0 min:0 max:0
+value |-------------------------------------------------- count
+ 0 | 0
+ 5 | 0
+ 10 | 0
+ 15 | 0
+ 20 | 0
+ 25 | 0
+ 30 | 0
+ 35 | 0
+ 40 | 0
+ 45 | 0
+ 50 | 0
+ 55 | 0
+ 60 | 0
+ 65 | 0
+ 70 | 0
+ 75 | 0
+ 80 | 0
+ 85 | 0
+ 90 | 0
+ 95 | 0
+}
+
+
+exec rm test
+
+cleanupTests
diff --git a/runtime/tests/agg/all.tcl b/runtime/tests/agg/all.tcl
new file mode 100644
index 00000000..23757202
--- /dev/null
+++ b/runtime/tests/agg/all.tcl
@@ -0,0 +1,4 @@
+package require tcltest
+namespace import -force tcltest::*
+tcltest::testsDirectory [file dir [info script]]
+tcltest::runAllTests
diff --git a/runtime/tests/agg/count.c b/runtime/tests/agg/count.c
new file mode 100644
index 00000000..8e674d1e
--- /dev/null
+++ b/runtime/tests/agg/count.c
@@ -0,0 +1,72 @@
+#include "runtime.h"
+
+/* test of Counters */
+#include "counter.c"
+
+int main ()
+{
+ int i;
+ Counter cnt1 = _stp_counter_init();
+ Counter cnt2 = _stp_counter_init();
+
+ /* testing _stp_counter_add(). These will only be correct if _stp_counter_init() */
+ /* set all values to 0 and add works properly. */
+ for (_processor_number = 0; _processor_number < NR_CPUS; _processor_number++) {
+ _stp_counter_add (cnt1, _processor_number + 1);
+ _stp_counter_add (cnt2, _processor_number + 10);
+ }
+
+ /* testing _stp_counter_get_cpu() */
+ for (i = 0; i < NR_CPUS; i++) {
+ printf ("cnt1[%d] = %lld\n", i, _stp_counter_get_cpu(cnt1, i, 0));
+ printf ("cnt2[%d] = %lld\n", i, _stp_counter_get_cpu(cnt2, i, 0));
+ }
+
+ /* testing _stp_counter_get() */
+ printf ("cnt1 = %d\n", _stp_counter_get(cnt1, 0));
+ printf ("cnt2 = %d\n", _stp_counter_get(cnt2, 0));
+ printf ("--------------------\n");
+
+ /* testing _stp_counter_add() */
+ for (_processor_number = 0; _processor_number < NR_CPUS; _processor_number++) {
+ _stp_counter_add (cnt1, _processor_number + 1);
+ _stp_counter_add (cnt2, _processor_number + 10);
+ }
+
+ for (i = 0; i < NR_CPUS; i++) {
+ printf ("cnt1[%d] = %lld\n", i, _stp_counter_get_cpu(cnt1, i, 0));
+ printf ("cnt2[%d] = %lld\n", i, _stp_counter_get_cpu(cnt2, i, 0));
+ }
+ printf ("cnt1 = %d\n", _stp_counter_get(cnt1, 1));
+ printf ("cnt2 = %d\n", _stp_counter_get(cnt2, 1));
+
+ printf ("--------------------\n");
+
+ for (_processor_number = 0; _processor_number < NR_CPUS; _processor_number++) {
+ _stp_counter_add (cnt1, _processor_number * _processor_number);
+ _stp_counter_add (cnt2, _processor_number * _processor_number * _processor_number);
+ }
+
+ printf ("cnt1 = %d\n", _stp_counter_get(cnt1, 1));
+ printf ("cnt2 = %d\n", _stp_counter_get(cnt2, 1));
+ printf ("cnt1 = %d\n", _stp_counter_get(cnt1, 0));
+ printf ("cnt2 = %d\n", _stp_counter_get(cnt2, 0));
+ printf ("--------------------\n");
+
+
+ for (_processor_number = 0; _processor_number < NR_CPUS; _processor_number++) {
+ _stp_counter_add (cnt1, _processor_number * _processor_number);
+ _stp_counter_add (cnt2, _processor_number * _processor_number * _processor_number);
+ }
+
+ for (i = 0; i < NR_CPUS; i++) {
+ printf ("cnt1[%d] = %lld\n", i, _stp_counter_get_cpu(cnt1, i, 0));
+ printf ("cnt2[%d] = %lld\n", i, _stp_counter_get_cpu(cnt2, i, 0));
+ }
+ printf ("cnt1 = %d\n", _stp_counter_get(cnt1, 0));
+ printf ("cnt2 = %d\n", _stp_counter_get(cnt2, 0));
+
+ _stp_counter_free (cnt1);
+ _stp_counter_free (cnt2);
+ return 0;
+}
diff --git a/runtime/tests/agg/stats.c b/runtime/tests/agg/stats.c
new file mode 100644
index 00000000..0d57d4d7
--- /dev/null
+++ b/runtime/tests/agg/stats.c
@@ -0,0 +1,59 @@
+#include "runtime.h"
+
+/* test of Stats */
+#include "stat.c"
+
+int main ()
+{
+ int i;
+ struct stat_data *st;
+ Stat st1 = _stp_stat_init(HIST_NONE);
+ Stat st2 = _stp_stat_init(HIST_LOG, 7);
+ Stat st3 = _stp_stat_init(HIST_LINEAR, 0, 100, 5);
+
+ for (_processor_number = 0; _processor_number < NR_CPUS; _processor_number++) {
+ _stp_stat_add (st1, _processor_number + 1);
+ _stp_stat_add (st2, _processor_number + 10);
+ _stp_stat_add (st3, _processor_number + 100);
+ }
+ _processor_number = 0;
+
+ /* this is for internal testing only. Not recommended */
+ for (i = 0; i < NR_CPUS; i++) {
+ st = _stp_stat_get_cpu(st1, i);
+ printf ("st1[%d] = count: %lld sum:%lld\n", i, st->count, st->sum);
+ STAT_UNLOCK(st1);
+ st = _stp_stat_get_cpu(st2, i);
+ printf ("st2[%d] = count: %lld sum:%lld\n", i, st->count, st->sum);
+ STAT_UNLOCK(st2);
+ st = _stp_stat_get_cpu(st3, i);
+ printf ("st3[%d] = count: %lld sum:%lld\n", i, st->count, st->sum);
+ STAT_UNLOCK(st3);
+ }
+ _stp_printf ("--------------------\n");
+
+ /* normal way to print per-cpu stats */
+ _stp_stat_print_cpu (st1, "CPU: %c\tCount: %C\tSum: %S", 0);
+ _stp_stat_print_cpu (st2, "CPU: %c\tCount: %C\tSum: %S", 0);
+ _stp_stat_print_cpu (st3, "CPU: %c\tCount: %C\tSum: %S", 0);
+ printf ("--------------------\n");
+
+ /* basic aggregated stats */
+ _stp_stat_print (st1, "Count: %C\tSum: %S", 0);
+ _stp_stat_print (st2, "Count: %C\tSum: %S", 0);
+ _stp_stat_print (st3, "Count: %C\tSum: %S", 0);
+ printf ("--------------------\n");
+
+ /* now print full stats */
+ _stp_stat_print (st1, "count:%C sum:%S avg:%A min:%m max:%M\n%H", 1);
+ _stp_stat_print (st2, "count:%C sum:%S avg:%A min:%m max:%M\n%H", 1);
+ _stp_stat_print (st3, "count:%C sum:%S avg:%A min:%m max:%M\n%H", 1);
+
+ /* and print again, after they were cleared */
+ _stp_stat_print (st1, "count:%C sum:%S avg:%A min:%m max:%M\n%H", 1);
+ _stp_stat_print (st2, "count:%C sum:%S avg:%A min:%m max:%M\n%H", 1);
+ _stp_stat_print (st3, "count:%C sum:%S avg:%A min:%m max:%M\n%H", 1);
+
+ _stp_print_flush();
+ return 0;
+}
diff --git a/runtime/tests/maps/all.tcl b/runtime/tests/maps/all.tcl
index aa408eea..c0b38a0e 100644
--- a/runtime/tests/maps/all.tcl
+++ b/runtime/tests/maps/all.tcl
@@ -1,12 +1,5 @@
package require tcltest
namespace import -force tcltest::*
-
-puts "Running all SystemTap tests"
-
-#puts [tcltest::configure]
-#puts [tcltest::configure -file]
-
tcltest::testsDirectory [file dir [info script]]
tcltest::runAllTests
-puts "All tests completed"
diff --git a/runtime/tests/maps/ii.c b/runtime/tests/maps/ii.c
index afee14d4..e44530cf 100644
--- a/runtime/tests/maps/ii.c
+++ b/runtime/tests/maps/ii.c
@@ -1,13 +1,10 @@
#include "runtime.h"
/* test of maps with keys of int64 and value of int64 */
-
+#define NEED_INT64_VALS
#define KEY1_TYPE INT64
#include "map-keys.c"
-#define VALUE_TYPE INT64
-#include "map-values.c"
-
#include "map.c"
int main ()
diff --git a/runtime/tests/maps/iiss.c b/runtime/tests/maps/iiss.c
index dc034c94..3321a329 100644
--- a/runtime/tests/maps/iiss.c
+++ b/runtime/tests/maps/iiss.c
@@ -1,15 +1,12 @@
#include "runtime.h"
/* test of maps with keys of int64,int64,string and value of string */
-
+#define NEED_STRING_VALS
#define KEY1_TYPE INT64
#define KEY2_TYPE INT64
#define KEY3_TYPE STRING
#include "map-keys.c"
-#define VALUE_TYPE STRING
-#include "map-values.c"
-
#include "map.c"
int main ()
diff --git a/runtime/tests/maps/is.c b/runtime/tests/maps/is.c
index 6b2cbb0e..8bdc6591 100644
--- a/runtime/tests/maps/is.c
+++ b/runtime/tests/maps/is.c
@@ -1,13 +1,10 @@
#include "runtime.h"
/* test of maps with keys of int64 and value of string */
-
+#define NEED_STRING_VALS
#define KEY1_TYPE INT64
#include "map-keys.c"
-#define VALUE_TYPE STRING
-#include "map-values.c"
-
#include "map.c"
int main ()
diff --git a/runtime/tests/maps/ist.c b/runtime/tests/maps/ist.c
index be3ca87d..2418a20c 100644
--- a/runtime/tests/maps/ist.c
+++ b/runtime/tests/maps/ist.c
@@ -1,13 +1,9 @@
#include "runtime.h"
/* test of maps with keys of int64 and value of stat */
-
+#define NEED_STAT_VALS
#define KEY1_TYPE INT64
#include "map-keys.c"
-
-#define VALUE_TYPE STAT
-#include "map-values.c"
-
#include "map.c"
int main ()
@@ -19,27 +15,27 @@ int main ()
_stp_map_key_int64 (map, 3);
for (i = 0; i < 100; i++)
for (j = 0; j <= i*10 ; j++ )
- _stp_map_add_int64_stat (map, i);
+ _stp_map_add_int64 (map, i);
_stp_map_key_int64 (map, 2);
for (i = 0; i < 10; i++)
for (j = 0; j < 10 ; j++ )
- _stp_map_add_int64_stat (map, j * i );
+ _stp_map_add_int64 (map, j * i );
_stp_map_key_int64 (map, 1);
for (i = 0; i < 100; i += 10)
for (j = 0; j < i/10 ; j++ )
- _stp_map_add_int64_stat (map, i);
+ _stp_map_add_int64 (map, i);
_stp_map_key_int64 (map2, 1);
for (i = 0; i < 128; i++)
for (j = 0; j < 128 ; j++ )
- _stp_map_add_int64_stat (map2, i);
+ _stp_map_add_int64 (map2, i);
_stp_map_key_int64 (map2, 2);
for (i = 0; i < 1024; i++)
for (j = 0; j < 1024 ; j++ )
- _stp_map_add_int64_stat (map2, i);
+ _stp_map_add_int64 (map2, i);
_stp_map_print (map, "map[%1d] = count:%C sum:%S avg:%A min:%m max:%M\n%H");
_stp_map_print (map2, "map2[%1d] = count:%C sum:%S avg:%A min:%m max:%M\n%H");
diff --git a/runtime/tests/maps/map_format.c b/runtime/tests/maps/map_format.c
index d6a848ab..338fd7dc 100644
--- a/runtime/tests/maps/map_format.c
+++ b/runtime/tests/maps/map_format.c
@@ -1,6 +1,9 @@
#include "runtime.h"
/* torture test of map formatting */
+#define NEED_INT64_VALS
+#define NEED_STRING_VALS
+#define NEED_STAT_VALS
#define KEY1_TYPE INT64
#define KEY2_TYPE INT64
@@ -11,15 +14,6 @@
#define KEY2_TYPE STRING
#include "map-keys.c"
-#define VALUE_TYPE STRING
-#include "map-values.c"
-
-#define VALUE_TYPE INT64
-#include "map-values.c"
-
-#define VALUE_TYPE STAT
-#include "map-values.c"
-
#include "map.c"
int main ()
@@ -61,17 +55,17 @@ int main ()
_stp_map_key_str_str (mapsst, "Riga", "Latvia");
for (i = 0; i < 100; i++)
for (j = 0; j <= i*10 ; j++ )
- _stp_map_add_int64_stat (mapsst, i);
+ _stp_map_add_int64 (mapsst, i);
_stp_map_key_str_str (mapsst, "Sofia", "Bulgaria");
for (i = 0; i < 10; i++)
for (j = 0; j < 10 ; j++ )
- _stp_map_add_int64_stat (mapsst, j * i );
+ _stp_map_add_int64 (mapsst, j * i );
_stp_map_key_str_str (mapsst, "Valletta", "Malta");
for (i = 0; i < 100; i += 10)
for (j = 0; j < i/10 ; j++ )
- _stp_map_add_int64_stat (mapsst, i);
+ _stp_map_add_int64 (mapsst, i);
_stp_map_print (mapsst, "Bogons per packet for %1s\ncount:%C sum:%S avg:%A min:%m max:%M\n%H");
diff --git a/runtime/tests/maps/si.c b/runtime/tests/maps/si.c
index 90544ed2..5f95e0dd 100644
--- a/runtime/tests/maps/si.c
+++ b/runtime/tests/maps/si.c
@@ -1,13 +1,9 @@
#include "runtime.h"
/* test of maps with keys of string and value of int64 */
-
+#define NEED_INT64_VALS
#define KEY1_TYPE STRING
#include "map-keys.c"
-
-#define VALUE_TYPE INT64
-#include "map-values.c"
-
#include "map.c"
int main ()
diff --git a/runtime/tests/maps/test_list_int64.c b/runtime/tests/maps/test_list_int64.c
index 810a18b6..6a0ce9a9 100644
--- a/runtime/tests/maps/test_list_int64.c
+++ b/runtime/tests/maps/test_list_int64.c
@@ -1,13 +1,10 @@
#include "runtime.h"
/* test of list with value of STRING */
-
+#define NEED_INT64_VALS
#define KEY1_TYPE INT64
#include "map-keys.c"
-#define VALUE_TYPE INT64
-#include "map-values.c"
-
#include "list.c"
int main ()
diff --git a/runtime/tests/maps/test_list_string.c b/runtime/tests/maps/test_list_string.c
index 455e8537..fa50a2f6 100644
--- a/runtime/tests/maps/test_list_string.c
+++ b/runtime/tests/maps/test_list_string.c
@@ -1,14 +1,10 @@
#include "runtime.h"
/* test of list with value of STRING */
-
+#define NEED_STRING_VALS
#define KEY1_TYPE INT64
#include "map-keys.c"
-#define VALUE_TYPE STRING
-#include "map-values.c"
-
-#include "map.c"
#include "list.c"
int main ()
diff --git a/runtime/tests/string/all.tcl b/runtime/tests/string/all.tcl
index aa408eea..23757202 100644
--- a/runtime/tests/string/all.tcl
+++ b/runtime/tests/string/all.tcl
@@ -1,12 +1,4 @@
package require tcltest
namespace import -force tcltest::*
-
-puts "Running all SystemTap tests"
-
-#puts [tcltest::configure]
-#puts [tcltest::configure -file]
-
tcltest::testsDirectory [file dir [info script]]
tcltest::runAllTests
-
-puts "All tests completed"