@@ -1,6 +1,7 @@
# SPDX-License-Identifier: GPL-2.0
import builtins
+import inspect
from .consts import KSFT_MAIN_NAME
KSFT_RESULT = None
@@ -18,32 +19,34 @@ KSFT_RESULT = None
print("#", *objs, **kwargs)
+def _fail(*args):
+ global KSFT_RESULT
+ KSFT_RESULT = False
+
+ frame = inspect.stack()[2]
+ ksft_pr("At " + frame.filename + " line " + str(frame.lineno) + ":")
+ ksft_pr(*args)
+
+
def ksft_eq(a, b, comment=""):
global KSFT_RESULT
if a != b:
- KSFT_RESULT = False
- ksft_pr("Check failed", a, "!=", b, comment)
+ _fail("Check failed", a, "!=", b, comment)
def ksft_true(a, comment=""):
- global KSFT_RESULT
if not a:
- KSFT_RESULT = False
- ksft_pr("Check failed", a, "does not eval to True", comment)
+ _fail("Check failed", a, "does not eval to True", comment)
def ksft_in(a, b, comment=""):
- global KSFT_RESULT
if a not in b:
- KSFT_RESULT = False
- ksft_pr("Check failed", a, "not in", b, comment)
+ _fail("Check failed", a, "not in", b, comment)
def ksft_ge(a, b, comment=""):
- global KSFT_RESULT
if a < b:
- KSFT_RESULT = False
- ksft_pr("Check failed", a, "<", b, comment)
+ _fail("Check failed", a, "<", b, comment)
def ktap_result(ok, cnt=1, case="", comment=""):