diff options
author | Christophe Milard <christophe.milard@linaro.org> | 2015-05-20 18:11:28 +0200 |
---|---|---|
committer | Mike Holmes <mike.holmes@linaro.org> | 2015-05-27 10:11:28 -0400 |
commit | 21028c8775c7c0956326e9fa34909751a5421605 (patch) | |
tree | 876156d4436ebac054cbf7bb356f5eb3c42b54a5 /test/validation/init/odp_init_log.c | |
parent | ee48c657b52d0f8dd8a11c18c62bce8920935c3e (diff) |
validation: init src files in single directory
The 3 tests for initialisation still generate 3 executables,
but their sources are simply gathered in a single directory called as
the module itself, init.
And other cosmetic fixes to please check-odp.
Signed-off-by: Christophe Milard <christophe.milard@linaro.org>
Signed-off-by: Mike Holmes <mike.holmes@linaro.org>
Diffstat (limited to 'test/validation/init/odp_init_log.c')
-rw-r--r-- | test/validation/init/odp_init_log.c | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/test/validation/init/odp_init_log.c b/test/validation/init/odp_init_log.c new file mode 100644 index 000000000..98cc0599b --- /dev/null +++ b/test/validation/init/odp_init_log.c @@ -0,0 +1,80 @@ +/* Copyright (c) 2015, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include <stdarg.h> +#include <odp.h> +#include <CUnit/Basic.h> + +int replacement_logging_used; + +ODP_PRINTF_FORMAT(2, 3) +static int odp_init_log(odp_log_level_e level, const char *fmt, ...); + +static void test_odp_init_global_replace_log(void) +{ + int status; + struct odp_init_t init_data; + + memset(&init_data, 0, sizeof(init_data)); + init_data.log_fn = &odp_init_log; + + replacement_logging_used = 0; + + status = odp_init_global(&init_data, NULL); + CU_ASSERT_FATAL(status == 0); + + CU_ASSERT_TRUE(replacement_logging_used); + + status = odp_term_global(); + CU_ASSERT(status == 0); +} + +CU_TestInfo test_odp_init[] = { + {"replace log", test_odp_init_global_replace_log}, + CU_TEST_INFO_NULL, +}; + +CU_SuiteInfo odp_testsuites[] = { + {"Init", NULL, NULL, NULL, NULL, test_odp_init}, + CU_SUITE_INFO_NULL, +}; + +int main(void) +{ + int ret; + + printf("\tODP API version: %s\n", odp_version_api_str()); + printf("\tODP implementation version: %s\n", odp_version_impl_str()); + + CU_set_error_action(CUEA_ABORT); + + CU_initialize_registry(); + CU_register_suites(odp_testsuites); + CU_basic_set_mode(CU_BRM_VERBOSE); + CU_basic_run_tests(); + + ret = CU_get_number_of_failure_records(); + + CU_cleanup_registry(); + + return ret; +} + +int odp_init_log(odp_log_level_e level __attribute__((unused)), + const char *fmt, ...) +{ + va_list args; + int r; + + /* just set a flag to be sure the replacement fn was used */ + replacement_logging_used = 1; + + va_start(args, fmt); + r = vfprintf(stderr, fmt, args); + va_end(args); + + return r; +} |