Skip to content

Commit

Permalink
platform-specfic testing is decided in the translation-units
Browse files Browse the repository at this point in the history
  • Loading branch information
supervacuus committed Mar 7, 2024
1 parent 77f6785 commit a1c4e26
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
15 changes: 3 additions & 12 deletions tests/unit/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ sentry_get_property(INCLUDE_DIRECTORIES)
sentry_get_property(LINK_LIBRARIES)
sentry_get_property(INTERFACE_LINK_LIBRARIES)

set(SENTRY_UNIT_TEST_SOURCES
add_executable(sentry_test_unit
${SENTRY_SOURCES}
main.c
sentry_testsupport.h
test_attachments.c
Expand All @@ -28,6 +29,7 @@ set(SENTRY_UNIT_TEST_SOURCES
test_modulefinder.c
test_mpack.c
test_options.c
test_os_release.c
test_path.c
test_ratelimiter.c
test_sampling.c
Expand All @@ -44,17 +46,6 @@ set(SENTRY_UNIT_TEST_SOURCES
tests.inc
)

if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
list(APPEND SENTRY_UNIT_TEST_SOURCES
test_os_release.c
)
endif()

add_executable(sentry_test_unit
${SENTRY_SOURCES}
${SENTRY_UNIT_TEST_SOURCES}
)

# FIXME: cmake 3.13 introduced target_link_options
target_compile_definitions(sentry_test_unit PRIVATE ${SENTRY_COMPILE_DEFINITIONS})
target_include_directories(sentry_test_unit PRIVATE
Expand Down
8 changes: 7 additions & 1 deletion tests/unit/test_os_release.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#include "sentry_path.h"
#include "sentry_testsupport.h"

#include <dirent.h>
#ifdef SENTRY_PLATFORM_LINUX
# include <dirent.h>

struct distro {
char *name;
Expand Down Expand Up @@ -122,9 +123,13 @@ assert_equals_snap(sentry_value_t os_dist)
}

extern sentry_value_t get_linux_os_release(const char *os_rel_path);
#endif

SENTRY_TEST(os_releases_snapshot)
{
#ifndef SENTRY_PLATFORM_LINUX
SKIP_TEST();
#else
const char *rel_test_data_path = "../fixtures/os_releases";
sentry_path_t *path = sentry__path_from_str(__FILE__);
sentry_path_t *dir = sentry__path_dir(path);
Expand Down Expand Up @@ -166,4 +171,5 @@ SENTRY_TEST(os_releases_snapshot)

closedir(test_data_dir);
sentry__path_free(test_data_path);
#endif
}

0 comments on commit a1c4e26

Please sign in to comment.