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

chore add wf4 tests #40

Merged
merged 9 commits into from
Apr 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ jobs:
make docker

- name: Run Tests
timeout-minutes: 5
timeout-minutes: 15
run: |
CONTAINER_CMD="make run-tests" \
IMAGE_NAME="${{ env.IMAGE_NAME }}" \
Expand Down
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ set(BUILD_TESTING "${BUILD_TESTING_SAVED}")
set(PHMAP_DIRECTORY ${Galois_SOURCE_DIR}/external/parallel-hashmap)
set(PCG_DIRECTORY ${Galois_SOURCE_DIR}/external/pcg-cpp/include)

# wf4 target
add_library(wf4-galois)
add_library(wf4-galois::wf4-galois ALIAS wf4-galois)

add_subdirectory(microbench)
add_subdirectory(scripts)
add_subdirectory(wf4)
Expand Down
6 changes: 2 additions & 4 deletions cmake/GaloisCompilerOptions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@

include_guard()

option(GALOIS_WERROR "Make all warnings into errors." ON)

# Default compiler options for targets
function(galois_compiler_options TARGET)
set_target_properties(${TARGET}
Expand All @@ -25,12 +23,12 @@ endfunction()
function(galois_compiler_warnings TARGET)
target_compile_options(${TARGET} PRIVATE
$<$<CXX_COMPILER_ID:MSVC>:/W4 /WX>
$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wall -Wextra -Wpedantic $<$<BOOL:${GALOIS_WERROR}>:-Werror>>
$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wall -Wextra -Wpedantic>
)
endfunction()

function(galois_add_executable TARGET)
add_executable(${TARGET} ${ARGN})
#galois_compiler_warnings(${TARGET})
galois_compiler_warnings(${TARGET})
galois_compiler_options(${TARGET})
endfunction()
34 changes: 31 additions & 3 deletions cmake/GaloisTesting.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ FetchContent_MakeAvailable(googletest)

include(GoogleTest)

include(${PROJECT_SOURCE_DIR}/cmake/GaloisCompilerOptions.cmake)
include(${graph-log-sketch_SOURCE_DIR}/cmake/GaloisCompilerOptions.cmake)

#
# options
Expand All @@ -25,17 +25,19 @@ option(GALOIS_TEST_DISCOVERY "Enable test discovery for use with ctest." ON)
if (${GALOIS_TEST_DISCOVERY})
set(GALOIS_TEST_DISCOVERY_TIMEOUT "" CACHE STRING "GoogleTest test discover timeout in seconds")
endif ()
set(GALOIS_TEST_DISCOVERY_TIMEOUT "120" CACHE STRING "Test timeout (secs)")

#
# functions
#

# Adds a source file as a GoogleTest based test
function(galois_add_test TARGET SOURCEFILE)
add_executable(${TARGET} ${SOURCEFILE})
function(galois_add_test TARGET LIBRARY SOURCEFILE)
galois_add_executable(${TARGET} ${SOURCEFILE})
target_link_libraries(${TARGET}
PRIVATE
GTest::gtest_main
${LIBRARY}
)
galois_compiler_options(${TARGET})
galois_compiler_warnings(${TARGET})
Expand All @@ -51,3 +53,29 @@ function(galois_add_test TARGET SOURCEFILE)
endif ()
endif ()
endfunction()

set(NUM_PROCS 2)

# Adds a source file as a GoogleTest based test using mpirun to launch it
function(galois_add_driver_test TARGET LIBRARY SOURCEFILE)
galois_add_executable(${TARGET} ${graph-log-sketch_SOURCE_DIR}/test/test_driver.cpp ${SOURCEFILE})
target_link_libraries(${TARGET}
PRIVATE
GTest::gtest
${LIBRARY}
)
galois_compiler_options(${TARGET})
galois_compiler_warnings(${TARGET})
set_property(TARGET ${TARGET} PROPERTY CROSSCOMPILING_EMULATOR 'mpirun -np ${NUM_PROCS}')

if (${GALOIS_TEST_DISCOVERY})
if (NOT DEFINED ${GALOIS_TEST_DISCOVERY_TIMEOUT})
# use default test discovery timeout
gtest_discover_tests(${TARGET})
else ()
gtest_discover_tests(${TARGET}
DISCOVERY_TIMEOUT ${GALOIS_TEST_DISCOVERY_TIMEOUT}
)
endif ()
endif ()
endfunction()
11 changes: 5 additions & 6 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
# SPDX-License-Identifier: BSD-2-Clause
# Copyright (c) 2023. University of Texas at Austin. All rights reserved.

galois_add_test(bfs-test test-algo-bfs.cpp)
target_link_libraries(bfs-test PRIVATE Galois::shmem)
galois_add_test(bfs-test Galois::shmem test-algo-bfs.cpp)
target_include_directories(bfs-test PRIVATE ${graph-log-sketch_SOURCE_DIR}/include)

galois_add_test(tc-test test-algo-tc.cpp)
target_link_libraries(tc-test PRIVATE Galois::shmem)
galois_add_test(tc-test Galois::shmem test-algo-tc.cpp)
target_include_directories(tc-test PRIVATE ${graph-log-sketch_SOURCE_DIR}/include)

galois_add_test(bc-test test-algo-bc.cpp)
target_link_libraries(bc-test PRIVATE Galois::shmem)
galois_add_test(bc-test Galois::shmem test-algo-bc.cpp)
target_include_directories(bc-test PRIVATE ${graph-log-sketch_SOURCE_DIR}/include)

add_subdirectory(wf4)
35 changes: 35 additions & 0 deletions test/test_driver.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// SPDX-License-Identifier: BSD-2-Clause
// Copyright (c) 2023. University of Texas at Austin. All rights reserved.

#include <gtest/gtest.h>

#include <stdio.h>
#include <stdlib.h>

#include "galois/DistGalois.h"

namespace {

bool isDiscoveringTests(int argc, char** argv) {
for (int64_t i = 0; i < argc; i++) {
if (std::string(argv[i]) == "--gtest_list_tests") {
return true;
}
}
return false;
}

} // namespace

int main(int argc, char** argv) {
bool discoveringTests = isDiscoveringTests(argc, argv);
::testing::InitGoogleTest(&argc, argv);
galois::DistMemSys G;
auto& net = galois::runtime::getSystemNetworkInterface();
int result = 0;

if (net.ID == 0 || !discoveringTests) {
result = RUN_ALL_TESTS();
}
return result;
}
10 changes: 3 additions & 7 deletions test/wf4/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
# SPDX-License-Identifier: BSD-2-Clause
# Copyright (c) 2023. University of Texas at Austin. All rights reserved.

enable_testing()

add_executable(influencer_test influencer_test.cpp)
target_link_libraries(influencer_test GTest::gtest_main)

include(GoogleTest)
gtest_discover_tests(influencer_test)
galois_add_driver_test(wf4_import_test wf4-galois::wf4-galois test_import.cpp)
galois_add_driver_test(wf4_influence_maximization_test wf4-galois::wf4-galois test_influence_maximization.cpp)
galois_add_driver_test(wf4_quiesce_test wf4-galois::wf4-galois test_quiesce.cpp)
12 changes: 0 additions & 12 deletions test/wf4/influencer_test.cpp

This file was deleted.

Loading