From: Justin Seyster Date: Thu, 23 Sep 2010 00:24:27 +0000 (-0400) Subject: Added test case for inparams. X-Git-Tag: release-v1.0~40^2~4 X-Git-Url: https://git.fsl.cs.stonybrook.edu/?a=commitdiff_plain;h=f55aedd8ff12ffc443889a5d1b85e890510894ce;p=interaspect.git Added test case for inparams. --- diff --git a/test/Makefile.am b/test/Makefile.am index d600a10..7426101 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -3,5 +3,5 @@ TESTS_ENVIRONMENT = $(PYTHON) $(srcdir)/run-testcase.py --with-gcc=$(CC) \ --with-ia-lib-dir=$(top_builddir)/src/.libs \ --with-ia-src-dir=$(top_srcdir) --with-tests-dir=$(srcdir) TESTS = int-types.xml float-types.xml pointer-types.xml struct-types.xml \ - reinst.xml noinstrument.xml duplicate.xml + reinst.xml noinstrument.xml duplicate.xml inparam.xml endif diff --git a/test/inparam-hooks.c b/test/inparam-hooks.c new file mode 100644 index 0000000..5e51636 --- /dev/null +++ b/test/inparam-hooks.c @@ -0,0 +1,7 @@ +#include +#include + +void _advice_foo(int64_t a, double b) +{ + printf("Foo entry advice: (%d, %f)\n", (int)a, (double)b); +} diff --git a/test/inparam-target.c b/test/inparam-target.c new file mode 100644 index 0000000..c8af30b --- /dev/null +++ b/test/inparam-target.c @@ -0,0 +1,12 @@ +#include + +void foo(int a, float b) +{ + printf("In foo: (%d, %f)\n", a, (double)b); +} + +void run_test() +{ + foo(12, 1.2); + foo(34, 3.4); +} diff --git a/test/inparam.xml b/test/inparam.xml new file mode 100644 index 0000000..de3c1de --- /dev/null +++ b/test/inparam.xml @@ -0,0 +1,17 @@ + + + + + + + + Foo entry advice: (12, 1.200000) + In foo: (12, 1.200000) + Foo entry advice: (34, 3.400000) + In foo: (34, 3.400000) + + + void _advice_foo(ALL_SIGNED_T, ALL_FP_T); + + + diff --git a/test/plugin-inparam.c b/test/plugin-inparam.c new file mode 100644 index 0000000..bb08381 --- /dev/null +++ b/test/plugin-inparam.c @@ -0,0 +1,47 @@ +#include +#include +#include + +AOP_I_AM_GPL_COMPATIBLE(); + +static void plugin_join_on_call(struct aop_joinpoint *jp, void *data) +{ + const char *advice_name = data; + struct aop_dynval *p1; + struct aop_dynval *p2; + + p1 = aop_capture_in_param(jp, 0); + p2 = aop_capture_in_param(jp, 1); + aop_insert_advice(jp, advice_name, AOP_INSERT_BEFORE, AOP_DYNVAL(p1), AOP_DYNVAL(p2), AOP_TERM_ARG); +} + +static unsigned int plugin_int() +{ + struct aop_pointcut *pc; + + pc = aop_match_function_entry(); + aop_filter_entry_by_name(pc, "foo"); + aop_filter_entry_by_in_param(pc, 0, aop_t_all_signed()); + aop_filter_entry_by_in_param(pc, 1, aop_t_all_fp()); + aop_join_on(pc, plugin_join_on_call, "_advice_foo"); + + return 0; +} + +void aop_finish() +{ + const char *header; + header = aop_get_arg_value("header"); + + if (header != NULL) { + int res; + res = aop_write_c_header(header, NULL, NULL, NULL); + if (res != 0) + perror(header); + } +} + +AOP_MAIN_PROTO aop_main() +{ + aop_register_pass("int", plugin_int); +}