summaryrefslogtreecommitdiffstats
path: root/testing/mozbase/mozcrash/tests/test_symbols_path.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 14:29:10 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 14:29:10 +0000
commit2aa4a82499d4becd2284cdb482213d541b8804dd (patch)
treeb80bf8bf13c3766139fbacc530efd0dd9d54394c /testing/mozbase/mozcrash/tests/test_symbols_path.py
parentInitial commit. (diff)
downloadfirefox-2aa4a82499d4becd2284cdb482213d541b8804dd.tar.xz
firefox-2aa4a82499d4becd2284cdb482213d541b8804dd.zip
Adding upstream version 86.0.1.upstream/86.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/mozbase/mozcrash/tests/test_symbols_path.py')
-rw-r--r--testing/mozbase/mozcrash/tests/test_symbols_path.py62
1 files changed, 62 insertions, 0 deletions
diff --git a/testing/mozbase/mozcrash/tests/test_symbols_path.py b/testing/mozbase/mozcrash/tests/test_symbols_path.py
new file mode 100644
index 0000000000..bd4d267ddb
--- /dev/null
+++ b/testing/mozbase/mozcrash/tests/test_symbols_path.py
@@ -0,0 +1,62 @@
+#!/usr/bin/env python
+# coding=UTF-8
+
+from __future__ import absolute_import
+
+import zipfile
+from six import BytesIO
+from six.moves.urllib.parse import urlunsplit
+
+import mozhttpd
+import mozunit
+
+from conftest import fspath
+
+
+def test_symbols_path_not_present(check_for_crashes, minidump_files):
+ """Test that no symbols path let mozcrash try to find the symbols."""
+ assert 1 == check_for_crashes(symbols_path=None)
+
+
+def test_symbols_path_unicode(check_for_crashes, minidump_files, tmpdir, capsys):
+ """Test that check_for_crashes can handle unicode in dump_directory."""
+ symbols_path = tmpdir.mkdir(u"🍪")
+
+ assert 1 == check_for_crashes(symbols_path=fspath(symbols_path), quiet=False)
+
+ out, _ = capsys.readouterr()
+ assert fspath(symbols_path) in out
+
+
+def test_symbols_path_url(check_for_crashes, minidump_files):
+ """Test that passing a URL as symbols_path correctly fetches the URL."""
+ data = {"retrieved": False}
+
+ def make_zipfile():
+ data = BytesIO()
+ z = zipfile.ZipFile(data, "w")
+ z.writestr("symbols.txt", "abc/xyz")
+ z.close()
+ return data.getvalue()
+
+ def get_symbols(req):
+ data["retrieved"] = True
+
+ headers = {}
+ return (200, headers, make_zipfile())
+
+ httpd = mozhttpd.MozHttpd(
+ port=0,
+ urlhandlers=[{"method": "GET", "path": "/symbols", "function": get_symbols}],
+ )
+ httpd.start()
+ symbol_url = urlunsplit(
+ ("http", "%s:%d" % httpd.httpd.server_address, "/symbols", "", "")
+ )
+
+ assert 1 == check_for_crashes(symbols_path=symbol_url)
+ assert data["retrieved"]
+
+
+if __name__ == "__main__":
+ mozunit.main()