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: 83116 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1897vqo; Thu, 13 Apr 2023 16:19:01 -0700 (PDT) X-Google-Smtp-Source: AKy350ZfF3YqihtUCAqhlvGsowtUu6ZQbi4LqxVViO2PqdZor17vapWG0EHIev7ToOrlA9A7vo1l X-Received: by 2002:a17:902:f543:b0:1a2:37fc:b591 with SMTP id h3-20020a170902f54300b001a237fcb591mr632619plf.69.1681427941383; Thu, 13 Apr 2023 16:19:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681427941; cv=none; d=google.com; s=arc-20160816; b=bx7fchIlbT5afuxGM7QEJodEZ8HaNVEZ7Y75Wm/YQ6PKaZGt9FAovxZgU5tkGuGq9D stKpFNZmOK/RwfHECPP8AFgUbQKB+6diS76maBXkUQSfXSy+YD1OP65BAGtDVkZvAXfK 3tqsDVgTduCryYgYyE+U+6l5PkZeC7c+6oFoO4pWPGXaF2IC3ZWxPXWg9XuHa7oaTQzf qOhDa47hX/AeOiGBcj/bivJAW+aKYAOw/pVhw/xtNc1wO4Kmd1+OQBIn/Y+nwMQeRG04 a1JWAMp16f3A7rjd1FaNy6zaK9mBavPbgYU7/wICHdmdJ2RYdgCLN3HG9fzIe/lJCxy/ R73g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=VlJAJroC0qfUjlayNMIBwxZydfuRD55bTGjabDZPAD4=; b=g6jgzoNeSccZiQWuMnQZJto4Caed4JKiZYOnm7H7+oqKDOKbW0rU8T48Y6FTS76w7v r1NH15s1n8Z979Q5QD1ReEZfhrjCG4xnu+me/Za4yNJUclHh3fSDxdnJfE7BfDM3h4MM 3ryILyZElF40RjI2drHZ6rLs31c34ANCLrCTUMSFqkO1syy8jHa5IHnlSgXhQQuVlTBO B8KFSRVJFIfoeq34l48pbZlp6ZI0SkVq5Cusmw1W0nkoW2+c6JcpQ6+Dc3KQ7hmvDHZf cnB99Y20Ku7jMr3Elh8oXFZqeKbS1xTvMw27s8e1+9wFz0N/0OoYA/B1VZ+NScRnCiBj VdAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=TnBSw08O; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id iw18-20020a170903045200b0019f269f06fbsi2919303plb.3.2023.04.13.16.18.24; Thu, 13 Apr 2023 16:19:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=TnBSw08O; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230368AbjDMXMe (ORCPT + 99 others); Thu, 13 Apr 2023 19:12:34 -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-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-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1763104984901058162?= X-GMAIL-MSGID: =?utf-8?q?1763104984901058162?= 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; }