From nobody Fri Dec 19 03:26:27 2025 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D1AD1C77B61 for ; Thu, 13 Apr 2023 23:12:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230316AbjDMXMf (ORCPT ); Thu, 13 Apr 2023 19:12:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42840 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230253AbjDMXM0 (ORCPT ); Thu, 13 Apr 2023 19:12:26 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1188646A9 for ; Thu, 13 Apr 2023 16:11:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1681427492; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=VlJAJroC0qfUjlayNMIBwxZydfuRD55bTGjabDZPAD4=; b=TnBSw08Ofe1FonYiJSbfR0l2EnYAnj0MC03K3hIMQ7u/rsHxBEbHEO7fpGjD4/HqeukUNk /nbKPWVovu7TqS5fgBwKVnGpBpIos5UokhNOXLKWKU1+Dbry8BBRIsLTehBq7CU1EbPDpT dVTP+33iie9nYpb0wx2yB4Q0sdEeG5w= Received: from mail-qt1-f197.google.com (mail-qt1-f197.google.com [209.85.160.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-126-EEkusKa8NRmbUY7Hswl6Vw-1; Thu, 13 Apr 2023 19:11:30 -0400 X-MC-Unique: EEkusKa8NRmbUY7Hswl6Vw-1 Received: by mail-qt1-f197.google.com with SMTP id d75a77b69052e-3eab4df3ef0so822621cf.0 for ; Thu, 13 Apr 2023 16:11:30 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681427489; x=1684019489; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=VlJAJroC0qfUjlayNMIBwxZydfuRD55bTGjabDZPAD4=; b=hP5pKlwPXgKbzIf6pKd1YPKN0Hr7s1y41L4kGCihHGx9DPQD0CZnA9OqhqEihJkrXA kFCPxAKyBw8oZaRykJOcfoy2GLlxzh9Oahvppt4i6wKS7Pxo807PIATTeC0bDaFHAsAB PiQoC+w1Zri2ORwo5e5KzF83D6CI6+mVkaQsGoKTervgh+8NqTHe8VKIIoO8BvtDyONr 3trs3+XLnofzqYCnCJa4JdUxhpEjl6PJYTOjHK4aIuEq3JK938DyV+MmkmG6/Pey93IC 7xPDC2AjDirba/HSsMBH7pVPNSdsi52Mjxjx3ESOovH0MrRbI7TxNY///ZIHkUbl9r43 E3Wg== X-Gm-Message-State: AAQBX9fSRb5kJ5jtbMo0L95umcnBa2oUQ9uuHYHOsqgDOy2BcBf+l0lj dq3ggk04mwVXonclbz0LZpT3IR+Fs+gJaOEppZTE/V+uT7LVLStvBtn1W8ymXOr68I1jc6nRTc/ BGOaccffjq8Y4mfWBCGmGqGIEluG6au6dXwJDfYi3HHTyDsmeteswtttwhlns3gyLHASR7R5Bgg 21cp3D6A== X-Received: by 2002:a05:622a:1a0b:b0:3e6:3af1:de7a with SMTP id f11-20020a05622a1a0b00b003e63af1de7amr979948qtb.4.1681427489625; Thu, 13 Apr 2023 16:11:29 -0700 (PDT) X-Google-Smtp-Source: AKy350an97YBpu5VR+5rQ8BpvcSWa0qXKTYAqU3oGcgNxCkPHbBxgc6lQQadGX+kjho8InyBO8r1YA== X-Received: by 2002:a05:622a:1a0b:b0:3e6:3af1:de7a with SMTP id f11-20020a05622a1a0b00b003e63af1de7amr979903qtb.4.1681427489278; Thu, 13 Apr 2023 16:11:29 -0700 (PDT) Received: from x1n.redhat.com (bras-base-aurron9127w-grc-40-70-52-229-124.dsl.bell.ca. [70.52.229.124]) by smtp.gmail.com with ESMTPSA id g3-20020ac81243000000b003ea1b97acfasm612446qtj.49.2023.04.13.16.11.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Apr 2023 16:11:28 -0700 (PDT) From: Peter Xu To: linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: Axel Rasmussen , Andrew Morton , David Hildenbrand , peterx@redhat.com, Mike Kravetz , Nadav Amit , Andrea Arcangeli Subject: [PATCH 3/6] selftests/mm: Add a few options for uffd-unit-test Date: Thu, 13 Apr 2023 19:11:17 -0400 Message-Id: <20230413231120.544685-4-peterx@redhat.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230413231120.544685-1-peterx@redhat.com> References: <20230413231120.544685-1-peterx@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Namely: "-f": add a wildcard filter for tests to run "-l": list tests rather than running any "-h": help msg Signed-off-by: Peter Xu --- tools/testing/selftests/mm/uffd-unit-tests.c | 52 +++++++++++++++++--- 1 file changed, 45 insertions(+), 7 deletions(-) diff --git a/tools/testing/selftests/mm/uffd-unit-tests.c b/tools/testing/s= elftests/mm/uffd-unit-tests.c index d871bf732e62..452ca05a829d 100644 --- a/tools/testing/selftests/mm/uffd-unit-tests.c +++ b/tools/testing/selftests/mm/uffd-unit-tests.c @@ -909,28 +909,65 @@ uffd_test_case_t uffd_tests[] =3D { }, }; =20 +static void usage(const char *prog) +{ + printf("usage: %s [-f TESTNAME]\n", prog); + puts(""); + puts(" -f: test name to filter (e.g., event)"); + puts(" -h: show the help msg"); + puts(" -l: list tests only"); + puts(""); + exit(KSFT_FAIL); +} + int main(int argc, char *argv[]) { int n_tests =3D sizeof(uffd_tests) / sizeof(uffd_test_case_t); int n_mems =3D sizeof(mem_types) / sizeof(mem_type_t); + const char *test_filter =3D NULL; + bool list_only =3D false; uffd_test_case_t *test; mem_type_t *mem_type; uffd_test_args_t args; char test_name[128]; const char *errmsg; - int has_uffd; + int has_uffd, opt; int i, j; =20 - has_uffd =3D test_uffd_api(false); - has_uffd |=3D test_uffd_api(true); + while ((opt =3D getopt(argc, argv, "f:hl")) !=3D -1) { + switch (opt) { + case 'f': + test_filter =3D optarg; + break; + case 'l': + list_only =3D true; + break; + case 'h': + default: + /* Unknown */ + usage(argv[0]); + break; + } + } + + if (!test_filter && !list_only) { + has_uffd =3D test_uffd_api(false); + has_uffd |=3D test_uffd_api(true); =20 - if (!has_uffd) { - printf("Userfaultfd not supported or unprivileged, skip all tests\n"); - exit(KSFT_SKIP); + if (!has_uffd) { + printf("Userfaultfd not supported or unprivileged, skip all tests\n"); + exit(KSFT_SKIP); + } } =20 for (i =3D 0; i < n_tests; i++) { test =3D &uffd_tests[i]; + if (test_filter && !strstr(test->name, test_filter)) + continue; + if (list_only) { + printf("%s\n", test->name); + continue; + } for (j =3D 0; j < n_mems; j++) { mem_type =3D &mem_types[j]; if (!(test->mem_targets & mem_type->mem_flag)) @@ -952,7 +989,8 @@ int main(int argc, char *argv[]) } } =20 - uffd_test_report(); + if (!list_only) + uffd_test_report(); =20 return ksft_get_fail_cnt() ? KSFT_FAIL : KSFT_PASS; } --=20 2.39.1