From patchwork Tue Jun 18 02:24:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Hubbard X-Patchwork-Id: 13701702 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 97823C27C79 for ; Tue, 18 Jun 2024 02:27:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 20AB86B0280; Mon, 17 Jun 2024 22:27:32 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 194456B0281; Mon, 17 Jun 2024 22:27:32 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F01666B0282; Mon, 17 Jun 2024 22:27:31 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id CF0D66B0280 for ; Mon, 17 Jun 2024 22:27:31 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 87066C02E1 for ; Tue, 18 Jun 2024 02:27:31 +0000 (UTC) X-FDA: 82242423102.02.8B848B7 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2084.outbound.protection.outlook.com [40.107.243.84]) by imf07.hostedemail.com (Postfix) with ESMTP id BD20E40007 for ; Tue, 18 Jun 2024 02:27:27 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=Nvidia.com header.s=selector2 header.b=R9dQgSVt; spf=pass (imf07.hostedemail.com: domain of jhubbard@nvidia.com designates 40.107.243.84 as permitted sender) smtp.mailfrom=jhubbard@nvidia.com; arc=pass ("microsoft.com:s=arcselector9901:i=1"); dmarc=pass (policy=reject) header.from=nvidia.com ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1718677643; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=lND8relr0oO4VJNIro7up2xxQynbvMNqIHPRAUyXI4A=; b=qOJgwadQ8kiAJhpJY8YeFiyeDDgCFT2V6tDojkQFw9FrdqqigaH/Xuds1fV374/fKEgQ6H OSwI96kGwDQ8t4FXwlKRR/82qyWRhJDhGGWJpCMqT7ZlvCYj+3MPwad7mdFZFp8ku/zQPr WsFXIT/B3X2yW1A3xSP0GL9U2STHJpA= ARC-Authentication-Results: i=2; imf07.hostedemail.com; dkim=pass header.d=Nvidia.com header.s=selector2 header.b=R9dQgSVt; spf=pass (imf07.hostedemail.com: domain of jhubbard@nvidia.com designates 40.107.243.84 as permitted sender) smtp.mailfrom=jhubbard@nvidia.com; arc=pass ("microsoft.com:s=arcselector9901:i=1"); dmarc=pass (policy=reject) header.from=nvidia.com ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1718677643; a=rsa-sha256; cv=pass; b=N/vQPsjSURA1SgonNGjozRfL3NsEAf+xpT0NHMNHI4YhBT7NMncX8LYwrJjVZ3pV75UhCg j1+XmO06hfZ9y1DfrE1AFTMd10aCnG+Vcy9EZ/nPWbB+j1gqjaRV06KDRVK4HqvuYWrsyL yajrbZ9914KbYQF1yBWY1VbxCJdSiUA= ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bAh4RBpjOajOqryWUlJe0lQ571wKD2l9BV+/z9YG42/lwZdHC4hxG4+0ROVCSS6cPGBmh3HEB+BVaiSFqpXRuSiwT8cf9Kvgy7PvqV+Cn0uqtAvS3SkE2dKQ6Jnh1H/P9EUvukXbgSnCvci9LDVMwuHpRaAr2G9FTnrlziwjMD2ktPxbg/HXzTvNb8hoJTOOEY8JgsAkfXcDQ4uu938VPbS7Y6FP6VkREz4hDTNdJ6dmZJOu3H6abTzV3JAqu+vQfWWrUZv4XQPtVTZysy1bg3XmGo+r/yj4BnN4LHxOU1cyu5ePcT5vkPqXzPKNezzl0nR3qOKOYDnCcyTa6X6MJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=lND8relr0oO4VJNIro7up2xxQynbvMNqIHPRAUyXI4A=; b=DgVuwnH2KY9QBm+a8kltOL89WMYCektTMrwyQ4Wvl8Qa/pLyWjdLPnzc+FQo1A5pgOPddbHxkwAzgBt7ssu6gSKohtnV/USzFBDtvCxrnaywqrDN62u2WQhRhDSt68Vs1TPsQaPwEgJue3y05lYSqZ3K76924LvpObkh9IucqgwrXatsPbGDj2zHDVvCbKv4OXDwOMf0qOgItpvzGy2mAZGu4Bo0UeNKfobhJZQgYtBsUcrPEsmrrEIzecmdBDR37ePLug/8QtifWo4IGLRWO1fP/zXNTU/uDvjN8goZ8+fJ+E/X5QrG9bcDYuannk4zo9XDWmYqmAKKqJYcx+CUDw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=lND8relr0oO4VJNIro7up2xxQynbvMNqIHPRAUyXI4A=; b=R9dQgSVtakbqUZJvgOFzVbj5nDb7vCpkXkyYnJGoRKdgnaQhY1Gk8LR5aUvzRU5ON1Cm8z1lm4YJwtzJ5pkGkJVDnxej0kwS13GTIApa6+h0LynIOqEgvpeYD9NUGw/s1RJ/D51RzVoMAyuyjKSKfGzH3nIaFYAbyU12dSTDjicf3u5dveQAo2A/2dlQHoKnGI0UvDVkYuGeDMWRF5hVdz+lI5EH9/LcyOg090RM5TRpJhm/T9qV3c9H3r22fb++yA1Y0m5yswkTasaHrzxXYDm8K2rvqaDE6O8AeMONG4YOAsblfKD0OD4JCGpwJBU2eXmvbNCT0SfIH0FbE/io/Q== Received: from BY5PR12MB4130.namprd12.prod.outlook.com (2603:10b6:a03:20b::16) by SA3PR12MB8047.namprd12.prod.outlook.com (2603:10b6:806:31b::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.31; Tue, 18 Jun 2024 02:24:25 +0000 Received: from BY5PR12MB4130.namprd12.prod.outlook.com ([fe80::2cf4:5198:354a:cd07]) by BY5PR12MB4130.namprd12.prod.outlook.com ([fe80::2cf4:5198:354a:cd07%4]) with mapi id 15.20.7677.030; Tue, 18 Jun 2024 02:24:25 +0000 From: John Hubbard To: Andrew Morton , Jeff Xu , Shuah Khan Cc: Andrei Vagin , Axel Rasmussen , Christian Brauner , David Hildenbrand , Kees Cook , Kent Overstreet , "Liam R . Howlett" , Muhammad Usama Anjum , Peter Xu , Rich Felker , linux-mm@kvack.org, linux-kselftest@vger.kernel.org, LKML , John Hubbard Subject: [PATCH v3 2/6] selftests/mm: mseal, self_elf: factor out test macros and other duplicated items Date: Mon, 17 Jun 2024 19:24:18 -0700 Message-ID: <20240618022422.804305-3-jhubbard@nvidia.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240618022422.804305-1-jhubbard@nvidia.com> References: <20240618022422.804305-1-jhubbard@nvidia.com> X-NVConfidentiality: public X-ClientProxiedBy: BYAPR07CA0065.namprd07.prod.outlook.com (2603:10b6:a03:60::42) To BY5PR12MB4130.namprd12.prod.outlook.com (2603:10b6:a03:20b::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BY5PR12MB4130:EE_|SA3PR12MB8047:EE_ X-MS-Office365-Filtering-Correlation-Id: c4fbb068-b541-45e3-185d-08dc8f3dc5ee X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230037|7416011|376011|366013|1800799021; X-Microsoft-Antispam-Message-Info: rH5oz+bsGRghn1K6KkaFGKr+PSRDtkMlIsKctaViJq/3ZjyMTwgNqaifHn78FLf9MgvqR82rc+C0KVosK3jwm2aWR8zNX9xibSOchPaJpw4/KmUFyJDlqaBfZEs2PcCck9a6Hex59ypfhZ5SnPR7g0vR06v/Oo7c8yjfBm2pIyNcxEBS8FggwabrdexZJPjn9SlvrCuxWlb5UdL0ZiScr04A5FqAmJCH6fJnEzVB54bim7Hey5bkb/WYZ2fpNZhcZAb/+Ht7Tg0MJIMYcmM3bwG+Ufd3lJL8a4DINxzDZmG40HtjC7TcIb8QqAnVxg6x21XlrBWtqmZtqY7o13al9K0az4VBaEmEh+nnHcBlefjIsndgO5Cz3m0R7+dZGTKEpX8019AO3nQwZ3glIHi10ESe4SZhJRv3aRHqpHbleH3pkFecw8BNGG0M7WA54dCi3mW3nis+IMs3mKjKAUyEWtipVhw2XUkX3BZvI+zRHz0nzBjerkaIKAyoaP9ccvwiVg+Z6yrFXlP4rZ74E1ZOg3ckYmBuQJUPLLaEaeB88Hs43L1utxvsoMGc4oFfAmyeMm2e9rgeLpT118/WgFzqCzyDLJQP9X8NCvTky1xdIIv74IwTYlcG12/WC+rNcSWVr3G8B/5sqbs6GSZqLXTQE7RvG5lFJOxCwmxlXKbLpIzu0ew89fv9D3rakdRKuKF+ngkvSI6ub1eCU0LCseYyKsIYYIgXARqIKG+47bbkayjlj9lhr3ptQZKCctT9GQCBxA6wkPXHJG2C4tbeBLYtCnZ1ymXU3hZqZOZ0nOvhtUHxtA1gn8lep5UY7xQJQzjCnPRTjwReY36vY4z5TFuRiBE7V3LK/xVuJNz5srHgrVk7IFvg8742q95bcW/wtq/FEoZLv6Wl7LAphiQ0oIREbMCDB5ItuyO6Q91zu0x4yWyjJc77SI2rv9lW92qIOGD1w66peb/FMUoRSPoe2ziyL5UIJHtMykWqfYKj8vU4kr0dFS5q6WkG0ryj8o1NUt06wvdunwE7xO1x14khQ/DujkDGGouCsYCmE7bKL+rmLAK5+u0+kGLbzNQrs4u1sbBXowuUnqy0q1S/uTQ7RhZKMGgpx+eLbum3xQ/0BhwgGGf17LsrOLuFv9hHety01Dvh1QCquL8g8UNWxymQMC8BDWpePw4p08JlQbts5sMVxIwraKnIouGB8c53ss/qdKI6obi7M2m95K+XmWXfmv6pfSb7J20gDY2NipaC+Csc+s6oSCZ8pEkh1ks5ZIr8V9lbiCBHefJY6QHEE+KCD4KHbEUOIkCuX8byqLz9WcFoQ3JIYU+/L0wdEmAymcxTIHjB X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR12MB4130.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230037)(7416011)(376011)(366013)(1800799021);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: HPiPbLStyQDMFAXkQXxwHFi8L6+PZ0bBu7vdN2IoOR3YeDSxDGpE2Xyf/7ubybBL+i6hkdWm8UI2jActJDdWnT6FkBM8WdJn4cXG1QO2h9iBeKitOM300ObzlQr+XsdLNMM8NushrIpNjBqv81wi4gzJ92SsDGZ9pKSpB37F0ywx/dUKXN2nVc+ah3Rof4T2tMexVwVZbcRyXWVHYmFAB8b/sf8rXGXZS2V0/7orbTT5EnWxkdYwImUG5m3MNC5yXji27IPFBV0P8LBsaSWXhD+newmOZlRUaDo9eVAbXIiOmBsUfG/coIRrTip02VN0JV7qsCuiUnaTlAkShhWk4VR0Wjqgx3/ynK7TaJhEM2MOsOagy0oHYbphVBplhKI+CnUgWuLGivurNxrTvt/h9E0Kfx9IXVv072z3jwlxZfbhOYjq/aOo/jfUBwPU3df9tW3Y7H6MTW21icGXk3MI2K9NuyeuY96mF0kpfJIHpXbErJwiPE/u0OBr2kCzFw2xNtN4NIUc7ZeFkv1q7d7a3/LueZ72VypOb9zZ/nClGcImKt6O1hOxa5OLaltwVqveQotmaxL9LkU6tXjPBT1PhIKQ9e9D5UK2680K+U+97aOwkGRdUSqGSAIVw4waFCjDi1AKtcNNC/KlIefnk/7jeHFZH8iTMvyfz+ZwqsqAwh81JaDlUmtuVPUU5o4xQiHY1sNRDLjfhro8g9pfdXyh7b4fsXcw+tjTVpNpSFB1Sb/DvDrivBtZlQ0su77PgJ1rtZvXvmYFw8RwKrHBoflrWy06JHocetLngCkJBI1lJEpdQXbLghNPhdCmI5Mm7GBnXZPEpVkyyo+GDTH6qmmPk8SVNLqDlT7wJsfW1+g2FSNuHhAvP/luNbc8MYxpgw09XBJydqhzjMli4YSuBbN4VsLD2OxlWTcRZHnvtJ3nlrdy2SNrLWavsSGy7cXgARxrXCgr8hpq0E5/9fW/ffRNUXBpm3UfQGM9bpPBBuWiyqcbw9hrxywCYNQmOmm8VHy3hq6zTYH1bHovwanlPyPLWwUthYGDMT57Ueie1Fi+h34RwGj451YiDAM7b9vu+kVDu9AXrTmSLbhKGdpt0G5fPjv2xRw3zL4qQom9v6bATwhIhw/ylaJAl9x66PJzZM7dK607m14poiGhk++Jc4ekbGvmnQaBUgtxr+9ki3xiqkcSm6IVdEx7Lj0V35fVUsBHpEYXBnQRWHlwVCcEb3yPYUqWwVWbj1USrKcFwX/H3w1cc2sg4/Iid4nnQFTwfa7dlE3yySqe4cQ4lGbBgId1fJFgmfk3kL6q4FgJl+A+LGPlLOdltD+b875cR7TkuPKbrLaxJDBtsx1rImNkElcDLa+ezmjxyYu6lwMRFXXYDy2wxY42dwKwdyafRJTMuG44FyuYn/Rlnpml91dcvySSi9y66lo8p7wyFMo2UGHUy88ozQOQbeepUJi6MhpMDP0qRe/gPtBPM97K2HHuZaeNDE9rz12EB51OdWL/3+nzvK4OrJQgCye2kD21A6uBau4n6hKxBI04Zn6TDzcFL24Y50AqBZ08++/orL6S6dKWgOrzZH6F0vOmJJC7pVDNt9ph X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: c4fbb068-b541-45e3-185d-08dc8f3dc5ee X-MS-Exchange-CrossTenant-AuthSource: BY5PR12MB4130.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Jun 2024 02:24:25.6826 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Hpid2NyCGtmihWlbSOO23pTZsVkOMeeIavtt9jPRtUzZCYa6M42QnqcHL/z3FAxBMK5lxlXdJmqt6LONPOwcAA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA3PR12MB8047 X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: BD20E40007 X-Stat-Signature: o1xhe3sw7gqixohcrbfpnrrfxb6gps45 X-Rspam-User: X-HE-Tag: 1718677647-745522 X-HE-Meta: U2FsdGVkX18Q6yCV76ys9MHAC1yVCJVui+TEptEumf77WC4NyCC/y1Yd7Kn0zJEz4Q5LjRDqgv71Nq/H0feTvg+z/Vwa9lJFFY583xTA1hbh3aWfhX+OpXUdJ/jj0Cg8UKTKabpnd+noNMp0TsRt9CCK7BQ3cRzpaNHZWoRr10eJgA1WxePLjbX66nD4s5tZfOXpg1cLJ2vApml2a7WtbE87aEV/BZAtKp5UIf+hbJE/gDb++JjMBW289PqiSvhX0xbNHaCCacX+Sy2RCLy4iLsXI9EfiBkqiQhr8awoBrdolAEXzePbAEVuMNC4JF++u6xVLDV7XYfzxXnHddj/mPixJBPJf7SKCj8VVfzR92L7j5YNl9zmFdmx3MDz9C7YLhI5N25MyIkvaCdEICgKl02gKF/iE8x1v9/modLeTnMMX6WwK9PbXRcZwtdV6FsuK5yLFVmAR8kEKJ8HDFo+NAq888LkR+28i+uDEOG40Uqxhqs05TrQuS3jKLWla8JOMDXzbDRETfTG/jJDGbjuAy7F7/EcobVzL4IS8U/5+zyz1jK/MJobfFoP768NkEMnRTuofgFjQH4+0VF7cyFoOZRA2EOJeZnUosgOBvIt+x7Vla7CTw2OWjSsC9Dsey2gRyBqD4SnrtL+vagDjTb0URNZb50d3TXc7E2qNtzuo3XUcZxPc8oEQTAs40+YV99RW/3kKmwxvRm2bR8ax4HTXWYMmhaqvyt6hiotk9xdiNhOWmUFZ2TH3jQ4R4Gk8JhkKZf9KcDa64eAixZdkYY3HwKIonYf7WRc6YCofDccGUF/et2WnQr/TACnxrfuuN0KW4zkzEhwx8gIWqmH72WDcSEYokXseeNCkjwv71WqVscTTh9690lKomaqDngfS5+ouiyXEcXu8PuUkse954lw0Ojh6Yyp8e00sa9Zb4doT/K1qgMRIGHlmMn/wzM+fql+d4P2/3H1UMkTvuGFJKK 3Ox4jQ58 GMYQdDwhAks0ZxclPYG473fewv25PnOquMxwCFfMw2AtQ/3VveOf4svMMkGF5CXiCGc9bTchqf9sdnZ6B85+dOt92hMziuPS4eIFURpw5fB7vyOp1ocoW9PkICbPUjfuRebhcaOHCfgYPX8irLdk6Qfj4IVSG7Fqj9ZPJCM+SxDLS7roeYx/CmbSmvwFYt/ip/Ws8tqBYsZeocNbvy5QSxf80hXPvJz19nGA2C4I2JLOzJTY5Rzal6nIZ1T2Mp468ndnpTWSklqNN8V6BqbaH/gl6tunpJ8Gkq/KRIx/afudtiteNysUw43YEd9GaXojQL/Z1DxRoyObERttbiV0bPreI2BLqhrC1Whwj X-Bogosity: Ham, tests=bogofilter, spamicity=0.000343, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Clean up and move some copy-pasted items into a new mseal_helpers.h. 1. The test macros can be made safer and simpler, by observing that they are invariably called when about to return. This means that the macros do not need an intrusive label to goto; they can simply return. 2. PKEY* items. We cannot, unfortunately use pkey-helpers.h. The best we can do is to factor out these few items into mseal_helpers.h. 3. These tests still need their own definition of u64, so also move that to the header file. Cc: Jeff Xu Acked-by: David Hildenbrand Signed-off-by: John Hubbard --- tools/testing/selftests/mm/mseal_helpers.h | 41 ++++++++++++++++++ tools/testing/selftests/mm/mseal_test.c | 49 +--------------------- tools/testing/selftests/mm/seal_elf.c | 33 +-------------- 3 files changed, 43 insertions(+), 80 deletions(-) create mode 100644 tools/testing/selftests/mm/mseal_helpers.h diff --git a/tools/testing/selftests/mm/mseal_helpers.h b/tools/testing/selftests/mm/mseal_helpers.h new file mode 100644 index 000000000000..108d3fd0becb --- /dev/null +++ b/tools/testing/selftests/mm/mseal_helpers.h @@ -0,0 +1,41 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +#define FAIL_TEST_IF_FALSE(test_passed) \ + do { \ + if (!(test_passed)) { \ + ksft_test_result_fail("%s: line:%d\n", \ + __func__, __LINE__); \ + return; \ + } \ + } while (0) + +#define SKIP_TEST_IF_FALSE(test_passed) \ + do { \ + if (!(test_passed)) { \ + ksft_test_result_skip("%s: line:%d\n", \ + __func__, __LINE__); \ + return; \ + } \ + } while (0) + +#define TEST_END_CHECK() ksft_test_result_pass("%s\n", __func__) + +#ifndef PKEY_DISABLE_ACCESS +#define PKEY_DISABLE_ACCESS 0x1 +#endif + +#ifndef PKEY_DISABLE_WRITE +#define PKEY_DISABLE_WRITE 0x2 +#endif + +#ifndef PKEY_BITS_PER_PKEY +#define PKEY_BITS_PER_PKEY 2 +#endif + +#ifndef PKEY_MASK +#define PKEY_MASK (PKEY_DISABLE_ACCESS | PKEY_DISABLE_WRITE) +#endif + +#ifndef u64 +#define u64 unsigned long long +#endif diff --git a/tools/testing/selftests/mm/mseal_test.c b/tools/testing/selftests/mm/mseal_test.c index 58c888529f42..d4d6ae42f502 100644 --- a/tools/testing/selftests/mm/mseal_test.c +++ b/tools/testing/selftests/mm/mseal_test.c @@ -17,54 +17,7 @@ #include #include #include - -/* - * need those definition for manually build using gcc. - * gcc -I ../../../../usr/include -DDEBUG -O3 -DDEBUG -O3 mseal_test.c -o mseal_test - */ -#ifndef PKEY_DISABLE_ACCESS -# define PKEY_DISABLE_ACCESS 0x1 -#endif - -#ifndef PKEY_DISABLE_WRITE -# define PKEY_DISABLE_WRITE 0x2 -#endif - -#ifndef PKEY_BITS_PER_PKEY -#define PKEY_BITS_PER_PKEY 2 -#endif - -#ifndef PKEY_MASK -#define PKEY_MASK (PKEY_DISABLE_ACCESS | PKEY_DISABLE_WRITE) -#endif - -#define FAIL_TEST_IF_FALSE(c) do {\ - if (!(c)) {\ - ksft_test_result_fail("%s, line:%d\n", __func__, __LINE__);\ - goto test_end;\ - } \ - } \ - while (0) - -#define SKIP_TEST_IF_FALSE(c) do {\ - if (!(c)) {\ - ksft_test_result_skip("%s, line:%d\n", __func__, __LINE__);\ - goto test_end;\ - } \ - } \ - while (0) - - -#define TEST_END_CHECK() {\ - ksft_test_result_pass("%s\n", __func__);\ - return;\ -test_end:\ - return;\ -} - -#ifndef u64 -#define u64 unsigned long long -#endif +#include "mseal_helpers.h" static unsigned long get_vma_size(void *addr, int *prot) { diff --git a/tools/testing/selftests/mm/seal_elf.c b/tools/testing/selftests/mm/seal_elf.c index 27bf2f84231d..45c73213775b 100644 --- a/tools/testing/selftests/mm/seal_elf.c +++ b/tools/testing/selftests/mm/seal_elf.c @@ -16,38 +16,7 @@ #include #include #include - -/* - * need those definition for manually build using gcc. - * gcc -I ../../../../usr/include -DDEBUG -O3 -DDEBUG -O3 seal_elf.c -o seal_elf - */ -#define FAIL_TEST_IF_FALSE(c) do {\ - if (!(c)) {\ - ksft_test_result_fail("%s, line:%d\n", __func__, __LINE__);\ - goto test_end;\ - } \ - } \ - while (0) - -#define SKIP_TEST_IF_FALSE(c) do {\ - if (!(c)) {\ - ksft_test_result_skip("%s, line:%d\n", __func__, __LINE__);\ - goto test_end;\ - } \ - } \ - while (0) - - -#define TEST_END_CHECK() {\ - ksft_test_result_pass("%s\n", __func__);\ - return;\ -test_end:\ - return;\ -} - -#ifndef u64 -#define u64 unsigned long long -#endif +#include "mseal_helpers.h" /* * define sys_xyx to call syscall directly.