This is an automated email from the ASF dual-hosted git repository. pengzheng pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/celix.git
The following commit(s) were added to refs/heads/master by this push: new 2275fd41 Fix test_dfi fails new 399785e4 Merge pull request #493 from xuzhenbao/fix_test_dfi_fails 2275fd41 is described below commit 2275fd4176ac432df846011a751cf6c7cdd372bd Author: xuzhenbao <xuzhenbao...@163.com> AuthorDate: Fri Mar 3 10:57:07 2023 +0800 Fix test_dfi fails --- libs/dfi/gtest/CMakeLists.txt | 6 ------ libs/dfi/gtest/src/dyn_avpr_function_tests.cpp | 19 ++++++++++--------- libs/dfi/gtest/src/dyn_function_tests.cpp | 6 +++--- 3 files changed, 13 insertions(+), 18 deletions(-) diff --git a/libs/dfi/gtest/CMakeLists.txt b/libs/dfi/gtest/CMakeLists.txt index 2ae8c232..83e30adc 100644 --- a/libs/dfi/gtest/CMakeLists.txt +++ b/libs/dfi/gtest/CMakeLists.txt @@ -32,12 +32,6 @@ add_executable(test_dfi src/avrobin_serialization_tests.cpp ) -#[[ -Note: setting optimize -O0 for the dfi test, because this is needed to get the -DynFunctionTests.DynFuncTest2 and DynFunctionTests.DynFuncTest3 working. -See issue #232 -]] -target_compile_options(test_dfi PRIVATE -O0) #This is needed because target_include_directories(test_dfi PRIVATE ${CMAKE_CURRENT_LIST_DIR}/../src) target_link_libraries(test_dfi PRIVATE Celix::dfi Celix::utils libffi::libffi jansson::jansson GTest::gtest GTest::gtest_main) diff --git a/libs/dfi/gtest/src/dyn_avpr_function_tests.cpp b/libs/dfi/gtest/src/dyn_avpr_function_tests.cpp index fd507a76..541fa3db 100644 --- a/libs/dfi/gtest/src/dyn_avpr_function_tests.cpp +++ b/libs/dfi/gtest/src/dyn_avpr_function_tests.cpp @@ -20,6 +20,7 @@ #include "gtest/gtest.h" #include <celix_utils.h> +#include <ffi.h> extern "C" { #include <stdio.h> @@ -259,7 +260,7 @@ TEST_F(DynAvprFunctionTests, Example1) { values[2] = &b; values[3] = &c; values[4] = &p_out; - int rVal = 1; + ffi_sarg rVal = 1; int rc = dynFunction_call(dynFunc, fp, &rVal, values); ASSERT_EQ(0, rc); @@ -305,7 +306,7 @@ TEST_F(DynAvprFunctionTests, Example2) { values[2] = &arg2; values[3] = &c; values[4] = &p_out; - int rVal = 1; + ffi_sarg rVal = 1; int rc = dynFunction_call(dynFunc, fp, &rVal, values); ASSERT_EQ(0, rc); @@ -366,7 +367,7 @@ TEST(DynAvprFunctionTests, Example4) { args[2] = &a; args[3] = &input; args[4] = &out_ptr; - int rVal = 1; + ffi_sarg rVal = 1; int rc = dynFunction_call(dynFunc, fp, &rVal, args); ASSERT_EQ(0, rc); @@ -422,7 +423,7 @@ TEST_F(DynAvprFunctionTests, Example5) { args[0] = &handle_ptr; args[1] = &seq; args[2] = &out_ptr; - int retArg = 1; + ffi_sarg retArg = 1; int rc = dynFunction_call(dynFunc, fp, &retArg, args); ASSERT_EQ(0, rc); @@ -464,7 +465,7 @@ TEST_F(DynAvprFunctionTests, Example6) { values[0] = &handle_ptr; values[1] = &argument; values[2] = &out_ptr; - int rVal = 1; + ffi_sarg rVal = 1; int rc = dynFunction_call(dynFunc, fp, &rVal, values); ASSERT_EQ(0, rc); @@ -508,7 +509,7 @@ TEST_F(DynAvprFunctionTests, Example7) { args[0] = &handle_ptr; args[1] = &s_seq; args[2] = &out_ptr; - int rVal = 0; + ffi_sarg rVal = 0; int rc = dynFunction_call(dynFunc, fp, &rVal, args); ASSERT_EQ(0, rc); @@ -549,7 +550,7 @@ TEST_F(DynAvprFunctionTests, Example8) { args[0] = &handle_ptr; args[1] = &arg1; args[2] = &out_ptr_ptr; - int rVal = 0; + ffi_sarg rVal = 0; int rc = dynFunction_call(dynFunc, fp, &rVal, args); ASSERT_EQ(0, rc); @@ -581,7 +582,7 @@ TEST_F(DynAvprFunctionTests, Example9) { void *args[2]; args[0] = &handle_ptr; args[1] = &out_ptr; - int rVal = 1; + ffi_sarg rVal = 1; int rc = dynFunction_call(dynFunc, fp, &rVal, args); ASSERT_EQ(0, rc); @@ -621,7 +622,7 @@ TEST_F(DynAvprFunctionTests, Example10) { void *args[2]; args[0] = &handle_ptr; args[1] = &out_ptr_ptr; - int rVal = 1; + ffi_sarg rVal = 1; int rc = dynFunction_call(dynFunc, fp, &rVal, args); ASSERT_EQ(0, rc); diff --git a/libs/dfi/gtest/src/dyn_function_tests.cpp b/libs/dfi/gtest/src/dyn_function_tests.cpp index 18dbf10a..7f0ba0dc 100644 --- a/libs/dfi/gtest/src/dyn_function_tests.cpp +++ b/libs/dfi/gtest/src/dyn_function_tests.cpp @@ -24,7 +24,7 @@ #include "dyn_common.h" #include "dyn_function.h" - +#include <ffi.h> static void stdLog(void*, int level, const char *file, int line, const char *msg, ...) { va_list ap; @@ -62,7 +62,7 @@ extern "C" { rc = dynFunction_parseWithStr(EXAMPLE1_DESCRIPTOR, nullptr, &dynFunc); - int32_t rVal = 0; + ffi_sarg rVal = 0; int32_t a = 2; int32_t b = 4; int32_t c = 8; @@ -173,7 +173,7 @@ static bool func_test3() { args[0] = &ptr; args[1] = &a; args[2] = &input; - int rVal = 0; + ffi_sarg rVal = 0; rc = dynFunction_call(dynFunc, fp, &rVal, args);