test suite reviews and discussions
 help / color / mirror / Atom feed
From: Ke Xu <ke1.xu@intel.com>
To: dts@dpdk.org
Cc: lijuan.tu@intel.com, ke1.xu@intel.com
Subject: [DTS][PATCH V2 1/2] framework/test_result: fix unsafe __set_test_case
Date: Wed, 15 Mar 2023 09:56:54 +0800	[thread overview]
Message-ID: <20230315015655.768885-2-ke1.xu@intel.com> (raw)
In-Reply-To: <20230315015655.768885-1-ke1.xu@intel.com>

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@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


  reply	other threads:[~2023-03-15  1:59 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-15  1:56 [DTS][PATCH V2 0/2] fix result output overwriting when using multiple lines in execution configuration for one suite Ke Xu
2023-03-15  1:56 ` Ke Xu [this message]
2023-03-15  1:56 ` [DTS][PATCH V2 2/2] framework/dts: fix result output by merging cases when parsing execution requirements Ke Xu
2023-03-28  0:54   ` lijuan.tu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230315015655.768885-2-ke1.xu@intel.com \
    --to=ke1.xu@intel.com \
    --cc=dts@dpdk.org \
    --cc=lijuan.tu@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).