From: Justin Seyster Date: Thu, 2 Sep 2010 21:46:46 +0000 (-0400) Subject: Added test case for matching floating point types. X-Git-Tag: release-v1.0~49^2~2 X-Git-Url: https://git.fsl.cs.stonybrook.edu/?a=commitdiff_plain;h=c1cf0075baf7dbd686f8d086f96161a1ce8e4549;p=interaspect.git Added test case for matching floating point types. --- diff --git a/test/Makefile.am b/test/Makefile.am index ba7b3db..60cfc79 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -2,5 +2,5 @@ if HAVE_PYTHON 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 +TESTS = int-types.xml float-types.xml endif diff --git a/test/float-types-hooks.c b/test/float-types-hooks.c new file mode 100644 index 0000000..6282702 --- /dev/null +++ b/test/float-types-hooks.c @@ -0,0 +1,21 @@ +#include + +void _advice_all(const char *func, double n1, double n2) +{ + printf("ALL advice in %s (%.20f, %.20f)\n", func, n1, n2); +} + +void _advice_32(const char *func, float n1, float n2) +{ + printf("32 advice in %s (%.20f, %.20f)\n", func, (double)n1, (float)n2); +} + +void _advice_64(const char *func, double n1, double n2) +{ + printf("64 advice in %s (%.20f, %.20f)\n", func, n1, n2); +} + +void _advice_128(const char *func, long double n1, long double n2) +{ + printf("128 advice in %s (%.20Lf, %.20Lf)\n", func, n1, n2); +} diff --git a/test/float-types-target.c b/test/float-types-target.c new file mode 100644 index 0000000..c9fcc1d --- /dev/null +++ b/test/float-types-target.c @@ -0,0 +1,23 @@ +#include + +void binary32(float n) +{ + printf("single:\t%.20f\n", (double)n); +} + +void binary64(double n) +{ + printf("double:\t%.20f\n", n); +} + +void binary128(long double n) +{ + printf("quad:\t%.20Lf\n", n); +} + +void run_test() +{ + binary32((float)1/3); + binary64((double)1/3); + binary128((long double)1/3); +} diff --git a/test/float-types.xml b/test/float-types.xml new file mode 100644 index 0000000..1deb6a4 --- /dev/null +++ b/test/float-types.xml @@ -0,0 +1,18 @@ + + + + + + + + ALL advice in binary32 (0.33333334326744079590, 0.33333334326744079590) + 32 advice in binary32 (0.33333334326744079590, 0.33333334326744079590) + single: 0.33333334326744079590 + ALL advice in binary64 (0.33333333333333331483, 0.33333333333333331483) + 64 advice in binary64 (0.33333333333333331483, 0.33333333333333331483) + double: 0.33333333333333331483 + 128 advice in binary128 (0.33333333333333333334, 0.33333333333333333334) + quad: 0.33333333333333333334 + + + diff --git a/test/plugin-float-types.c b/test/plugin-float-types.c new file mode 100644 index 0000000..e6902e1 --- /dev/null +++ b/test/plugin-float-types.c @@ -0,0 +1,44 @@ +#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; + const char *name; + struct aop_dynval *n; + + name = aop_capture_called_function_name(jp); + n = aop_capture_param(jp, 0); + aop_insert_advice(jp, advice_name, AOP_INSERT_BEFORE, AOP_STR_CST(name), AOP_DYNVAL(n), AOP_DYNVAL(n), AOP_TERM_ARG); +} + +static unsigned int plugin_float() +{ + struct aop_pointcut *pc; + + pc = aop_match_function_call(); + aop_filter_call_pc_by_param(pc, 0, aop_t_all_fp()); + aop_join_on(pc, plugin_join_on_call, "_advice_all"); + + pc = aop_match_function_call(); + aop_filter_call_pc_by_param(pc, 0, aop_t_float32()); + aop_join_on(pc, plugin_join_on_call, "_advice_32"); + + pc = aop_match_function_call(); + aop_filter_call_pc_by_param(pc, 0, aop_t_float64()); + aop_join_on(pc, plugin_join_on_call, "_advice_64"); + + pc = aop_match_function_call(); + aop_filter_call_pc_by_param(pc, 0, aop_t_float128()); + aop_join_on(pc, plugin_join_on_call, "_advice_128"); + + return 0; +} + +AOP_MAIN_PROTO aop_main() +{ + aop_register_pass("float", plugin_float); +}