summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--runtime/tests/README4
-rw-r--r--runtime/tests/all.tcl1
-rw-r--r--runtime/tests/map.test385
-rw-r--r--runtime/tests/maps/Makefile3
-rw-r--r--runtime/tests/maps/README2
-rw-r--r--runtime/tests/maps/all.tcl12
-rw-r--r--runtime/tests/maps/ii.c101
-rw-r--r--runtime/tests/maps/iiss.c51
-rw-r--r--runtime/tests/maps/is.c109
-rw-r--r--runtime/tests/maps/ist.c50
-rw-r--r--runtime/tests/maps/map.test269
-rw-r--r--runtime/tests/maps/si.c112
-rw-r--r--runtime/tests/test.h247
-rw-r--r--runtime/tests/testl64.c134
-rw-r--r--runtime/tests/testl64R.c50
-rw-r--r--runtime/tests/testl64_alloc.c139
-rw-r--r--runtime/tests/testlist.c63
-rw-r--r--runtime/tests/testll64.c111
-rw-r--r--runtime/tests/testlongstr.c120
-rw-r--r--runtime/tests/teststat.c72
-rw-r--r--runtime/tests/teststr.c117
-rw-r--r--runtime/tests/teststrlong.c114
-rw-r--r--runtime/tests/teststrstr.c103
-rw-r--r--runtime/tests/teststrstrstr.c121
24 files changed, 711 insertions, 1779 deletions
diff --git a/runtime/tests/README b/runtime/tests/README
index a9457011..795d8a02 100644
--- a/runtime/tests/README
+++ b/runtime/tests/README
@@ -1,4 +1,2 @@
-The *.c files test associative arrays (maps). "make tests" to run.
-
-test4_probe and shellsnoop are sample probes that use the new runtime.
+maps/ tests for associative arrays (maps) and lists
diff --git a/runtime/tests/all.tcl b/runtime/tests/all.tcl
index 2d44d6bb..f820c588 100644
--- a/runtime/tests/all.tcl
+++ b/runtime/tests/all.tcl
@@ -6,6 +6,7 @@ puts "Running all SystemTap tests"
#puts [tcltest::configure]
#puts [tcltest::configure -file]
+
tcltest::runAllTests
puts "All tests completed"
diff --git a/runtime/tests/map.test b/runtime/tests/map.test
deleted file mode 100644
index 1cbb7367..00000000
--- a/runtime/tests/map.test
+++ /dev/null
@@ -1,385 +0,0 @@
-package require tcltest
-namespace import -force tcltest::*
-
-set CFLAGS {-O3}
-
-test long_int64_1 {Test of long keys and int64 values} -setup {
- exec gcc $CFLAGS -o test testl64.c
-} -body {
- exec ./test
-} -result {mymap[1]=2
-mymap[101]=202 mymap[1]=2 mymap[42]=83
-mymap[42]=84
-mymap[1024]=2048
-mymap[1024]=0
-mymap[10]=0
-
-mymap[1] = 2
-mymap[42] = 84
-mymap[101] = 202
-
-mymap[42] = 84
-mymap[101] = 202
-
-mymap[101] = 202
-
-
-mymap[10]=20
-mymap[0] = 100
-mymap[1] = 102
-mymap[2] = 104
-mymap[3] = 106
-
-mymap[5] = 1005
-mymap[382] = 1382
-mymap[526] = 1526
-mymap[903] = 1903
-
-mymap[5] = 1005
-mymap[526] = 1526
-mymap[903] = 1903
-
-mymap[526] = 1526
-mymap[903] = 1903
-
-mymap[526] = 1526
-}
-
-test long_int64_2 {Range test of long keys and int64 values} -setup {
- exec gcc $CFLAGS -o test testl64R.c
-} -body {
- exec ./test
-} -result {mymap[1] = -9223372036854775808
-mymap[2] = 9223372036854775807
-mymap[4] = -1
-mymap[5] = 5
-mymap[999996] = 1999992
-mymap[999997] = 1999994
-mymap[999998] = 1999996
-mymap[999999] = 1999998}
-
-# same test as long_int64_1, except dynamic alloc
-test long_int64_3 {Test of long keys and int64 values, dynamic allocation} -setup {
- exec gcc $CFLAGS -o test testl64_alloc.c
-} -body {
- exec ./test
-} -result {mymap[1]=2
-mymap[101]=202 mymap[1]=2 mymap[42]=83
-mymap[42]=84
-mymap[1024]=2048
-mymap[1024]=0
-mymap[10]=0
-
-mymap[1] = 2
-mymap[42] = 84
-mymap[101] = 202
-
-mymap[42] = 84
-mymap[101] = 202
-
-mymap[101] = 202
-
-
-mymap[10]=20
-mymap[10] = 20
-mymap[0] = 100
-mymap[1] = 102
-mymap[2] = 104
-mymap[3] = 106
-
-mymap[5] = 1005
-mymap[382] = 1382
-mymap[526] = 1526
-mymap[903] = 1903
-
-mymap[5] = 1005
-mymap[526] = 1526
-mymap[903] = 1903
-
-mymap[526] = 1526
-mymap[903] = 1903
-
-mymap[526] = 1526
-}
-
-test long_long_int64_1 {Test of long,long keys and int64 values} -setup {
- exec gcc $CFLAGS -o test testll64.c
-} -body {
- exec ./test
-} -result {mymap[1,1]=1
-mymap[1,2]=2
-mymap[2,1]=3
-mymap[1,1] = 1
-mymap[1,2] = 2
-mymap[2,1] = 3}
-
-test str_int64_4 {Test of string keys and int64 values} -setup {
- exec gcc $CFLAGS -o test teststr.c
-} -body {
- exec ./test
-} -result {mymap[two]=2
-mymap[two-oh-two]=202 mymap[two]=2 mymap[eighty-four]=83
-mymap[eighty-four]=84
-
-mymap[two] = 2
-mymap[eighty-four] = 84
-mymap[two-oh-two] = 202
-mymap[0123456789] = 1000000
-mymap[2048]=2048
-mymap[2048]=0
-mymap[10]=0
-
-mymap[eighty-four] = 84
-mymap[two-oh-two] = 202
-mymap[0123456789] = 1000000
-
-mymap[eighty-four] = 84
-mymap[0123456789] = 1000000
-
-mymap[0123456789] = 1000000
-
-
-mymap[Ohio]=10123456
-mymap[Ohio] = 10123456
-
-mymap[test_number_0] = 1000
-mymap[test_number_1] = 1001
-mymap[test_number_2] = 1002
-mymap[test_number_3] = 1003}
-
-test str_str_int64_1 {Test of string,string keys and int64 values} -setup {
- exec gcc $CFLAGS -o test teststrstr.c
-} -body {
- exec ./test
-} -result {mymap[two,three]=6
-mymap[two-oh-two,four]=808 mymap[two,three]=6 mymap[eighty-four,two]=167
-mymap[eighty-four,two]=168
-
-mymap[two,three] = 6
-mymap[eighty-four,two] = 168
-mymap[two-oh-two,four] = 808
-mymap[0123456789,foo] = 1000000
-mymap[2048,2]=4096
-mymap[2048,2]=0
-mymap[10,six]=0
-
-mymap[eighty-four,two] = 168
-mymap[two-oh-two,four] = 808
-mymap[0123456789,foo] = 1000000
-
-mymap[eighty-four,two] = 168
-mymap[0123456789,foo] = 1000000
-
-mymap[eighty-four,two] = 168
-mymap[0123456789,foo] = 1000000
-mymap[Ohio,1801] = 10123456
-
-mymap[test_number_2,**test number 4**] = 8
-mymap[test_number_3,**test number 9**] = 27
-mymap[test_number_4,**test number 16**] = 64
-mymap[test_number_5,**test number 25**] = 125}
-
-
-test str_long_int64_1 {Test of string,long keys and int64 values} -setup {
- exec gcc $CFLAGS -o test teststrlong.c
-} -body {
- exec ./test
-} -result {map[two,3]=6
-map[two-oh-two,4]=808
-map[two,3]=6
-map[eighty-four,2]=167
-map[eighty-four,2]=168
-
-map[two,3] = 6
-map[eighty-four,2] = 168
-map[two-oh-two,4] = 808
-map[0123456789,4444] = 1000000
-
-map[2048,2]=4096
-mymap[2048,2]=0
-mymap[six,10]=0
-
-map[eighty-four,2] = 168
-map[two-oh-two,4] = 808
-map[0123456789,4444] = 1000000
-
-
-map[eighty-four,2] = 168
-map[0123456789,4444] = 1000000
-
-
-map[eighty-four,2] = 168
-map[0123456789,4444] = 1000000
-map[Ohio,1801] = 10123456
-
-
-map[test_number_2,2] = 8
-map[test_number_3,3] = 27
-map[test_number_4,4] = 64
-map[test_number_5,5] = 125
-
-Should be empty:
-}
-
-
-test long_str_int64_1 {Test of long,string keys and int64 values} -setup {
- exec gcc $CFLAGS -o test testlongstr.c
-} -body {
- exec ./test
-} -result {map[3,two]=6
-map[4,two-oh-two]=808
-map[3,two]=6
-map[2,eighty-four]=167
-map[2,eighty-four]=168
-
-map[3,two] = 6
-map[2,eighty-four] = 168
-map[4,two-oh-two] = 808
-map[4444,0123456789] = 1000000
-
-map[2048,2]=4096
-mymap[2048,2]=0
-mymap[10,six]=0
-
-map[2,eighty-four] = 168
-map[4,two-oh-two] = 808
-map[4444,0123456789] = 1000000
-
-
-map[2,eighty-four] = 168
-map[4444,0123456789] = 1000000
-
-
-map[2,eighty-four] = 168
-
-
-
-
-map[1801,Ohio] = 10123456
-
-
-map[2,test_number_2] = 8
-map[3,test_number_3] = 27
-map[4,test_number_4] = 64
-map[5,test_number_5] = 125
-
-Should be empty:
-}
-
-test str_str_str_1 {Test of string,string keys and string values} -setup {
- exec gcc $CFLAGS -o test teststrstrstr.c
-} -body {
- exec ./test
-} -result {map[two,2]=four
-map[two-two-one-B,Baker Street]=7% solution
-map[two,2]=four
-map[eighty-four,nineteen hundred]=nineteen hundred and eighty-three
-map[eighty-four,nineteen hundred]=nineteen hundred and eighty-four
-
-map[two,2] = four
-map[eighty-four,nineteen hundred] = nineteen hundred and eighty-four
-map[two-two-one-B,Baker Street] = 7% solution
-map[0123456789,4444] = 1000000
-
-map[2048,2]=4096
-mymap[2048,2]=(null)
-mymap[six,10]=(null)
-
-map[eighty-four,nineteen hundred] = nineteen hundred and eighty-four
-map[two-two-one-B,Baker Street] = 7% solution
-map[0123456789,4444] = 1000000
-
-
-map[eighty-four,nineteen hundred] = nineteen hundred and eighty-four
-map[0123456789,4444] = 1000000
-
-
-map[eighty-four,nineteen hundred] = nineteen hundred and eighty-four
-map[0123456789,4444] = 1000000
-map[abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ,(null)] = TESTING 1,2,3
-map[abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZhiasdhgfiudsgfiusdgfisdugfisdugfsdiufgsdfiugsdifugsdiufgsdiufgisdugfisdugfigsdfiusdgfiugsdifu sdfigsdifugsdifugsdiufgsdiufgisdugfiudsgfisudgfiusdgfiusdgfisdugfisdufgiusdfgsdiufgdsiufgsdiufgsdiufgsdiufgwiugfw89e4rf98yf897ywef98wyef98wyf98wyf89ys9d8yfsd sdfysd98fy9s8fyds98fy98dsfy89sdfy,yw98fty98sfts98d7fts89d7f9sdfoooooooooooooooooooooooooooooooooooooooooooof8eo7stfew87fwet8tw87rf7fpowft7ewfptpwefpwetfpwepwfwetfp8we] = TESTING 1,2,3 ***************************************************************************************************************************************************************************************************************************************************************************** 4,5,6
-
-
-map[test_number_2,TEST_NUMBER_4] = TEST_NUMBER_8
-map[test_number_3,TEST_NUMBER_9] = TEST_NUMBER_27
-map[test_number_4,TEST_NUMBER_16] = TEST_NUMBER_64
-map[test_number_5,TEST_NUMBER_25] = TEST_NUMBER_125
-
-Should be empty:
-}
-
-test stat_1 {Test of string,long keys and stat values} -setup {
- exec gcc $CFLAGS -o test teststat.c
-} -body {
- exec ./test
-} -result {map[created with set,2001] = [c=5 s=125 minmax =2,42]
-map[created with set,2001] = [c=6 s=142 minmax =2,42]
-map[created with add,2020] = [c=1 s=1700 minmax =1700,1700]
-map[created with add,2020] = [c=2 s=1702 minmax =2,1700]
-map[created with add,2020] = [c=3 s=4047 minmax =2,2345]
-
-map[created with set,2001] = [c=6 s=142 minmax =2,42]
-map[created with add,2020] = [c=3 s=4047 minmax =2,2345]
-
-
-map[created with add,2020] = [c=3 s=4047 minmax =2,2345]
-
-
-map[created with add,2020] = [c=5 s=123456 minmax =2,42]
-
-
-
-map[created with add,1234] = [c=2 s=100 minmax =42,58]
-
-map[created with add,1234] = [c=2 s=100 minmax =42,58]
-}
-
-test list_1 {Test of List of string values} -setup {
- exec gcc $CFLAGS -o test testlist.c
-} -body {
- exec ./test
-} -result {map[0] = Item0
-map[1] = Item1
-map[2] = Item2
-map[3] = Item3
-map[4] = Item4
-map[5] = Item5
-map[6] = Item6
-map[7] = Item7
-map[8] = Item8
-map[9] = Item9
-
-size is 10
-map[0] = Item0
-map[1] = Item1
-map[2] = Item2
-map[3] = Item3
-map[4] = Item4
-map[5] = Item5
-map[6] = Item6
-map[7] = Item7
-map[8] = Item8
-map[9] = Item9
-
-map[0] = Item0
-map[1] = Item1
-map[2] = Item2
-map[3] = Item3
-map[4] = Item4
-map[5] = Item5
-map[6] = Item6
-map[7] = Item7
-map[8] = Item8
-map[9] = Item9
-
-
-map[0] = Item50
-map[1] = Item51
-map[2] = Item52
-map[3] = Item53
-map[4] = Item54
-}
-
-exec rm test
-
-cleanupTests
diff --git a/runtime/tests/maps/Makefile b/runtime/tests/maps/Makefile
new file mode 100644
index 00000000..4e744d25
--- /dev/null
+++ b/runtime/tests/maps/Makefile
@@ -0,0 +1,3 @@
+tests:
+ tclsh all.tcl
+
diff --git a/runtime/tests/maps/README b/runtime/tests/maps/README
new file mode 100644
index 00000000..02406464
--- /dev/null
+++ b/runtime/tests/maps/README
@@ -0,0 +1,2 @@
+The *.c files test associative arrays (maps). "make tests" to run.
+
diff --git a/runtime/tests/maps/all.tcl b/runtime/tests/maps/all.tcl
new file mode 100644
index 00000000..aa408eea
--- /dev/null
+++ b/runtime/tests/maps/all.tcl
@@ -0,0 +1,12 @@
+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
new file mode 100644
index 00000000..64aa05ac
--- /dev/null
+++ b/runtime/tests/maps/ii.c
@@ -0,0 +1,101 @@
+#include "runtime.h"
+
+/* test of maps with keys of int64 and value of int64 */
+
+#define KEY1_TYPE INT64
+#include "map-keys.c"
+
+#define VALUE_TYPE INT64
+#include "map-values.c"
+
+#include "map.c"
+
+int main ()
+{
+ MAP map = _stp_map_new_int64(4, INT64);
+
+ /* map[1] = 2 */
+ _stp_map_key_int64 (map, 1);
+ _stp_map_set_int64 (map, 2);
+ printf ("map[%lld]=%lld\n", key1int(map->key), _stp_map_get_int64(map));
+ _stp_map_print(map,"map");
+
+ /* map[3] = 4 */
+ /* try it with macros this time */
+ _stp_map_key (map, 3);
+ _stp_map_set (map, 4);
+ _stp_map_print (map, "map");
+
+ /* now try to confuse things */
+ /* These won't do anything useful, but shouldn't crash */
+ _stp_map_key_int64 (map, 0);
+ _stp_map_key_del (map);
+ _stp_map_key_int64 (map, 77);
+ _stp_map_key_del (map);
+ _stp_map_key_del (map);
+ _stp_map_set_int64 (map,1000000);
+
+ _stp_map_print (map, "map");
+
+ /* create and delete a key */
+ _stp_map_key_int64 (map, 1024);
+ _stp_map_set_int64 (map, 2048);
+ _stp_map_key_int64 (map, 1024);
+ _stp_map_key_del (map);
+
+ _stp_map_print (map, "map");
+
+ /* create and delete a key again*/
+ _stp_map_key_int64 (map, 1024);
+ _stp_map_set_int64 (map, 2048);
+ _stp_map_key_del (map);
+
+ _stp_map_print (map, "map");
+
+ /* check that unset values are 0 */
+ _stp_map_key_int64 (map, 5);
+ printf ("map[%lld]=%lld\n", key1int(map->key), _stp_map_get_int64(map));
+
+ /* map[5] = 6 */
+ _stp_map_set (map, 6);
+ _stp_map_print (map, "map");
+
+ /* add 4 new entries, pushing the others out */
+ int i;
+ for (i = 6; i < 10; i++)
+ {
+ _stp_map_key_int64 (map, i);
+ _stp_map_set_int64 (map, 100 + i);
+ }
+
+ _stp_map_print (map, "map");
+
+ /* 5, 382, 526, and 903 all hash to the same value (23) */
+ /* use them to test the hash chain */
+ _stp_map_key_int64 (map, 5); _stp_map_set_int64 (map, 1005);
+ _stp_map_key_int64 (map, 382); _stp_map_set_int64 (map, 1382);
+ _stp_map_key_int64 (map, 526); _stp_map_set_int64 (map, 1526);
+ _stp_map_key_int64 (map, 903); _stp_map_set_int64 (map, 1903);
+
+ _stp_map_print (map, "map");
+
+ /* now delete all 4 nodes, one by one */
+ _stp_map_key_int64 (map, 382); _stp_map_key_del (map);
+
+ _stp_map_print (map, "map");
+
+ _stp_map_key_int64 (map, 5); _stp_map_key_del (map);
+
+ _stp_map_print (map, "map");
+
+ _stp_map_key_int64 (map, 903); _stp_map_key_del (map);
+
+ _stp_map_print (map, "map");
+
+ _stp_map_key_int64 (map, 526); _stp_map_key_del (map);
+
+ _stp_map_print (map, "map");
+
+ _stp_map_del (map);
+ return 0;
+}
diff --git a/runtime/tests/maps/iiss.c b/runtime/tests/maps/iiss.c
new file mode 100644
index 00000000..e1ec2407
--- /dev/null
+++ b/runtime/tests/maps/iiss.c
@@ -0,0 +1,51 @@
+#include "runtime.h"
+
+/* test of maps with keys of int64,int64,string and value of string */
+
+#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 ()
+{
+ MAP map = _stp_map_new_int64_int64_str(4, STRING);
+
+ _stp_map_key_int64_int64_str (map, 1,2,"Ohio");
+ _stp_map_set_str (map, "Columbus" );
+ _stp_map_key_int64_int64_str (map, 3,4,"California");
+ _stp_map_add_str (map, "Sacramento" );
+ _stp_map_key_int64_int64_str (map, 5,6,"Washington");
+ _stp_map_set_str (map, "Seattle" );
+ _stp_map_key_int64_int64_str (map, 7,8,"Oregon");
+ _stp_map_set_str (map, "Salem" );
+
+ _stp_map_print (map, "map");
+
+ _stp_map_key_int64_int64_str (map, -9,-10,"Nevada");
+ _stp_map_set_str (map, "Carson City" );
+ _stp_map_print (map, "map");
+
+ _stp_map_key_int64_int64_str (map, 5,6,"Washington");
+ _stp_map_set (map, "Olymp" );
+ _stp_map_print (map, "map");
+
+ _stp_map_add_str (map, "ia" );
+ _stp_map_print (map, "map");
+
+ _stp_map_key_int64_int64_str (map, -9,-10,"Nevada");
+ _stp_map_key_del (map);
+ _stp_map_print (map, "map");
+
+ _stp_map_key_int64_int64_str (map, 0,0,"");
+ _stp_map_set_str (map, "XX" );
+ _stp_map_print (map, "map");
+
+ _stp_map_del (map);
+ return 0;
+}
diff --git a/runtime/tests/maps/is.c b/runtime/tests/maps/is.c
new file mode 100644
index 00000000..69a0b842
--- /dev/null
+++ b/runtime/tests/maps/is.c
@@ -0,0 +1,109 @@
+#include "runtime.h"
+
+/* test of maps with keys of int64 and value of string */
+
+#define KEY1_TYPE INT64
+#include "map-keys.c"
+
+#define VALUE_TYPE STRING
+#include "map-values.c"
+
+#include "map.c"
+
+int main ()
+{
+ MAP map = _stp_map_new_int64(4, STRING);
+
+ /* map[1] = one */
+ _stp_map_key_int64 (map, 1);
+ _stp_map_set_str (map, "one");
+ printf ("map[%lld]=%s\n", key1int(map->key), _stp_map_get_str(map));
+ _stp_map_print(map,"map");
+
+ /* map[3] = "three" */
+ /* try it with macros this time */
+ _stp_map_key (map, 3);
+ _stp_map_set (map, "three");
+ _stp_map_print (map, "map");
+
+
+ /* now try to confuse things */
+ /* These won't do anything useful, but shouldn't crash */
+ _stp_map_key_int64 (map, 0);
+ _stp_map_key_del (map);
+ _stp_map_key_int64 (map, 77);
+ _stp_map_key_del (map);
+ _stp_map_key_del (map);
+ _stp_map_set_str (map,"1000000");
+
+ _stp_map_print (map, "map");
+
+ /* create and delete a key */
+ _stp_map_key_int64 (map, 1024);
+ _stp_map_set_str (map, "2048");
+ _stp_map_key_int64 (map, 1024);
+ _stp_map_key_del (map);
+
+ _stp_map_print (map, "map");
+
+ /* create and delete a key again*/
+ _stp_map_key_int64 (map, 1024);
+ _stp_map_set_str (map, "2048");
+ _stp_map_key_del (map);
+
+ _stp_map_print (map, "map");
+
+ /* check that unset values are 0 */
+ _stp_map_key_int64 (map, 5);
+ printf ("map[%lld]=%lld\n", key1int(map->key), _stp_map_get_str(map));
+
+ /* map[5] = "five" */
+ _stp_map_set (map, "five");
+ _stp_map_print (map, "map");
+
+ /* test empty string */
+ _stp_map_set (map, "");
+ _stp_map_print (map, "map");
+
+
+ /* add 4 new entries, pushing the others out */
+ int i;
+ for (i = 6; i < 10; i++)
+ {
+ char buf[32];
+ sprintf(buf, "value of %d", i);
+ _stp_map_key_int64 (map, i);
+ _stp_map_set_str (map, buf);
+ }
+
+ _stp_map_print (map, "map");
+
+ /* 5, 382, 526, and 903 all hash to the same value (23) */
+ /* use them to test the hash chain */
+ _stp_map_key_int64 (map, 5); _stp_map_set_str (map, "1005");
+ _stp_map_key_int64 (map, 382); _stp_map_set_str (map, "1382");
+ _stp_map_key_int64 (map, 526); _stp_map_set_str (map, "1526");
+ _stp_map_key_int64 (map, 903); _stp_map_set_str (map, "1903");
+
+ _stp_map_print (map, "map");
+
+ /* now delete all 4 nodes, one by one */
+ _stp_map_key_int64 (map, 382); _stp_map_key_del (map);
+
+ _stp_map_print (map, "map");
+
+ _stp_map_key_int64 (map, 5); _stp_map_key_del (map);
+
+ _stp_map_print (map, "map");
+
+ _stp_map_key_int64 (map, 903); _stp_map_key_del (map);
+
+ _stp_map_print (map, "map");
+
+ _stp_map_key_int64 (map, 526); _stp_map_key_del (map);
+
+ _stp_map_print (map, "map");
+
+ _stp_map_del (map);
+ return 0;
+}
diff --git a/runtime/tests/maps/ist.c b/runtime/tests/maps/ist.c
new file mode 100644
index 00000000..24eb6f42
--- /dev/null
+++ b/runtime/tests/maps/ist.c
@@ -0,0 +1,50 @@
+#include "runtime.h"
+
+/* test of maps with keys of int64 and value of stat */
+
+#define KEY1_TYPE INT64
+#include "map-keys.c"
+
+#define VALUE_TYPE STAT
+#include "map-values.c"
+
+#include "map.c"
+
+int main ()
+{
+ int i, j;
+ MAP map = _stp_map_new_int64(4, HSTAT_LINEAR, 0, 100, 10 );
+ MAP map2 = _stp_map_new_int64(4, HSTAT_LOG, 11);
+
+ _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_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_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_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_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_print (map, "map");
+ _stp_map_print (map2, "map2");
+
+ _stp_map_del (map);
+ _stp_map_del (map2);
+ return 0;
+}
diff --git a/runtime/tests/maps/map.test b/runtime/tests/maps/map.test
new file mode 100644
index 00000000..4b72ffb7
--- /dev/null
+++ b/runtime/tests/maps/map.test
@@ -0,0 +1,269 @@
+package require tcltest
+namespace import -force tcltest::*
+
+cd $tcltest::testsDirectory
+
+set CFLAGS "-Os"
+set KPATH "/lib/modules/[exec uname -r]/build/include"
+set PATH "../../user"
+
+test ii {Test of int64 keys and int64 values} -setup {
+ exec gcc $CFLAGS -I $KPATH -I $PATH -o test ii.c
+} -body {
+ exec ./test
+} -result {map[1]=2
+map[1] = 2
+
+map[1] = 2
+map[3] = 4
+
+map[1] = 2
+map[3] = 4
+
+map[1] = 2
+map[3] = 4
+
+map[1] = 2
+map[3] = 4
+
+map[0]=0
+map[1] = 2
+map[3] = 4
+map[5] = 6
+
+map[6] = 106
+map[7] = 107
+map[8] = 108
+map[9] = 109
+
+map[5] = 1005
+map[382] = 1382
+map[526] = 1526
+map[903] = 1903
+
+map[5] = 1005
+map[526] = 1526
+map[903] = 1903
+
+map[526] = 1526
+map[903] = 1903
+
+map[526] = 1526
+
+}
+
+test is {Test of int64 keys and string values} -setup {
+ exec gcc $CFLAGS -I $KPATH -I $PATH -o test is.c
+} -body {
+ exec ./test
+} -result {map[1]=one
+map[1] = one
+
+map[1] = one
+map[3] = three
+
+map[1] = one
+map[3] = three
+
+map[1] = one
+map[3] = three
+
+map[1] = one
+map[3] = three
+
+map[0]=0
+map[1] = one
+map[3] = three
+map[5] = five
+
+map[1] = one
+map[3] = three
+map[5] =
+
+map[6] = value of 6
+map[7] = value of 7
+map[8] = value of 8
+map[9] = value of 9
+
+map[5] = 1005
+map[382] = 1382
+map[526] = 1526
+map[903] = 1903
+
+map[5] = 1005
+map[526] = 1526
+map[903] = 1903
+
+map[526] = 1526
+map[903] = 1903
+
+map[526] = 1526
+
+}
+
+test si {Test of string keys and int64 values} -setup {
+ exec gcc $CFLAGS -I $KPATH -I $PATH -o test si.c
+} -body {
+ exec ./test
+} -result {map[Ohio]=1
+map[Ohio] = 1
+
+map[Ohio] = 1
+map[Washington] = 2
+
+map[Ohio] = 1
+map[Washington] = 2
+
+map[Ohio] = 1
+map[Washington] = 2
+
+map[Ohio] = 1
+map[Washington] = 2
+
+map[0]=0
+map[Ohio] = 1
+map[Washington] = 2
+map[California] = 3
+
+map[Ohio] = 1
+map[Washington] = 2
+map[California] = 3
+map[] = 7777
+
+map[Ohio] = 1
+map[Washington] = 2
+map[California] = 3
+map[] = 8888
+
+map[String 6] = 106
+map[String 7] = 107
+map[String 8] = 108
+map[String 9] = 109
+
+map[5] = 1005
+map[382] = 1382
+map[526] = 1526
+map[903] = 1903
+
+map[5] = 1005
+map[526] = 1526
+map[903] = 1903
+
+map[526] = 1526
+map[903] = 1903
+
+map[526] = 1526
+
+}
+
+test ist {Test of int64 keys and stat values} -setup {
+ exec gcc $CFLAGS -I $KPATH -I $PATH -o test ist.c
+} -body {
+ exec ./test
+} -result {map[3] = 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
+
+map[2] = 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
+
+map[1] = 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
+
+
+map2[1] = count:16384 sum:1040384 avg:63 min:0 max:127
+value |-------------------------------------------------- count
+ 0 | 128
+ 1 | 128
+ 2 |@ 256
+ 4 |@@@ 512
+ 8 |@@@@@@ 1024
+ 16 |@@@@@@@@@@@@ 2048
+ 32 |@@@@@@@@@@@@@@@@@@@@@@@@ 4096
+ 64 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 8192
+ 128 | 0
+ 256 | 0
+ 512 | 0
+
+map2[2] = count:1048576 sum:536346624 avg:511 min:0 max:1023
+value |-------------------------------------------------- count
+ 0 | 1024
+ 1 | 1024
+ 2 | 2048
+ 4 | 4096
+ 8 | 8192
+ 16 |@ 16384
+ 32 |@@@ 32768
+ 64 |@@@@@@ 65536
+ 128 |@@@@@@@@@@@@ 131072
+ 256 |@@@@@@@@@@@@@@@@@@@@@@@@ 262144
+ 512 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 524288
+
+}
+
+test iiss {Test of int64,int64,string keys and string values} -setup {
+ exec gcc $CFLAGS -I $KPATH -I $PATH -o test iiss.c
+} -body {
+ exec ./test
+} -result {map[1, 2, Ohio] = Columbus
+map[3, 4, California] = Sacramento
+map[5, 6, Washington] = Seattle
+map[7, 8, Oregon] = Salem
+
+map[3, 4, California] = Sacramento
+map[5, 6, Washington] = Seattle
+map[7, 8, Oregon] = Salem
+map[-9, -10, Nevada] = Carson City
+
+map[3, 4, California] = Sacramento
+map[5, 6, Washington] = Olymp
+map[7, 8, Oregon] = Salem
+map[-9, -10, Nevada] = Carson City
+
+map[3, 4, California] = Sacramento
+map[5, 6, Washington] = Olympia
+map[7, 8, Oregon] = Salem
+map[-9, -10, Nevada] = Carson City
+
+map[3, 4, California] = Sacramento
+map[5, 6, Washington] = Olympia
+map[7, 8, Oregon] = Salem
+
+map[3, 4, California] = Sacramento
+map[5, 6, Washington] = Olympia
+map[7, 8, Oregon] = Salem
+map[0, 0, ] = XX
+}
+
+exec rm test
+
+cleanupTests
diff --git a/runtime/tests/maps/si.c b/runtime/tests/maps/si.c
new file mode 100644
index 00000000..4f3e3f35
--- /dev/null
+++ b/runtime/tests/maps/si.c
@@ -0,0 +1,112 @@
+#include "runtime.h"
+
+/* test of maps with keys of string and value of int64 */
+
+#define KEY1_TYPE STRING
+#include "map-keys.c"
+
+#define VALUE_TYPE INT64
+#include "map-values.c"
+
+#include "map.c"
+
+int main ()
+{
+ MAP map = _stp_map_new_str(4, INT64);
+
+ /* map[Ohio] = 1 */
+ _stp_map_key_str (map, "Ohio");
+ _stp_map_set_int64 (map, 1);
+ printf ("map[%s]=%lld\n", key1str(map->key), _stp_map_get_int64(map));
+ _stp_map_print(map,"map");
+
+ /* map[Washington] = 2 */
+ /* try it with macros this time */
+ _stp_map_key (map, "Washington");
+ _stp_map_set (map, 2);
+ _stp_map_print (map, "map");
+
+ /* now try to confuse things */
+ /* These won't do anything useful, but shouldn't crash */
+ _stp_map_key_str (map, "");
+ _stp_map_key_del (map);
+ _stp_map_key_str (map, "77");
+ _stp_map_key_del (map);
+ _stp_map_key_del (map);
+ _stp_map_set_int64 (map,1000000);
+
+ _stp_map_print (map, "map");
+
+ /* create and delete a key */
+ _stp_map_key_str (map, "1024");
+ _stp_map_set_int64 (map, 2048);
+ _stp_map_key_str (map, "1024");
+ _stp_map_key_del (map);
+
+ _stp_map_print (map, "map");
+
+ /* create and delete a key again*/
+ _stp_map_key_str (map, "1024");
+ _stp_map_set_int64 (map, 2048);
+ _stp_map_key_del (map);
+
+ _stp_map_print (map, "map");
+
+ /* check that unset values are 0 */
+ _stp_map_key_str (map, "California");
+ printf ("map[%lld]=%lld\n", key1int(map->key), _stp_map_get_int64(map));
+
+ /* map[California] = 3 */
+ _stp_map_set (map, 3);
+ _stp_map_print (map, "map");
+
+ /* test an empty string as key */
+ _stp_map_key (map, "");
+ _stp_map_set_int64 (map, 7777);
+ _stp_map_print (map, "map");
+ _stp_map_key (map, "");
+ _stp_map_set_int64 (map, 8888);
+ _stp_map_print (map, "map");
+
+ /* add 4 new entries, pushing the others out */
+ int i;
+ for (i = 6; i < 10; i++)
+ {
+ char buf[32];
+ sprintf (buf, "String %d", i);
+ _stp_map_key (map, buf);
+ _stp_map_set_int64 (map, 100 + i);
+ }
+
+ _stp_map_print (map, "map");
+
+
+ /* 5, 382, 526, and 903 all hash to the same value (23) */
+ /* use them to test the hash chain */
+ _stp_map_key (map, "5"); _stp_map_set_int64 (map, 1005);
+ _stp_map_key (map, "382"); _stp_map_set_int64 (map, 1382);
+ _stp_map_key (map, "526"); _stp_map_set_int64 (map, 1526);
+ _stp_map_key (map, "903"); _stp_map_set_int64 (map, 1903);
+
+ _stp_map_print (map, "map");
+
+ /* now delete all 4 nodes, one by one */
+ _stp_map_key (map, "382"); _stp_map_key_del (map);
+
+ _stp_map_print (map, "map");
+
+ _stp_map_key (map, "5"); _stp_map_key_del (map);
+
+ _stp_map_print (map, "map");
+
+ _stp_map_key (map, "903"); _stp_map_key_del (map);
+
+ _stp_map_print (map, "map");
+
+ _stp_map_key (map, "526"); _stp_map_key_del (map);
+
+ _stp_map_print (map, "map");
+
+ _stp_map_del (map);
+ return 0;
+}
diff --git a/runtime/tests/test.h b/runtime/tests/test.h
deleted file mode 100644
index 3139cfec..00000000
--- a/runtime/tests/test.h
+++ /dev/null
@@ -1,247 +0,0 @@
-/* include file for testing maps without running in the kernel */
-
-#include <stdio.h>
-#include <stdarg.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <limits.h>
-#include <errno.h>
-
-#define likely(x) __builtin_expect(!!(x), 1)
-#define unlikely(x) __builtin_expect(!!(x), 0)
-
-static inline unsigned long hash_long(unsigned long val, unsigned int bits)
-{
- unsigned long hash = val;
-
-#if __WORDSIZE == 64
- /* Sigh, gcc can't optimise this alone like it does for 32 bits. */
- unsigned long n = hash;
- n <<= 18;
- hash -= n;
- n <<= 33;
- hash -= n;
- n <<= 3;
- hash += n;
- n <<= 3;
- hash -= n;
- n <<= 4;
- hash += n;
- n <<= 2;
- hash += n;
-#else
- /* On some cpus multiply is faster, on others gcc will do shifts */
- hash *= 0x9e370001UL;
-#endif
-
- /* High bits are more random, so use them. */
- return hash >> (8*sizeof(long) - bits);
-}
-
-
-#define STRINGLEN 128
-#define HASH_ELEM_NUM 5000
-#define HASH_TABLE_BITS 8
-#define HASH_TABLE_SIZE (1<<HASH_TABLE_BITS)
-#define BUCKETS 16 /* largest histogram width */
-#define PK 0 /* sprinkle debug printk into probe code */
-
-#define LIST_POISON1 ((void *) 0x00100100)
-#define LIST_POISON2 ((void *) 0x00200200)
-
-struct list_head {
- struct list_head *next, *prev;
-};
-
-#define LIST_HEAD_INIT(name) { &(name), &(name) }
-
-#define LIST_HEAD(name) \
- struct list_head name = LIST_HEAD_INIT(name)
-
-#define INIT_LIST_HEAD(ptr) do { \
- (ptr)->next = (ptr); (ptr)->prev = (ptr); \
-} while (0)
-
-/*
- * Insert a new entry between two known consecutive entries.
- *
- * This is only for internal list manipulation where we know
- * the prev/next entries already!
- */
-static inline void __list_add(struct list_head *new,
- struct list_head *prev,
- struct list_head *next)
-{
- next->prev = new;
- new->next = next;
- new->prev = prev;
- prev->next = new;
-}
-
-static inline void list_add(struct list_head *new, struct list_head *head)
-{
- __list_add(new, head, head->next);
-}
-
-
-static inline void list_add_tail(struct list_head *new, struct list_head *head)
-{
- __list_add(new, head->prev, head);
-}
-/*
- * Delete a list entry by making the prev/next entries
- * point to each other.
- *
- * This is only for internal list manipulation where we know
- * the prev/next entries already!
- */
-static inline void __list_del(struct list_head * prev, struct list_head * next)
-{
- next->prev = prev;
- prev->next = next;
-}
-
-static inline void list_del(struct list_head *entry)
-{
- __list_del(entry->prev, entry->next);
- entry->next = LIST_POISON1;
- entry->prev = LIST_POISON2;
-}
-
-static inline int list_empty(const struct list_head *head)
-{
- return head->next == head;
-}
-
-static inline void list_move_tail(struct list_head *list,
- struct list_head *head)
-{
- __list_del(list->prev, list->next);
- list_add_tail(list, head);
-}
-
-
-struct hlist_head {
- struct hlist_node *first;
-};
-
-struct hlist_node {
- struct hlist_node *next, **pprev;
-};
-#define HLIST_HEAD_INIT { .first = NULL }
-#define HLIST_HEAD(name) struct hlist_head name = { .first = NULL }
-#define INIT_HLIST_HEAD(ptr) ((ptr)->first = NULL)
-#define INIT_HLIST_NODE(ptr) ((ptr)->next = NULL, (ptr)->pprev = NULL)
-
-static inline void hlist_add_head(struct hlist_node *n, struct hlist_head *h)
-{
- struct hlist_node *first = h->first;
- n->next = first;
- if (first)
- first->pprev = &n->next;
- h->first = n;
- n->pprev = &h->first;
-}
-
-#define hlist_for_each(pos, head) \
- for (pos = (head)->first; pos; pos = pos->next)
-
-#define hlist_entry(ptr, type, member) container_of(ptr,type,member)
-
-#define container_of(ptr, type, member) ({ \
- const typeof( ((type *)0)->member ) *__mptr = (ptr); \
- (type *)( (char *)__mptr - offsetof(type,member) );})
-
-#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
-
-static inline void __hlist_del(struct hlist_node *n)
-{
- struct hlist_node *next = n->next;
- struct hlist_node **pprev = n->pprev;
- *pprev = next;
- if (next)
- next->pprev = pprev;
-}
-
-static inline void hlist_del(struct hlist_node *n)
-{
- __hlist_del(n);
- n->next = LIST_POISON1;
- n->pprev = LIST_POISON2;
-}
-
-static inline void hlist_del_init(struct hlist_node *n)
-{
- if (n->pprev) {
- __hlist_del(n);
- INIT_HLIST_NODE(n);
- }
-}
-
-static inline void hlist_add_before(struct hlist_node *n,
- struct hlist_node *next)
-{
- n->pprev = next->pprev;
- n->next = next;
- next->pprev = &n->next;
- *(n->pprev) = n;
-}
-
-#define GFP_ATOMIC 0
-
-void *kmalloc (size_t len, int flags)
-{
- return malloc (len);
-}
-
-void *vmalloc (size_t len)
-{
- return malloc (len);
-}
-
-#define kfree(x) free(x)
-#define vfree(x) free(x)
-
-/***** END OF KERNEL STUFF ********/
-
-#ifdef DEBUG
-#define dbug(args...) \
- { \
- printf("%s:%d: ", __FUNCTION__, __LINE__); \
- printf(args); \
- }
-#else
-#define dbug(args...) ;
-#endif
-
-#define dlog(args...) printf(args);
-#define _stp_log(args...) printf(args);
-
-#define STP_NUM_STRINGS 5
-#define NR_CPUS 2
-
-int smp_processor_id(void)
-{
- return 0;
-}
-
-#define vscnprintf vsnprintf
-
-#include "../alloc.c"
-#include "../map.h"
-#include "../map.c"
-
-/* handle renamed functions */
-#define map_new _stp_map_new
-#define map_key_del _stp_map_key_del
-#define map_start _stp_map_start
-#define map_iter _stp_map_iter
-#define map_get_str _stp_map_get_str
-#define map_set_int64 _stp_map_set_int64
-#define map_get_int64 _stp_map_get_int64
-#define map_key_str_str _stp_map_key_str_str
-#define map_key_str _stp_map_key_str
-#define map_key_long _stp_map_key_long
-#define map_key_long_long _stp_map_key_long_long
-#define map_set_stat _stp_map_set_stat
diff --git a/runtime/tests/testl64.c b/runtime/tests/testl64.c
deleted file mode 100644
index 62b43641..00000000
--- a/runtime/tests/testl64.c
+++ /dev/null
@@ -1,134 +0,0 @@
-#include "test.h"
-
-/* testl64.c - DO NOT EDIT without updating the expected results in map.test. */
-
-/*
- key - long
- val - INT64
-
- Testing circular buffers, set, get
-*/
-
-int main ()
-{
- MAP mymap = map_new(4, INT64);
-
- map_key_long (mymap, 1);
- map_set_int64 (mymap, 2);
- printf ("mymap[%d]=%ld\n", 1, map_get_int64(mymap));
-
- map_key_long (mymap, 42);
- map_set_int64 (mymap, 83);
-
- map_key_long (mymap, 101);
- map_set_int64 (mymap, 202);
- /* at this point, we have 1, 42, and 101 in the array */
-
- printf ("mymap[%d]=%ld ", 101, map_get_int64(mymap));
- map_key_long (mymap, 1);
- printf ("mymap[%d]=%ld ", 1, map_get_int64(mymap));
- map_key_long (mymap, 42);
- printf ("mymap[%d]=%ld\n", 42, map_get_int64(mymap));
-
- map_set_int64 (mymap, 84);
- printf ("mymap[%d]=%ld\n", 42, map_get_int64(mymap));
-
- /* now try to confuse things */
- /* These won't do anything useful, but shouldn't crash */
- map_key_long (mymap, 0);
- map_key_del (mymap);
- map_key_long (mymap, 77);
- map_key_del (mymap);
- map_key_del (mymap);
- map_set_int64 (mymap,1000000);
-
- /* create and delete a key */
- map_key_long (mymap, 1024);
- map_set_int64 (mymap, 2048);
- map_key_long (mymap, 1024);
- printf ("mymap[%d]=%ld\n", 1024, map_get_int64(mymap));
- map_key_del (mymap);
- printf ("mymap[%d]=%ld\n", 1024, map_get_int64(mymap));
- map_key_long (mymap, 10);
- printf ("mymap[%d]=%ld\n", 10, map_get_int64(mymap));
-
- printf ("\n");
- struct map_node_int64 *ptr;
- for (ptr = (struct map_node_int64 *)map_start(mymap); ptr;
- ptr = (struct map_node_int64 *)map_iter (mymap, (struct map_node *)ptr))
- printf ("mymap[%ld] = %d\n", key1int(ptr), (int)ptr->val);
-
-
- printf ("\n");
- map_key_long (mymap, 1); map_key_del (mymap);
- for (ptr = (struct map_node_int64 *)map_start(mymap); ptr;
- ptr = (struct map_node_int64 *)map_iter (mymap, (struct map_node *)ptr))
- printf ("mymap[%ld] = %d\n", key1int(ptr), (int)ptr->val);
-
- printf ("\n");
- map_key_long (mymap, 42); map_key_del (mymap);
- for (ptr = (struct map_node_int64 *)map_start(mymap); ptr;
- ptr = (struct map_node_int64 *)map_iter (mymap, (struct map_node *)ptr))
- printf ("mymap[%ld] = %d\n", key1int(ptr), (int)ptr->val);
-
-
- printf ("\n");
- map_key_long (mymap, 101); map_key_del (mymap);
- for (ptr = (struct map_node_int64 *)map_start(mymap); ptr;
- ptr = (struct map_node_int64 *)map_iter (mymap, (struct map_node *)ptr))
- printf ("mymap[%ld] = %d\n", key1int(ptr), (int)ptr->val);
-
- printf ("\n");
-
- map_key_long (mymap, 10); map_set_int64 (mymap, 20);
- printf ("mymap[%d]=%ld\n", 10, map_get_int64(mymap));
-
- /* add 4 new entries, pushing "10" out */
- int i;
- for (i = 0; i < 4; i++)
- {
- map_key_long (mymap, i);
- map_set_int64 (mymap, 100 + 2 * i);
- }
- for (ptr = (struct map_node_int64 *)map_start(mymap); ptr;
- ptr = (struct map_node_int64 *)map_iter (mymap, (struct map_node *)ptr))
- printf ("mymap[%ld] = %d\n", key1int(ptr), (int)ptr->val);
-
- printf ("\n");
- /* 5, 382, 526, and 903 all hash to the same value (23) */
- /* use them to test the hash chain */
- map_key_long (mymap, 5); map_set_int64 (mymap, 1005);
- map_key_long (mymap, 382); map_set_int64 (mymap, 1382);
- map_key_long (mymap, 526); map_set_int64 (mymap, 1526);
- map_key_long (mymap, 903); map_set_int64 (mymap, 1903);
-
- for (ptr = (struct map_node_int64 *)map_start(mymap); ptr;
- ptr = (struct map_node_int64 *)map_iter (mymap, (struct map_node *)ptr))
- printf ("mymap[%ld] = %d\n", key1int(ptr), (int)ptr->val);
-
- map_key_long (mymap, 382); map_key_del (mymap);
- printf ("\n");
- for (ptr = (struct map_node_int64 *)map_start(mymap); ptr;
- ptr = (struct map_node_int64 *)map_iter (mymap, (struct map_node *)ptr))
- printf ("mymap[%ld] = %d\n", key1int(ptr), (int)ptr->val);
-
- map_key_long (mymap, 5); map_key_del (mymap);
- printf ("\n");
- for (ptr = (struct map_node_int64 *)map_start(mymap); ptr;
- ptr = (struct map_node_int64 *)map_iter (mymap, (struct map_node *)ptr))
- printf ("mymap[%ld] = %d\n", key1int(ptr), (int)ptr->val);
-
- map_key_long (mymap, 903); map_key_del (mymap);
- printf ("\n");
- for (ptr = (struct map_node_int64 *)map_start(mymap); ptr;
- ptr = (struct map_node_int64 *)map_iter (mymap, (struct map_node *)ptr))
- printf ("mymap[%ld] = %d\n", key1int(ptr), (int)ptr->val);
-
- map_key_long (mymap, 526); map_key_del (mymap);
- printf ("\n");
- for (ptr = (struct map_node_int64 *)map_start(mymap); ptr;
- ptr = (struct map_node_int64 *)map_iter (mymap, (struct map_node *)ptr))
- printf ("mymap[%ld] = %d\n", key1int(ptr), (int)ptr->val);
-
- return 0;
-}
diff --git a/runtime/tests/testl64R.c b/runtime/tests/testl64R.c
deleted file mode 100644
index b5db7228..00000000
--- a/runtime/tests/testl64R.c
+++ /dev/null
@@ -1,50 +0,0 @@
-#include "test.h"
-
-#define LLONG_MAX 9223372036854775807LL
-#define LLONG_MIN (-LLONG_MAX - 1LL)
-
-/* testl64R.c - DO NOT EDIT without updating the expected results in map.test. */
-
-/*
- key - long
- val - INT64
-
- Testing range of values
-*/
-
-int main ()
-{
- struct map_node_int64 *ptr;
- MAP mymap = map_new(4, INT64);
-
- map_key_long (mymap, 1);
- map_set_int64 (mymap, LLONG_MIN);
- map_key_long (mymap, 2);
- map_set_int64 (mymap, LLONG_MAX);
- map_key_long (mymap, 3);
- map_set_int64 (mymap, 0); /* will not be saved */
- map_key_long (mymap, 4);
- map_set_int64 (mymap, -1);
- map_key_long (mymap, 5);
- map_set_int64 (mymap, 5);
-
-
- for (ptr = (struct map_node_int64 *)map_start(mymap); ptr;
- ptr = (struct map_node_int64 *)map_iter (mymap, (struct map_node *)ptr))
- printf ("mymap[%ld] = %lld\n", key1int(ptr), (long long)ptr->val);
-
-
- /* stress test - create a million entries then print last 4 */
- int i;
- for (i = 0; i < 1000000; i++)
- {
- map_key_long (mymap, i);
- map_set_int64 (mymap, i+i);
- }
-
- for (ptr = (struct map_node_int64 *)map_start(mymap); ptr;
- ptr = (struct map_node_int64 *)map_iter (mymap, (struct map_node *)ptr))
- printf ("mymap[%ld] = %lld\n", key1int(ptr), (long long)ptr->val);
-
- return 0;
-}
diff --git a/runtime/tests/testl64_alloc.c b/runtime/tests/testl64_alloc.c
deleted file mode 100644
index fcfa6cf5..00000000
--- a/runtime/tests/testl64_alloc.c
+++ /dev/null
@@ -1,139 +0,0 @@
-#include "test.h"
-
-/* testl64_alloc.c - DO NOT EDIT without updating the expected results in map.test. */
-
-/*
- key - long
- val - INT64
- uses kalloc to allocate buffers dynamically. No circular buffers
-*/
-
-int main ()
-{
- MAP mymap = map_new(0, INT64);
-
- map_key_long (mymap, 1);
- map_set_int64 (mymap, 2);
- printf ("mymap[%d]=%ld\n", 1, map_get_int64(mymap));
-
- map_key_long (mymap, 42);
- map_set_int64 (mymap, 83);
-
- map_key_long (mymap, 101);
- map_set_int64 (mymap, 202);
- /* at this point, we have 1, 42, and 101 in the array */
-
- printf ("mymap[%d]=%ld ", 101, map_get_int64(mymap));
- map_key_long (mymap, 1);
- printf ("mymap[%d]=%ld ", 1, map_get_int64(mymap));
- map_key_long (mymap, 42);
- printf ("mymap[%d]=%ld\n", 42, map_get_int64(mymap));
-
- map_set_int64 (mymap, 84);
- printf ("mymap[%d]=%ld\n", 42, map_get_int64(mymap));
-
- /* now try to confuse things */
- /* These won't do anything useful, but shouldn't crash */
- map_key_long (mymap, 0);
- map_key_del (mymap);
- map_key_long (mymap, 77);
- map_key_del (mymap);
- map_key_del (mymap);
- map_set_int64 (mymap,1000000);
-
- /* create and delete a key */
- map_key_long (mymap, 1024);
- map_set_int64 (mymap, 2048);
- map_key_long (mymap, 1024);
- printf ("mymap[%d]=%ld\n", 1024, map_get_int64(mymap));
- map_key_del (mymap);
- printf ("mymap[%d]=%ld\n", 1024, map_get_int64(mymap));
- map_key_long (mymap, 10);
- printf ("mymap[%d]=%ld\n", 10, map_get_int64(mymap));
-
- printf ("\n");
- struct map_node_int64 *ptr;
- for (ptr = (struct map_node_int64 *)map_start(mymap); ptr;
- ptr = (struct map_node_int64 *)map_iter (mymap, (struct map_node *)ptr))
- printf ("mymap[%ld] = %d\n", key1int(ptr), (int)ptr->val);
-
-
- printf ("\n");
- map_key_long (mymap, 1); map_key_del (mymap);
- for (ptr = (struct map_node_int64 *)map_start(mymap); ptr;
- ptr = (struct map_node_int64 *)map_iter (mymap, (struct map_node *)ptr))
- printf ("mymap[%ld] = %d\n", key1int(ptr), (int)ptr->val);
-
- printf ("\n");
- map_key_long (mymap, 42); map_key_del (mymap);
- for (ptr = (struct map_node_int64 *)map_start(mymap); ptr;
- ptr = (struct map_node_int64 *)map_iter (mymap, (struct map_node *)ptr))
- printf ("mymap[%ld] = %d\n", key1int(ptr), (int)ptr->val);
-
-
- printf ("\n");
- map_key_long (mymap, 101); map_key_del (mymap);
- for (ptr = (struct map_node_int64 *)map_start(mymap); ptr;
- ptr = (struct map_node_int64 *)map_iter (mymap, (struct map_node *)ptr))
- printf ("mymap[%ld] = %d\n", key1int(ptr), (int)ptr->val);
-
- printf ("\n");
-
- map_key_long (mymap, 10); map_set_int64 (mymap, 20);
- printf ("mymap[%d]=%ld\n", 10, map_get_int64(mymap));
-
- /* add 4 new entries, NOT pushing "10" out */
- int i;
- for (i = 0; i < 4; i++)
- {
- map_key_long (mymap, i);
- map_set_int64 (mymap, 100 + 2 * i);
- }
- for (ptr = (struct map_node_int64 *)map_start(mymap); ptr;
- ptr = (struct map_node_int64 *)map_iter (mymap, (struct map_node *)ptr))
- printf ("mymap[%ld] = %d\n", key1int(ptr), (int)ptr->val);
-
- map_key_long (mymap, 10); map_key_del (mymap);
- map_key_long (mymap, 3); map_key_del (mymap);
- map_key_long (mymap, 2); map_key_del (mymap);
- map_key_long (mymap, 1); map_key_del (mymap);
- map_key_long (mymap, 0); map_key_del (mymap);
-
- /* 5, 382, 526, and 903 all hash to the same value (23) */
- /* use them to test the hash chain */
- map_key_long (mymap, 5); map_set_int64 (mymap, 1005);
- map_key_long (mymap, 382); map_set_int64 (mymap, 1382);
- map_key_long (mymap, 526); map_set_int64 (mymap, 1526);
- map_key_long (mymap, 903); map_set_int64 (mymap, 1903);
-
- printf ("\n");
- for (ptr = (struct map_node_int64 *)map_start(mymap); ptr;
- ptr = (struct map_node_int64 *)map_iter (mymap, (struct map_node *)ptr))
- printf ("mymap[%ld] = %d\n", key1int(ptr), (int)ptr->val);
-
- map_key_long (mymap, 382); map_key_del (mymap);
- printf ("\n");
- for (ptr = (struct map_node_int64 *)map_start(mymap); ptr;
- ptr = (struct map_node_int64 *)map_iter (mymap, (struct map_node *)ptr))
- printf ("mymap[%ld] = %d\n", key1int(ptr), (int)ptr->val);
-
- map_key_long (mymap, 5); map_key_del (mymap);
- printf ("\n");
- for (ptr = (struct map_node_int64 *)map_start(mymap); ptr;
- ptr = (struct map_node_int64 *)map_iter (mymap, (struct map_node *)ptr))
- printf ("mymap[%ld] = %d\n", key1int(ptr), (int)ptr->val);
-
- map_key_long (mymap, 903); map_key_del (mymap);
- printf ("\n");
- for (ptr = (struct map_node_int64 *)map_start(mymap); ptr;
- ptr = (struct map_node_int64 *)map_iter (mymap, (struct map_node *)ptr))
- printf ("mymap[%ld] = %d\n", key1int(ptr), (int)ptr->val);
-
- map_key_long (mymap, 526); map_key_del (mymap);
- printf ("\n");
- for (ptr = (struct map_node_int64 *)map_start(mymap); ptr;
- ptr = (struct map_node_int64 *)map_iter (mymap, (struct map_node *)ptr))
- printf ("mymap[%ld] = %d\n", key1int(ptr), (int)ptr->val);
-
- return 0;
-}
diff --git a/runtime/tests/testlist.c b/runtime/tests/testlist.c
deleted file mode 100644
index 7086ff9b..00000000
--- a/runtime/tests/testlist.c
+++ /dev/null
@@ -1,63 +0,0 @@
-#include "test.h"
-
-/* testliat.c - DO NOT EDIT without updating the expected results in map.test. */
-
-/*
- Tests maps acting as Lists
-*/
-
-
-
-static void
-map_dump (MAP map)
-{
- struct map_node_str *ptr;
- foreach (map, ptr)
- printf ("map[%ld] = %s\n", key1int(ptr), ptr->str);
- printf ("\n");
-}
-
-
-int main ()
-{
- char buf[32];
- int i;
- MAP map = _stp_list_new(10, STRING);
-
- for (i = 0; i < 10; i++)
- {
- sprintf (buf, "Item%d", i);
- _stp_list_add_str (map, buf);
- }
-
- map_dump(map);
- printf ("size is %d\n", _stp_list_size(map));
-
- /* we set a limit of 10 elements so these push */
- /* the first entries out of the list */
- for (i = 50; i < 55; i++)
- {
- sprintf (buf, "Item%d", i);
- _stp_list_add_str (map, buf);
- }
-
- map_dump(map);
-
- for (i = 0; i < 10; i++)
- {
- sprintf (buf, "Item%d", i);
- _stp_list_add_str (map, buf);
- }
-
- map_dump(map);
- _stp_list_clear (map);
- map_dump(map);
- for (i = 50; i < 55; i++)
- {
- sprintf (buf, "Item%d", i);
- _stp_list_add_str (map, buf);
- }
- map_dump(map);
- _stp_map_del (map);
- return 0;
-}
diff --git a/runtime/tests/testll64.c b/runtime/tests/testll64.c
deleted file mode 100644
index bfe4ae94..00000000
--- a/runtime/tests/testll64.c
+++ /dev/null
@@ -1,111 +0,0 @@
-#include "test.h"
-
-/* testll64.c - DO NOT EDIT without updating the expected results in map.test. */
-
-/*
- key - long,long
- val - INT64
-
- Testing circular buffers, set, get
-*/
-
-int main ()
-{
- struct map_node_int64 *ptr;
- MAP mymap = map_new(4, INT64);
-
- map_key_long_long (mymap, 1,1);
- map_set_int64 (mymap, 1);
- map_key_long_long (mymap, 1,2);
- map_set_int64 (mymap, 2);
- map_key_long_long (mymap, 2,1);
- map_set_int64 (mymap, 3);
-
- map_key_long_long (mymap, 1,1);
- printf ("mymap[1,1]=%ld\n", map_get_int64(mymap));
- map_key_long_long (mymap, 1,2);
- printf ("mymap[1,2]=%ld\n", map_get_int64(mymap));
- map_key_long_long (mymap, 2,1);
- printf ("mymap[2,1]=%ld\n", map_get_int64(mymap));
-
-#if 0
- map_key_long (mymap, 42);
- map_set_int64 (mymap, 83);
-
- map_key_long (mymap, 101);
- map_set_int64 (mymap, 202);
- /* at this point, we have 1, 42, and 101 in the array */
-
- printf ("mymap[%d]=%ld ", 101, map_get_int64(mymap));
- map_key_long (mymap, 1);
- printf ("mymap[%d]=%ld ", 1, map_get_int64(mymap));
- map_key_long (mymap, 42);
- printf ("mymap[%d]=%ld\n", 42, map_get_int64(mymap));
-
- map_set_int64 (mymap, 84);
- printf ("mymap[%d]=%ld\n", 42, map_get_int64(mymap));
-
- /* now try to confuse things */
- /* These won't do anything useful, but shouldn't crash */
- map_key_long (mymap, 0);
- map_key_del (mymap);
- map_key_long (mymap, 77);
- map_key_del (mymap);
- map_key_del (mymap);
- map_set_int64 (mymap,1000000);
-
- /* create and delete a key */
- map_key_long (mymap, 1024);
- map_set_int64 (mymap, 2048);
- map_key_long (mymap, 1024);
- printf ("mymap[%d]=%ld\n", 1024, map_get_int64(mymap));
- map_key_del (mymap);
- printf ("mymap[%d]=%ld\n", 1024, map_get_int64(mymap));
- map_key_long (mymap, 10);
- printf ("mymap[%d]=%ld\n", 10, map_get_int64(mymap));
-
- printf ("\n");
- for (ptr = (struct map_node_int64 *)map_start(mymap); ptr;
- ptr = (struct map_node_int64 *)map_iter (mymap, (struct map_node *)ptr))
- printf ("mymap[%ld] = %d\n", ptr->key1.val, (int)ptr->val);
-
-
- printf ("\n");
- map_key_long (mymap, 1); map_key_del (mymap);
- for (ptr = (struct map_node_int64 *)map_start(mymap); ptr;
- ptr = (struct map_node_int64 *)map_iter (mymap, (struct map_node *)ptr))
- printf ("mymap[%ld] = %d\n", ptr->key1.val, (int)ptr->val);
-
- printf ("\n");
- map_key_long (mymap, 42); map_key_del (mymap);
- for (ptr = (struct map_node_int64 *)map_start(mymap); ptr;
- ptr = (struct map_node_int64 *)map_iter (mymap, (struct map_node *)ptr))
- printf ("mymap[%ld] = %d\n", ptr->key1.val, (int)ptr->val);
-
-
- printf ("\n");
- map_key_long (mymap, 101); map_key_del (mymap);
- for (ptr = (struct map_node_int64 *)map_start(mymap); ptr;
- ptr = (struct map_node_int64 *)map_iter (mymap, (struct map_node *)ptr))
- printf ("mymap[%ld] = %d\n", ptr->key1.val, (int)ptr->val);
-
- printf ("\n");
-
- map_key_long (mymap, 10); map_set_int64 (mymap, 20);
- printf ("mymap[%d]=%ld\n", 10, map_get_int64(mymap));
-
- /* add 4 new entries, pushing "10" out */
- int i;
- for (i = 0; i < 4; i++)
- {
- map_key_long (mymap, i);
- map_set_int64 (mymap, 100 + 2 * i);
- }
-#endif
-
- for (ptr = (struct map_node_int64 *)map_start(mymap); ptr;
- ptr = (struct map_node_int64 *)map_iter (mymap, (struct map_node *)ptr))
- printf ("mymap[%ld,%ld] = %d\n", key1int(ptr), key2int(ptr),(int)ptr->val);
-
- return 0;
-}
diff --git a/runtime/tests/testlongstr.c b/runtime/tests/testlongstr.c
deleted file mode 100644
index 6dcfaf8b..00000000
--- a/runtime/tests/testlongstr.c
+++ /dev/null
@@ -1,120 +0,0 @@
-#include "test.h"
-
-/* testlongstr.c - DO NOT EDIT without updating the expected results in map.test. */
-
-/*
- key - long,str
- val - INT64
-*/
-
-
-
-static void
-map_dump (MAP map)
-{
- struct map_node_int64 *ptr;
- printf ("\n");
- for (ptr = (struct map_node_int64 *)map_start(map); ptr;
- ptr = (struct map_node_int64 *)map_iter (map, (struct map_node *)ptr))
- printf ("map[%ld,%s] = %lld\n", key1int(ptr), key2str(ptr),
- (long long)ptr->val);
- printf ("\n");
-}
-
-static void m_print (MAP map)
-{
- struct map_node_int64 *m = (struct map_node_int64 *)map->key;
- printf ("map[%ld,%s]=%lld\n", key1int(m), key2str(m),
- (long long)map_get_int64(map));
-}
-int main ()
-{
- MAP mymap = map_new(4, INT64);
-
- _stp_map_key2 (mymap, 3, "two");
- _stp_map_set (mymap, 6);
- m_print (mymap);
-
- _stp_map_key2 (mymap, 2, "eighty-four");
- map_set_int64 (mymap, 167);
-
- _stp_map_key2 (mymap, 4, "two-oh-two");
- map_set_int64 (mymap, 808);
- /* at this point, we have 6, 167, and 808 in the array */
-
- m_print (mymap);
- _stp_map_key2 (mymap, 3, "two");
- m_print (mymap);
- _stp_map_key2 (mymap, 2, "eighty-four");
- m_print (mymap);
-
- map_set_int64 (mymap, 168);
- m_print (mymap);
-
-
- /* now try to confuse things */
- /* These won't do anything useful, but shouldn't crash */
- _stp_map_key2 (mymap, 0, NULL);
- map_key_del (mymap);
-
- _stp_map_key2 (mymap, 4444, "0123456789");
- map_set_int64 (mymap,1000000);
-
- map_dump (mymap);
-
- _stp_map_key2 (mymap, 77, "66");
- map_key_del (mymap);
- map_key_del (mymap);
- map_set_int64 (mymap,99999999);
-
- /* create and delete a key */
- _stp_map_key2 (mymap, 2048, "2");
- map_set_int64 (mymap, 4096);
-
- _stp_map_key2 (mymap, 2048, "2");
- m_print (mymap);
- map_key_del (mymap);
-
- printf ("mymap[2048,2]=%ld\n", map_get_int64(mymap));
- _stp_map_key2 (mymap, 10, "six");
- printf ("mymap[10,six]=%ld\n", map_get_int64(mymap));
-
- map_dump(mymap);
-
- _stp_map_key2 (mymap, 4, "two-oh-two"); map_key_del (mymap);
- map_dump(mymap);
-
- _stp_map_key2 (mymap, 4444, "0123456789"); map_key_del (mymap);
- map_dump(mymap);
-
- _stp_map_key2 (mymap, 2, "eighty-four"); map_key_del (mymap);
- map_dump(mymap);
-
-
- _stp_map_key2 (mymap, 1801, "Ohio"); map_set_int64 (mymap, 10123456);
- map_dump(mymap);
-
- /* add 4 new entries, pushing "Ohio" out */
- int i;
- for (i = 2; i < 6; i++)
- {
- char buf[32];
- sprintf (buf, "test_number_%d", i);
- _stp_map_key2 (mymap, (long)i, buf);
- _stp_map_set_int64 (mymap, i*i*i);
- }
- map_dump (mymap);
-
- /* delete all entries */
- for (i = 2; i < 6; i++)
- {
- char buf[32];
- sprintf (buf, "test_number_%d", i);
- _stp_map_key2 (mymap, (long)i, buf);
- map_key_del (mymap);
- }
-
- printf ("Should be empty: ");
- map_dump (mymap);
- return 0;
-}
diff --git a/runtime/tests/teststat.c b/runtime/tests/teststat.c
deleted file mode 100644
index d204a585..00000000
--- a/runtime/tests/teststat.c
+++ /dev/null
@@ -1,72 +0,0 @@
-#include "test.h"
-
-/* teststat.c - DO NOT EDIT without updating the expected results in map.test. */
-
-/*
- key - str,long
- val - stat
-*/
-
-
-
-static void
-map_dump (MAP map)
-{
- struct map_node_stat *ptr;
- printf ("\n");
- foreach (map, ptr)
- printf ("map[%s,%ld] = [c=%lld s=%lld minmax =%lld,%lld]\n", key1str(ptr),
- key2int(ptr), ptr->stats.count, ptr->stats.sum, ptr->stats.min, ptr->stats.max);
- printf ("\n");
-}
-
-static void m_print (MAP map)
-{
- struct map_node_stat *m = (struct map_node_stat *)map->key;
- stat *st = _stp_map_get_stat (map);
- printf ("map[%s,%ld] = [c=%ld s=%ld minmax =%ld,%ld]\n", key1str(m), key2int(m),
- (long)st->count, (long)st->sum, (long)st->min, (long)st->max);
-}
-int main ()
-{
- stat st, *stp;
-
- MAP mymap = map_new(4, STAT);
-
- st.count = 5; st.sum = 125; st.min = 2; st.max = 42;
- _stp_map_key2 (mymap, "created with set", 2001 );
- map_set_stat (mymap, &st);
- m_print (mymap);
-
- _stp_map_stat_add (mymap, 17);
- m_print (mymap);
-
- _stp_map_key2 (mymap, "created with add", 2020 );
- _stp_map_stat_add (mymap, 1700);
- m_print (mymap);
- _stp_map_stat_add (mymap, 2);
- m_print (mymap);
- _stp_map_stat_add (mymap, 2345);
- m_print (mymap);
-
- map_dump(mymap);
- _stp_map_key2 (mymap, "created with set", 2001 ); map_key_del (mymap);
- map_dump(mymap);
- _stp_map_key2 (mymap, "created with add", 2020 );
- st.sum=123456;
- map_set_stat (mymap, &st);
- map_dump(mymap);
- map_key_del (mymap);
- map_dump(mymap);
-
- mymap = map_new(4, STAT);
- _stp_map_key2 (mymap, "created with add", 1234 );
- _stp_map_stat_add (mymap, 42);
- _stp_map_stat_add (mymap, 58);
- stp = _stp_map_get_stat (mymap);
- m_print(mymap);
- map_dump(mymap);
- _stp_map_del (mymap);
-
- return 0;
-}
diff --git a/runtime/tests/teststr.c b/runtime/tests/teststr.c
deleted file mode 100644
index e7b06a17..00000000
--- a/runtime/tests/teststr.c
+++ /dev/null
@@ -1,117 +0,0 @@
-#include "test.h"
-
-/* teststr.c - DO NOT EDIT without updating the expected results in map.test. */
-
-/*
- key - str
- val - INT64
-
- Testing circular buffers, set, get
-*/
-
-int main ()
-{
- struct map_node_int64 *ptr;
-
- MAP mymap = map_new(4, INT64);
-
- map_key_str (mymap, "two");
- map_set_int64 (mymap, 2);
- printf ("mymap[two]=%ld\n", map_get_int64(mymap));
-
- map_key_str (mymap, "eighty-four");
- map_set_int64 (mymap, 83);
-
- map_key_str (mymap, "two-oh-two");
- map_set_int64 (mymap, 202);
- /* at this point, we have 2, 83, and 202 in the array */
-
- printf ("mymap[two-oh-two]=%ld ",map_get_int64(mymap));
- map_key_str (mymap, "two");
- printf ("mymap[two]=%ld ", map_get_int64(mymap));
- map_key_str (mymap, "eighty-four");
- printf ("mymap[eighty-four]=%ld\n", map_get_int64(mymap));
-
- map_set_int64 (mymap, 84);
- printf ("mymap[eighty-four]=%ld\n", map_get_int64(mymap));
-
-
- /* now try to confuse things */
- /* These won't do anything useful, but shouldn't crash */
- map_key_str (mymap, NULL);
- map_key_del (mymap);
-
- map_key_str (mymap, "0123456789");
- map_set_int64 (mymap,1000000);
-
- printf ("\n");
-
- for (ptr = (struct map_node_int64 *)map_start(mymap); ptr;
- ptr = (struct map_node_int64 *)map_iter (mymap, (struct map_node *)ptr))
- printf ("mymap[%s] = %d\n", key1str(ptr), (int)ptr->val);
-
- map_key_str (mymap, "77");
- map_key_del (mymap);
- map_key_del (mymap);
- map_set_int64 (mymap,99999999);
-
- /* create and delete a key */
- map_key_str (mymap, "2048");
- map_set_int64 (mymap, 2048);
-
- //map_key_str (mymap, "2048");
- printf ("mymap[2048]=%ld\n", map_get_int64(mymap));
- map_key_del (mymap);
-
- printf ("mymap[2048]=%ld\n", map_get_int64(mymap));
- map_key_str (mymap, "10");
- printf ("mymap[10]=%ld\n", map_get_int64(mymap));
-
- printf ("\n");
- for (ptr = (struct map_node_int64 *)map_start(mymap); ptr;
- ptr = (struct map_node_int64 *)map_iter (mymap, (struct map_node *)ptr))
- printf ("mymap[%s] = %d\n", key1str(ptr), (int)ptr->val);
-
- printf ("\n");
- map_key_str (mymap, "two-oh-two"); map_key_del (mymap);
- for (ptr = (struct map_node_int64 *)map_start(mymap); ptr;
- ptr = (struct map_node_int64 *)map_iter (mymap, (struct map_node *)ptr))
- printf ("mymap[%s] = %d\n", key1str(ptr), (int)ptr->val);
-
- printf ("\n");
- map_key_str (mymap, "eighty-four"); map_key_del (mymap);
- for (ptr = (struct map_node_int64 *)map_start(mymap); ptr;
- ptr = (struct map_node_int64 *)map_iter (mymap, (struct map_node *)ptr))
- printf ("mymap[%s] = %d\n", key1str(ptr), (int)ptr->val);
-
- printf ("\n");
- map_key_str (mymap, "0123456789"); map_key_del (mymap);
- for (ptr = (struct map_node_int64 *)map_start(mymap); ptr;
- ptr = (struct map_node_int64 *)map_iter (mymap, (struct map_node *)ptr))
- printf ("mymap[%s] = %d\n", key1str(ptr), (int)ptr->val);
-
- printf ("\n");
-
- map_key_str (mymap, "Ohio"); map_set_int64 (mymap, 10123456);
- printf ("mymap[Ohio]=%ld\n",map_get_int64(mymap));
-
- for (ptr = (struct map_node_int64 *)map_start(mymap); ptr;
- ptr = (struct map_node_int64 *)map_iter (mymap, (struct map_node *)ptr))
- printf ("mymap[%s] = %d\n", key1str(ptr), (int)ptr->val);
- printf ("\n");
-
- /* add 4 new entries, pushing "Ohio" out */
- int i;
- for (i = 0; i < 4; i++)
- {
- char buf[32];
- sprintf (buf, "test_number_%d", i);
- map_key_str (mymap, buf);
- map_set_int64 (mymap, 1000 + i);
- }
- for (ptr = (struct map_node_int64 *)map_start(mymap); ptr;
- ptr = (struct map_node_int64 *)map_iter (mymap, (struct map_node *)ptr))
- printf ("mymap[%s] = %d\n", key1str(ptr), (int)ptr->val);
-
- return 0;
-}
diff --git a/runtime/tests/teststrlong.c b/runtime/tests/teststrlong.c
deleted file mode 100644
index 83301d12..00000000
--- a/runtime/tests/teststrlong.c
+++ /dev/null
@@ -1,114 +0,0 @@
-#include "test.h"
-
-/* teststrlong.c - DO NOT EDIT without updating the expected results in map.test. */
-
-/*
- key - str,long
- val - INT64
-*/
-
-
-
-static void
-map_dump (MAP map)
-{
- struct map_node_int64 *ptr;
- printf ("\n");
- for (ptr = (struct map_node_int64 *)map_start(map); ptr;
- ptr = (struct map_node_int64 *)map_iter (map, (struct map_node *)ptr))
- printf ("map[%s,%ld] = %lld\n", key1str(ptr), key2int(ptr),
- (long long)ptr->val);
- printf ("\n");
-}
-
-static void m_print (MAP map)
-{
- struct map_node_int64 *m = (struct map_node_int64 *)map->key;
- printf ("map[%s,%ld]=%lld\n", key1str(m), key2int(m),
- (long long)map_get_int64(map));
-}
-int main ()
-{
- MAP mymap = map_new(4, INT64);
-
- _stp_map_key2 (mymap, "two", 3);
- _stp_map_set (mymap, 6);
- m_print (mymap);
-
- _stp_map_key2 (mymap, "eighty-four", 2);
- map_set_int64 (mymap, 167);
-
- _stp_map_key2 (mymap, "two-oh-two", 4);
- map_set_int64 (mymap, 808);
- /* at this point, we have 6, 167, and 808 in the array */
-
- m_print (mymap);
- _stp_map_key2 (mymap, "two", 3);
- m_print (mymap);
- _stp_map_key2 (mymap, "eighty-four", 2);
- m_print (mymap);
-
- map_set_int64 (mymap, 168);
- m_print (mymap);
-
-
- /* now try to confuse things */
- /* These won't do anything useful, but shouldn't crash */
- _stp_map_key2 (mymap, NULL, 0);
- map_key_del (mymap);
-
- _stp_map_key2 (mymap, "0123456789", 4444);
- map_set_int64 (mymap,1000000);
-
- map_dump (mymap);
-
- _stp_map_key2 (mymap, "77", 66);
- map_key_del (mymap);
- map_key_del (mymap);
- map_set_int64 (mymap,99999999);
-
- /* create and delete a key */
- _stp_map_key2 (mymap, "2048", 2);
- map_set_int64 (mymap, 4096);
-
- _stp_map_key2 (mymap, "2048", 2);
- m_print (mymap);
- map_key_del (mymap);
-
- printf ("mymap[2048,2]=%ld\n", map_get_int64(mymap));
- _stp_map_key2 (mymap, "six", 10);
- printf ("mymap[six,10]=%ld\n", map_get_int64(mymap));
-
- map_dump(mymap);
-
- _stp_map_key2 (mymap, "two-oh-two", 4); map_key_del (mymap);
- map_dump(mymap);
-
-
- _stp_map_key2 (mymap, "Ohio", 1801); map_set_int64 (mymap, 10123456);
- map_dump(mymap);
-
- /* add 4 new entries, pushing "Ohio" out */
- int i;
- for (i = 2; i < 6; i++)
- {
- char buf[32];
- sprintf (buf, "test_number_%d", i);
- _stp_map_key2 (mymap, buf, (long)i);
- _stp_map_set_int64 (mymap, i*i*i);
- }
- map_dump (mymap);
-
- /* delete all entries */
- for (i = 2; i < 6; i++)
- {
- char buf[32];
- sprintf (buf, "test_number_%d", i);
- _stp_map_key2 (mymap, buf, (long)i);
- map_key_del (mymap);
- }
-
- printf ("Should be empty: ");
- map_dump (mymap);
- return 0;
-}
diff --git a/runtime/tests/teststrstr.c b/runtime/tests/teststrstr.c
deleted file mode 100644
index 86a2419b..00000000
--- a/runtime/tests/teststrstr.c
+++ /dev/null
@@ -1,103 +0,0 @@
-#include "test.h"
-
-/* teststrstr.c - DO NOT EDIT without updating the expected results in map.test. */
-
-/*
- key - str,str
- val - INT64
-
- Testing circular buffers, set, get
-*/
-
-int main ()
-{
- struct map_node_int64 *ptr;
- MAP mymap = map_new(4, INT64);
-
- map_key_str_str (mymap, "two", "three");
- map_set_int64 (mymap, 6);
- printf ("mymap[two,three]=%ld\n", map_get_int64(mymap));
-
- map_key_str_str (mymap, "eighty-four", "two");
- map_set_int64 (mymap, 167);
-
- map_key_str_str (mymap, "two-oh-two", "four");
- map_set_int64 (mymap, 808);
- /* at this point, we have 6, 167, and 808 in the array */
-
- printf ("mymap[two-oh-two,four]=%ld ",map_get_int64(mymap));
- map_key_str_str (mymap, "two", "three");
- printf ("mymap[two,three]=%ld ", map_get_int64(mymap));
- map_key_str_str (mymap, "eighty-four", "two");
- printf ("mymap[eighty-four,two]=%ld\n", map_get_int64(mymap));
-
- map_set_int64 (mymap, 168);
- printf ("mymap[eighty-four,two]=%ld\n", map_get_int64(mymap));
-
-
- /* now try to confuse things */
- /* These won't do anything useful, but shouldn't crash */
- map_key_str_str (mymap, NULL, NULL);
- map_key_del (mymap);
-
- map_key_str_str (mymap, "0123456789", "foo");
- map_set_int64 (mymap,1000000);
-
- printf ("\n");
- for (ptr = (struct map_node_int64 *)map_start(mymap); ptr;
- ptr = (struct map_node_int64 *)map_iter (mymap, (struct map_node *)ptr))
- printf ("mymap[%s,%s] = %d\n", key1str(ptr), key2str(ptr), (int)ptr->val);
-
- map_key_str_str (mymap, "77", "66");
- map_key_del (mymap);
- map_key_del (mymap);
- map_set_int64 (mymap,99999999);
-
- /* create and delete a key */
- map_key_str_str (mymap, "2048", "2");
- map_set_int64 (mymap, 4096);
-
- map_key_str_str (mymap, "2048", "2");
- printf ("mymap[2048,2]=%ld\n", map_get_int64(mymap));
- map_key_del (mymap);
-
- printf ("mymap[2048,2]=%ld\n", map_get_int64(mymap));
- map_key_str_str (mymap, "10", "six");
- printf ("mymap[10,six]=%ld\n", map_get_int64(mymap));
-
- printf ("\n");
- for (ptr = (struct map_node_int64 *)map_start(mymap); ptr;
- ptr = (struct map_node_int64 *)map_iter (mymap, (struct map_node *)ptr))
- printf ("mymap[%s,%s] = %d\n", key1str(ptr), key2str(ptr), (int)ptr->val);
-
- map_key_str_str (mymap, "two-oh-two", "four"); map_key_del (mymap);
- printf ("\n");
- for (ptr = (struct map_node_int64 *)map_start(mymap); ptr;
- ptr = (struct map_node_int64 *)map_iter (mymap, (struct map_node *)ptr))
- printf ("mymap[%s,%s] = %d\n", key1str(ptr), key2str(ptr), (int)ptr->val);
-
-
- map_key_str_str (mymap, "Ohio", "1801"); map_set_int64 (mymap, 10123456);
- printf ("\n");
- for (ptr = (struct map_node_int64 *)map_start(mymap); ptr;
- ptr = (struct map_node_int64 *)map_iter (mymap, (struct map_node *)ptr))
- printf ("mymap[%s,%s] = %d\n", key1str(ptr), key2str(ptr), (int)ptr->val);
-
- /* add 4 new entries, pushing "Ohio" out */
- int i;
- for (i = 2; i < 6; i++)
- {
- char buf[32], buf2[32];
- sprintf (buf, "test_number_%d", i);
- sprintf (buf2, "**test number %d**", i*i);
- map_key_str_str (mymap, buf, buf2);
- map_set_int64 (mymap, i*i*i);
- }
- printf ("\n");
- for (ptr = (struct map_node_int64 *)map_start(mymap); ptr;
- ptr = (struct map_node_int64 *)map_iter (mymap, (struct map_node *)ptr))
- printf ("mymap[%s,%s] = %d\n", key1str(ptr), key2str(ptr), (int)ptr->val);
-
-
- return 0;
-}
diff --git a/runtime/tests/teststrstrstr.c b/runtime/tests/teststrstrstr.c
deleted file mode 100644
index 95ffc1a2..00000000
--- a/runtime/tests/teststrstrstr.c
+++ /dev/null
@@ -1,121 +0,0 @@
-#include "test.h"
-
-/* teststrstrstr.c - DO NOT EDIT without updating the expected results in map.test. */
-
-/*
- key - str,str
- val - str
-*/
-
-
-
-static void
-map_dump (MAP map)
-{
- struct map_node_str *ptr;
- printf ("\n");
- for (ptr = (struct map_node_str *)map_start(map); ptr;
- ptr = (struct map_node_str *)map_iter (map, (struct map_node *)ptr))
- printf ("map[%s,%s] = %s\n", key1str(ptr), key2str(ptr), ptr->str);
- printf ("\n");
-}
-
-static void m_print (MAP map)
-{
- struct map_node_str *m = (struct map_node_str *)map->key;
- printf ("map[%s,%s]=%s\n", key1str(m), key2str(m), map_get_str(map));
-}
-int main ()
-{
- MAP mymap = map_new(4, STRING);
-
- _stp_map_key2 (mymap, "two", "2" );
- _stp_map_set (mymap, "four");
- m_print (mymap);
-
- _stp_map_key2 (mymap, "eighty-four", "nineteen hundred");
- _stp_map_set (mymap, "nineteen hundred and eighty-three");
-
- _stp_map_key2 (mymap, "two-two-one-B", "Baker Street");
- _stp_map_set (mymap, "7% solution");
-
- m_print (mymap);
- _stp_map_key2 (mymap, "two", "2");
- m_print (mymap);
- _stp_map_key2 (mymap, "eighty-four", "nineteen hundred");
- m_print (mymap);
-
- _stp_map_set (mymap, "nineteen hundred and eighty-four");
- m_print (mymap);
-
-
- /* now try to confuse things */
- /* These won't do anything useful, but shouldn't crash */
- _stp_map_key2 (mymap, NULL, NULL);
- map_key_del (mymap);
-
- _stp_map_key2 (mymap, "0123456789", "4444");
- _stp_map_set (mymap,"1000000");
-
- map_dump (mymap);
-
- _stp_map_key2 (mymap, "77", "66");
- map_key_del (mymap);
- map_key_del (mymap);
- _stp_map_set (mymap,"99999999");
-
- /* create and delete a key */
- _stp_map_key2 (mymap, "2048", "2");
- _stp_map_set (mymap, "4096");
-
- _stp_map_key2 (mymap, "2048", "2");
- m_print (mymap);
- map_key_del (mymap);
-
- printf ("mymap[2048,2]=%s\n", map_get_str(mymap));
- _stp_map_key2 (mymap, "six", "10");
- printf ("mymap[six,10]=%s\n", map_get_str(mymap));
-
- map_dump(mymap);
-
- _stp_map_key2 (mymap, "two-two-one-B", "Baker Street"); map_key_del (mymap);
- map_dump(mymap);
-
-
- _stp_map_key2 (mymap, "abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ", NULL);
- _stp_map_set (mymap, "TESTING 1,2,3");
-
- _stp_map_key2 (mymap, "abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZhiasdhgfiudsgfiusdgfisdugfisdugfsdiufgsdfiugsdifugsdiufgsdiufgisdugfisdugfigsdfiusdgfiugsdifu sdfigsdifugsdifugsdiufgsdiufgisdugfiudsgfisudgfiusdgfiusdgfisdugfisdufgiusdfgsdiufgdsiufgsdiufgsdiufgsdiufgwiugfw89e4rf98yf897ywef98wyef98wyf98wyf89ys9d8yfsd sdfysd98fy9s8fyds98fy98dsfy89sdfy", "yw98fty98sfts98d7fts89d7f9sdfoooooooooooooooooooooooooooooooooooooooooooof8eo7stfew87fwet8tw87rf7fpowft7ewfptpwefpwetfpwepwfwetfp8we");
-
- _stp_map_set (mymap, "TESTING 1,2,3 ***************************************************************************************************************************************************************************************************************************************************************************** 4,5,6");
- map_dump(mymap);
-
- /* add 4 new entries, pushing "Ohio" out */
- int i;
- for (i = 2; i < 6; i++)
- {
- char buf[32], buf2[32], buf3[32];
- sprintf (buf, "test_number_%d", i);
- sprintf (buf2, "TEST_NUMBER_%d", i*i);
- sprintf (buf3, "TEST_NUMBER_%d", i*i*i);
- _stp_map_key2 (mymap, buf, buf2);
- _stp_map_set_str (mymap, buf3);
- }
- map_dump (mymap);
-
- /* delete all entries */
- for (i = 2; i < 6; i++)
- {
- char buf[32], buf2[32], buf3[32];
- sprintf (buf, "test_number_%d", i);
- sprintf (buf2, "TEST_NUMBER_%d", i*i);
- sprintf (buf3, "TEST_NUMBER_%d", i*i*i);
- _stp_map_key2 (mymap, buf, buf2);
- map_key_del (mymap);
- }
-
- printf ("Should be empty: ");
- map_dump (mymap);
- _stp_map_del (mymap);
- return 0;
-}