Received: by 2002:a05:7412:cfc7:b0:fc:a2b0:25d7 with SMTP id by7csp1720122rdb; Tue, 20 Feb 2024 05:15:22 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXwqZPb8cMmFx0xofXF0lkGuf2vwWe6KFVhoSURBLGzY217z94rFZ7ylV1rpGrxMXKFjw2ikzvQEprUlfFfjxYC603M6JiQchpHyx00cw== X-Google-Smtp-Source: AGHT+IFVKPfjgb1DOnaX3Usb022veYuDWoHAgxse53DFLxIFOt1vl1SaATTRJCmsza5pQwJbKBxB X-Received: by 2002:a17:902:f711:b0:1db:ad25:488 with SMTP id h17-20020a170902f71100b001dbad250488mr14044744plo.19.1708434921736; Tue, 20 Feb 2024 05:15:21 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708434921; cv=pass; d=google.com; s=arc-20160816; b=j1looih/xhjASEJoufoAQX9WdZ0FniA0C387w2q04q09ik6iL314dRgJa8ZS36W1m5 9LIIAQ+ePQuEBJY9ydSlS+6hdN6i5r2R2bSTqbsFaZKm+mQSbpnbEI4EGYe8F/a40o/6 SVTf9KdbhoiR1FP70FTbvBrkCUjZqdUusWZRX0k0iHN7dc4+VX2kHJjjLL4VGQM7/gqZ wBNlXjYCbPzRM0bFaFuqQeJALZw7DPsJB3ipI8wCGmdG43Pmu0JTsIcSkIcF0a6SBLBr g11L7O8YVgKihSzMrvTAa7qUSQ/Jvm4GG/cfBIw1wOR5ZWqJh29UVM/4bww/r4Bk/bY7 UEpw== 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=dUP0hmPO+Q1QZLO8j/7aoGrc2CWGxl6lKxY3slwz0LryhFnKapqV+3IM9G825+SQk8 Z5N3WdYhR1rPsnk4IVax3Kx01Ut8KhnJTmXRc+zAlVCwpeZKWk9AgsELVq6tisZvhHI+ WHdU/U+5KrYr0Q56P2CkVHUW9HK9Mbp6ojPD6DeSmd3V70A+fAwv6s+jTNdph6F9xwGk OBsydyOBWK782TogITdh3BfCyA7BkMkLNmMkG1zJw5YrfcHs/n+jS3NtM14ZLPVWHm0a kIFct3TDwibsAxrzrjCxtgHVGxyyEBZcF9fLTUp1TJ4bDCOo2N2yAHbEN4K2IsRsalDe BS0A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="SpuCm5l/"; 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-73058-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-73058-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id b2-20020a170902ed0200b001db7c8f7cb8si6070062pld.24.2024.02.20.05.15.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Feb 2024 05:15:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-73058-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="SpuCm5l/"; 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-73058-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-73058-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 609CA283FB0 for ; Tue, 20 Feb 2024 13:15:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7A0B86A033; Tue, 20 Feb 2024 13:15:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="SpuCm5l/" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.17]) (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 1A3C16A00B; Tue, 20 Feb 2024 13:14:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.17 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708434900; cv=none; b=gosQAP7weOVj2m5WO76jioszg7uu+aMDPqNpmigKaS5U2sNs5i7YcbBOSFRd5PrNjVhGaoN1vvgBalAeUIX1m0oLFIm24MhijVdaF/R0yYX9OZgjkA1H+8HGEXmibVK91qcOtU++jNbhB7JrwTHq+Qo1n6q+MFubcHhJLAOug1g= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708434900; c=relaxed/simple; bh=Gi1VkP9GPyzQfNuuc0NAYEJ6mkbO6wyMOkVcf8T5EK0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=e78Q/4bqnmSn/1nx+PMk3vzz84i+agPPhyDa7GTdNlNZwUjV7b3xCApWJCdcXcqpIurdHvirx7NGfxBeerjneevNycUR+TDMdhuxWNfns3P4H2ANLgoVYuzkv6hYgKMuR5ywQ9k1Y6CRIDBgWF4Y72JfANnUGjZNTYP/XCDfcFw= 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=SpuCm5l/; arc=none smtp.client-ip=198.175.65.17 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=1708434899; x=1739970899; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Gi1VkP9GPyzQfNuuc0NAYEJ6mkbO6wyMOkVcf8T5EK0=; b=SpuCm5l/UzBPYuTtJCHIITtY0oRYY+9ShbRu4wY+e1HS91sCzMLGRICm xsP+qDFo7uOlkAHqcEa6eprdwT+NcY1XWaBQQRFIjYUSy1MTJMUrjUUaZ ctlXsz9bj/0deMyzi3MXQ02I0ovJElgMkPXa+Gdq8BkmMJlhLIqMTZ2ZF jdix8u0qiet4YizJDItOlcXMGhqBEN9W6m00rowzQLSHlF+STuvTFnk2V gdfIw7+6ILHEuQzNQMjaqJA3lNzvYaoQZNgqKXy6oFXRx3Ogqdd/65bkW AD7FejfpsTgtHIV428ONECB/w8MikjwjT/K1IuMxMJ+6sgK1kiI/qrNTV A==; X-IronPort-AV: E=McAfee;i="6600,9927,10989"; a="2660614" X-IronPort-AV: E=Sophos;i="6.06,172,1705392000"; d="scan'208";a="2660614" Received: from orviesa006.jf.intel.com ([10.64.159.146]) by orvoesa109.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Feb 2024 05:14:58 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,172,1705392000"; d="scan'208";a="5130948" Received: from jmuniak-mobl.ger.corp.intel.com (HELO wieczorr-mobl1.intel.com) ([10.213.4.63]) by orviesa006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Feb 2024 05:14:55 -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 1/3] selftests/resctrl: Add cleanup function to test framework Date: Tue, 20 Feb 2024 14:14:32 +0100 Message-ID: <357fdb981c7dddcc474818f7bedb1f57a79e117c.1708434017.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