mirror of
https://github.com/boykopovar/AnyPS5.git
synced 2026-11-07 13:39:55 +00:00
fix(tools): reject thread filters on collapsed samples
This commit is contained in:
1 parent
828ac0b2ae
commit
67a6dcfe69
2 files changed
+18
No files matched your search
@@ -272,6 +272,8 @@ def load(path, thread=None):
|
||||
frames, _, count = line.rpartition(" ")
|
||||
if not frames or not count.isdigit():
|
||||
raise ValueError(f"{path}:{number}: expected 'frame;...;frame count', 'module offset self inclusive' or 'thread <id> samples <n>'")
|
||||
if thread is not None:
|
||||
raise ValueError(f"{path}:{number}: thread filtering requires an address capture; collapsed stacks have no thread IDs")
|
||||
samples.stacks[frames] += int(count)
|
||||
return samples
|
||||
|
||||
|
||||
@@ -67,6 +67,22 @@ def build_pe(path, with_symbols=True, with_exports=False, second_code=False, tim
|
||||
|
||||
|
||||
class SymbolizeSamplesTests(unittest.TestCase):
|
||||
def test_collapsed_stacks_reject_thread_filter_without_writing_output(self):
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
root = Path(directory)
|
||||
capture = root / "samples.txt"
|
||||
capture.write_text("example.prx+0x1010 5\n", encoding="utf-8")
|
||||
output = root / "output.txt"
|
||||
output.write_bytes(b"existing output\n")
|
||||
result = subprocess.run([sys.executable, symbolize_samples.__file__, str(capture),
|
||||
"--libs", str(root), "--thread", "123", "--out", str(output)],
|
||||
capture_output=True, text=True, timeout=5)
|
||||
self.assertEqual(result.returncode, 2, result.stdout + result.stderr)
|
||||
self.assertIn("thread filtering requires an address capture", result.stderr)
|
||||
self.assertEqual(result.stdout, "")
|
||||
self.assertNotIn("Traceback", result.stderr)
|
||||
self.assertEqual(output.read_bytes(), b"existing output\n")
|
||||
|
||||
def setUp(self):
|
||||
self.directory = tempfile.TemporaryDirectory()
|
||||
self.root = Path(self.directory.name)
|
||||
|
||||
Reference in new issue
Block a user