summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2023-05-24 13:27:38 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2023-06-14 13:58:42 +0200
commit697e33618fd8b6122370f33322d26b6af7dbd7d1 (patch)
tree8969826796b5b484bb0e3b443f3b0d6a27dfbd57
parentinterface: Add register set macros (diff)
downloadrtems-central-697e33618fd8b6122370f33322d26b6af7dbd7d1.tar.bz2
content: Improve duration()
-rw-r--r--rtemsspec/content.py4
-rw-r--r--rtemsspec/tests/test_content.py1
2 files changed, 4 insertions, 1 deletions
diff --git a/rtemsspec/content.py b/rtemsspec/content.py
index 5bccd325..9651664e 100644
--- a/rtemsspec/content.py
+++ b/rtemsspec/content.py
@@ -1208,8 +1208,10 @@ def get_integer_type(value: int) -> str:
return f"uint{power}_t"
-def duration(value: float) -> str:
+def duration(value: Union[float, str]) -> str:
""" Converts a duration in seconds into a value with unit string. """
+ if isinstance(value, str):
+ return value
assert value >= 0.0
if value == 0.0:
return "0s"
diff --git a/rtemsspec/tests/test_content.py b/rtemsspec/tests/test_content.py
index e2a17d12..6bc344fa 100644
--- a/rtemsspec/tests/test_content.py
+++ b/rtemsspec/tests/test_content.py
@@ -333,6 +333,7 @@ def test_enabled_by_to_python_exp():
def test_duration():
+ assert duration("abc") == "abc"
assert duration(1.0) == "1.000s"
assert duration(0.0) == "0s"
assert duration(0.001) == "1.000ms"