Skip to content

Commit

Permalink
Add few tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tfiedor committed May 10, 2024
1 parent e31419b commit 780ed60
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
19 changes: 9 additions & 10 deletions perun/profile/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,16 +135,15 @@ def to_flame_graph_format(profile: Profile, profile_key: str = "amount") -> list
for alloc in snapshot:
if "subtype" not in alloc.keys() or alloc["subtype"] != "free":
# Workaround for total time used in some collectors, so it is not outputted
if alloc["uid"] == "%TOTAL_TIME%":
continue
stack_str = to_uid(alloc["uid"]) + ";"
for frame in alloc["trace"][::-1]:
line = to_string_line(frame)
stack_str += line + ";"
if stack_str and stack_str.endswith(";"):
final = stack_str[:-1]
final += " " + str(alloc[profile_key]) + "\n"
stacks.append(final)
if alloc["uid"] != "%TOTAL_TIME%":
stack_str = to_uid(alloc["uid"]) + ";"
for frame in alloc["trace"][::-1]:
line = to_string_line(frame)
stack_str += line + ";"
if stack_str and stack_str.endswith(";"):
final = stack_str[:-1]
final += " " + str(alloc[profile_key]) + "\n"
stacks.append(final)

return stacks

Expand Down
4 changes: 4 additions & 0 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from perun.collect.trace.optimizations.structs import Complexity
from perun.fuzz import filetype
from perun.logic import commands, config
from perun.profile import convert
from perun.testing import asserts
from perun.utils import log
from perun.utils.common import common_kit, cli_kit, traces_kit
Expand Down Expand Up @@ -291,6 +292,9 @@ def simple_generator():
assert common_kit.compact_convert_num_to_str(10.0) == "10"
assert common_kit.compact_convert_num_to_str(10.123) == "10.12"

assert convert.to_string_line("uid") == "uid"
assert convert.flatten(["hello", "world"]) == "hello,world"


def test_predicates(capsys):
"""Test predicates used for testing"""
Expand Down

0 comments on commit 780ed60

Please sign in to comment.