tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test_stackwalk.py (1247B)


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