From patchwork Tue Mar 14 09:01:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ke Xu X-Patchwork-Id: 125094 Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 7BFF241E90; Tue, 14 Mar 2023 10:04:03 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7656A41101; Tue, 14 Mar 2023 10:04:03 +0100 (CET) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by mails.dpdk.org (Postfix) with ESMTP id 0DA6540A7E for ; Tue, 14 Mar 2023 10:04:01 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1678784642; x=1710320642; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=SZOCM6PF7yfaooLJF87YSYLx0xWJa/T9/1BrIb/vytA=; b=Zpz13dmpMd+G+G7NHBIs7oYmGKPuHbGYeBoQaxGhrdY9HSicyLyZf3dP 81rN+cUK1Qxah1vLwNUifkedH/YwQezi2w4itMR07XdBeUMkVE00cSnnq ObzrUFiRlD/0pF6emD8HQbQSKRjRc1hLTGLmMUqPgl6l21lZd6SnNz3yI NE3DUZ6eIoWiIZpAJOf5CBrOPPUA7QH2OojOp9VX8cKavxE44arR4w6bl zBlk+u5aHU1oxy8mgGJkkjeEwhtgcX2lQv48By9daMOLj1D38hpCr0K5b VIX1mY2xw7Ca6IIAGxBLT29huJDICI92Ba54Vd59rxKc+NxLL3xubhGvR w==; X-IronPort-AV: E=McAfee;i="6500,9779,10648"; a="334851326" X-IronPort-AV: E=Sophos;i="5.98,259,1673942400"; d="scan'208";a="334851326" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Mar 2023 02:04:01 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10648"; a="628974530" X-IronPort-AV: E=Sophos;i="5.98,259,1673942400"; d="scan'208";a="628974530" Received: from dpdk-xuke-lab.sh.intel.com ([10.67.119.8]) by orsmga003.jf.intel.com with ESMTP; 14 Mar 2023 02:03:59 -0700 From: Ke Xu To: dts@dpdk.org Cc: lijuan.tu@intel.com, ke1.xu@intel.com Subject: [DTS][PATCH V1 1/2] framework/test_result: fix unsafe __set_test_case Date: Tue, 14 Mar 2023 17:01:06 +0800 Message-Id: <20230314090107.669640-2-ke1.xu@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230314090107.669640-1-ke1.xu@intel.com> References: <20230314090107.669640-1-ke1.xu@intel.com> MIME-Version: 1.0 X-BeenThere: dts@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: test suite reviews and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dts-bounces@dpdk.org 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 --- 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):