Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unit tests configurations for emp_games #1875

Closed
xsu2-sc opened this issue Nov 2, 2022 · 1 comment
Closed

Unit tests configurations for emp_games #1875

xsu2-sc opened this issue Nov 2, 2022 · 1 comment

Comments

@xsu2-sc
Copy link

xsu2-sc commented Nov 2, 2022

Hello Facebook team,

I am attempting to run the unit tests within the repo using CLion IDE. To be more specific, I am trying to setting up pcf2's unit tests by extending the CMakeLists.txt file under fbpcs/docker/emp_games. Currently, I can successfully load CMakeLists.txt but keep having a linker error below. My understanding is the complier complains about the missing dependency of folly package within the fbpcf.

====================[ Build | pcf2_attribution_calculator_test | Debug - pcs ]====
/usr/bin/cmake --build /root/snap-int-fbpcs/cmake-build-debug---pcs --target pcf2_attribution_calculator_test -- -j 8
[ 13%] Built target empgamecommon
[ 33%] Built target gtest
[ 40%] Built target perftools
[ 53%] Built target gtest_main
[ 60%] Linking CXX executable bin/pcf2_attribution_calculator_test
/usr/bin/ld: /usr/local/lib/libfbpcf.a(S3Util.cpp.o): in function `fbpcf::aws::uriToObjectReference(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)':
S3Util.cpp:(.text+0x87d): undefined reference to `folly::Uri::Uri(folly::Range<char const*>)'
/usr/bin/ld: /usr/local/lib/libfbpcf.a(GCSUtil.cpp.o): in function `fbpcf::gcp::uriToObjectReference(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)':
GCSUtil.cpp:(.text+0x1dd): undefined reference to `folly::Uri::Uri(folly::Range<char const*>)'
/usr/bin/ld: CMakeFiles/pcf2_attribution_calculator_test.dir/fbpcs/emp_games/pcf2_attribution/test/AttributionAppTest.cpp.o: in function `pcf2_attribution::verifyOutput(pcf2_attribution::AttributionOutputMetrics, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)':
/root/snap-int-fbpcs/fbpcs/emp_games/pcf2_attribution/test/AttributionTestUtils.h:31: undefined reference to `folly::compareJson(folly::Range<char const*>, folly::Range<char const*>)'
collect2: error: ld returned 1 exit status
make[3]: *** [CMakeFiles/pcf2_attribution_calculator_test.dir/build.make:222: bin/pcf2_attribution_calculator_test] Error 1
make[2]: *** [CMakeFiles/Makefile2:226: CMakeFiles/pcf2_attribution_calculator_test.dir/all] Error 2
make[1]: *** [CMakeFiles/Makefile2:233: CMakeFiles/pcf2_attribution_calculator_test.dir/rule] Error 2
make: *** [Makefile:201: pcf2_attribution_calculator_test] Error 2

However, when I looked over this website and double-checked the common.cmake within the fbpcs repo, I believe the folly package has been already included in the common cmake. Furthermore, since the CMakeLists.txt I am using now has already include("common.cmake"), the Uri should have been included. Please feel free to correct me if I am wrong.

I also try copying the following block of code into the CMakeLists.txt but the same linker error still show up:

find_package(folly REQUIRED)
set_and_check(FOLLY_INCLUDE_DIR /usr/local/include/folly)
set_and_check(FOLLY_CMAKE_DIR /usr/local/lib/cmake/folly)
if(NOT TARGET Folly::folly)
    include("${FOLLY_CMAKE_DIR}/folly-targets.cmake")
endif()
if(NOT folly_FIND_QUIETLY)
    message(STATUS "Found folly: ${PACKAGE_PREFIX_DIR}")
endif()

The following represents my sample code for building a gtest target:

# Test - pcf2_aggregation_test
file(GLOB pcf2_aggregation_test_src
        "fbpcs/emp_games/pcf2_aggregation/**.h"
        "fbpcs/emp_games/pcf2_aggregation/**.cpp"
        "fbpcs/emp_games/pcf2_aggregation/test/**.h"
        "fbpcs/emp_games/pcf2_aggregation/test/**.cpp"
        "fbpcs/emp_games/common/TestUtil.**"
)
add_executable(
        pcf2_aggregation_calculator_test
        ${pcf2_aggregation_test_src})
target_link_libraries(
        pcf2_aggregation_calculator_test
        empgamecommon
        perftools
        gtest_main
        Folly:folly
)
install(TARGETS pcf2_aggregation_calculator_test DESTINATION bin)

Could you please share any advice with me on how to proceed with setting up unit tests? Many thanks in advance!

Context:

  1. I copy-paste the CMakeLists.txt file under fbpcs/docker/emp_games to the root directory and then try extending files upon that.
  2. I also have fbpcf repo under the same directory as fbpcs.

Best regards,
Hokssey

@xsu2-sc xsu2-sc changed the title Unit tests configurations Unit tests configurations for emp_games Nov 2, 2022
@xsu2-sc xsu2-sc changed the title Unit tests configurations for emp_games [Snapchat Team] Unit tests configurations for emp_games Nov 3, 2022
@xsu2-sc xsu2-sc changed the title [Snapchat Team] Unit tests configurations for emp_games Unit tests configurations for emp_games Nov 3, 2022
@xsu2-sc
Copy link
Author

xsu2-sc commented Nov 3, 2022

I was able to figure out this issue by my own. Thanks for your consideration!

@xsu2-sc xsu2-sc closed this as completed Nov 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant