-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
384 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
enable_testing() | ||
|
||
include( GoogleTest ) | ||
|
||
set ( TESTS | ||
auxiliary.cpp | ||
interface_c.cpp ) | ||
|
||
|
||
foreach ( TEST ${TESTS} ) | ||
|
||
get_filename_component ( TEST_BASE ${TEST} NAME_WE ) | ||
|
||
# define target | ||
set ( TARGET_NAME ${TEST_BASE} ) | ||
add_executable ( ${TARGET_NAME} ${TEST}) | ||
|
||
# set libraries to link | ||
target_link_libraries( | ||
${TARGET_NAME} | ||
PRIVATE MPI::MPI_C ${PROJECT_NAME} ${PROJECT_NAME}_tls GTest::gtest_main | ||
) | ||
|
||
# set include directories | ||
target_include_directories( | ||
${TARGET_NAME} | ||
PRIVATE ${CMAKE_SOURCE_DIR}/src | ||
) | ||
|
||
# set runtime path for installed binaries | ||
set_target_properties( | ||
${TARGET_NAME} | ||
PROPERTIES INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib" | ||
) | ||
|
||
# enable warnings | ||
target_compile_options( ${TARGET_NAME} PRIVATE -Wall -Wextra -Werror ) | ||
|
||
# pass julia project path | ||
target_compile_definitions( ${TARGET_NAME} PRIVATE | ||
JULIA_PROJECT_PATH=\"${JULIA_PROJECT_PATH}\" ) | ||
|
||
# discover tests | ||
gtest_discover_tests( ${TARGET_NAME} ) | ||
|
||
endforeach() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
#include <gtest/gtest.h> | ||
|
||
|
||
extern "C" { | ||
int show_debug_output(); | ||
void update_depot_path(const char * project_directory, const char * depot_path); | ||
} | ||
|
||
// Julia project path defined via cmake | ||
const char * julia_project_path = JULIA_PROJECT_PATH; | ||
|
||
const char* default_depot_path = "julia-depot"; | ||
|
||
|
||
TEST(AuxiliaryTest, DebugOutput) { | ||
|
||
const char * envvar = "LIBTRIXI_DEBUG"; | ||
|
||
// environment variable not set -> no debug output | ||
unsetenv(envvar); | ||
EXPECT_EQ( show_debug_output(), 0 ); | ||
|
||
// environment variable set to "all" -> debug output | ||
setenv(envvar, "all", /*overwrite*/ 1 ); | ||
EXPECT_EQ( show_debug_output(), 1 ); | ||
|
||
// environment variable set to "c" -> debug output | ||
setenv(envvar, "c", /*overwrite*/ 1 ); | ||
EXPECT_EQ( show_debug_output(), 1 ); | ||
|
||
// environment variable set to "julia" -> no debug output | ||
setenv(envvar, "julia", /*overwrite*/ 1 ); | ||
EXPECT_EQ( show_debug_output(), 0 ); | ||
} | ||
|
||
|
||
TEST(AuxiliaryTest, DepotPath) { | ||
|
||
const char * depot_envvar = "JULIA_DEPOT_PATH"; | ||
|
||
// unset depot path environment variable | ||
unsetenv(depot_envvar); | ||
|
||
// let it be set explicitly and check | ||
update_depot_path( julia_project_path, julia_project_path ); | ||
EXPECT_STREQ( getenv(depot_envvar), julia_project_path ); | ||
|
||
// unset depot path environment variable | ||
unsetenv(depot_envvar); | ||
|
||
// let it be set to default location and check | ||
update_depot_path( julia_project_path, NULL ); | ||
std::string expected_depot_path( julia_project_path ); | ||
expected_depot_path.append("/"); | ||
expected_depot_path.append( default_depot_path ); | ||
EXPECT_STREQ( getenv(depot_envvar), expected_depot_path.c_str() ); | ||
|
||
// unset depot path environment variable | ||
unsetenv(depot_envvar); | ||
|
||
// be evil: use probably non-existing project path | ||
const char * garbage_path = "/no/where"; | ||
EXPECT_DEATH( update_depot_path( garbage_path, NULL ), | ||
"could not resolve depot path"); | ||
|
||
// unset depot path environment variable | ||
unsetenv(depot_envvar); | ||
|
||
// be evil: use too long project path | ||
const char * garbage = "this_string_is_just_way_toooooooooooooooooooo_long" | ||
"this_string_is_just_way_toooooooooooooooooooo_long" | ||
"this_string_is_just_way_toooooooooooooooooooo_long" | ||
"this_string_is_just_way_toooooooooooooooooooo_long" | ||
"this_string_is_just_way_toooooooooooooooooooo_long" | ||
"this_string_is_just_way_toooooooooooooooooooo_long" | ||
"this_string_is_just_way_toooooooooooooooooooo_long" | ||
"this_string_is_just_way_toooooooooooooooooooo_long" | ||
"this_string_is_just_way_toooooooooooooooooooo_long" | ||
"this_string_is_just_way_toooooooooooooooooooo_long" | ||
"this_string_is_just_way_toooooooooooooooooooo_long" | ||
"this_string_is_just_way_toooooooooooooooooooo_long" | ||
"this_string_is_just_way_toooooooooooooooooooo_long" | ||
"this_string_is_just_way_toooooooooooooooooooo_long" | ||
"this_string_is_just_way_toooooooooooooooooooo_long" | ||
"this_string_is_just_way_toooooooooooooooooooo_long" | ||
"this_string_is_just_way_toooooooooooooooooooo_long" | ||
"this_string_is_just_way_toooooooooooooooooooo_long" | ||
"this_string_is_just_way_toooooooooooooooooooo_long" | ||
"this_string_is_just_way_toooooooooooooooooooo_long" | ||
"this_string_is_just_way_toooooooooooooooooooo_long"; | ||
EXPECT_DEATH( update_depot_path( garbage, NULL ), | ||
"buffer size not sufficient for depot path construction"); | ||
} |
Oops, something went wrong.