summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhunt <hunt>2005-11-11 06:13:24 +0000
committerhunt <hunt>2005-11-11 06:13:24 +0000
commit15997cc74dd4e2a17b62d49d45eee410cd0db49c (patch)
tree1b241f8f0137842d1242207efbf0b80e7368f0d2
parent6ed93e502ec2845f4e1f76cd33e917d613c66863 (diff)
downloadsystemtap-steved-15997cc74dd4e2a17b62d49d45eee410cd0db49c.tar.gz
systemtap-steved-15997cc74dd4e2a17b62d49d45eee410cd0db49c.tar.xz
systemtap-steved-15997cc74dd4e2a17b62d49d45eee410cd0db49c.zip
2005-11-10 Martin Hunt <hunt@redhat.com>
* pmaps/ix2.c: New test. Test _stp_pmap_get_*(). * pmaps/iii3.c: New test. Test _stp_pmap_get_*(). * pmaps/pmap.test: Update.
-rw-r--r--runtime/tests/ChangeLog4
-rw-r--r--runtime/tests/pmaps/ii3.c59
-rw-r--r--runtime/tests/pmaps/ix2.c64
-rw-r--r--runtime/tests/pmaps/pmap.test187
4 files changed, 313 insertions, 1 deletions
diff --git a/runtime/tests/ChangeLog b/runtime/tests/ChangeLog
index 915a55c7..d373c24f 100644
--- a/runtime/tests/ChangeLog
+++ b/runtime/tests/ChangeLog
@@ -1,5 +1,9 @@
2005-11-10 Martin Hunt <hunt@redhat.com>
+ * pmaps/ix2.c: New test. Test _stp_pmap_get_*().
+ * pmaps/iii3.c: New test. Test _stp_pmap_get_*().
+ * pmaps/pmap.test: Update.
+2005-11-10 Martin Hunt <hunt@redhat.com>
* pmaps/ii2.c: New test of maps and pmaps with the same keysym.
* pmaps/pmap.test: Update.
diff --git a/runtime/tests/pmaps/ii3.c b/runtime/tests/pmaps/ii3.c
new file mode 100644
index 00000000..560de4cd
--- /dev/null
+++ b/runtime/tests/pmaps/ii3.c
@@ -0,0 +1,59 @@
+#include "runtime.h"
+
+/* test of pmaps with keys of int64 and value of int64 */
+
+/* It's not clear this would ever be used in the systemtap language.
+ It would be useful as an array of counters. */
+
+#define VALUE_TYPE INT64
+#define KEY1_TYPE INT64
+#include "pmap-gen.c"
+
+#include "map.c"
+
+int main ()
+{
+ MAP map = _stp_pmap_new_ii(4);
+ int i;
+
+ /* put some data in. _processor_number is a global hack that allows */
+ /* us to set the current emulated cpu number for our userspace tests. */
+ /* Note that we set values based on the cpu number just to show that */
+ /* different values are stored in each cpu */
+ for (_processor_number = 0; _processor_number < NR_CPUS; _processor_number++) {
+ _stp_pmap_add_ii(map, 1, _processor_number);
+ _stp_pmap_add_ii(map, 2, 10 *_processor_number + 1);
+ _stp_pmap_add_ii(map, 3, _processor_number * _processor_number);
+ _stp_pmap_add_ii(map, 4, 1);
+ }
+
+ _processor_number = 0;
+
+ /* get the data with get calls. this is not very efficient */
+ for (i = 1; i < 5; i++)
+ printf("map[%d] = %lld\n", i, _stp_pmap_get_ii(map, i));
+ printf("\n");
+
+ /* do it again. test that the aggregation map got cleared */
+ for (i = 1; i < 5; i++)
+ printf("map[%d] = %lld\n", i, _stp_pmap_get_ii(map, i));
+ printf("\n");
+
+ /* print the aggregated data */
+ _stp_pmap_print(map,"map[%1d] = %d");
+
+ /* delete an entry and repeat */
+ for (_processor_number = 0; _processor_number < NR_CPUS; _processor_number++)
+ _stp_pmap_set_ii(map, 2, 0);
+ _processor_number = 0;
+
+ for (i = 1; i < 5; i++)
+ printf("map[%d] = %lld\n", i, _stp_pmap_get_ii(map, i));
+ printf("\n");
+
+ _stp_pmap_print(map,"map[%1d] = %d");
+
+ _stp_pmap_del (map);
+ return 0;
+}
+
diff --git a/runtime/tests/pmaps/ix2.c b/runtime/tests/pmaps/ix2.c
new file mode 100644
index 00000000..6016bf53
--- /dev/null
+++ b/runtime/tests/pmaps/ix2.c
@@ -0,0 +1,64 @@
+#include "runtime.h"
+
+/* test of pmaps with keys of int64 and value of stat */
+
+#define VALUE_TYPE STAT
+#define KEY1_TYPE INT64
+#include "pmap-gen.c"
+
+#include "map.c"
+
+int main ()
+{
+ MAP map = _stp_pmap_new_ix(4, HIST_LINEAR, 0, 100, 10);
+ int i;
+
+ /* put some data in. _processor_number is a global hack that allows */
+ /* us to set the current emulated cpu number for our userspace tests. */
+ /* Note that we set values based on the cpu number just to show that */
+ /* different values are stored in each cpu */
+ for (_processor_number = 0; _processor_number < NR_CPUS; _processor_number++) {
+ _stp_pmap_add_ix(map, 1, _processor_number);
+ _stp_pmap_add_ix(map, 2, 10 *_processor_number + 1);
+ _stp_pmap_add_ix(map, 3, _processor_number * _processor_number);
+ _stp_pmap_add_ix(map, 4, 1);
+ }
+
+ /* now print the per-cpu data */
+ for (_processor_number = 0; _processor_number < NR_CPUS; _processor_number++) {
+ printf("CPU #%d\n", _processor_number);
+ _stp_pmap_printn_cpu (map,
+ 0,
+ "map[%1d] = count:%C sum:%S avg:%A min:%m max:%M",
+ _processor_number);
+ }
+ _processor_number = 0;
+
+ /* print the aggregated data */
+ _stp_pmap_print(map,"map[%1d] = count:%C sum:%S avg:%A min:%m max:%M\n%H");
+
+ /* now use GET */
+ for (i = 1; i < 5; i++)
+ printf("map[%d] Sum = %lld\n", i, _stp_pmap_get_ix(map, i)->sum);
+ printf("\n");
+
+ /* delete an entry and repeat */
+ for (_processor_number = 0; _processor_number < NR_CPUS; _processor_number++)
+ _stp_pmap_set_ix(map, 2, 0);
+ _processor_number = 0;
+
+ /* print the aggregated data */
+ _stp_pmap_print(map,"map[%1d] = count:%C sum:%S avg:%A min:%m max:%M\n%H");
+
+ /* now use GET */
+ for (i = 1; i < 5; i++) {
+ stat *sd = _stp_pmap_get_ix(map, i);
+ if (sd)
+ printf("map[%d] Sum = %lld\n", i, sd->sum);
+ }
+ printf("\n");
+
+ _stp_pmap_del (map);
+ return 0;
+}
+
diff --git a/runtime/tests/pmaps/pmap.test b/runtime/tests/pmaps/pmap.test
index 4e6a6ce4..cbda7baf 100644
--- a/runtime/tests/pmaps/pmap.test
+++ b/runtime/tests/pmaps/pmap.test
@@ -179,7 +179,7 @@ map[THREE] = 140
map[ONE] = 28
}
-test ix {Test of int64 keys and string values} -setup {
+test ix {Test of int64 keys and stat values} -setup {
exec gcc $CFLAGS -I $KPATH -I $PATH -I $MPATH -o test ix.c
} -body {
exec ./test
@@ -386,6 +386,191 @@ pmap[1] = 28
pmap[3] = 140
}
+test ii3 {Test of int64 keys and int64 values with GET} -setup {
+ exec gcc $CFLAGS -I $KPATH -I $PATH -I $MPATH -o test ii3.c
+} -body {
+ exec ./test
+} -result {map[1] = 28
+map[2] = 288
+map[3] = 140
+map[4] = 8
+
+map[1] = 28
+map[2] = 288
+map[3] = 140
+map[4] = 8
+
+map[2] = 288
+map[4] = 8
+map[1] = 28
+map[3] = 140
+
+map[1] = 28
+map[2] = 0
+map[3] = 140
+map[4] = 8
+
+map[4] = 8
+map[1] = 28
+map[3] = 140
+}
+
+test ix2 {Test of int64 keys and sttat values with GET} -setup {
+ exec gcc $CFLAGS -I $KPATH -I $PATH -I $MPATH -o test ix2.c
+} -body {
+ exec ./test
+} -result {CPU #0
+map[1] = count:1 sum:0 avg:0 min:0 max:0
+map[2] = count:1 sum:1 avg:1 min:1 max:1
+map[3] = count:1 sum:0 avg:0 min:0 max:0
+map[4] = count:1 sum:1 avg:1 min:1 max:1
+
+CPU #1
+map[1] = count:1 sum:1 avg:1 min:1 max:1
+map[2] = count:1 sum:11 avg:11 min:11 max:11
+map[3] = count:1 sum:1 avg:1 min:1 max:1
+map[4] = count:1 sum:1 avg:1 min:1 max:1
+
+CPU #2
+map[1] = count:1 sum:2 avg:2 min:2 max:2
+map[2] = count:1 sum:21 avg:21 min:21 max:21
+map[3] = count:1 sum:4 avg:4 min:4 max:4
+map[4] = count:1 sum:1 avg:1 min:1 max:1
+
+CPU #3
+map[1] = count:1 sum:3 avg:3 min:3 max:3
+map[2] = count:1 sum:31 avg:31 min:31 max:31
+map[3] = count:1 sum:9 avg:9 min:9 max:9
+map[4] = count:1 sum:1 avg:1 min:1 max:1
+
+CPU #4
+map[1] = count:1 sum:4 avg:4 min:4 max:4
+map[2] = count:1 sum:41 avg:41 min:41 max:41
+map[3] = count:1 sum:16 avg:16 min:16 max:16
+map[4] = count:1 sum:1 avg:1 min:1 max:1
+
+CPU #5
+map[1] = count:1 sum:5 avg:5 min:5 max:5
+map[2] = count:1 sum:51 avg:51 min:51 max:51
+map[3] = count:1 sum:25 avg:25 min:25 max:25
+map[4] = count:1 sum:1 avg:1 min:1 max:1
+
+CPU #6
+map[1] = count:1 sum:6 avg:6 min:6 max:6
+map[2] = count:1 sum:61 avg:61 min:61 max:61
+map[3] = count:1 sum:36 avg:36 min:36 max:36
+map[4] = count:1 sum:1 avg:1 min:1 max:1
+
+CPU #7
+map[1] = count:1 sum:7 avg:7 min:7 max:7
+map[2] = count:1 sum:71 avg:71 min:71 max:71
+map[3] = count:1 sum:49 avg:49 min:49 max:49
+map[4] = count:1 sum:1 avg:1 min:1 max:1
+
+map[2] = count:8 sum:288 avg:36 min:1 max:71
+value |-------------------------------------------------- count
+ 0 |@ 1
+ 10 |@ 1
+ 20 |@ 1
+ 30 |@ 1
+ 40 |@ 1
+ 50 |@ 1
+ 60 |@ 1
+ 70 |@ 1
+ 80 | 0
+ 90 | 0
+
+map[4] = count:8 sum:8 avg:1 min:1 max:1
+value |-------------------------------------------------- count
+ 0 |@@@@@@@@ 8
+ 10 | 0
+ 20 | 0
+ 30 | 0
+ 40 | 0
+ 50 | 0
+ 60 | 0
+ 70 | 0
+ 80 | 0
+ 90 | 0
+
+map[1] = count:8 sum:28 avg:3 min:0 max:7
+value |-------------------------------------------------- count
+ 0 |@@@@@@@@ 8
+ 10 | 0
+ 20 | 0
+ 30 | 0
+ 40 | 0
+ 50 | 0
+ 60 | 0
+ 70 | 0
+ 80 | 0
+ 90 | 0
+
+map[3] = count:8 sum:140 avg:17 min:0 max:49
+value |-------------------------------------------------- count
+ 0 |@@@@ 4
+ 10 |@ 1
+ 20 |@ 1
+ 30 |@ 1
+ 40 |@ 1
+ 50 | 0
+ 60 | 0
+ 70 | 0
+ 80 | 0
+ 90 | 0
+
+
+map[1] Sum = 28
+map[2] Sum = 288
+map[3] Sum = 140
+map[4] Sum = 8
+
+map[4] = count:8 sum:8 avg:1 min:1 max:1
+value |-------------------------------------------------- count
+ 0 |@@@@@@@@ 8
+ 10 | 0
+ 20 | 0
+ 30 | 0
+ 40 | 0
+ 50 | 0
+ 60 | 0
+ 70 | 0
+ 80 | 0
+ 90 | 0
+
+map[1] = count:8 sum:28 avg:3 min:0 max:7
+value |-------------------------------------------------- count
+ 0 |@@@@@@@@ 8
+ 10 | 0
+ 20 | 0
+ 30 | 0
+ 40 | 0
+ 50 | 0
+ 60 | 0
+ 70 | 0
+ 80 | 0
+ 90 | 0
+
+map[3] = count:8 sum:140 avg:17 min:0 max:49
+value |-------------------------------------------------- count
+ 0 |@@@@ 4
+ 10 |@ 1
+ 20 |@ 1
+ 30 |@ 1
+ 40 |@ 1
+ 50 | 0
+ 60 | 0
+ 70 | 0
+ 80 | 0
+ 90 | 0
+
+
+map[1] Sum = 28
+map[3] Sum = 140
+map[4] Sum = 8
+}
+
+
catch {exec rm test}