diff options
author | Jiri Olsa <Jiri Olsa jolsa@redhat.com> | 2011-06-17 12:54:03 +0200 |
---|---|---|
committer | Jiri Olsa <Jiri Olsa jolsa@redhat.com> | 2011-06-17 13:00:12 +0200 |
commit | 8dae1b6682b34411c4e82f44f786f0f49095598c (patch) | |
tree | d0a6bc8567e4c6b336500c841b94adc15541fb51 /test/test-common.c | |
parent | d07b36b6bb898666c313b6d3708aee82d5b80550 (diff) | |
download | latrace-8dae1b6682b34411c4e82f44f786f0f49095598c.tar.gz latrace-8dae1b6682b34411c4e82f44f786f0f49095598c.tar.xz latrace-8dae1b6682b34411c4e82f44f786f0f49095598c.zip |
test: Add test for ARGS_STRING_POINTER_LENGTH option
Diffstat (limited to 'test/test-common.c')
-rw-r--r-- | test/test-common.c | 37 |
1 files changed, 35 insertions, 2 deletions
diff --git a/test/test-common.c b/test/test-common.c index d125ad4..a34b932 100644 --- a/test/test-common.c +++ b/test/test-common.c @@ -4,7 +4,10 @@ #include <sys/types.h> extern void test_common_f1(void); +extern void test_common_args_ptrlen(char *ptr); + #define BUFSIZE 1000 +#define DATA_CNT(num) (sizeof(data ## num)/sizeof(struct re_test_data)) static int test_function(struct lt_config_shared *sh) { @@ -15,7 +18,6 @@ static int test_function(struct lt_config_shared *sh) { RE_TEST_TYPE_STR, -1, -1, "test_common_f1" }, { RE_TEST_TYPE_STR, -1, -1, "\\[.*lib-test-common.so\\]" } }; - #define DATA_CNT (sizeof(data)/sizeof(struct re_test_data)) config_clear(sh); @@ -27,7 +29,37 @@ static int test_function(struct lt_config_shared *sh) if (!ret) return -1; - ret = re_test(buf, data, DATA_CNT); + ret = re_test(buf, data, DATA_CNT()); + if (RE_TEST_OK != ret) + FAILED("test %i, pattern '%s'\n", ret, data[ret].pat); + + PASSED(); + return 0; +} + +static int test_args_ptrlen(struct lt_config_shared *sh) +{ + char buf[BUFSIZE]; + int ret; + struct re_test_data data[] = { + { RE_TEST_TYPE_PID, 1, -1, "[0-9]+" }, + { RE_TEST_TYPE_STR, -1, -1, " test_common_args_ptrlen\\(ptr = \\(0x[0-9a-z]+, 5\\) \"krava\"\\)" }, + { RE_TEST_TYPE_STR, -1, -1, "\\[.*lib-test-common.so\\]" } + }; + + config_clear(sh); + sh->args_string_pointer_length = 1; + sh->args_enabled = 1; + + TEST_START(); + test_common_args_ptrlen("krava"); + TEST_STOP(); + + ret = fout_read(sh, buf, BUFSIZE); + if (!ret) + return -1; + + ret = re_test(buf, data, DATA_CNT()); if (RE_TEST_OK != ret) FAILED("test %i, pattern '%s'\n", ret, data[ret].pat); @@ -44,5 +76,6 @@ int main(int argc, char **argv) return -1; TEST(test_function); + TEST(test_args_ptrlen); return 0; } |