Debian Codegraph @

testing/mozbase/mozcrash/tests/test_stackwalk.py

raw
1 #!/usr/bin/env python
2 # coding=UTF-8
3
4 import os
5
6 import mozunit
7 from conftest import fspath
8
9
10 def test_stackwalk_not_found(check_for_crashes, minidump_files, tmpdir, capsys):
11 """Test that check_for_crashes can handle unicode in dump_directory."""
12 stackwalk = tmpdir.join("stackwalk")
13
14 assert 1 == check_for_crashes(stackwalk_binary=fspath(stackwalk), quiet=False)
15
16 out, _ = capsys.readouterr()
17 assert "MINIDUMP_STACKWALK binary not found" in out
18
19
20 def test_stackwalk_envvar(check_for_crashes, minidump_files, stackwalk):
21 """Test that check_for_crashes uses the MINIDUMP_STACKWALK environment var."""
22 os.environ["MINIDUMP_STACKWALK"] = fspath(stackwalk)
23 try:
24 assert 1 == check_for_crashes(stackwalk_binary=None)
25 finally:
26 del os.environ["MINIDUMP_STACKWALK"]
27
28
29 def test_stackwalk_unicode(check_for_crashes, minidump_files, tmpdir, capsys):
30 """Test that check_for_crashes can handle unicode in dump_directory."""
31 stackwalk = tmpdir.mkdir("🍪").join("stackwalk")
32 stackwalk.write("fake binary")
33 stackwalk.chmod(0o744)
34
35 assert 1 == check_for_crashes(stackwalk_binary=fspath(stackwalk), quiet=False)
36
37 out, err = capsys.readouterr()
38 assert fspath(stackwalk) in out
39
40
41 if __name__ == "__main__":
42 mozunit.main()