-
Notifications
You must be signed in to change notification settings - Fork 14
Crashpad - replace crashpad_handler executable with JavaCrashHandler #128
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
Merged
konraddysput
merged 14 commits into
release-candidate/3.8.3
from
improvement/crashpad-crash-handler
Jun 4, 2024
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
432d2ab
Use Java crash handler
konraddysput 2c14d7e
Setup Java Crash Handler. Dump faulting process via JavaCrashHandler …
konraddysput cd44fcd
Cleanup: Cmake and database code
konraddysput 39c0e50
Use library version and version code in the gradle.build configuration
konraddysput 963b38c
Refactor code and prepare project for testing crashpad integration
konraddysput c36ccab
Merge branch 'release-candidate/3.8.3' into improvement/crashpad-cras…
BartoszLitwiniuk 52a6a78
Update test workflow to use java 17
konraddysput 4b32ffc
Use new crashpad env variable
konraddysput 70a4522
Do not verify ABI on Database native intergration startup
konraddysput ef32fee
Do not use stream and allow to use native crash handler on x86_64
konraddysput caf7d3c
Use Android 6.0 at least
konraddysput 8a1abb5
Use the latest version of mockito
konraddysput 50d51c3
Update mockito-core to 2.28.2
konraddysput ec35958
Bring back support for crash_handler.so for backward compatibility (#…
konraddysput File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
3 changes: 1 addition & 2 deletions
3
backtrace-library/src/androidTest/java/backtraceio/library/AndroidManifest.xml
This file contains hidden or 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
69 changes: 69 additions & 0 deletions
69
...t/java/backtraceio/library/crashHandler/BacktraceCrashHandlerRunnerConfigurationTest.java
This file contains hidden or 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,69 @@ | ||
| package backtraceio.library.crashHandler; | ||
|
|
||
| import static org.junit.Assert.assertEquals; | ||
| import static org.junit.Assert.assertFalse; | ||
| import static org.junit.Assert.assertTrue; | ||
| import static org.junit.Assert.fail; | ||
|
|
||
| import androidx.test.ext.junit.runners.AndroidJUnit4; | ||
|
|
||
| import org.junit.Test; | ||
| import org.junit.runner.RunWith; | ||
|
|
||
| import java.util.List; | ||
| import java.util.Map; | ||
|
|
||
| import backtraceio.library.models.nativeHandler.CrashHandlerConfiguration; | ||
|
|
||
| @RunWith(AndroidJUnit4.class) | ||
| public class BacktraceCrashHandlerRunnerConfigurationTest { | ||
| @Test | ||
| public void unsupportedAbiVersion() { | ||
| CrashHandlerConfiguration crashHandlerConfiguration = new CrashHandlerConfiguration(); | ||
| for (String unsupportedAbi : | ||
| CrashHandlerConfiguration.UNSUPPORTED_ABIS) { | ||
| assertFalse(crashHandlerConfiguration.isSupportedAbi(unsupportedAbi)); | ||
| } | ||
| } | ||
|
|
||
| @Test | ||
| public void supportedAbiVersion() { | ||
| CrashHandlerConfiguration crashHandlerConfiguration = new CrashHandlerConfiguration(); | ||
| for (String unsupportedAbi : | ||
| new String[]{"armeabi", "arm64", "arm64-v8", "x86-64"}) { | ||
| assertTrue(crashHandlerConfiguration.isSupportedAbi(unsupportedAbi)); | ||
| } | ||
| } | ||
|
|
||
| @Test | ||
| public void environmentVariableHasCorrectPathToLibrary() { | ||
| CrashHandlerConfiguration crashHandlerConfiguration = new CrashHandlerConfiguration(); | ||
| String fakePathToApk = "fake/path/to/apk/apk.apk"; | ||
| String fakePathToLib = "fake/path/to/lib/arm64"; | ||
| String fakeAbi = "fake-abi"; | ||
| List<String> environmentVariables = crashHandlerConfiguration.getCrashHandlerEnvironmentVariables(fakePathToApk, fakePathToLib, fakeAbi); | ||
| for (String envVariable : environmentVariables) { | ||
| if (envVariable.startsWith(CrashHandlerConfiguration.BACKTRACE_CRASH_HANDLER)) { | ||
| assertEquals(envVariable, String.format("%s=%s!/lib/%s/libbacktrace-native.so", CrashHandlerConfiguration.BACKTRACE_CRASH_HANDLER, fakePathToApk, fakeAbi)); | ||
| return; | ||
| } | ||
| } | ||
| fail("Cannot find Backtrace Crash Handler environment variable"); | ||
| } | ||
|
|
||
| @Test | ||
| public void environmentVariableContainsJavaEnvVariables() { | ||
| CrashHandlerConfiguration crashHandlerConfiguration = new CrashHandlerConfiguration(); | ||
| String fakePathToApk = "fake/path/to/apk/apk.apk"; | ||
| String fakePathToLib = "fake/path/to/lib/arm64"; | ||
| String fakeAbi = "fake-abi"; | ||
| List<String> environmentVariables = crashHandlerConfiguration.getCrashHandlerEnvironmentVariables(fakePathToApk, fakePathToLib, fakeAbi); | ||
|
|
||
| Map<String, String> systemEnvVariables = System.getenv(); | ||
|
|
||
| for (Map.Entry<String, String> envVariable : systemEnvVariables.entrySet()) { | ||
| assertTrue(environmentVariables.indexOf(String.format("%s=%s", envVariable.getKey(), envVariable.getValue())) != -1); | ||
| } | ||
| } | ||
|
|
||
| } |
69 changes: 69 additions & 0 deletions
69
...c/androidTest/java/backtraceio/library/crashHandler/CrashHandlerRunnerInvocationTest.java
This file contains hidden or 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,69 @@ | ||
| package backtraceio.library.crashHandler; | ||
|
|
||
|
|
||
| import static org.junit.Assert.assertFalse; | ||
| import static org.junit.Assert.assertTrue; | ||
| import static org.mockito.ArgumentMatchers.any; | ||
| import static org.mockito.Mockito.mock; | ||
| import static org.mockito.Mockito.when; | ||
|
|
||
| import org.junit.Before; | ||
| import org.junit.Test; | ||
| import org.junit.runner.RunWith; | ||
| import org.mockito.Mock; | ||
| import org.mockito.MockitoAnnotations; | ||
| import org.mockito.junit.MockitoJUnitRunner; | ||
|
|
||
| import java.util.HashMap; | ||
|
|
||
| import backtraceio.library.models.nativeHandler.CrashHandlerConfiguration; | ||
| import backtraceio.library.nativeCalls.BacktraceCrashHandlerWrapper; | ||
| import backtraceio.library.nativeCalls.SystemLoader; | ||
| import backtraceio.library.services.BacktraceCrashHandlerRunner; | ||
|
|
||
| @RunWith(MockitoJUnitRunner.class) | ||
| public class CrashHandlerRunnerInvocationTest { | ||
|
|
||
| private final static String fakePathLibrary = "path/to/lib"; | ||
| @Mock | ||
| BacktraceCrashHandlerWrapper backtraceCrashHandlerWrapper; | ||
|
|
||
| @Before | ||
| public void setup() { | ||
| MockitoAnnotations.initMocks(this); | ||
| } | ||
|
|
||
| @Test | ||
| public void failIfEnvVariablesAreNotDefined() { | ||
| BacktraceCrashHandlerRunner runner = new BacktraceCrashHandlerRunner(); | ||
| assertFalse(runner.run(new String[]{}, null)); | ||
| } | ||
|
|
||
| @Test | ||
| public void failIfEnvVariablesDontStoreHandlerPath() { | ||
| BacktraceCrashHandlerRunner runner = new BacktraceCrashHandlerRunner(); | ||
| assertFalse(runner.run(new String[]{}, new HashMap<>())); | ||
| } | ||
|
|
||
| @Test | ||
| public void shouldExecuteCorrectlyCrashpadHandlerMethod() { | ||
| HashMap<String, String> envVariables = new HashMap<String, String>(); | ||
| envVariables.put(CrashHandlerConfiguration.BACKTRACE_CRASH_HANDLER, fakePathLibrary); | ||
|
|
||
| when(backtraceCrashHandlerWrapper.handleCrash(any(String[].class))).thenReturn(true); | ||
|
|
||
| BacktraceCrashHandlerRunner runner = new BacktraceCrashHandlerRunner(backtraceCrashHandlerWrapper, mock(SystemLoader.class)); | ||
| assertTrue(runner.run(new String[]{}, envVariables)); | ||
| } | ||
|
|
||
| @Test | ||
| public void shouldReturnFalseWhenCrashpadFails() { | ||
| HashMap<String, String> envVariables = new HashMap<String, String>(); | ||
| envVariables.put(CrashHandlerConfiguration.BACKTRACE_CRASH_HANDLER, fakePathLibrary); | ||
|
|
||
| when(backtraceCrashHandlerWrapper.handleCrash(any(String[].class))).thenReturn(true); | ||
|
|
||
| BacktraceCrashHandlerRunner runner = new BacktraceCrashHandlerRunner(backtraceCrashHandlerWrapper, mock(SystemLoader.class)); | ||
| assertTrue(runner.run(new String[]{}, envVariables)); | ||
| } | ||
| } |
This file contains hidden or 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
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.