From patchwork Thu Apr 13 23:11:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13210720 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 1B092C77B6E for ; Thu, 13 Apr 2023 23:11:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AB48D900004; Thu, 13 Apr 2023 19:11:34 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A3D73280001; Thu, 13 Apr 2023 19:11:34 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8B757900006; Thu, 13 Apr 2023 19:11:34 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 7D167900004 for ; Thu, 13 Apr 2023 19:11:34 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 4CEEF1C6100 for ; Thu, 13 Apr 2023 23:11:34 +0000 (UTC) X-FDA: 80677916508.11.D696AB5 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf11.hostedemail.com (Postfix) with ESMTP id EB97A4001E for ; Thu, 13 Apr 2023 23:11:31 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Bs3bSm5s; spf=pass (imf11.hostedemail.com: domain of peterx@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=peterx@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1681427492; 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=VlJAJroC0qfUjlayNMIBwxZydfuRD55bTGjabDZPAD4=; b=LZcaRILHsoWqYdOiDLVR3K5OP7MBRTaiXrXyRvzVObyBfrVp2i3n1E95LozeuMtg/3eqR2 Dk3mtMF4ElVqhEJELcJuTrp10bUvnrgxNJeLrNSXbQxIBrFgCEPOyLiLhK0HBjPHkD4FsK MK8rTHsBBbZXFEePPLAQqF3oY5W/mcA= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Bs3bSm5s; spf=pass (imf11.hostedemail.com: domain of peterx@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=peterx@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1681427492; a=rsa-sha256; cv=none; b=QUCUsj9fanrh+fc8FbpgerF6aU+EAGxhvpmGg+4Myk5ALVERyjKNjrGiugGER7BWjmLNZQ MajdiUYlqtzAnA6JflB7Gj1gPIaoe5nt5phcGAKT9FpF2rOkIfYiN4SYD/bzQOiGbHLrKy Zb9KVT1LK3VIlLMNlu5VDjZCdd0aTP8= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1681427491; h=from:from: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; bh=VlJAJroC0qfUjlayNMIBwxZydfuRD55bTGjabDZPAD4=; b=Bs3bSm5sgWADy+7brHUZo3b7Ue5nyWpm1wQP/ExIT4Gm/dj0y22eMQlnThhXR+WXylsdzw yIYwj/3iw8psFx/b9YYbvXmBpQHP2uMlH7VCDa/X2FApHDJnL4YdgsywLHxOVVBuK0mw3+ OCxu9GHrQE1mGie3uWQqeaa0HoE7RYE= 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-287-QbDtX7TNPzyj--sHkPD5Cg-1; Thu, 13 Apr 2023 19:11:29 -0400 X-MC-Unique: QbDtX7TNPzyj--sHkPD5Cg-1 Received: by mail-qt1-f197.google.com with SMTP id d75a77b69052e-3eab4df3ef0so822571cf.0 for ; Thu, 13 Apr 2023 16:11:29 -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=hsgnpNTe6Yx1fPVurV8ui0qSzMoWf02flZtHgs5yxZGOOeQSGyuBQ0jY/+Y/4xlqBZ KkaUdBSjjPqT5f0OF5idFMylgIRgEI5Njs/AquIbbHK9gTm8lt8QTkNN14VfTn74heVX 3nKjOFSJKGMzb31MmPwa6Pudo5kLwUJdBYsxkzjmxMf/WQTX+BWAH3GfWXFXDGXbrksu hnGM8GFuOgpn7jE4N7XRsBxUIdyT14EQsJNH+oq67djJ7Z4kB3a4opqM+eDMvrZGOvVA bKyjFmY/m7O2u7A9lGR+LTkhwdvwqGX10U4588NTnsfq6Ov0p9TfuXq2RLfaP+dSBojL o2pA== X-Gm-Message-State: AAQBX9fJmpLnkHqm4OmV2jj0rBwac5S3DCRb6urypUaoIh8x8Wbcghxm PsCXOVhR7XzNFJZ0GlUHoQMWbsZ2+GfOTb6WvcTZAGjr5DykLKq5wRda6W2sUODpkR/iEjRuDA/ ZcaJZ9Cyohyc= X-Received: by 2002:a05:622a:1a0b:b0:3e6:3af1:de7a with SMTP id f11-20020a05622a1a0b00b003e63af1de7amr979927qtb.4.1681427489497; 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 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Rspam-User: X-Rspamd-Server: rspam03 X-Stat-Signature: kkwk19eox46u9afsyfd9p936e934qou4 X-Rspamd-Queue-Id: EB97A4001E X-HE-Tag: 1681427491-798209 X-HE-Meta: U2FsdGVkX1+swXFkBaAWW0rJEfwunpseRj1+JDhXr1Q1Hmz4YbozB1j+WJ/aptQ4V45+leOhI+RISZOG2yuhRGW2XkaJkbkYUXZYvDBvut/q6f1AVrdMkSJQ7gx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JDHv3wovJmYg+1pdCWxYcq7nlo3MJNRbNbRjHCGmdd8/IuySgM+MayJmIeby9VBqr4bcxh7AFzSKhCEvnXbDdDlV3WFfTtKTJv1kZXPu2RUTHRjrIjuAe+y0hrYscYpTk/KFcEM/WiVsv/U+bc9CCVgYfKDc/8Mo384umyunHmsmLwObnSj2I9Z3sit/cxl6ViiT/PXWc2SJMYjlJMQwJnPgxhYWVyDy2YMr/kvZplW/ckdki2vWyK3+XfsiCBvSGZ4FnixwnhjO8ti/1kT+Q+v2qVmvQvnT5JLbKF5lHaoLQABHWW X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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/selftests/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[] = { }, }; +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 = sizeof(uffd_tests) / sizeof(uffd_test_case_t); int n_mems = sizeof(mem_types) / sizeof(mem_type_t); + const char *test_filter = NULL; + bool list_only = 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; - has_uffd = test_uffd_api(false); - has_uffd |= test_uffd_api(true); + while ((opt = getopt(argc, argv, "f:hl")) != -1) { + switch (opt) { + case 'f': + test_filter = optarg; + break; + case 'l': + list_only = true; + break; + case 'h': + default: + /* Unknown */ + usage(argv[0]); + break; + } + } + + if (!test_filter && !list_only) { + has_uffd = test_uffd_api(false); + has_uffd |= test_uffd_api(true); - 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); + } } for (i = 0; i < n_tests; i++) { test = &uffd_tests[i]; + if (test_filter && !strstr(test->name, test_filter)) + continue; + if (list_only) { + printf("%s\n", test->name); + continue; + } for (j = 0; j < n_mems; j++) { mem_type = &mem_types[j]; if (!(test->mem_targets & mem_type->mem_flag)) @@ -952,7 +989,8 @@ int main(int argc, char *argv[]) } } - uffd_test_report(); + if (!list_only) + uffd_test_report(); return ksft_get_fail_cnt() ? KSFT_FAIL : KSFT_PASS; }