diff options
author | hunt <hunt> | 2005-06-18 07:12:41 +0000 |
---|---|---|
committer | hunt <hunt> | 2005-06-18 07:12:41 +0000 |
commit | ef0e92b0335077884edd5ac9997a203bec1839b0 (patch) | |
tree | 8247b545c18d83a3b580744b8689a3227a1a364d /runtime/tests/agg | |
parent | 96124157d812d71cbdfd018e984dc42bed17d072 (diff) | |
download | systemtap-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/tests/agg')
-rw-r--r-- | runtime/tests/agg/Makefile | 5 | ||||
-rw-r--r-- | runtime/tests/agg/agg.test | 209 | ||||
-rw-r--r-- | runtime/tests/agg/all.tcl | 4 | ||||
-rw-r--r-- | runtime/tests/agg/count.c | 72 | ||||
-rw-r--r-- | runtime/tests/agg/stats.c | 59 |
5 files changed, 349 insertions, 0 deletions
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; +} |