-
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
2 changed files
with
87 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ enable_testing() | |
include( GoogleTest ) | ||
|
||
set ( TESTS | ||
auxiliary.cpp | ||
interface_c.cpp ) | ||
|
||
|
||
|
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,86 @@ | ||
#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"; | ||
const char * custom_depot_path = "/tmp/julia-depot"; | ||
|
||
// unset depot path environment variable | ||
unsetenv(depot_envvar); | ||
|
||
// let it be set explictly and check | ||
update_depot_path( julia_project_path, custom_depot_path ); | ||
EXPECT_STREQ( getenv(depot_envvar), custom_depot_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 | ||
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"); | ||
} |