summaryrefslogtreecommitdiffstats
path: root/runtime/tests/string/string2.c
diff options
context:
space:
mode:
authorhunt <hunt>2005-05-19 05:25:26 +0000
committerhunt <hunt>2005-05-19 05:25:26 +0000
commit7edfd9e24568502f54175b08da4168f2af6642fe (patch)
treeaa2d578a4d7d99fef111a179e51a90198be0f2c1 /runtime/tests/string/string2.c
parent752870c4bea5f43859ec4e10ae2579018908bbe3 (diff)
downloadsystemtap-steved-7edfd9e24568502f54175b08da4168f2af6642fe.tar.gz
systemtap-steved-7edfd9e24568502f54175b08da4168f2af6642fe.tar.xz
systemtap-steved-7edfd9e24568502f54175b08da4168f2af6642fe.zip
Add String test files.
Diffstat (limited to 'runtime/tests/string/string2.c')
-rw-r--r--runtime/tests/string/string2.c68
1 files changed, 68 insertions, 0 deletions
diff --git a/runtime/tests/string/string2.c b/runtime/tests/string/string2.c
new file mode 100644
index 00000000..ccf3997a
--- /dev/null
+++ b/runtime/tests/string/string2.c
@@ -0,0 +1,68 @@
+/* test of Strings */
+
+/* use very small buffer size for testing */
+#define STP_STRING_SIZE 20
+#define STP_NUM_STRINGS 1
+#include "runtime.h"
+
+int main ()
+{
+ String str = _stp_string_init (0);
+
+ /* can we see output? */
+ _stp_sprintf(str, "ABCDE\n");
+ _stp_print(str);
+
+
+ /* overflow */
+ str = _stp_string_init (0);
+ _stp_sprintf(str, "1234567890123456789012345\n");
+ _stp_sprintf(str, "XYZZY\n");
+ _stp_print(str);
+ _stp_printf("\n");
+
+ /* small string then overflow string */
+ str = _stp_string_init (0);
+ _stp_sprintf(str,"XYZZY\n");
+ _stp_sprintf(str,"1234567890123456789012345");
+ _stp_print(str);
+ _stp_printf("\n");
+
+ /* two small string that overflow */
+ str = _stp_string_init (0);
+ _stp_sprintf(str,"abcdefghij");
+ _stp_sprintf(str,"123456789");
+ _stp_print(str);
+ _stp_printf("\n");
+
+ /* two small string that overflow */
+ str = _stp_string_init (0);
+ _stp_sprintf(str,"abcdefghij");
+ _stp_sprintf(str,"1234567890X");
+ _stp_print(str);
+ _stp_printf("\n");
+
+ str = _stp_string_init (0);
+ _stp_sprintf(str,"12345\n");
+ _stp_sprintf(str,"67890\n");
+ _stp_sprintf(str,"abcde\n");
+ _stp_print(str);
+
+ str = _stp_string_init (0);
+ _stp_sprintf(str,"12345");
+ _stp_sprintf(str,"67890");
+ _stp_sprintf(str,"abcde");
+ _stp_sprintf(str,"fghij");
+ _stp_print(str);
+ _stp_printf("\n");
+
+ /* null string */
+ str = _stp_string_init (0);
+ _stp_sprintf(str,"");
+ _stp_sprintf(str,"");
+ _stp_sprintf(str,"Q\n");
+ _stp_print(str);
+
+ _stp_print_flush();
+ return 0;
+}