[DTS][PATCH V2 1/2] framework/test_result: fix unsafe __set_test_case
Ke Xu
ke1.xu at intel.com
Wed Mar 15 02:56:54 CET 2023
Without a pre-append check, __set_test_case method will append redundant
elements when setting but locating the result at the first element. If
this method is called several times, the outcome will de-organize in data
structure.
There is a pre-append check in __set_test_suite and __set_test_suite. This
implementation imitated the methods above.
Signed-off-by: Ke Xu <ke1.xu at intel.com>
---
framework/test_result.py | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/framework/test_result.py b/framework/test_result.py
index b62ed120..081b7256 100644
--- a/framework/test_result.py
+++ b/framework/test_result.py
@@ -232,8 +232,9 @@ class Result(object):
def __set_test_case(self, test_case):
cases = self.__current_cases()
- cases.append(test_case)
- cases.append([])
+ if test_case not in cases:
+ cases.append(test_case)
+ cases.append([])
self.__test_case = cases.index(test_case)
def __get_test_case(self):
--
2.25.1
More information about the dts
mailing list