From 958c654a682425163748aa83cf8f21d05671b200 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Wed, 19 Aug 2026 21:38:17 +0200 Subject: [PATCH 1/5] feat(native): add platform integration hook Allow downstream platform SDKs to register an integration without replacing sentry_init(). Add an integration fixture that verifies a mixture of SDK metadata, platform scope data, and application event data. --- CMakeLists.txt | 16 +++++ src/sentry_core.c | 5 +- src/sentry_core.h | 5 +- src/sentry_integration.h | 12 ++++ src/sentry_options.c | 14 ++++- src/sentry_options.h | 4 +- tests/fixtures/test_platform/CMakeLists.txt | 9 +++ tests/fixtures/test_platform/test_platform.c | 46 ++++++++++++++ tests/test_integration_platform.py | 63 ++++++++++++++++++++ tests/unit/test_basic.c | 2 +- 10 files changed, 167 insertions(+), 9 deletions(-) create mode 100644 tests/fixtures/test_platform/CMakeLists.txt create mode 100644 tests/fixtures/test_platform/test_platform.c create mode 100644 tests/test_integration_platform.py diff --git a/CMakeLists.txt b/CMakeLists.txt index e955145be8..3aefdaba60 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -115,6 +115,14 @@ option(SENTRY_BUILD_TESTS "Build sentry-native tests" "${SENTRY_MAIN_PROJECT}") option(SENTRY_BUILD_EXAMPLES "Build sentry-native example(s)" "${SENTRY_MAIN_PROJECT}") option(SENTRY_BUILD_BENCHMARKS "Build sentry-native benchmarks" OFF) +set(SENTRY_INTEGRATION_PLATFORM "" CACHE STRING + "Downstream-provided platform integration to create automatically") +if(NOT SENTRY_INTEGRATION_PLATFORM STREQUAL "" + AND NOT SENTRY_INTEGRATION_PLATFORM MATCHES "^[A-Za-z_][A-Za-z0-9_]*$") + message(FATAL_ERROR + "SENTRY_INTEGRATION_PLATFORM must be empty or a valid C identifier") +endif() + # Platform version embedding options option(SENTRY_EMBED_INFO "Embed version information in binary" OFF) set(SENTRY_BUILD_PLATFORM "${CMAKE_SYSTEM_NAME}" CACHE STRING "Platform name for embedded version (e.g., switch, playstation, xbox)") @@ -298,6 +306,7 @@ message(STATUS "SENTRY_TRANSPORT=${SENTRY_TRANSPORT}") message(STATUS "SENTRY_BACKEND=${SENTRY_BACKEND}") message(STATUS "SENTRY_LIBRARY_TYPE=${SENTRY_LIBRARY_TYPE}") message(STATUS "SENTRY_SDK_NAME=${SENTRY_SDK_NAME}") +message(STATUS "SENTRY_INTEGRATION_PLATFORM=${SENTRY_INTEGRATION_PLATFORM}") message(STATUS "SENTRY_HANDLER_STACK_SIZE=${SENTRY_HANDLER_STACK_SIZE}") message(STATUS "SENTRY_BATCHER_BUFFER_COUNT=${SENTRY_BATCHER_BUFFER_COUNT}") if (WIN32) @@ -419,6 +428,10 @@ endif() add_subdirectory(src) +if(NOT SENTRY_INTEGRATION_PLATFORM STREQUAL "") + target_compile_definitions(sentry PRIVATE SENTRY_INTEGRATION_PLATFORM) +endif() + target_compile_definitions(sentry PRIVATE SENTRY_HANDLER_STACK_SIZE=${SENTRY_HANDLER_STACK_SIZE}) target_compile_definitions(sentry PRIVATE SENTRY_BATCHER_BUFFER_COUNT=${SENTRY_BATCHER_BUFFER_COUNT}) if(WIN32) @@ -1030,6 +1043,9 @@ if(SENTRY_BUILD_TESTS) add_subdirectory(tests/unit) add_subdirectory(tests/fixtures/crash_reporter) add_subdirectory(tests/fixtures/early_init) + if(SENTRY_INTEGRATION_PLATFORM STREQUAL "test") + add_subdirectory(tests/fixtures/test_platform) + endif() add_subdirectory(tests/fixtures/screenshot) if(WIN32 AND NOT XBOX) add_subdirectory(tests/fixtures/appx) diff --git a/src/sentry_core.c b/src/sentry_core.c index b87e36c599..969443a0ef 100644 --- a/src/sentry_core.c +++ b/src/sentry_core.c @@ -117,8 +117,9 @@ unregister_integrations(sentry_scope_t *scope, const sentry_options_t *options) } } -#if defined(SENTRY_PLATFORM_NX) || defined(SENTRY_PLATFORM_PS) \ - || defined(SENTRY_PLATFORM_XBOX) +#if (defined(SENTRY_PLATFORM_NX) || defined(SENTRY_PLATFORM_PS) \ + || defined(SENTRY_PLATFORM_XBOX)) \ + && !defined(SENTRY_INTEGRATION_PLATFORM) int sentry__native_init(sentry_options_t *options) #else diff --git a/src/sentry_core.h b/src/sentry_core.h index b2ac8ae072..1e45c37e03 100644 --- a/src/sentry_core.h +++ b/src/sentry_core.h @@ -162,8 +162,9 @@ bool sentry__should_send_transaction( sentry_value_t tx_ctx, sentry_sampling_context_t *sampling_ctx); #endif -#if defined(SENTRY_PLATFORM_NX) || defined(SENTRY_PLATFORM_PS) \ - || defined(SENTRY_PLATFORM_XBOX) +#if (defined(SENTRY_PLATFORM_NX) || defined(SENTRY_PLATFORM_PS) \ + || defined(SENTRY_PLATFORM_XBOX)) \ + && !defined(SENTRY_INTEGRATION_PLATFORM) int sentry__native_init(sentry_options_t *options); #endif diff --git a/src/sentry_integration.h b/src/sentry_integration.h index b02e74d9b1..2bcfd52f2f 100644 --- a/src/sentry_integration.h +++ b/src/sentry_integration.h @@ -14,4 +14,16 @@ typedef struct sentry_integration_s { void (*free_func)(void *data); } sentry_integration_t; +#ifdef SENTRY_INTEGRATION_PLATFORM +# ifdef __cplusplus +extern "C" { +# endif + +sentry_integration_t *sentry_integration_platform_new(void); + +# ifdef __cplusplus +} +# endif +#endif + #endif diff --git a/src/sentry_options.c b/src/sentry_options.c index 1710ca6e1e..6da6966ef7 100644 --- a/src/sentry_options.c +++ b/src/sentry_options.c @@ -136,6 +136,13 @@ sentry_options_new(void) #ifdef SENTRY_INTEGRATION_WER sentry__options_add_integration(opts, sentry_integration_wer_new()); #endif +#ifdef SENTRY_INTEGRATION_PLATFORM + if (!sentry__options_add_integration( + opts, sentry_integration_platform_new())) { + sentry_options_free(opts); + return NULL; + } +#endif return opts; } @@ -980,12 +987,12 @@ sentry_options_set_backend(sentry_options_t *opts, sentry_backend_t *backend) opts->backend = backend; } -void +bool sentry__options_add_integration( sentry_options_t *opts, sentry_integration_t *integration) { if (!integration) { - return; + return false; } size_t new_count = opts->num_integrations + 1; @@ -993,7 +1000,7 @@ sentry__options_add_integration( = sentry__calloc(new_count, sizeof(sentry_integration_t *)); if (!integrations) { free_integration(integration); - return; + return false; } for (size_t i = 0; i < opts->num_integrations; i++) { @@ -1003,6 +1010,7 @@ sentry__options_add_integration( sentry_free(opts->integrations); opts->integrations = integrations; opts->num_integrations = new_count; + return true; } bool diff --git a/src/sentry_options.h b/src/sentry_options.h index dcdfeec729..280016a445 100644 --- a/src/sentry_options.h +++ b/src/sentry_options.h @@ -137,8 +137,10 @@ const char *sentry__options_get_org_id(const sentry_options_t *options); * * Takes ownership of `integration`. If the integration owns `data`, it must * provide `free_func`. + * + * Returns true if the integration was added. */ -void sentry__options_add_integration( +bool sentry__options_add_integration( sentry_options_t *opts, sentry_integration_t *integration); /** diff --git a/tests/fixtures/test_platform/CMakeLists.txt b/tests/fixtures/test_platform/CMakeLists.txt new file mode 100644 index 0000000000..89d94d443f --- /dev/null +++ b/tests/fixtures/test_platform/CMakeLists.txt @@ -0,0 +1,9 @@ +cmake_minimum_required(VERSION 3.10) +project(sentry_test_platform LANGUAGES C) + +target_compile_definitions(sentry PRIVATE + SENTRY_SDK_NAME="sentry.native.test") + +add_executable(sentry_test_platform test_platform.c) +target_include_directories(sentry_test_platform PRIVATE ${SENTRY_SOURCE_DIR}/src) +target_link_libraries(sentry_test_platform PRIVATE sentry) diff --git a/tests/fixtures/test_platform/test_platform.c b/tests/fixtures/test_platform/test_platform.c new file mode 100644 index 0000000000..f9da671fcb --- /dev/null +++ b/tests/fixtures/test_platform/test_platform.c @@ -0,0 +1,46 @@ +#include "sentry_alloc.h" +#include "sentry_integration.h" +#include "sentry_scope.h" + +static void +register_platform( + void *data, sentry_scope_t *scope, const sentry_options_t *options) +{ + (void)data; + (void)options; + + sentry_value_t device = sentry_value_new_object(); + sentry_value_set_by_key(device, "name", sentry_value_new_string("Test")); + sentry_value_set_by_key( + device, "model", sentry_value_new_string("test-model")); + sentry_value_set_by_key( + device, "arch", sentry_value_new_string("test-arch")); + sentry_scope_set_context(scope, "device", device); +} + +sentry_integration_t * +sentry_integration_platform_new(void) +{ + sentry_integration_t *integration = SENTRY_MAKE(sentry_integration_t); + integration->name = "test"; + integration->register_func = register_platform; + return integration; +} + +int +main(void) +{ + sentry_options_t *options = sentry_options_new(); + sentry_options_set_auto_session_tracking(options, 0); + sentry_options_set_debug(options, true); + sentry_init(options); + + sentry_set_tag("my-tag", "my-value"); + sentry_set_user(sentry_value_new_user("123", "my-user", NULL, NULL)); + + sentry_value_t event = sentry_value_new_message_event( + SENTRY_LEVEL_INFO, "my-logger", "Hello World!"); + sentry_capture_event(event); + + sentry_close(); +} diff --git a/tests/test_integration_platform.py b/tests/test_integration_platform.py new file mode 100644 index 0000000000..c0853843dd --- /dev/null +++ b/tests/test_integration_platform.py @@ -0,0 +1,63 @@ +import os + +import pytest + +from . import Envelope, SENTRY_VERSION, make_dsn, run +from .conditions import has_http + +pytestmark = pytest.mark.skipif(not has_http, reason="tests need http transport") + + +def test_platform_integration(cmake, httpserver): + cwd = cmake( + ["sentry_test_platform"], + { + "SENTRY_BACKEND": "none", + "SENTRY_BUILD_SHARED_LIBS": "OFF", + "SENTRY_INTEGRATION_PLATFORM": "test", + }, + ) + + httpserver.expect_oneshot_request("/api/123456/envelope/").respond_with_data("OK") + + run( + cwd, + "sentry_test_platform", + [], + env=dict(os.environ, SENTRY_DSN=make_dsn(httpserver)), + ) + + assert len(httpserver.log) == 1 + envelope = Envelope.deserialize(httpserver.log[0][0].get_data()) + + (item,) = envelope.items + assert item.headers["type"] == "event" + event = item.payload.json + + # SDK + assert event["platform"] == "native" + assert event["environment"] == "production" + assert event["event_id"] + assert event["contexts"]["os"]["name"] + assert len(event["contexts"]["trace"]["trace_id"]) == 32 + assert len(event["contexts"]["trace"]["span_id"]) == 16 + assert event["sdk"]["version"] == SENTRY_VERSION + assert event["sdk"]["packages"] == [ + { + "name": "github:getsentry/sentry-native", + "version": SENTRY_VERSION, + } + ] + + # platform integration + assert event["contexts"]["device"] == { + "name": "Test", + "model": "test-model", + "arch": "test-arch", + } + assert event["sdk"]["name"] == "sentry.native.test" + assert event["sdk"]["integrations"].count("test") == 1 + + # app + assert event["tags"] == {"my-tag": "my-value"} + assert event["user"] == {"id": "123", "username": "my-user"} diff --git a/tests/unit/test_basic.c b/tests/unit/test_basic.c index b08f2551ab..0c2fd735bf 100644 --- a/tests/unit/test_basic.c +++ b/tests/unit/test_basic.c @@ -419,7 +419,7 @@ SENTRY_TEST(client_sdk_integrations) sentry_integration_t *integration = SENTRY_MAKE(sentry_integration_t); TEST_ASSERT(!!integration); integration->name = "custom"; - sentry__options_add_integration(options, integration); + TEST_ASSERT(sentry__options_add_integration(options, integration)); sentry_init(options); From 29507ae909c9606b4e67937924e862fc3e6854ea Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Thu, 20 Aug 2026 08:09:30 +0200 Subject: [PATCH 2/5] fix llvm-cov --- tests/cmake.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/cmake.py b/tests/cmake.py index 305d784b5c..8413b820f0 100644 --- a/tests/cmake.py +++ b/tests/cmake.py @@ -106,6 +106,7 @@ def lib_name(name): lib_name("sentry"), exe_name("sentry-crash"), exe_name("sentry_early_init"), + exe_name("sentry_test_platform"), ] cmd = [ os.environ.get("LLVM_COV", "llvm-cov"), From 2f18d74a8361dfd57bd30c461bc2a7ebe0c53e13 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Thu, 20 Aug 2026 08:15:15 +0200 Subject: [PATCH 3/5] SENTRY_INTEGRATION_PLATFORM --- CMakeLists.txt | 13 ++++--------- tests/test_integration_platform.py | 2 +- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3aefdaba60..0c3d3ffaa8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -115,13 +115,8 @@ option(SENTRY_BUILD_TESTS "Build sentry-native tests" "${SENTRY_MAIN_PROJECT}") option(SENTRY_BUILD_EXAMPLES "Build sentry-native example(s)" "${SENTRY_MAIN_PROJECT}") option(SENTRY_BUILD_BENCHMARKS "Build sentry-native benchmarks" OFF) -set(SENTRY_INTEGRATION_PLATFORM "" CACHE STRING - "Downstream-provided platform integration to create automatically") -if(NOT SENTRY_INTEGRATION_PLATFORM STREQUAL "" - AND NOT SENTRY_INTEGRATION_PLATFORM MATCHES "^[A-Za-z_][A-Za-z0-9_]*$") - message(FATAL_ERROR - "SENTRY_INTEGRATION_PLATFORM must be empty or a valid C identifier") -endif() +option(SENTRY_INTEGRATION_PLATFORM + "Enable the downstream-provided platform integration" OFF) # Platform version embedding options option(SENTRY_EMBED_INFO "Embed version information in binary" OFF) @@ -428,7 +423,7 @@ endif() add_subdirectory(src) -if(NOT SENTRY_INTEGRATION_PLATFORM STREQUAL "") +if(SENTRY_INTEGRATION_PLATFORM) target_compile_definitions(sentry PRIVATE SENTRY_INTEGRATION_PLATFORM) endif() @@ -1043,7 +1038,7 @@ if(SENTRY_BUILD_TESTS) add_subdirectory(tests/unit) add_subdirectory(tests/fixtures/crash_reporter) add_subdirectory(tests/fixtures/early_init) - if(SENTRY_INTEGRATION_PLATFORM STREQUAL "test") + if(SENTRY_INTEGRATION_PLATFORM AND SENTRY_MAIN_PROJECT) add_subdirectory(tests/fixtures/test_platform) endif() add_subdirectory(tests/fixtures/screenshot) diff --git a/tests/test_integration_platform.py b/tests/test_integration_platform.py index c0853843dd..ae4860e507 100644 --- a/tests/test_integration_platform.py +++ b/tests/test_integration_platform.py @@ -14,7 +14,7 @@ def test_platform_integration(cmake, httpserver): { "SENTRY_BACKEND": "none", "SENTRY_BUILD_SHARED_LIBS": "OFF", - "SENTRY_INTEGRATION_PLATFORM": "test", + "SENTRY_INTEGRATION_PLATFORM": "ON", }, ) From 18eb75af502880a8b3cfe61031eb43d56d90c8ce Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Thu, 20 Aug 2026 08:44:58 +0200 Subject: [PATCH 4/5] add sentry__scope_set_release for sentry-switch Allow sentry-switch platform integration to infer a release while registering with an already-locked scope. Keep the scope release, DSC, and observer notifications in sync. --- src/sentry_core.c | 6 +----- src/sentry_scope.c | 18 ++++++++++++++++++ src/sentry_scope.h | 4 ++++ tests/unit/test_scope.c | 17 +++++++++++++++++ tests/unit/tests.inc | 1 + 5 files changed, 41 insertions(+), 5 deletions(-) diff --git a/src/sentry_core.c b/src/sentry_core.c index 969443a0ef..04b0ffa322 100644 --- a/src/sentry_core.c +++ b/src/sentry_core.c @@ -984,11 +984,7 @@ void sentry_set_release_n(const char *release, size_t release_len) { SENTRY_WITH_SCOPE_MUT (scope) { - sentry_free(scope->release); - scope->release = sentry__string_clone_n(release, release_len); - sentry_value_set_by_key(scope->dynamic_sampling_context, "release", - sentry_value_new_string(scope->release)); - SENTRY_SCOPE_NOTIFY(scope, set_release, scope->release); + sentry__scope_set_release_n(scope, release, release_len); } } diff --git a/src/sentry_scope.c b/src/sentry_scope.c index 0bb7057e14..7fe5c20586 100644 --- a/src/sentry_scope.c +++ b/src/sentry_scope.c @@ -909,6 +909,24 @@ sentry_scope_update_context_n(sentry_scope_t *scope, const char *key, SENTRY_SCOPE_NOTIFY(scope, set_context, k, value); } +void +sentry__scope_set_release_n( + sentry_scope_t *scope, const char *release, size_t release_len) +{ + sentry_free(scope->release); + scope->release = sentry__string_clone_n(release, release_len); + sentry_value_set_by_key(scope->dynamic_sampling_context, "release", + sentry_value_new_string(scope->release)); + SENTRY_SCOPE_NOTIFY(scope, set_release, scope->release); +} + +void +sentry__scope_set_release(sentry_scope_t *scope, const char *release) +{ + sentry__scope_set_release_n( + scope, release, sentry__guarded_strlen(release)); +} + void sentry__scope_set_fingerprint_va( sentry_scope_t *scope, const char *fingerprint, va_list va) diff --git a/src/sentry_scope.h b/src/sentry_scope.h index f2133bbdab..8cf1a3ebe7 100644 --- a/src/sentry_scope.h +++ b/src/sentry_scope.h @@ -145,6 +145,10 @@ void sentry__scope_apply_to_event(const sentry_scope_t *scope, const sentry_options_t *options, sentry_value_t event, sentry_scope_mode_t mode); +void sentry__scope_set_release(sentry_scope_t *scope, const char *release); +void sentry__scope_set_release_n( + sentry_scope_t *scope, const char *release, size_t release_len); + void sentry__scope_set_fingerprint_va( sentry_scope_t *scope, const char *fingerprint, va_list va); void sentry__scope_set_fingerprint_nva(sentry_scope_t *scope, diff --git a/tests/unit/test_scope.c b/tests/unit/test_scope.c index e21e79e87a..6d99d43bb9 100644 --- a/tests/unit/test_scope.c +++ b/tests/unit/test_scope.c @@ -1352,6 +1352,23 @@ SENTRY_TEST(scope_local_attributes) sentry_close(); } +SENTRY_TEST(scope_release) +{ + SENTRY_TEST_OPTIONS_NEW(options); + sentry_init(options); + + SENTRY_WITH_SCOPE_MUT (scope) { + sentry__scope_set_release(scope, "my-release"); + TEST_CHECK_STRING_EQUAL(scope->release, "my-release"); + TEST_CHECK_STRING_EQUAL( + sentry_value_as_string(sentry_value_get_by_key( + scope->dynamic_sampling_context, "release")), + "my-release"); + } + + sentry_close(); +} + typedef struct { sentry_value_t release; sentry_value_t environment; diff --git a/tests/unit/tests.inc b/tests/unit/tests.inc index f3af596d00..fd41d0dc0e 100644 --- a/tests/unit/tests.inc +++ b/tests/unit/tests.inc @@ -371,6 +371,7 @@ XX(scope_observer_user) XX(scope_ownership) XX(scope_propagation_context) XX(scope_rebind_same_object) +XX(scope_release) XX(scope_remove_fingerprint_capture) XX(scope_set_attribute_invalid_decref_value) XX(scope_set_attribute_null_key_decref_value) From 59712b4a81ff807cc084784f4f4abed0c5a59d60 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Thu, 20 Aug 2026 12:17:44 +0200 Subject: [PATCH 5/5] test: allow "initial" observers injected by platform integrations --- tests/unit/test_scope.c | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/tests/unit/test_scope.c b/tests/unit/test_scope.c index 6d99d43bb9..147b11a87b 100644 --- a/tests/unit/test_scope.c +++ b/tests/unit/test_scope.c @@ -1702,13 +1702,16 @@ SENTRY_TEST(scope_observer_null) sentry_init(options); SENTRY_WITH_SCOPE_MUT (scope) { + size_t initial_count = scope->num_observers; + sentry_scope_observer_t **initial_observers = scope->observers; + TEST_CHECK(!sentry__scope_add_observer(scope, NULL)); - TEST_CHECK_INT_EQUAL(scope->num_observers, 0); - TEST_CHECK(scope->observers == NULL); + TEST_CHECK_INT_EQUAL(scope->num_observers, initial_count); + TEST_CHECK(scope->observers == initial_observers); sentry__scope_remove_observer(scope, NULL); - TEST_CHECK_INT_EQUAL(scope->num_observers, 0); - TEST_CHECK(scope->observers == NULL); + TEST_CHECK_INT_EQUAL(scope->num_observers, initial_count); + TEST_CHECK(scope->observers == initial_observers); } test_observer_data_t d = { .tags = sentry_value_new_null() }; @@ -1747,7 +1750,9 @@ SENTRY_TEST(scope_observer_multiple) observer2->data = &d2; observer2->set_tag = observe_set_tag; + size_t initial_count = 0; SENTRY_WITH_SCOPE_MUT (scope) { + initial_count = scope->num_observers; TEST_CHECK(sentry__scope_add_observer(scope, observer1)); TEST_CHECK(sentry__scope_add_observer(scope, observer2)); } @@ -1766,7 +1771,7 @@ SENTRY_TEST(scope_observer_multiple) d2.was_called = false; SENTRY_WITH_SCOPE_MUT (scope) { sentry__scope_remove_observer(scope, observer2); - TEST_CHECK_INT_EQUAL(scope->num_observers, 1); + TEST_CHECK_INT_EQUAL(scope->num_observers, initial_count + 1); TEST_CHECK(scope->observers != NULL); } @@ -1779,8 +1784,8 @@ SENTRY_TEST(scope_observer_multiple) SENTRY_WITH_SCOPE_MUT (scope) { sentry__scope_remove_observer(scope, observer1); - TEST_CHECK_INT_EQUAL(scope->num_observers, 0); - TEST_CHECK(scope->observers == NULL); + TEST_CHECK_INT_EQUAL(scope->num_observers, initial_count); + TEST_CHECK((scope->observers == NULL) == (initial_count == 0)); } sentry_value_decref(d1.tags); @@ -1814,7 +1819,9 @@ SENTRY_TEST(scope_observer_mutate) observer3->data = &d3; observer3->set_tag = observe_set_tag; + size_t initial_count; SENTRY_WITH_SCOPE_MUT (scope) { + initial_count = scope->num_observers; TEST_CHECK(sentry__scope_add_observer(scope, observer1)); TEST_CHECK(sentry__scope_add_observer(scope, observer2)); } @@ -1845,14 +1852,14 @@ SENTRY_TEST(scope_observer_mutate) SENTRY_WITH_SCOPE_MUT (scope) { TEST_CHECK(sentry__scope_add_observer(scope, observer4)); - TEST_CHECK_INT_EQUAL(scope->num_observers, 1); + TEST_CHECK_INT_EQUAL(scope->num_observers, initial_count + 1); } sentry_set_tag("self", "remove"); TEST_CHECK(d4.was_called); SENTRY_WITH_SCOPE_MUT (scope) { - TEST_CHECK_INT_EQUAL(scope->num_observers, 0); - TEST_CHECK(scope->observers == NULL); + TEST_CHECK_INT_EQUAL(scope->num_observers, initial_count); + TEST_CHECK((scope->observers == NULL) == (initial_count == 0)); } sentry_value_decref(d1.tags);