summaryrefslogtreecommitdiffstats
path: root/testing/mozbase/mozdebug/tests
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
commit43a97878ce14b72f0981164f87f2e35e14151312 (patch)
tree620249daf56c0258faa40cbdcf9cfba06de2a846 /testing/mozbase/mozdebug/tests
parentInitial commit. (diff)
downloadfirefox-43a97878ce14b72f0981164f87f2e35e14151312.tar.xz
firefox-43a97878ce14b72f0981164f87f2e35e14151312.zip
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/mozbase/mozdebug/tests')
-rwxr-xr-xtesting/mozbase/mozdebug/tests/fake_debuggers/cgdb/cgdb0
-rwxr-xr-xtesting/mozbase/mozdebug/tests/fake_debuggers/devenv/devenv.exe0
-rwxr-xr-xtesting/mozbase/mozdebug/tests/fake_debuggers/gdb/gdb0
-rwxr-xr-xtesting/mozbase/mozdebug/tests/fake_debuggers/lldb/lldb0
-rwxr-xr-xtesting/mozbase/mozdebug/tests/fake_debuggers/wdexpress/wdexpress.exe0
-rw-r--r--testing/mozbase/mozdebug/tests/manifest.ini3
-rw-r--r--testing/mozbase/mozdebug/tests/test.py65
7 files changed, 68 insertions, 0 deletions
diff --git a/testing/mozbase/mozdebug/tests/fake_debuggers/cgdb/cgdb b/testing/mozbase/mozdebug/tests/fake_debuggers/cgdb/cgdb
new file mode 100755
index 0000000000..e69de29bb2
--- /dev/null
+++ b/testing/mozbase/mozdebug/tests/fake_debuggers/cgdb/cgdb
diff --git a/testing/mozbase/mozdebug/tests/fake_debuggers/devenv/devenv.exe b/testing/mozbase/mozdebug/tests/fake_debuggers/devenv/devenv.exe
new file mode 100755
index 0000000000..e69de29bb2
--- /dev/null
+++ b/testing/mozbase/mozdebug/tests/fake_debuggers/devenv/devenv.exe
diff --git a/testing/mozbase/mozdebug/tests/fake_debuggers/gdb/gdb b/testing/mozbase/mozdebug/tests/fake_debuggers/gdb/gdb
new file mode 100755
index 0000000000..e69de29bb2
--- /dev/null
+++ b/testing/mozbase/mozdebug/tests/fake_debuggers/gdb/gdb
diff --git a/testing/mozbase/mozdebug/tests/fake_debuggers/lldb/lldb b/testing/mozbase/mozdebug/tests/fake_debuggers/lldb/lldb
new file mode 100755
index 0000000000..e69de29bb2
--- /dev/null
+++ b/testing/mozbase/mozdebug/tests/fake_debuggers/lldb/lldb
diff --git a/testing/mozbase/mozdebug/tests/fake_debuggers/wdexpress/wdexpress.exe b/testing/mozbase/mozdebug/tests/fake_debuggers/wdexpress/wdexpress.exe
new file mode 100755
index 0000000000..e69de29bb2
--- /dev/null
+++ b/testing/mozbase/mozdebug/tests/fake_debuggers/wdexpress/wdexpress.exe
diff --git a/testing/mozbase/mozdebug/tests/manifest.ini b/testing/mozbase/mozdebug/tests/manifest.ini
new file mode 100644
index 0000000000..72aff7539a
--- /dev/null
+++ b/testing/mozbase/mozdebug/tests/manifest.ini
@@ -0,0 +1,3 @@
+[DEFAULT]
+subsuite = mozbase
+[test.py]
diff --git a/testing/mozbase/mozdebug/tests/test.py b/testing/mozbase/mozdebug/tests/test.py
new file mode 100644
index 0000000000..57bbfec95d
--- /dev/null
+++ b/testing/mozbase/mozdebug/tests/test.py
@@ -0,0 +1,65 @@
+#!/usr/bin/env python
+
+import os
+
+import mozunit
+import pytest
+from mozdebug.mozdebug import (
+ _DEBUGGER_PRIORITIES,
+ DebuggerSearch,
+ get_default_debugger_name,
+)
+
+here = os.path.abspath(os.path.dirname(__file__))
+
+
+@pytest.fixture
+def set_debuggers(monkeypatch):
+ debugger_dir = os.path.join(here, "fake_debuggers")
+
+ def _set_debuggers(*debuggers):
+ dirs = []
+ for d in debuggers:
+ if d.endswith(".exe"):
+ d = d[: -len(".exe")]
+ dirs.append(os.path.join(debugger_dir, d))
+ monkeypatch.setenv("PATH", os.pathsep.join(dirs))
+
+ return _set_debuggers
+
+
+@pytest.mark.parametrize("os_name", ["android", "linux", "mac", "win", "unknown"])
+def test_default_debugger_name(os_name, set_debuggers, monkeypatch):
+ import sys
+
+ import mozinfo
+
+ def update_os_name(*args, **kwargs):
+ mozinfo.info["os"] = os_name
+
+ monkeypatch.setattr(mozinfo, "find_and_update_from_json", update_os_name)
+
+ if sys.platform == "win32":
+ # This is used so distutils.spawn.find_executable doesn't add '.exe'
+ # suffixes to all our dummy binaries on Windows.
+ monkeypatch.setattr(sys, "platform", "linux")
+
+ debuggers = _DEBUGGER_PRIORITIES[os_name][:]
+ debuggers.reverse()
+ first = True
+ while len(debuggers) > 0:
+ set_debuggers(*debuggers)
+
+ if first:
+ assert get_default_debugger_name() == debuggers[-1]
+ first = False
+ else:
+ assert get_default_debugger_name() is None
+ assert (
+ get_default_debugger_name(DebuggerSearch.KeepLooking) == debuggers[-1]
+ )
+ debuggers = debuggers[:-1]
+
+
+if __name__ == "__main__":
+ mozunit.main()