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

Add run-time version info #726

Merged
merged 2 commits into from
Jun 15, 2022
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ __pycache__

# Devtools
CodeChecker
.ccls-cache

# Coverage
coverage
15 changes: 15 additions & 0 deletions include/sentry.h
Original file line number Diff line number Diff line change
Expand Up @@ -1774,6 +1774,21 @@ SENTRY_EXPERIMENTAL_API int sentry_get_crashed_last_run();
*/
SENTRY_EXPERIMENTAL_API int sentry_clear_crashed_last_run();

/**
* Sentry SDK version.
*/
SENTRY_EXPERIMENTAL_API const char *sentry_sdk_version();

/**
* Sentry SDK name.
*/
SENTRY_EXPERIMENTAL_API const char *sentry_sdk_name();

/**
* Sentry SDK User-Agent.
*/
SENTRY_EXPERIMENTAL_API const char *sentry_sdk_user_agent();

#ifdef __cplusplus
}
#endif
Expand Down
1 change: 1 addition & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ sentry_target_sources_cwd(sentry
sentry_database.h
sentry_envelope.c
sentry_envelope.h
sentry_info.c
sentry_json.c
sentry_json.h
sentry_logger.c
Expand Down
19 changes: 19 additions & 0 deletions src/sentry_info.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#include "sentry_boot.h"

const char *
sentry_sdk_version()
{
return SENTRY_SDK_VERSION;
}

const char *
sentry_sdk_name()
{
return SENTRY_SDK_NAME;
}

const char *
sentry_sdk_user_agent()
{
return SENTRY_SDK_USER_AGENT;
}
1 change: 1 addition & 0 deletions tests/unit/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ add_executable(sentry_test_unit
test_envelopes.c
test_failures.c
test_fuzzfailures.c
test_info.c
test_logger.c
test_modulefinder.c
test_mpack.c
Expand Down
16 changes: 16 additions & 0 deletions tests/unit/test_info.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#include "sentry_testsupport.h"

SENTRY_TEST(assert_sdk_version)
{
TEST_CHECK_STRING_EQUAL(sentry_sdk_version(), SENTRY_SDK_VERSION);
}

SENTRY_TEST(assert_sdk_name)
{
TEST_CHECK_STRING_EQUAL(sentry_sdk_name(), SENTRY_SDK_NAME);
}

SENTRY_TEST(assert_sdk_user_agent)
{
TEST_CHECK_STRING_EQUAL(sentry_sdk_user_agent(), SENTRY_SDK_USER_AGENT);
}
9 changes: 6 additions & 3 deletions tests/unit/tests.inc
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
XX(assert_sdk_name)
XX(assert_sdk_user_agent)
XX(assert_sdk_version)
XX(background_worker)
XX(basic_consent_tracking)
XX(basic_function_transport)
Expand All @@ -15,15 +18,15 @@ XX(child_spans)
XX(concurrent_init)
XX(concurrent_uninit)
XX(count_sampled_events)
XX(crash_marker)
XX(crashed_last_run)
XX(crash_marker)
XX(custom_logger)
XX(distributed_headers)
XX(drop_unfinished_spans)
XX(dsn_parsing_complete)
XX(dsn_parsing_invalid)
XX(dsn_store_url_with_path)
XX(dsn_store_url_without_path)
XX(dsn_store_url_with_path)
XX(empty_transport)
XX(fuzz_json)
XX(init_failure)
Expand Down Expand Up @@ -86,7 +89,7 @@ XX(value_null)
XX(value_object)
XX(value_object_merge)
XX(value_object_merge_nested)
XX(value_set_stacktrace)
XX(value_string)
XX(value_unicode)
XX(value_wrong_type)
XX(value_set_stacktrace)