summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhunt <hunt>2005-05-18 00:17:55 +0000
committerhunt <hunt>2005-05-18 00:17:55 +0000
commit042803219fdd22aed9a134d46788ed01d29e1d7c (patch)
tree232e073c1d6a9681e7c2da40af213e5c7cc0d346
parent4ed11cee2365c604b3c2a39a846706cc0ae0ac1a (diff)
downloadsystemtap-steved-042803219fdd22aed9a134d46788ed01d29e1d7c.tar.gz
systemtap-steved-042803219fdd22aed9a134d46788ed01d29e1d7c.tar.xz
systemtap-steved-042803219fdd22aed9a134d46788ed01d29e1d7c.zip
Add two new tests. Fix some warnings on i386.
-rw-r--r--runtime/tests/maps/is.c2
-rw-r--r--runtime/tests/maps/map.test73
-rw-r--r--runtime/tests/maps/si.c2
-rw-r--r--runtime/tests/maps/test_list_int64.c44
-rw-r--r--runtime/tests/maps/test_list_string.c53
5 files changed, 172 insertions, 2 deletions
diff --git a/runtime/tests/maps/is.c b/runtime/tests/maps/is.c
index 69a0b842..bfb21753 100644
--- a/runtime/tests/maps/is.c
+++ b/runtime/tests/maps/is.c
@@ -55,7 +55,7 @@ int main ()
/* 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));
+ printf ("map[%lld]=%ld\n", key1int(map->key), (long)_stp_map_get_str(map));
/* map[5] = "five" */
_stp_map_set (map, "five");
diff --git a/runtime/tests/maps/map.test b/runtime/tests/maps/map.test
index 4b72ffb7..59e213aa 100644
--- a/runtime/tests/maps/map.test
+++ b/runtime/tests/maps/map.test
@@ -264,6 +264,79 @@ map[7, 8, Oregon] = Salem
map[0, 0, ] = XX
}
+test test_list_int64 {Test of lists of int64s} -setup {
+ exec gcc $CFLAGS -I $KPATH -I $PATH -o test test_list_int64.c
+} -body {
+ exec ./test
+} -result {list[0] = 0
+list[1] = 1
+list[2] = 2
+list[3] = 3
+list[4] = 4
+list[5] = 5
+list[6] = 6
+list[7] = 7
+list[8] = 8
+list[9] = 9
+
+size is 10
+
+list[0] = 0
+list[1] = 1
+list[2] = 2
+list[3] = 3
+list[4] = 4
+list[5] = 5
+list[6] = 6
+list[7] = 7
+list[8] = 8
+list[9] = 9
+
+
+newlist[0] = 50
+newlist[1] = 51
+newlist[2] = 52
+newlist[3] = 53
+newlist[4] = 54
+}
+
+
+test test_list_string {Test of lists of strings} -setup {
+ exec gcc $CFLAGS -I $KPATH -I $PATH -o test test_list_string.c
+} -body {
+ exec ./test
+} -result {list[0] = Item0
+list[1] = Item1
+list[2] = Item2
+list[3] = Item3
+list[4] = Item4
+list[5] = Item5
+list[6] = Item6
+list[7] = Item7
+list[8] = Item8
+list[9] = Item9
+
+size is 10
+
+list[0] = Item0
+list[1] = Item1
+list[2] = Item2
+list[3] = Item3
+list[4] = Item4
+list[5] = Item5
+list[6] = Item6
+list[7] = Item7
+list[8] = Item8
+list[9] = Item9
+
+
+newlist[0] = Item50
+newlist[1] = Item51
+newlist[2] = Item52
+newlist[3] = Item53
+newlist[4] = Item54
+}
+
exec rm test
cleanupTests
diff --git a/runtime/tests/maps/si.c b/runtime/tests/maps/si.c
index 4f3e3f35..0e88bc4e 100644
--- a/runtime/tests/maps/si.c
+++ b/runtime/tests/maps/si.c
@@ -74,7 +74,7 @@ int main ()
{
char buf[32];
sprintf (buf, "String %d", i);
- _stp_map_key (map, buf);
+ _stp_map_key_str (map, buf);
_stp_map_set_int64 (map, 100 + i);
}
diff --git a/runtime/tests/maps/test_list_int64.c b/runtime/tests/maps/test_list_int64.c
new file mode 100644
index 00000000..4355cb45
--- /dev/null
+++ b/runtime/tests/maps/test_list_int64.c
@@ -0,0 +1,44 @@
+#include "runtime.h"
+
+/* test of list with value of STRING */
+
+#define KEY1_TYPE INT64
+#include "map-keys.c"
+
+#define VALUE_TYPE INT64
+#include "map-values.c"
+
+#include "list.c"
+
+int main ()
+{
+ int i;
+
+ MAP map = _stp_list_new (10, INT64);
+
+ for (i = 0; i < 10; i++)
+ _stp_list_add_int64 (map, (int64_t)i);
+
+
+ _stp_map_print(map, "list");
+ printf ("size is %d\n\n", _stp_list_size(map));
+
+ /* we set a limit of 10 elements so these */
+ /* won't be added to the list */
+ for (i = 50; i < 55; i++)
+ _stp_list_add_int64 (map, i);
+ _stp_map_print(map, "list");
+
+
+ _stp_list_clear (map);
+ _stp_map_print(map, "list");
+
+ for (i = 50; i < 55; i++)
+ _stp_list_add_int64 (map, i);
+
+ _stp_map_print(map, "newlist");
+
+ _stp_map_del (map);
+
+ return 0;
+}
diff --git a/runtime/tests/maps/test_list_string.c b/runtime/tests/maps/test_list_string.c
new file mode 100644
index 00000000..5edae41f
--- /dev/null
+++ b/runtime/tests/maps/test_list_string.c
@@ -0,0 +1,53 @@
+#include "runtime.h"
+
+/* test of list with value of STRING */
+
+#define KEY1_TYPE INT64
+#include "map-keys.c"
+
+#define VALUE_TYPE STRING
+#include "map-values.c"
+
+#include "map.c"
+#include "list.c"
+
+int main ()
+{
+ int i;
+ char buf[32];
+
+ MAP map = _stp_list_new (10, STRING);
+
+ for (i = 0; i < 10; i++)
+ {
+ sprintf (buf, "Item%d", i);
+ _stp_list_add_str (map, buf);
+ }
+
+ _stp_map_print(map, "list");
+ printf ("size is %d\n\n", _stp_list_size(map));
+
+ /* we set a limit of 10 elements so these */
+ /* won't be added to the list */
+ for (i = 50; i < 55; i++)
+ {
+ sprintf (buf, "Item%d", i);
+ _stp_list_add_str (map, buf);
+ }
+ _stp_map_print(map, "list");
+
+
+ _stp_list_clear (map);
+ _stp_map_print(map, "list");
+
+ for (i = 50; i < 55; i++)
+ {
+ sprintf (buf, "Item%d", i);
+ _stp_list_add_str (map, buf);
+ }
+ _stp_map_print(map, "newlist");
+
+ _stp_map_del (map);
+
+ return 0;
+}