Received: by 2002:a05:7412:798b:b0:fc:a2b0:25d7 with SMTP id fb11csp240098rdb; Thu, 22 Feb 2024 02:05:40 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXTkLeE1c37hz2cFFLOI6rJ1HjK2aSZIhkceTXQ1V1fu7TQOcRI3wpW2hhcFWyvw1eLj1xxCnUoT7vIjnCqdQc4KzwYll7OO9/tUyDL2Q== X-Google-Smtp-Source: AGHT+IHmgHtck6RL/z9euxWeINrSdpjK3+OUd65RzgjYawZyjV3FXMlHgJLAq0fWzDiE5t2omuq9 X-Received: by 2002:aa7:df19:0:b0:565:221a:e9f8 with SMTP id c25-20020aa7df19000000b00565221ae9f8mr1587981edy.26.1708596340620; Thu, 22 Feb 2024 02:05:40 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708596340; cv=pass; d=google.com; s=arc-20160816; b=hRw6Y6XuYnakiNJN/3hDT0tm040MTWVVc9l/PFOTn57x4mUHACJ0zwUa4XUgEqJE4B iWYYNWjtbKYD7sI1wZw1StmUewHMrey2xNBMc2A+iOgXYIZ4FwXd4hNo0c77b8/Gwe4z Rn+khkHqDYhpTGi0BL6GBb8SslnTHOfCzsnfWlsarY9MYAyIyLfT9rja4pOIRjJBW8jm iSUOIM9X5nvw3geGvuOfz1ezhPB8fgwfe+2+kexmhZTv1RBgZ9ojx97jDiKafuI4fYP/ W9MgJ3PCNkGcliSKDwxSVUcyOorCTY4n2K2rgzeUBhjAT/EiD1ArUt5d7qH/R6opMj1f vT6A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=Kz+Gt17KXu3MufKvcjoPUtuGH/UHQhj9Uv5dvuxf7Ik=; fh=/pACME0x50g4vorTSG5vEdNwgU981WFvy8LGbk4DPBk=; b=XnGt4Kf64A15OrOr+OXjlgS7AqNfAE8iwX2aCP8dCaBl6S5hsUzfcj9hCcPenM6elM zGFkNE59n/t9v2sFjH1LcwsZuZGLOo6E3EMNN5euCfWZiavo4kpvxXXNiH+CLcB8MJyS FV8d5CXWwcnpUVkmjLeutZ7MKfUjdKjanf7F1GxX/jB59lxWhp+p7NyzBQZvuWs4q5Pt lbnpEKLpymqSvEUKdW8wT+GkJnnww3CHiMEZjOt+Rv7z4/EapmVB9tWir2f/5i0BLWQO 3oyqhjBrOr1lUghOMKW09p69H7VwtDNdQED0Z3e245gh9WEVWh+GRdF1m2WZH+cZe+GA BUug==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=VaZBzezE; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-76291-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76291-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id l2-20020a50d6c2000000b0056459dad586si4141851edj.357.2024.02.22.02.05.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 02:05:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-76291-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=VaZBzezE; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-76291-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76291-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 33C301F225E2 for ; Thu, 22 Feb 2024 10:05:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CF8613A1C6; Thu, 22 Feb 2024 10:05:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="VaZBzezE" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 791C639FDC; Thu, 22 Feb 2024 10:05:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708596325; cv=none; b=IO9bezJsbrLPs8TH08H7sd+FgoDYcCtK9XxWct3z5bmW6fR51KtZF2XSCu89HaqtAuHvZ+ftKMKsNlwTeKz5mV0RcZS7TqJFP8MfZhSR7Y1Yx4MT0rSTPiiLjdgrGgQGzXdxL1SDYw4aGMCp+342Epxw1XYIU+SjzSkjBvKv/7E= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708596325; c=relaxed/simple; bh=Gi1VkP9GPyzQfNuuc0NAYEJ6mkbO6wyMOkVcf8T5EK0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HxtnV274viniheZM1k/597B+PSyTku7kaycS/CiIqQ+XbLlGgw4yOBLCILlokdyT1xZKNoARxgBut2tSh4KYhZxzxHaii0hRpLVlkspBjjSS4ivtHfhXOQWaDp8FSP+vqwY+JX0U8sP5jLqh5rUD1BR3PHDCapjQo8+75Frou1U= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=VaZBzezE; arc=none smtp.client-ip=198.175.65.18 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1708596311; x=1740132311; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Gi1VkP9GPyzQfNuuc0NAYEJ6mkbO6wyMOkVcf8T5EK0=; b=VaZBzezERro6mMGYSi+ENTxKhb6n6BO27p2EmIgKHZaDQ3b8cpIuVD/9 FbOUeGubfYU/gA7p75ER4o+ZDzjFwMM02Ti8ButrG10e45We4Z3+mDiUJ dYM6/5SWtyjD3FLgaHrAlQjz5d1ljDVSCNtsQnosODExFWkr3XsaAjTr6 me3reEwxjbGDa7RJi8OgnokIwWzV0MtuhuE2xx4gcNV4xgNf4NrEho3Z3 2oq01WY6Q/CGRV/KNUhRWQ8SnwuZ1RKnLF9d1WgrKBoIE1kmpdPg+2bxc JXqnWyYgp+J9PsWjatABDLDKQ2SQqw0Jx0whEIcXupF1McFp0SiUmd97/ A==; X-IronPort-AV: E=McAfee;i="6600,9927,10991"; a="2920696" X-IronPort-AV: E=Sophos;i="6.06,177,1705392000"; d="scan'208";a="2920696" Received: from orviesa007.jf.intel.com ([10.64.159.147]) by orvoesa110.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Feb 2024 02:05:04 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,177,1705392000"; d="scan'208";a="5753878" Received: from ksulimow-mobl1.ger.corp.intel.com (HELO wieczorr-mobl1.intel.com) ([10.213.23.120]) by orviesa007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Feb 2024 02:05:02 -0800 From: Maciej Wieczor-Retman To: Fenghua Yu , Reinette Chatre , Shuah Khan Cc: ilpo.jarvinen@linux.intel.com, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: [PATCH v2 1/3] selftests/resctrl: Add cleanup function to test framework Date: Thu, 22 Feb 2024 11:04:28 +0100 Message-ID: <357fdb981c7dddcc474818f7bedb1f57a79e117c.1708596015.git.maciej.wieczor-retman@intel.com> X-Mailer: git-send-email 2.43.2 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Resctrl selftests use very similar functions to cleanup after themselves. This creates a lot of code duplication. Also not being hooked to the test framework means that ctrl-c handler isn't aware of what test is currently running and executes all cleanups even though only one is needed. Add a function pointer to the resctrl_test struct and attach to it cleanup functions from individual tests. Signed-off-by: Maciej Wieczor-Retman --- tools/testing/selftests/resctrl/cat_test.c | 1 + tools/testing/selftests/resctrl/cmt_test.c | 1 + tools/testing/selftests/resctrl/mba_test.c | 1 + tools/testing/selftests/resctrl/mbm_test.c | 1 + tools/testing/selftests/resctrl/resctrl.h | 2 ++ 5 files changed, 6 insertions(+) diff --git a/tools/testing/selftests/resctrl/cat_test.c b/tools/testing/selftests/resctrl/cat_test.c index 24af8310288a..2d2f69d3e5b7 100644 --- a/tools/testing/selftests/resctrl/cat_test.c +++ b/tools/testing/selftests/resctrl/cat_test.c @@ -299,4 +299,5 @@ struct resctrl_test l3_cat_test = { .resource = "L3", .feature_check = test_resource_feature_check, .run_test = cat_run_test, + .cleanup = cat_test_cleanup, }; diff --git a/tools/testing/selftests/resctrl/cmt_test.c b/tools/testing/selftests/resctrl/cmt_test.c index dd5ca343c469..32ddee87e43d 100644 --- a/tools/testing/selftests/resctrl/cmt_test.c +++ b/tools/testing/selftests/resctrl/cmt_test.c @@ -178,4 +178,5 @@ struct resctrl_test cmt_test = { .resource = "L3", .feature_check = cmt_feature_check, .run_test = cmt_run_test, + .cleanup = cmt_test_cleanup, }; diff --git a/tools/testing/selftests/resctrl/mba_test.c b/tools/testing/selftests/resctrl/mba_test.c index da256d2dbe5c..7cc4067ce930 100644 --- a/tools/testing/selftests/resctrl/mba_test.c +++ b/tools/testing/selftests/resctrl/mba_test.c @@ -180,4 +180,5 @@ struct resctrl_test mba_test = { .vendor_specific = ARCH_INTEL, .feature_check = mba_feature_check, .run_test = mba_run_test, + .cleanup = mba_test_cleanup, }; diff --git a/tools/testing/selftests/resctrl/mbm_test.c b/tools/testing/selftests/resctrl/mbm_test.c index 34879e7b71a0..071e2d3808a7 100644 --- a/tools/testing/selftests/resctrl/mbm_test.c +++ b/tools/testing/selftests/resctrl/mbm_test.c @@ -150,4 +150,5 @@ struct resctrl_test mbm_test = { .vendor_specific = ARCH_INTEL, .feature_check = mbm_feature_check, .run_test = mbm_run_test, + .cleanup = mbm_test_cleanup, }; diff --git a/tools/testing/selftests/resctrl/resctrl.h b/tools/testing/selftests/resctrl/resctrl.h index c52eaf46f24d..0f49df4961ea 100644 --- a/tools/testing/selftests/resctrl/resctrl.h +++ b/tools/testing/selftests/resctrl/resctrl.h @@ -70,6 +70,7 @@ struct user_params { * @disabled: Test is disabled * @feature_check: Callback to check required resctrl features * @run_test: Callback to run the test + * @cleanup: Callback to cleanup after the test */ struct resctrl_test { const char *name; @@ -79,6 +80,7 @@ struct resctrl_test { bool (*feature_check)(const struct resctrl_test *test); int (*run_test)(const struct resctrl_test *test, const struct user_params *uparams); + void (*cleanup)(void); }; /* -- 2.43.2