From patchwork Thu Feb 22 10:04:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maciej Wieczor-Retman X-Patchwork-Id: 204662 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:aa16:b0:108:e6aa:91d0 with SMTP id by22csp149975dyb; Thu, 22 Feb 2024 02:06:02 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCX9tPClvrYE23xkpm4cnh6DPKj2dPrKVVLpO+NgZT2weaHOr51sH0C9AIhnc0oQxFCBXmat0hunzShoJ2aRU/5vnj/ZAw== X-Google-Smtp-Source: AGHT+IEcnJUBoQ+aQ/JwfGo6BcX0vpsIi2svsLHTGJ6AuF7K1aZ4GLwuiB6o6Sd/tanIxZG2ISQx X-Received: by 2002:a05:6808:228b:b0:3c1:6005:4512 with SMTP id bo11-20020a056808228b00b003c160054512mr10540442oib.51.1708596362816; Thu, 22 Feb 2024 02:06:02 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708596362; cv=pass; d=google.com; s=arc-20160816; b=oW8+cZniwwEd0Dq5ckffJbEBbyhM0mVeBq9kY2RAer4+4LiZt4ZRnJCGxgao6S4X/z XoVf0Uz0QHG6PSHoQCb6QyfY7s8OIsP7f1eOWtv8PRicQjihSIkfU7aufg6gu7q0CqLJ PKrchYPOsNQhEOeItUmhQUjAp6k5B83pI09TI4MTu76kpiANvcbFnQ8yrGSK0k0gGFrr B+mqMeIdJr723TShtniO3+CZ4QdtjMNm1dgRJWtbnDGAGteTu/w5oRZwhkOLClQeoNje 0gJgxDeGSZZqYXRbwV7gU4BwXcftIPkI8pi5H7mt4jbOV8leMxwZSwAiYyAUwU8SRZTY fv2w== 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-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76291-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id r14-20020ac867ce000000b0042e4c2f9486si907422qtp.690.2024.02.22.02.06.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 02:06:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-76291-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; 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-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76291-ouuuleilei=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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 935171C218D8 for ; Thu, 22 Feb 2024 10:06:02 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CE9633E48E; Thu, 22 Feb 2024 10:05:34 +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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791593139858166143 X-GMAIL-MSGID: 1791593139858166143 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); }; /*