summaryrefslogtreecommitdiffstats
path: root/toolkit/crashreporter/test
diff options
context:
space:
mode:
Diffstat (limited to 'toolkit/crashreporter/test')
-rw-r--r--toolkit/crashreporter/test/gtest/TestElfSoVersion.cpp143
-rw-r--r--toolkit/crashreporter/test/gtest/moz.build16
-rw-r--r--toolkit/crashreporter/test/moz.build4
-rw-r--r--toolkit/crashreporter/test/unit/head_crashreporter.js3
-rw-r--r--toolkit/crashreporter/test/unit/test_crash_modules_linux.js33
-rw-r--r--toolkit/crashreporter/test/unit/xpcshell-phc.toml4
-rw-r--r--toolkit/crashreporter/test/unit/xpcshell.toml40
7 files changed, 224 insertions, 19 deletions
diff --git a/toolkit/crashreporter/test/gtest/TestElfSoVersion.cpp b/toolkit/crashreporter/test/gtest/TestElfSoVersion.cpp
new file mode 100644
index 0000000000..a6c91a8dff
--- /dev/null
+++ b/toolkit/crashreporter/test/gtest/TestElfSoVersion.cpp
@@ -0,0 +1,143 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "gtest/gtest.h"
+#include "mozilla/SpinEventLoopUntil.h"
+
+#include "linux_utils.h"
+
+#define ASSERT_EQ_UNSIGNED(v, e) ASSERT_EQ((v), (uint32_t)(e))
+
+using namespace mozilla;
+
+class CrashReporter : public ::testing::Test {};
+
+TEST_F(CrashReporter, ElfSoNoVersion) {
+ uint32_t version[4] = {0, 0, 0, 0};
+ bool rv = ElfFileSoVersion("libdbus1.so", version);
+ ASSERT_TRUE(rv);
+}
+
+TEST_F(CrashReporter, ElfSo6) {
+ uint32_t version[4] = {0, 0, 0, 0};
+ bool rv = ElfFileSoVersion("libm.so.6", version);
+ ASSERT_TRUE(rv);
+ ASSERT_EQ_UNSIGNED(version[0], 6);
+}
+
+TEST_F(CrashReporter, ElfSoNormalShort) {
+ uint32_t version[4] = {0, 0, 0, 0};
+ bool rv = ElfFileSoVersion("libdbus1.so.1.2", version);
+ ASSERT_TRUE(rv);
+ ASSERT_EQ_UNSIGNED(version[0], 1);
+ ASSERT_EQ_UNSIGNED(version[1], 2);
+}
+
+TEST_F(CrashReporter, ElfSoNormalComplete) {
+ uint32_t version[4] = {0, 0, 0, 0};
+ bool rv = ElfFileSoVersion("libdbus1.so.1.2.3", version);
+ ASSERT_TRUE(rv);
+ ASSERT_EQ_UNSIGNED(version[0], 1);
+ ASSERT_EQ_UNSIGNED(version[1], 2);
+ ASSERT_EQ_UNSIGNED(version[2], 3);
+}
+
+TEST_F(CrashReporter, ElfSoNormalPrerelease) {
+ uint32_t version[4] = {0, 0, 0, 0};
+ bool rv = ElfFileSoVersion("libdbus1.so.1.2.3.98", version);
+ ASSERT_TRUE(rv);
+ ASSERT_EQ_UNSIGNED(version[0], 1);
+ ASSERT_EQ_UNSIGNED(version[1], 2);
+ ASSERT_EQ_UNSIGNED(version[2], 3);
+ ASSERT_EQ_UNSIGNED(version[3], 98);
+}
+
+TEST_F(CrashReporter, ElfSoNormalPrereleaseToomuch) {
+ uint32_t version[4] = {0, 0, 0, 0};
+ bool rv = ElfFileSoVersion("libdbus1.so.1.2.3.98.9.2.3", version);
+ ASSERT_TRUE(rv);
+ ASSERT_EQ_UNSIGNED(version[0], 1);
+ ASSERT_EQ_UNSIGNED(version[1], 2);
+ ASSERT_EQ_UNSIGNED(version[2], 3);
+ ASSERT_EQ_UNSIGNED(version[3], 98);
+}
+
+TEST_F(CrashReporter, ElfSoBig) {
+ uint32_t version[4] = {0, 0, 0, 0};
+ bool rv = ElfFileSoVersion("libatk-1.0.so.0.25009.1", version);
+ ASSERT_TRUE(rv);
+ ASSERT_EQ_UNSIGNED(version[0], 0);
+ ASSERT_EQ_UNSIGNED(version[1], 25009);
+ ASSERT_EQ_UNSIGNED(version[2], 1);
+}
+
+TEST_F(CrashReporter, ElfSoCairo) {
+ uint32_t version[4] = {0, 0, 0, 0};
+ bool rv = ElfFileSoVersion("libcairo.so.2.11800.3", version);
+ ASSERT_TRUE(rv);
+ ASSERT_EQ_UNSIGNED(version[0], 2);
+ ASSERT_EQ_UNSIGNED(version[1], 11800);
+ ASSERT_EQ_UNSIGNED(version[2], 3);
+}
+
+TEST_F(CrashReporter, ElfSoMax) {
+ uint32_t version[4] = {0, 0, 0, 0};
+ bool rv = ElfFileSoVersion(
+ "libcairo.so.2147483647.2147483647.2147483647.2147483647", version);
+ ASSERT_TRUE(rv);
+ ASSERT_EQ_UNSIGNED(version[0], INT32_MAX);
+ ASSERT_EQ_UNSIGNED(version[1], INT32_MAX);
+ ASSERT_EQ_UNSIGNED(version[2], INT32_MAX);
+ ASSERT_EQ_UNSIGNED(version[3], INT32_MAX);
+}
+
+TEST_F(CrashReporter, ElfSoTimestamp) {
+ uint32_t version[4] = {0, 0, 0, 0};
+ bool rv = ElfFileSoVersion("libabsl_time_zone.so.20220623.0.0", version);
+ ASSERT_TRUE(rv);
+ ASSERT_EQ_UNSIGNED(version[0], 20220623);
+ ASSERT_EQ_UNSIGNED(version[1], 0);
+ ASSERT_EQ_UNSIGNED(version[2], 0);
+}
+
+TEST_F(CrashReporter, ElfSoChars) {
+ uint32_t version[4] = {0, 0, 0, 0};
+ bool rv = ElfFileSoVersion("libabsl_time_zone.so.1.2.3rc4", version);
+ ASSERT_TRUE(rv);
+ ASSERT_EQ_UNSIGNED(version[0], 1);
+ ASSERT_EQ_UNSIGNED(version[1], 2);
+ ASSERT_EQ_UNSIGNED(version[2], 34);
+}
+
+TEST_F(CrashReporter, ElfSoCharsMore) {
+ uint32_t version[4] = {0, 0, 0, 0};
+ bool rv = ElfFileSoVersion("libabsl_time_zone.so.1.2.3rc4.9", version);
+ ASSERT_TRUE(rv);
+ ASSERT_EQ_UNSIGNED(version[0], 1);
+ ASSERT_EQ_UNSIGNED(version[1], 2);
+ ASSERT_EQ_UNSIGNED(version[2], 34);
+ ASSERT_EQ_UNSIGNED(version[3], 9);
+}
+
+TEST_F(CrashReporter, ElfSoCharsOnly) {
+ uint32_t version[4] = {0, 0, 0, 0};
+ bool rv = ElfFileSoVersion("libabsl_time_zone.so.final", version);
+ ASSERT_TRUE(rv);
+}
+
+TEST_F(CrashReporter, ElfSoNullVersion) {
+ bool rv = ElfFileSoVersion("libabsl_time_zone.so.1", nullptr);
+ ASSERT_FALSE(rv);
+}
+
+TEST_F(CrashReporter, ElfSoFullPath) {
+ uint32_t version[4] = {0, 0, 0, 0};
+ bool rv = ElfFileSoVersion(
+ "/usr/lib/x86_64-linux-gnu/libabsl_time_zone.so.20220623.0.0", version);
+ ASSERT_TRUE(rv);
+ ASSERT_EQ_UNSIGNED(version[0], 20220623);
+ ASSERT_EQ_UNSIGNED(version[1], 0);
+ ASSERT_EQ_UNSIGNED(version[2], 0);
+}
diff --git a/toolkit/crashreporter/test/gtest/moz.build b/toolkit/crashreporter/test/gtest/moz.build
new file mode 100644
index 0000000000..9aa1c0a0db
--- /dev/null
+++ b/toolkit/crashreporter/test/gtest/moz.build
@@ -0,0 +1,16 @@
+# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
+# vim: set filetype=python:
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, you can obtain one at http://mozilla.org/MPL/2.0/.
+
+Library("crashreportertest")
+
+if CONFIG["OS_ARCH"] == "Linux":
+ UNIFIED_SOURCES = [
+ "TestElfSoVersion.cpp",
+ ]
+
+include("/ipc/chromium/chromium-config.mozbuild")
+
+FINAL_LIBRARY = "xul-gtest"
diff --git a/toolkit/crashreporter/test/moz.build b/toolkit/crashreporter/test/moz.build
index 1ebd9b9029..254d232e0e 100644
--- a/toolkit/crashreporter/test/moz.build
+++ b/toolkit/crashreporter/test/moz.build
@@ -9,6 +9,10 @@ XPCSHELL_TESTS_MANIFESTS += ["unit/xpcshell.toml", "unit_ipc/xpcshell.toml"]
if CONFIG["MOZ_PHC"]:
XPCSHELL_TESTS_MANIFESTS += ["unit/xpcshell-phc.toml", "unit_ipc/xpcshell-phc.toml"]
+TEST_DIRS += [
+ "gtest",
+]
+
BROWSER_CHROME_MANIFESTS += ["browser/browser.toml"]
UNIFIED_SOURCES += [
diff --git a/toolkit/crashreporter/test/unit/head_crashreporter.js b/toolkit/crashreporter/test/unit/head_crashreporter.js
index c37c8acf8c..34602e2107 100644
--- a/toolkit/crashreporter/test/unit/head_crashreporter.js
+++ b/toolkit/crashreporter/test/unit/head_crashreporter.js
@@ -156,6 +156,9 @@ async function handleMinidump(callback) {
registerCleanupFunction(cleanup);
Assert.ok(extrafile.exists());
+ let data = await IOUtils.read(extrafile.path);
+ let decoder = new TextDecoder("ascii");
+ console.log("data = " + decoder.decode(data));
let extra = await IOUtils.readJSON(extrafile.path);
if (callback) {
diff --git a/toolkit/crashreporter/test/unit/test_crash_modules_linux.js b/toolkit/crashreporter/test/unit/test_crash_modules_linux.js
new file mode 100644
index 0000000000..9fcf587308
--- /dev/null
+++ b/toolkit/crashreporter/test/unit/test_crash_modules_linux.js
@@ -0,0 +1,33 @@
+add_task(async function run_test() {
+ if (!("@mozilla.org/toolkit/crash-reporter;1" in Cc)) {
+ dump(
+ "INFO | test_crash_modules.js | Can't test crashreporter in a non-libxul build.\n"
+ );
+ return;
+ }
+
+ await do_crash(
+ function () {
+ crashType = CrashTestUtils.CRASH_ABORT;
+ },
+ async function (mdump, extra, extraFile) {
+ runMinidumpAnalyzer(mdump);
+
+ // Refresh updated extra data
+ extra = await IOUtils.readJSON(extraFile.path);
+
+ // Check modules' versions
+ const modules = extra.StackTraces.modules;
+ const version_regexp = /^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$/;
+
+ for (let module of modules) {
+ console.debug("module", module);
+ console.debug("version => ", module.version);
+ console.debug("version regex => ", version_regexp.exec(module.version));
+ Assert.notEqual(version_regexp.exec(module.version), null);
+ }
+ },
+ // process will exit with a zero exit status
+ true
+ );
+});
diff --git a/toolkit/crashreporter/test/unit/xpcshell-phc.toml b/toolkit/crashreporter/test/unit/xpcshell-phc.toml
index 278cf28193..1bb182d852 100644
--- a/toolkit/crashreporter/test/unit/xpcshell-phc.toml
+++ b/toolkit/crashreporter/test/unit/xpcshell-phc.toml
@@ -1,8 +1,8 @@
[DEFAULT]
head = "head_crashreporter.js"
skip-if = [
- "toolkit == 'android'", # 1536217
- "os == 'win' && msix", # https://bugzilla.mozilla.org/show_bug.cgi?id=1807922
+ "os == 'android'", # 1536217
+ "win11_2009 && msix", # https://bugzilla.mozilla.org/show_bug.cgi?id=1807922
]
support-files = [
"crasher_subprocess_head.js",
diff --git a/toolkit/crashreporter/test/unit/xpcshell.toml b/toolkit/crashreporter/test/unit/xpcshell.toml
index ffa631d0a1..6b1676ac32 100644
--- a/toolkit/crashreporter/test/unit/xpcshell.toml
+++ b/toolkit/crashreporter/test/unit/xpcshell.toml
@@ -40,6 +40,10 @@ run-if = ["os == 'win'"]
reason = "Test covering Windows-specific module handling"
run-sequentially = "very high failure rate in parallel"
+["test_crash_modules_linux.js"]
+run-if = ["os == 'linux'"]
+reason = "Test covering Linux-specific module handling"
+
["test_crash_moz_crash.js"]
["test_crash_oom.js"]
@@ -51,7 +55,7 @@ run-sequentially = "very high failure rate in parallel"
["test_crash_rust_panic_multiline.js"]
["test_crash_stack_overflow.js"]
-skip-if = ["os != 'linux'"]
+run-if = ["os == 'linux'"]
reason = "Still broken on macOS and not yet supported on Windows"
["test_crash_terminator.js"]
@@ -60,71 +64,71 @@ reason = "Still broken on macOS and not yet supported on Windows"
["test_crash_win64cfi_alloc_large.js"]
head = "head_crashreporter.js head_win64cfi.js"
-run-if = ["os == 'win' && bits == 64 && processor == 'x86_64'"]
+run-if = ["os == 'win' && bits == 64"]
reason = "Windows test specific to the x86-64 architecture"
["test_crash_win64cfi_alloc_small.js"]
head = "head_crashreporter.js head_win64cfi.js"
-run-if = ["os == 'win' && bits == 64 && processor == 'x86_64'"]
+run-if = ["os == 'win' && bits == 64"]
reason = "Windows test specific to the x86-64 architecture"
["test_crash_win64cfi_epilog.js"]
head = "head_crashreporter.js head_win64cfi.js"
-run-if = ["os == 'win' && bits == 64 && processor == 'x86_64'"]
+run-if = ["os == 'win' && bits == 64"]
reason = "Windows test specific to the x86-64 architecture"
["test_crash_win64cfi_infinite_code_chain.js"]
head = "head_crashreporter.js head_win64cfi.js"
-run-if = ["os == 'win' && bits == 64 && processor == 'x86_64'"]
+run-if = ["os == 'win' && bits == 64"]
reason = "Windows test specific to the x86-64 architecture"
support-files = ["test_crash_win64cfi_infinite_code_chain.exe"]
["test_crash_win64cfi_infinite_entry_chain.js"]
head = "head_crashreporter.js head_win64cfi.js"
-run-if = ["os == 'win' && bits == 64 && processor == 'x86_64'"]
+run-if = ["os == 'win' && bits == 64"]
reason = "Windows test specific to the x86-64 architecture"
support-files = ["test_crash_win64cfi_infinite_entry_chain.exe"]
["test_crash_win64cfi_invalid_exception_rva.js"]
head = "head_crashreporter.js head_win64cfi.js"
-run-if = ["os == 'win' && bits == 64 && processor == 'x86_64'"]
+run-if = ["os == 'win' && bits == 64"]
reason = "Windows test specific to the x86-64 architecture"
support-files = ["test_crash_win64cfi_invalid_exception_rva.exe"]
["test_crash_win64cfi_not_a_pe.js"]
head = "head_crashreporter.js head_win64cfi.js"
-run-if = ["os == 'win' && bits == 64 && processor == 'x86_64'"]
+run-if = ["os == 'win' && bits == 64"]
reason = "Windows test specific to the x86-64 architecture"
support-files = ["test_crash_win64cfi_not_a_pe.exe"]
["test_crash_win64cfi_push_nonvol.js"]
head = "head_crashreporter.js head_win64cfi.js"
-run-if = ["os == 'win' && bits == 64 && processor == 'x86_64'"]
+run-if = ["os == 'win' && bits == 64"]
reason = "Windows test specific to the x86-64 architecture"
["test_crash_win64cfi_save_nonvol.js"]
head = "head_crashreporter.js head_win64cfi.js"
-run-if = ["os == 'win' && bits == 64 && processor == 'x86_64'"]
+run-if = ["os == 'win' && bits == 64"]
reason = "Windows test specific to the x86-64 architecture"
["test_crash_win64cfi_save_nonvol_far.js"]
head = "head_crashreporter.js head_win64cfi.js"
-run-if = ["os == 'win' && bits == 64 && processor == 'x86_64'"]
+run-if = ["os == 'win' && bits == 64"]
reason = "Windows test specific to the x86-64 architecture"
["test_crash_win64cfi_save_xmm128.js"]
head = "head_crashreporter.js head_win64cfi.js"
-run-if = ["os == 'win' && bits == 64 && processor == 'x86_64'"]
+run-if = ["os == 'win' && bits == 64"]
reason = "Windows test specific to the x86-64 architecture"
["test_crash_win64cfi_save_xmm128_far.js"]
head = "head_crashreporter.js head_win64cfi.js"
-run-if = ["os == 'win' && bits == 64 && processor == 'x86_64'"]
+run-if = ["os == 'win' && bits == 64"]
reason = "Windows test specific to the x86-64 architecture"
["test_crash_win64cfi_unknown_op.js"]
head = "head_crashreporter.js head_win64cfi.js"
-run-if = ["os == 'win' && bits == 64 && processor == 'x86_64'"]
+run-if = ["os == 'win' && bits == 64"]
reason = "Windows test specific to the x86-64 architecture"
["test_crash_with_memory_report.js"]
@@ -134,8 +138,10 @@ reason = "Windows test specific to the x86-64 architecture"
["test_crashreporter_appmem.js"]
# we need to skip this due to bug 838613
skip-if = [
- "os != 'win' && os != 'linux'",
- "os=='linux' && bits==32",
+ "os == 'android'",
+ "apple_silicon",
+ "apple_catalina",
+ "os == 'linux' && os_version == '18.04' && bits == 32",
]
["test_crashreporter_crash.js"]
@@ -149,4 +155,4 @@ run-sequentially = "very high failure rate in parallel"
run-sequentially = "very high failure rate in parallel"
["test_override_exception_handler.js"]
-skip-if = ["os != 'win'"]
+run-if = ["os == 'win'"]