testing/mozbase/mozcrash/tests/test_stackwalk.py
author Marian-Vasile Laza <mlaza@mozilla.com>
Mon, 06 Feb 2023 13:45:17 +0200
changeset 651854 b06e825a4d8137434a1524b1ef7049f85cdc60d1
parent 647332 8e89f8e20ad6336c3cbb4d895d36077e46f6489b
permissions -rw-r--r--
Backed out changeset 8b3b3c83025d (bug 1797899) for bc failures on browser_AddonStudies.js. CLOSED TREE

#!/usr/bin/env python
# coding=UTF-8

import os

import mozunit
from conftest import fspath


def test_stackwalk_not_found(check_for_crashes, minidump_files, tmpdir, capsys):
    """Test that check_for_crashes can handle unicode in dump_directory."""
    stackwalk = tmpdir.join("stackwalk")

    assert 1 == check_for_crashes(stackwalk_binary=fspath(stackwalk), quiet=False)

    out, _ = capsys.readouterr()
    assert "MINIDUMP_STACKWALK binary not found" in out


def test_stackwalk_envvar(check_for_crashes, minidump_files, stackwalk):
    """Test that check_for_crashes uses the MINIDUMP_STACKWALK environment var."""
    os.environ["MINIDUMP_STACKWALK"] = fspath(stackwalk)
    try:
        assert 1 == check_for_crashes(stackwalk_binary=None)
    finally:
        del os.environ["MINIDUMP_STACKWALK"]


def test_stackwalk_unicode(check_for_crashes, minidump_files, tmpdir, capsys):
    """Test that check_for_crashes can handle unicode in dump_directory."""
    stackwalk = tmpdir.mkdir(u"🍪").join("stackwalk")
    stackwalk.write("fake binary")
    stackwalk.chmod(0o744)

    assert 1 == check_for_crashes(stackwalk_binary=fspath(stackwalk), quiet=False)

    out, err = capsys.readouterr()
    assert fspath(stackwalk) in out


if __name__ == "__main__":
    mozunit.main()