Skip to content
Open
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
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1006,6 +1006,9 @@ if(SENTRY_BUILD_TESTS)
add_subdirectory(tests/unit)
add_subdirectory(tests/fixtures/crash_reporter)
add_subdirectory(tests/fixtures/screenshot)
if(WIN32 AND NOT XBOX)
add_subdirectory(tests/fixtures/appx)
endif()
Comment thread
cursor[bot] marked this conversation as resolved.
if(SENTRY_BUILD_BENCHMARKS)
set(BENCHMARK_ENABLE_TESTING OFF)
set(BENCHMARK_ENABLE_GTEST_TESTS OFF)
Expand Down
39 changes: 39 additions & 0 deletions examples/example.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,44 @@

#if defined(SENTRY_PLATFORM_WINDOWS)
# include <windows.h>
# ifdef HAVE_APPMODEL
# include <appmodel.h>
# endif
unsigned long
get_current_thread_id()
{
return GetCurrentThreadId();
}

# ifdef HAVE_APPMODEL
static void
print_package_identity(void)
{
UINT32 length = 0;
LONG status = GetCurrentPackageFullName(&length, NULL);
if (status == APPMODEL_ERROR_NO_PACKAGE) {
printf("PACKAGE_IDENTITY:none\n");
fflush(stdout);
return;
}

wchar_t *package_name = (wchar_t *)calloc(length, sizeof(wchar_t));
if (!package_name) {
printf("PACKAGE_IDENTITY:allocation-failed\n");
fflush(stdout);
return;
}

status = GetCurrentPackageFullName(&length, package_name);
if (status == ERROR_SUCCESS) {
printf("PACKAGE_IDENTITY:present\n");
} else {
printf("PACKAGE_IDENTITY:error:%ld\n", status);
}
fflush(stdout);
free(package_name);
}
# endif
#elif defined(SENTRY_PLATFORM_MACOS)
# include <pthread.h>
# include <stdint.h>
Expand Down Expand Up @@ -932,6 +965,12 @@ main(int argc, char **argv)
sentry_value_new_string("my_global_value"), NULL));
}

#if defined(SENTRY_PLATFORM_WINDOWS) && defined(HAVE_APPMODEL)
if (has_arg(argc, argv, "appx")) {
print_package_identity();
}
#endif

// E2E test mode: set tags and output test ID for event correlation
if (e2e_test_id[0] != '\0') {
sentry_set_tag("test.id", e2e_test_id);
Expand Down
61 changes: 61 additions & 0 deletions tests/fixtures/appx/AppxManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?xml version="1.0" encoding="utf-8"?>
<Package
xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"
xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"
xmlns:uap4="http://schemas.microsoft.com/appx/manifest/uap/windows10/4"
xmlns:uap10="http://schemas.microsoft.com/appx/manifest/uap/windows10/10"
xmlns:desktop7="http://schemas.microsoft.com/appx/manifest/desktop/windows10/7"
xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"
IgnorableNamespaces="uap uap4 uap10 desktop7 rescap">
<Identity
Name="SentryNativeExample"
Publisher="CN=Sentry Native Test"
Version="1.0.0.0"
ProcessorArchitecture="neutral" />
<Properties>
<DisplayName>Sentry Native AppX Test</DisplayName>
<PublisherDisplayName>Sentry Native Test</PublisherDisplayName>
<Logo>Assets\StoreLogo.png</Logo>
<uap10:AllowExternalContent>true</uap10:AllowExternalContent>
</Properties>
<Resources>
<Resource Language="en-us" />
</Resources>
<Dependencies>
<TargetDeviceFamily
Name="Windows.Desktop"
MinVersion="10.0.19041.0"
MaxVersionTested="10.0.26100.0" />
</Dependencies>
<Capabilities>
<rescap:Capability Name="runFullTrust" />
<uap4:CustomCapability Name="Microsoft.classicAppCompat_8wekyb3d8bbwe" />
</Capabilities>
<Applications>
<Application
Id="App"
Executable="sentry_example_appx.exe"
uap10:TrustLevel="mediumIL"
uap10:RuntimeBehavior="win32App">
<uap:VisualElements
AppListEntry="none"
DisplayName="Sentry Native AppX Test"
Description="Sentry Native AppX Test"
BackgroundColor="transparent"
Square150x150Logo="Assets\Square150x150Logo.png"
Square44x44Logo="Assets\Square44x44Logo.png" />
</Application>
</Applications>
<Extensions>
<desktop7:Extension
Category="windows.errorReporting"
desktop7:CompatMode="classic"
desktop7:Scope="user"
uap10:TrustLevel="mediumIL"
uap10:RuntimeBehavior="win32App">
<desktop7:ErrorReporting>
<desktop7:RuntimeExceptionHelperModule Path="sentry-wer.dll" />
</desktop7:ErrorReporting>
</desktop7:Extension>
</Extensions>
Comment thread
jpnurmi marked this conversation as resolved.
</Package>
49 changes: 49 additions & 0 deletions tests/fixtures/appx/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
cmake_minimum_required(VERSION 3.10)
project(sentry_example_appx LANGUAGES C)

if(WIN32 AND NOT XBOX)
include(CheckSymbolExists)
check_symbol_exists(GetCurrentPackageFullName "windows.h;appmodel.h" HAVE_APPMODEL)

add_executable(sentry_example_appx
${SENTRY_SOURCE_DIR}/examples/example.c
)
Comment thread
cursor[bot] marked this conversation as resolved.
target_link_libraries(sentry_example_appx PRIVATE sentry)
if(HAVE_APPMODEL)
target_compile_definitions(sentry_example_appx PRIVATE HAVE_APPMODEL)
endif()

if(MSVC)
target_sources(sentry_example_appx PRIVATE sentry_example_appx.manifest)
target_compile_options(sentry_example_appx PRIVATE /wd5105 /wd4717)
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
target_compile_options(sentry_example_appx PRIVATE -Wno-infinite-recursion /Od)
endif()

target_compile_options(sentry_example_appx PRIVATE /guard:cf)
target_link_options(sentry_example_appx PRIVATE /GUARD:CF)
else()
target_sources(sentry_example_appx PRIVATE sentry_example_appx.rc)
endif()
Comment thread
cursor[bot] marked this conversation as resolved.

if(SENTRY_BUILD_RUNTIMESTATIC AND MSVC)
set_property(TARGET sentry_example_appx PROPERTY
MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
endif()

set_target_properties(sentry_example_appx PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}"
RUNTIME_OUTPUT_DIRECTORY_DEBUG "${CMAKE_BINARY_DIR}"
RUNTIME_OUTPUT_DIRECTORY_RELEASE "${CMAKE_BINARY_DIR}"
RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO "${CMAKE_BINARY_DIR}"
RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL "${CMAKE_BINARY_DIR}"
)

add_custom_command(TARGET sentry_example_appx POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
"${CMAKE_CURRENT_SOURCE_DIR}/AppxManifest.xml"
"$<TARGET_FILE_DIR:sentry_example_appx>/AppxManifest.xml"
COMMAND ${CMAKE_COMMAND} -E copy_if_different
"${CMAKE_CURRENT_SOURCE_DIR}/classicAppCompat.sccd"
"$<TARGET_FILE_DIR:sentry_example_appx>/classicAppCompat.sccd")
endif()
14 changes: 14 additions & 0 deletions tests/fixtures/appx/classicAppCompat.sccd
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<CustomCapabilityDescriptor
xmlns="http://schemas.microsoft.com/appx/2016/sccd">
<CustomCapabilities>
<CustomCapability Name="Microsoft.classicAppCompat_8wekyb3d8bbwe" />
</CustomCapabilities>
<AuthorizedEntities>
<AuthorizedEntity
AppPackageFamilyName="SentryNativeExample_4d5x6dfn6mhjm"
CertificateSignatureHash="0000000000000000000000000000000000000000000000000000000000000000" />
</AuthorizedEntities>
<Catalog>0000</Catalog>
<DeveloperModeOnly Value="true" />
</CustomCapabilityDescriptor>
8 changes: 8 additions & 0 deletions tests/fixtures/appx/sentry_example_appx.manifest
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
<assemblyIdentity version="1.0.0.0" name="SentryNativeExample"/>
<msix xmlns="urn:schemas-microsoft-com:msix.v1"
publisher="CN=Sentry Native Test"
packageName="SentryNativeExample"
applicationId="App"/>
</assembly>
1 change: 1 addition & 0 deletions tests/fixtures/appx/sentry_example_appx.rc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1 RT_MANIFEST "sentry_example_appx.manifest"
Loading
Loading