821918a512
* Update TT API * Rework serialization * update att_core * Fix tests * Fix tool * Formatting * Fix perfcounter * Formatting * Rename agent TT * Format * Workaround for codeQL alert * Tidy fix * Fix compiler error * Tidy * Fix some tests * Fixing some tests * formatting * Fixing ATT serialization * Format * Fix test commandline * Fixing init order * Format * Tidy fixes * Removing unused sample * Fix tests and schema * Added ATT + PMC test * Fix mode * Fix file mode * Review comments * Fix typo * Review comments * Review comments * Fix missing id inc after review comment * Review comments * Suggested Fixes * Testing changes * Test fix * Build fixes * Minor build fix --------- Co-authored-by: Giovanni Baraldi <gbaraldi@amd.com> Co-authored-by: Benjamin Welton <bewelton@amd.com> Co-authored-by: Welton, Benjamin <Benjamin.Welton@amd.com>
49 lines
1.4 KiB
Python
49 lines
1.4 KiB
Python
#!/usr/bin/env python3
|
|
|
|
import sys
|
|
import pytest
|
|
import re
|
|
import os
|
|
|
|
|
|
def test_json_data(json_data):
|
|
data = json_data["rocprofiler-sdk-tool"]
|
|
strings = data["strings"]
|
|
assert "att_filenames" in strings.keys()
|
|
att_files = data["strings"]["att_filenames"]
|
|
assert len(att_files) > 0
|
|
|
|
|
|
def test_code_object_memory(code_object_file_path, json_data, output_path):
|
|
|
|
data = json_data["rocprofiler-sdk-tool"]
|
|
tool_memory_load = data["strings"]["code_object_snapshot_filenames"]
|
|
gfx_pattern = "gfx[a-z0-9]+"
|
|
match = re.search(gfx_pattern, tool_memory_load[1])
|
|
assert match != None
|
|
gpu_name = match.group(0)
|
|
|
|
read_bytes = lambda filename: open(os.path.join(output_path, filename), "rb").read()
|
|
# Loads all saved code objects
|
|
tool_memory = [read_bytes(saved) for saved in tool_memory_load[1:]]
|
|
|
|
found = False
|
|
for hsa_file in code_object_file_path["hsa_memory_load"]:
|
|
|
|
m = re.search(gfx_pattern, hsa_file)
|
|
assert m != None
|
|
gpu = m.group(0)
|
|
|
|
if gpu == gpu_name:
|
|
found = True
|
|
hsa_memory_bytes = open(hsa_file, "rb").read()
|
|
# Checks if hsa_file is one of the saved code objects
|
|
assert any([hsa_memory_bytes == fs for fs in tool_memory])
|
|
break
|
|
assert found == True
|
|
|
|
|
|
if __name__ == "__main__":
|
|
exit_code = pytest.main(["-x", __file__] + sys.argv[1:])
|
|
sys.exit(exit_code)
|