diff options
Diffstat (limited to 'runtime/tests/pmaps')
-rw-r--r-- | runtime/tests/pmaps/Makefile | 5 | ||||
-rw-r--r-- | runtime/tests/pmaps/all.tcl | 5 | ||||
-rw-r--r-- | runtime/tests/pmaps/ii.c | 59 | ||||
-rw-r--r-- | runtime/tests/pmaps/ii2.c | 48 | ||||
-rw-r--r-- | runtime/tests/pmaps/ii3.c | 59 | ||||
-rw-r--r-- | runtime/tests/pmaps/is.c | 67 | ||||
-rw-r--r-- | runtime/tests/pmaps/ix.c | 61 | ||||
-rw-r--r-- | runtime/tests/pmaps/ix2.c | 64 | ||||
-rw-r--r-- | runtime/tests/pmaps/ix_log.c | 62 | ||||
-rw-r--r-- | runtime/tests/pmaps/ix_none.c | 62 | ||||
-rw-r--r-- | runtime/tests/pmaps/map_format.c | 92 | ||||
-rw-r--r-- | runtime/tests/pmaps/pmap.test | 678 | ||||
-rw-r--r-- | runtime/tests/pmaps/si.c | 62 | ||||
-rw-r--r-- | runtime/tests/pmaps/size.c | 72 |
14 files changed, 0 insertions, 1396 deletions
diff --git a/runtime/tests/pmaps/Makefile b/runtime/tests/pmaps/Makefile deleted file mode 100644 index c396c132..00000000 --- a/runtime/tests/pmaps/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -default: tests - -tests: - tclsh all.tcl - diff --git a/runtime/tests/pmaps/all.tcl b/runtime/tests/pmaps/all.tcl deleted file mode 100644 index c0b38a0e..00000000 --- a/runtime/tests/pmaps/all.tcl +++ /dev/null @@ -1,5 +0,0 @@ -package require tcltest -namespace import -force tcltest::* -tcltest::testsDirectory [file dir [info script]] -tcltest::runAllTests - diff --git a/runtime/tests/pmaps/ii.c b/runtime/tests/pmaps/ii.c deleted file mode 100644 index dfce0a07..00000000 --- a/runtime/tests/pmaps/ii.c +++ /dev/null @@ -1,59 +0,0 @@ -#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 () -{ - PMAP map = _stp_pmap_new_ii(4); - int64_t x; - - /* 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); - } - - /* read it back out and verify. Use the special get_cpu call to get non-aggregated data */ - for (_processor_number = 0; _processor_number < NR_CPUS; _processor_number++) { - x = _stp_pmap_get_cpu_ii (map, 3); - if (x != _processor_number * _processor_number) - printf("ERROR: Got %lld when expected %lld\n", x, (long long)(_processor_number * _processor_number)); - x = _stp_pmap_get_cpu_ii (map, 1); - if (x != _processor_number) - printf("ERROR: Got %lld when expected %lld\n", x, (long long)_processor_number); - x = _stp_pmap_get_cpu_ii (map, 2); - if (x != 10 * _processor_number + 1) - printf("ERROR: Got %lld when expected %lld\n", x, (long long)(10 * _processor_number + 1)); - x = _stp_pmap_get_cpu_ii (map, 4); - if (x != 1LL) - printf("ERROR: Got %lld when expected %lld\n", x, 1LL); - } - - /* 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] = %d", _processor_number); - } - _processor_number = 0; - - /* print the aggregated data */ - _stp_pmap_print(map,"map[%1d] = %d"); - - _stp_pmap_del (map); - return 0; -} - diff --git a/runtime/tests/pmaps/ii2.c b/runtime/tests/pmaps/ii2.c deleted file mode 100644 index 0a28ad87..00000000 --- a/runtime/tests/pmaps/ii2.c +++ /dev/null @@ -1,48 +0,0 @@ -#include "runtime.h" - -/* test of maps and pmaps with keys of int64 and value of int64 */ - -/* Make sure we can cleanly generate both */ - -#define VALUE_TYPE INT64 -#define KEY1_TYPE INT64 -#include "pmap-gen.c" - -#define VALUE_TYPE INT64 -#define KEY1_TYPE INT64 -#include "map-gen.c" - -#include "map.c" - -int main () -{ - MAP map = _stp_map_new_ii(4); - PMAP pmap = _stp_pmap_new_ii(4); - int64_t x; - - /* 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(pmap, 1, _processor_number); - _stp_pmap_add_ii(pmap, 2, 10 *_processor_number + 1); - _stp_pmap_add_ii(pmap, 3, _processor_number * _processor_number); - _stp_pmap_add_ii(pmap, 4, 1); - _stp_map_add_ii(map, 1, _processor_number); - _stp_map_add_ii(map, 2, 10 *_processor_number + 1); - _stp_map_add_ii(map, 3, _processor_number * _processor_number); - _stp_map_add_ii(map, 4, 1); - } - - _processor_number = 0; - - /* print the aggregated data */ - _stp_map_print(map,"map[%1d] = %d"); - _stp_pmap_print(pmap,"pmap[%1d] = %d"); - - _stp_map_del (map); - _stp_pmap_del (pmap); - return 0; -} - diff --git a/runtime/tests/pmaps/ii3.c b/runtime/tests/pmaps/ii3.c deleted file mode 100644 index e2dee7a6..00000000 --- a/runtime/tests/pmaps/ii3.c +++ /dev/null @@ -1,59 +0,0 @@ -#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 () -{ - PMAP 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/is.c b/runtime/tests/pmaps/is.c deleted file mode 100644 index a97d8b0b..00000000 --- a/runtime/tests/pmaps/is.c +++ /dev/null @@ -1,67 +0,0 @@ -#include "runtime.h" - -/* test of pmaps with keys of int64 and value of string */ - -/* It's not clear this would ever be used in the systemtap language. - It is not clear this would be useful. */ - -#define VALUE_TYPE STRING -#define KEY1_TYPE INT64 -#include "pmap-gen.c" - -#include "map.c" - -int main () -{ - PMAP map = _stp_pmap_new_is(4); - char *x; - char buf[32]; - - /* 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++) { - sprintf(buf, "%d,", _processor_number); - _stp_pmap_add_is(map, 1, buf); - sprintf(buf, "%d,", 10 *_processor_number + 1); - _stp_pmap_add_is(map, 2, buf); - sprintf(buf, "%d,", _processor_number * _processor_number); - _stp_pmap_add_is(map, 3, buf); - _stp_pmap_add_is(map, 4, "1,"); - } - - /* read it back out and verify. Use the special get_cpu call to get non-aggregated data */ - for (_processor_number = 0; _processor_number < NR_CPUS; _processor_number++) { - x = _stp_pmap_get_cpu_is (map, 3); - sprintf(buf, "%d,", _processor_number * _processor_number); - if (strcmp(x, buf)) - printf("ERROR: Got %s when expected %s\n", x, buf); - x = _stp_pmap_get_cpu_is (map, 1); - sprintf(buf, "%d,", _processor_number); - if (strcmp(x, buf)) - printf("ERROR: Got %s when expected %s\n", x, buf); - x = _stp_pmap_get_cpu_is (map, 4); - sprintf(buf, "%d,", 1); - if (strcmp(x, buf)) - printf("ERROR: Got %s when expected %s\n", x, buf); - x = _stp_pmap_get_cpu_is (map, 2); - sprintf(buf, "%d,", 10 * _processor_number +1); - if (strcmp(x, buf)) - printf("ERROR: Got %s when expected %s\n", x, buf); - } - - /* 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] = %s", _processor_number); - } - _processor_number = 0; - - /* print the aggregated data */ - _stp_pmap_print(map,"map[%1d] = %s"); - - _stp_pmap_del (map); - return 0; -} - diff --git a/runtime/tests/pmaps/ix.c b/runtime/tests/pmaps/ix.c deleted file mode 100644 index 0eba2d54..00000000 --- a/runtime/tests/pmaps/ix.c +++ /dev/null @@ -1,61 +0,0 @@ -#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 () -{ - PMAP map = _stp_pmap_new_ix(4, HIST_LINEAR, 0, 100, 10); - int64_t x; - - /* 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); - } - -#if 0 - /* read it back out and verify. Use the special get_cpu call to get non-aggregated data */ - for (_processor_number = 0; _processor_number < NR_CPUS; _processor_number++) { - x = _stp_pmap_get_cpu_ix (map, 3); - if (x != _processor_number * _processor_number) - printf("ERROR: Got %lld when expected %lld\n", x, (long long)(_processor_number * _processor_number)); - x = _stp_pmap_get_cpu_ix (map, 1); - if (x != _processor_number) - printf("ERROR: Got %lld when expected %lld\n", x, (long long)_processor_number); - x = _stp_pmap_get_cpu_ix (map, 2); - if (x != 10 * _processor_number + 1) - printf("ERROR: Got %lld when expected %lld\n", x, (long long)(10 * _processor_number + 1)); - x = _stp_pmap_get_cpu_ix (map, 4); - if (x != 1LL) - printf("ERROR: Got %lld when expected %lld\n", x, 1LL); - } -#endif - - /* 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"); - - _stp_pmap_del (map); - return 0; -} - diff --git a/runtime/tests/pmaps/ix2.c b/runtime/tests/pmaps/ix2.c deleted file mode 100644 index 638e5226..00000000 --- a/runtime/tests/pmaps/ix2.c +++ /dev/null @@ -1,64 +0,0 @@ -#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 () -{ - PMAP 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/ix_log.c b/runtime/tests/pmaps/ix_log.c deleted file mode 100644 index 4f3c5503..00000000 --- a/runtime/tests/pmaps/ix_log.c +++ /dev/null @@ -1,62 +0,0 @@ -#include "runtime.h" - -/* like ix.c, except use HIST_LOG */ -/* 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 () -{ - PMAP map = _stp_pmap_new_ix(4, HIST_LOG, 5); - int64_t x; - - /* 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); - } - -#if 0 - /* read it back out and verify. Use the special get_cpu call to get non-aggregated data */ - for (_processor_number = 0; _processor_number < NR_CPUS; _processor_number++) { - x = _stp_pmap_get_cpu_ix (map, 3); - if (x != _processor_number * _processor_number) - printf("ERROR: Got %lld when expected %lld\n", x, (long long)(_processor_number * _processor_number)); - x = _stp_pmap_get_cpu_ix (map, 1); - if (x != _processor_number) - printf("ERROR: Got %lld when expected %lld\n", x, (long long)_processor_number); - x = _stp_pmap_get_cpu_ix (map, 2); - if (x != 10 * _processor_number + 1) - printf("ERROR: Got %lld when expected %lld\n", x, (long long)(10 * _processor_number + 1)); - x = _stp_pmap_get_cpu_ix (map, 4); - if (x != 1LL) - printf("ERROR: Got %lld when expected %lld\n", x, 1LL); - } -#endif - - /* 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"); - - _stp_pmap_del (map); - return 0; -} - diff --git a/runtime/tests/pmaps/ix_none.c b/runtime/tests/pmaps/ix_none.c deleted file mode 100644 index 440b0069..00000000 --- a/runtime/tests/pmaps/ix_none.c +++ /dev/null @@ -1,62 +0,0 @@ -#include "runtime.h" - -/* like ix.c, except with no histogram */ -/* 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 () -{ - PMAP map = _stp_pmap_new_ix(4, HIST_NONE); - int64_t x; - - /* 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); - } - -#if 0 - /* read it back out and verify. Use the special get_cpu call to get non-aggregated data */ - for (_processor_number = 0; _processor_number < NR_CPUS; _processor_number++) { - x = _stp_pmap_get_cpu_ix (map, 3); - if (x != _processor_number * _processor_number) - printf("ERROR: Got %lld when expected %lld\n", x, (long long)(_processor_number * _processor_number)); - x = _stp_pmap_get_cpu_ix (map, 1); - if (x != _processor_number) - printf("ERROR: Got %lld when expected %lld\n", x, (long long)_processor_number); - x = _stp_pmap_get_cpu_ix (map, 2); - if (x != 10 * _processor_number + 1) - printf("ERROR: Got %lld when expected %lld\n", x, (long long)(10 * _processor_number + 1)); - x = _stp_pmap_get_cpu_ix (map, 4); - if (x != 1LL) - printf("ERROR: Got %lld when expected %lld\n", x, 1LL); - } -#endif - - /* 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"); - - _stp_pmap_del (map); - return 0; -} - diff --git a/runtime/tests/pmaps/map_format.c b/runtime/tests/pmaps/map_format.c deleted file mode 100644 index b27506e0..00000000 --- a/runtime/tests/pmaps/map_format.c +++ /dev/null @@ -1,92 +0,0 @@ -#include "runtime.h" - -/* map formatting test. Same as the non-pmap version. Output should be identical */ - -/* torture test of map formatting */ -#define VALUE_TYPE STRING -#define KEY1_TYPE INT64 -#define KEY2_TYPE INT64 -#define KEY3_TYPE STRING -#include "pmap-gen.c" - -#define VALUE_TYPE INT64 -#define KEY1_TYPE STRING -#define KEY2_TYPE STRING -#include "pmap-gen.c" - -#define VALUE_TYPE STAT -#define KEY1_TYPE STRING -#define KEY2_TYPE STRING -#include "pmap-gen.c" - -#include "map.c" - -void inc_cpu(void) -{ - _processor_number++; - if (_processor_number == NR_CPUS) - _processor_number = 0; -} - -int main () -{ - PMAP mapiis = _stp_pmap_new_iiss(4); - _processor_number = 0; - _stp_pmap_set_iiss (mapiis, 1,2,"Ohio", "Columbus" ); - _stp_pmap_set_iiss (mapiis, 3,4,"California", "Sacramento" ); - _stp_pmap_set_iiss (mapiis, 5,6,"Washington", "Olympia" ); - _stp_pmap_set_iiss (mapiis, 7,8,"Oregon", "Salem" ); - _stp_pmap_print (mapiis, "%s -> mapiis %1d %2d %3s"); - - /* test printing of '%' */ - _stp_pmap_print (mapiis, "%s %% %3s"); - - /* very bad string. don't crash */ - _stp_pmap_print (mapiis, "%s -> mapiis %1s %2s %3d %4d"); - - PMAP mapss = _stp_pmap_new_ssi(4); - _stp_pmap_set_ssi (mapss, "Riga", "Latvia", 0x0000c0dedbad0000LL); - _stp_pmap_set_ssi (mapss, "Sofia", "Bulgaria", 0xdeadf00d12345678LL); - _stp_pmap_set_ssi (mapss, "Valletta", "Malta", 1); - _stp_pmap_set_ssi (mapss, "Nicosia", "Cyprus", -1); - _stp_pmap_print (mapss, "The capitol of %1s is %2s and the nerd population is %d"); - _stp_pmap_print (mapss, "The capitol of %1s is %2s and the nerd population is %x"); - _stp_pmap_print (mapss, "The capitol of %1s is %2s and the nerd population is %X"); - - PMAP mapssx = _stp_pmap_new_ssx (4, HIST_LINEAR, 0, 100, 10 ); - int i,j; - - for (i = 0; i < 100; i++) - for (j = 0; j <= i*10 ; j++ ) { - inc_cpu(); - _stp_pmap_add_ssx (mapssx, "Riga", "Latvia", i); - } - - for (i = 0; i < 10; i++) - for (j = 0; j < 10 ; j++ ) { - inc_cpu(); - _stp_pmap_add_ssx (mapssx, "Sofia", "Bulgaria", j * i ); - } - - for (i = 0; i < 100; i += 10) - for (j = 0; j < i/10 ; j++ ) { - inc_cpu(); - _stp_pmap_add_ssx (mapssx, "Valletta", "Malta", i); - } - - _stp_pmap_print (mapssx, "Bogons per packet for %1s\ncount:%C sum:%S avg:%A min:%m max:%M\n%H"); - - _stp_pmap_print (mapssx, "%C was the count for %1s, %2s"); - - /* here's how to print a map without using _stp_pmap_print(). */ - _stp_pmap_agg (mapssx); - struct map_node *ptr; - foreach (_stp_pmap_get_agg(mapssx), ptr) - _stp_printf ("mapssx[%09s,%09s] = %llX\n", key1str(ptr), key2str(ptr), _stp_get_stat(ptr)->sum); - _stp_print_flush(); - - _stp_pmap_del (mapssx); - _stp_pmap_del (mapiis); - _stp_pmap_del (mapss); - return 0; -} diff --git a/runtime/tests/pmaps/pmap.test b/runtime/tests/pmaps/pmap.test deleted file mode 100644 index fb5c3d0d..00000000 --- a/runtime/tests/pmaps/pmap.test +++ /dev/null @@ -1,678 +0,0 @@ -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 ii {Test of int64 keys and int64 values} -setup { - puts "gcc $CFLAGS -I $KPATH -I $PATH -I $MPATH -o test ii.c" - exec gcc $CFLAGS -I $KPATH -I $PATH -I $MPATH -o test ii.c -} -body { - exec ./test -} -result {CPU #0 -map[2] = 1 -map[4] = 1 - -CPU #1 -map[1] = 1 -map[2] = 11 -map[3] = 1 -map[4] = 1 - -CPU #2 -map[1] = 2 -map[2] = 21 -map[3] = 4 -map[4] = 1 - -CPU #3 -map[1] = 3 -map[2] = 31 -map[3] = 9 -map[4] = 1 - -CPU #4 -map[1] = 4 -map[2] = 41 -map[3] = 16 -map[4] = 1 - -CPU #5 -map[1] = 5 -map[2] = 51 -map[3] = 25 -map[4] = 1 - -CPU #6 -map[1] = 6 -map[2] = 61 -map[3] = 36 -map[4] = 1 - -CPU #7 -map[1] = 7 -map[2] = 71 -map[3] = 49 -map[4] = 1 - -map[2] = 288 -map[4] = 8 -map[1] = 28 -map[3] = 140 -} - -test is {Test of int64 keys and string values} -setup { - exec gcc $CFLAGS -I $KPATH -I $PATH -I $MPATH -o test is.c -} -body { - exec ./test -} -result {CPU #0 -map[1] = 0, -map[2] = 1, -map[3] = 0, -map[4] = 1, - -CPU #1 -map[1] = 1, -map[2] = 11, -map[3] = 1, -map[4] = 1, - -CPU #2 -map[1] = 2, -map[2] = 21, -map[3] = 4, -map[4] = 1, - -CPU #3 -map[1] = 3, -map[2] = 31, -map[3] = 9, -map[4] = 1, - -CPU #4 -map[1] = 4, -map[2] = 41, -map[3] = 16, -map[4] = 1, - -CPU #5 -map[1] = 5, -map[2] = 51, -map[3] = 25, -map[4] = 1, - -CPU #6 -map[1] = 6, -map[2] = 61, -map[3] = 36, -map[4] = 1, - -CPU #7 -map[1] = 7, -map[2] = 71, -map[3] = 49, -map[4] = 1, - -map[2] = 1,11,21,31,41,51,61,71, -map[4] = 1,1,1,1,1,1,1,1, -map[1] = 0,1,2,3,4,5,6,7, -map[3] = 0,1,4,9,16,25,36,49, -} - -test si {Test of string keys and int64 values} -setup { - exec gcc $CFLAGS -I $KPATH -I $PATH -I $MPATH -o test si.c -} -body { - exec ./test -} -result {CPU #0 -map[TWO] = 1 -map[FOUR] = 1 - -CPU #1 -map[ONE] = 1 -map[TWO] = 11 -map[THREE] = 1 -map[FOUR] = 1 - -CPU #2 -map[ONE] = 2 -map[TWO] = 21 -map[THREE] = 4 -map[FOUR] = 1 - -CPU #3 -map[ONE] = 3 -map[TWO] = 31 -map[THREE] = 9 -map[FOUR] = 1 - -CPU #4 -map[ONE] = 4 -map[TWO] = 41 -map[THREE] = 16 -map[FOUR] = 1 - -CPU #5 -map[ONE] = 5 -map[TWO] = 51 -map[THREE] = 25 -map[FOUR] = 1 - -CPU #6 -map[ONE] = 6 -map[TWO] = 61 -map[THREE] = 36 -map[FOUR] = 1 - -CPU #7 -map[ONE] = 7 -map[TWO] = 71 -map[THREE] = 49 -map[FOUR] = 1 - -map[FOUR] = 8 -map[TWO] = 288 -map[THREE] = 140 -map[ONE] = 28 -} - -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 -} -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 - -map[1] = count:8 sum:28 avg:3 min:0 max:7 -value |-------------------------------------------------- count - 0 |@@@@@@@@ 8 - 10 | 0 - 20 | 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 - -} - -test ix_log {Test of int64 keys and stat values (log histogram)} -setup { - exec gcc $CFLAGS -I $KPATH -I $PATH -I $MPATH -o test ix_log.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 | 0 - 1 |@ 1 - 2 | 0 - 4 | 0 - 8 |@@@@@@@ 7 - -map[4] = count:8 sum:8 avg:1 min:1 max:1 -value |-------------------------------------------------- count - 0 | 0 - 1 |@@@@@@@@ 8 - 2 | 0 - 4 | 0 - -map[1] = count:8 sum:28 avg:3 min:0 max:7 -value |-------------------------------------------------- count - 0 |@ 1 - 1 |@ 1 - 2 |@@ 2 - 4 |@@@@ 4 - 8 | 0 - -map[3] = count:8 sum:140 avg:17 min:0 max:49 -value |-------------------------------------------------- count - 0 |@ 1 - 1 |@ 1 - 2 | 0 - 4 |@ 1 - 8 |@@@@@ 5 - -} - -test ix_none {Test of int64 keys and stat values (no histogram)} -setup { - exec gcc $CFLAGS -I $KPATH -I $PATH -I $MPATH -o test ix_none.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 - -map[4] = count:8 sum:8 avg:1 min:1 max:1 - -map[1] = count:8 sum:28 avg:3 min:0 max:7 - -map[3] = count:8 sum:140 avg:17 min:0 max:49 - -} - -test map_format {Test of map formatting and histograms} -setup { - exec gcc $CFLAGS -I $KPATH -I $PATH -I $MPATH -o test map_format.c -} -body { - exec ./test -} -result {Columbus -> mapiis 1 2 Ohio -Salem -> mapiis 7 8 Oregon -Olympia -> mapiis 5 6 Washington -Sacramento -> mapiis 3 4 California - -Columbus % Ohio -Salem % Oregon -Olympia % Washington -Sacramento % California - -Columbus -> mapiis -Salem -> mapiis -Olympia -> mapiis -Sacramento -> mapiis - -The capitol of Riga is Latvia and the nerd population is 212063400820736 -The capitol of Sofia is Bulgaria and the nerd population is -2400999087387945352 -The capitol of Nicosia is Cyprus and the nerd population is -1 -The capitol of Valletta is Malta and the nerd population is 1 - -The capitol of Riga is Latvia and the nerd population is c0dedbad0000 -The capitol of Sofia is Bulgaria and the nerd population is deadf00d12345678 -The capitol of Nicosia is Cyprus and the nerd population is ffffffffffffffff -The capitol of Valletta is Malta and the nerd population is 1 - -The capitol of Riga is Latvia and the nerd population is C0DEDBAD0000 -The capitol of Sofia is Bulgaria and the nerd population is DEADF00D12345678 -The capitol of Nicosia is Cyprus and the nerd population is FFFFFFFFFFFFFFFF -The capitol of Valletta is Malta and the nerd population is 1 - -Bogons per packet for Riga -count:49600 sum:3288450 avg:66 min:0 max:99 -value |-------------------------------------------------- count - 0 |@@ 460 - 10 |@@@@@@@ 1460 - 20 |@@@@@@@@@@@@ 2460 - 30 |@@@@@@@@@@@@@@@@@@ 3460 - 40 |@@@@@@@@@@@@@@@@@@@@@@@ 4460 - 50 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 5460 - 60 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 6460 - 70 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 7460 - 80 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 8460 - 90 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 9460 - -Bogons per packet for Sofia -count:100 sum:2025 avg:20 min:0 max:81 -value |-------------------------------------------------- count - 0 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 42 - 10 |@@@@@@@@@@@@@@@@@ 17 - 20 |@@@@@@@@@@@@@ 13 - 30 |@@@@@@@@@ 9 - 40 |@@@@@@@@@ 9 - 50 |@@@@ 4 - 60 |@@@ 3 - 70 |@@ 2 - 80 |@ 1 - 90 | 0 - -Bogons per packet for Valletta -count:45 sum:2850 avg:63 min:10 max:90 -value |-------------------------------------------------- count - 0 | 0 - 10 |@ 1 - 20 |@@ 2 - 30 |@@@ 3 - 40 |@@@@ 4 - 50 |@@@@@ 5 - 60 |@@@@@@ 6 - 70 |@@@@@@@ 7 - 80 |@@@@@@@@ 8 - 90 |@@@@@@@@@ 9 - - -49600 was the count for Riga, Latvia -100 was the count for Sofia, Bulgaria -45 was the count for Valletta, Malta - -mapssx[ Riga, Latvia] = 322D82 -mapssx[ Sofia, Bulgaria] = 7E9 -mapssx[ Valletta, Malta] = B22} - - -test ii2 {Test of maps and pmaps with int64 keys and int64 values} -setup { - exec gcc $CFLAGS -I $KPATH -I $PATH -I $MPATH -o test ii2.c -} -body { - exec ./test -} -result {map[2] = 288 -map[4] = 8 -map[1] = 28 -map[3] = 140 - -pmap[2] = 288 -pmap[4] = 8 -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 - -map[1] = count:8 sum:28 avg:3 min:0 max:7 -value |-------------------------------------------------- count - 0 |@@@@@@@@ 8 - 10 | 0 - 20 | 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 - - -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 - -map[1] = count:8 sum:28 avg:3 min:0 max:7 -value |-------------------------------------------------- count - 0 |@@@@@@@@ 8 - 10 | 0 - 20 | 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 - - -map[1] Sum = 28 -map[3] Sum = 140 -map[4] Sum = 8 -} - - -test size {Test _stp_pmap_size()} -setup { - exec gcc $CFLAGS -I $KPATH -I $PATH -I $MPATH -o test size.c -} -body { - exec ./test -} -result {} - -catch {exec rm test} - -cleanupTests diff --git a/runtime/tests/pmaps/si.c b/runtime/tests/pmaps/si.c deleted file mode 100644 index 8b05da74..00000000 --- a/runtime/tests/pmaps/si.c +++ /dev/null @@ -1,62 +0,0 @@ -#include "runtime.h" - -/* test of pmaps with keys of string 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 STRING -#include "pmap-gen.c" - -#include "map.c" - -int main () -{ - PMAP map = _stp_pmap_new_si(4); - int64_t x; - - if (!map) - return -1; - - /* 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_si(map, "ONE", _processor_number); - _stp_pmap_add_si(map, "TWO", 10 *_processor_number + 1); - _stp_pmap_add_si(map, "THREE", _processor_number * _processor_number); - _stp_pmap_add_si(map, "FOUR", 1); - } - - /* read it back out and verify. Use the special get_cpu call to get non-aggregated data */ - for (_processor_number = 0; _processor_number < NR_CPUS; _processor_number++) { - x = _stp_pmap_get_cpu_si (map, "THREE"); - if (x != _processor_number * _processor_number) - printf("ERROR: Got %lld when expected %lld\n", x, (long long)(_processor_number * _processor_number)); - x = _stp_pmap_get_cpu_si (map, "ONE"); - if (x != _processor_number) - printf("ERROR: Got %lld when expected %lld\n", x, (long long)_processor_number); - x = _stp_pmap_get_cpu_si (map, "TWO"); - if (x != 10 * _processor_number + 1) - printf("ERROR: Got %lld when expected %lld\n", x, (long long)(10 * _processor_number + 1)); - x = _stp_pmap_get_cpu_si (map, "FOUR"); - if (x != 1LL) - printf("ERROR: Got %lld when expected %lld\n", x, 1LL); - } - - /* 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[%1s] = %d", _processor_number); - } - _processor_number = 0; - - /* print the aggregated data */ - _stp_pmap_print(map,"map[%1s] = %d"); - - _stp_pmap_del (map); - return 0; -} - diff --git a/runtime/tests/pmaps/size.c b/runtime/tests/pmaps/size.c deleted file mode 100644 index be8b4590..00000000 --- a/runtime/tests/pmaps/size.c +++ /dev/null @@ -1,72 +0,0 @@ -#include "runtime.h" - -/* test of _stp_pmap_size() */ - -/* 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" - -#define check(map,num) \ - { \ - int size = _stp_pmap_size(map); \ - if (size != num) \ - printf("ERROR at line %d: expected size %d and got %d instead.\n", __LINE__, num, size); \ - } - -int main () -{ - PMAP map = _stp_pmap_new_ii(8); - int64_t x; - - check(map,0); - - /* 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; - - check(map,4*NR_CPUS-2); - - _stp_pmap_add_ii(map, 1, 1); - _stp_pmap_add_ii(map, 3, 1); - check(map,4*NR_CPUS); - - _stp_pmap_add_ii(map, 5, 100); - check(map,4*NR_CPUS+1); - - _processor_number = 1; - _stp_pmap_add_ii(map, 5, 100); - check(map,4*NR_CPUS+2); - - _stp_pmap_set_ii(map, 5, 0); - check(map,4*NR_CPUS+1); - - _processor_number = 0; - _stp_pmap_set_ii(map, 5, 0); - check(map,4*NR_CPUS); - - for (_processor_number = 0; _processor_number < NR_CPUS; _processor_number++) { - _stp_pmap_set_ii(map, 1, 0); - _stp_pmap_set_ii(map, 2, 0); - _stp_pmap_set_ii(map, 3, 0); - _stp_pmap_set_ii(map, 4, 0); - } - _processor_number = 0; - check(map,0); - - _stp_pmap_del (map); - return 0; -} - |