From patchwork Thu Jun 29 23:23:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Zhangjin Wu X-Patchwork-Id: 114483 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp9982172vqr; Thu, 29 Jun 2023 16:36:27 -0700 (PDT) X-Google-Smtp-Source: APBJJlEGXSTYGfptp5OsXDZQvYBxqgqWgrBNgieVBGghZr54M2RdfSdugXuDEsn7T53TeY9ximgz X-Received: by 2002:a17:90b:30d7:b0:25c:1ad3:a4a1 with SMTP id hi23-20020a17090b30d700b0025c1ad3a4a1mr980697pjb.1.1688081787396; Thu, 29 Jun 2023 16:36:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688081787; cv=none; d=google.com; s=arc-20160816; b=mx+FHS7LIUUIZCKb/GYjXSDgYHg0ZQtIfXzn56T5DLKuvXm2S6LFuh6MByCKsZjFB9 vnHUvsQe9i6kM5QMR3K+YxcGR8Dz45gXOMtiFQqqqiXh+ZWmOyB3O1g2e6zYkVfueaI7 bS0WSFMTc3NdpOvFiwr6dvx7RSG4Di9ENEPZFJQ+V41WeJ75mbmrsjuO9uQrz3+7mtsb y3hA7b26wK75r6Mw8s+6g5trOtWjIIxeNXjROmgkGUvT1dbrqbcRB1oVgZ53z3I/lzlo YxAu95/PK78mpZuiWwbXu8+NqohKqjKUWPEXvVZKbfrAcLFzTJFCU+ldYSaqF9n5YvnF qDLg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:feedback-id:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from; bh=dkl46wvlwVNCabS76BZ/GHyd17IqOAgpiu/zjaI64Gs=; fh=GzghTQzqgly4pZn8BwQ4U8bZ8zCadAK8Sl/utskeyEs=; b=B0deGXRYUT7MeFt/0us92Pj4diyTWYhDzuY18AF0odNHw95nsUSMn6wUSII8G/RI9P fJ8RWaCwKFDzn0+XaLiqCiR5UMhRB5aFiSqdHe1Y0KtkApR2Hk6UIyb0oSpjbc20Bifr 4bduXg//lWsIEAo04bfDkFvjZDEeJr5Efe3LVNvaFPjRqJnvpwBunERhMRA8lvXBOShO 47fgw58H0gGIP1jA9dSCVFZ4JuVRFt7XcFghTg06iENxoCn1LEPzVIZYBuG0PdlLNJrt /s0wymdeOdSvV9ogb8JxBmuCohvQOGG9LcagEnFKoi5YUpS4KZOXpLOQ661sB9LjkORW MmLA== ARC-Authentication-Results: i=1; mx.google.com; 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t9-20020a170902e84900b001a1e0fd406csi11896327plg.217.2023.06.29.16.36.12; Thu, 29 Jun 2023 16:36:27 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229742AbjF2XY0 (ORCPT + 99 others); Thu, 29 Jun 2023 19:24:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59484 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230327AbjF2XYW (ORCPT ); Thu, 29 Jun 2023 19:24:22 -0400 Received: from bg4.exmail.qq.com (bg4.exmail.qq.com [43.154.54.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4784A1FC2; Thu, 29 Jun 2023 16:24:21 -0700 (PDT) X-QQ-mid: bizesmtp89t1688081051teyogk65 Received: from linux-lab-host.localdomain ( [119.123.131.49]) by bizesmtp.qq.com (ESMTP) with id ; Fri, 30 Jun 2023 07:24:10 +0800 (CST) X-QQ-SSF: 00200000000000D0W000000A0000000 X-QQ-FEAT: rZJGTgY0+YOVTQ2kNXjsPZ3MGX+TVmKJcovJh/8yjg+hV2a7oyT97pXC4kLUt mj9kJr6hG0y/CgiAEGGVEQ4x8Y9AeFZstxg5XaUwLeMy80LNWwim6uWDIJUnX6Ztr7ukka1 amq3OMPGiPSMhwkSmJDwXL23FHx8t+SuFEbAuNwNV/of0y9mJKUzwS4DwkqsQUzuEoEjk1f uXXZVY5h8yw/DOBh76j+UqmQ25T3BY41/ByGpxOCochUrt0fUUqYmZJdMXliAYePfLoBrZj JOzjvwk+WeruPWku6rWBrYp8v5IEsP3ixD6wEetyP/yUR1iezjb2ttPlzHVx1ai6IHfodGv 21qh12wA/PRoTW43Af1PqTnR3fswnj8HWQdDzi5ThJF3q0lgJYnhgkuDaVYYQ== X-QQ-GoodBg: 0 X-BIZMAIL-ID: 12172486614225476365 From: Zhangjin Wu To: thomas@t-8ch.de, w@1wt.eu Cc: falcon@tinylab.org, arnd@arndb.de, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: [PATCH v2 01/15] selftests/nolibc: stat_fault: silence NULL argument warning with glibc Date: Fri, 30 Jun 2023 07:23:58 +0800 Message-Id: <64938ffca05019a13e2cbcdc5beaa12625947572.1688078604.git.falcon@tinylab.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:tinylab.org:qybglogicsvrgz:qybglogicsvrgz5a-1 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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?1770082047962057158?= X-GMAIL-MSGID: =?utf-8?q?1770082047962057158?= Use another invalid address (void *)1 instead of NULL to silence this compile warning with glibc: $ make libc-test CC libc-test nolibc-test.c: In function ‘run_syscall’: nolibc-test.c:622:49: warning: null argument where non-null required (argument 1) [-Wnonnull] 622 | CASE_TEST(stat_fault); EXPECT_SYSER(1, stat(NULL, &stat_buf), -1, EFAULT); break; | ^~~~ nolibc-test.c:304:79: note: in definition of macro ‘EXPECT_SYSER2’ 304 | do { if (!cond) pad_spc(llen, 64, "[SKIPPED]\n"); else ret += expect_syserr2(expr, expret, experr1, experr2, llen); } while (0) | ^~~~ nolibc-test.c:622:33: note: in expansion of macro ‘EXPECT_SYSER’ 622 | CASE_TEST(stat_fault); EXPECT_SYSER(1, stat(NULL, &stat_buf), -1, EFAULT); break; Signed-off-by: Zhangjin Wu --- tools/testing/selftests/nolibc/nolibc-test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c index b178bfa29ad9..a2eacd6436d0 100644 --- a/tools/testing/selftests/nolibc/nolibc-test.c +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -734,7 +734,7 @@ int run_syscall(int min, int max) CASE_TEST(select_stdout); EXPECT_SYSNE(1, ({ fd_set fds; FD_ZERO(&fds); FD_SET(1, &fds); select(2, NULL, &fds, NULL, NULL); }), -1); break; CASE_TEST(select_fault); EXPECT_SYSER(1, select(1, (void *)1, NULL, NULL, 0), -1, EFAULT); break; CASE_TEST(stat_blah); EXPECT_SYSER(1, stat("/proc/self/blah", &stat_buf), -1, ENOENT); break; - CASE_TEST(stat_fault); EXPECT_SYSER(1, stat(NULL, &stat_buf), -1, EFAULT); break; + CASE_TEST(stat_fault); EXPECT_SYSER(1, stat((void *)1, &stat_buf), -1, EFAULT); break; CASE_TEST(stat_timestamps); EXPECT_SYSZR(1, test_stat_timestamps()); break; CASE_TEST(symlink_root); EXPECT_SYSER(1, symlink("/", "/"), -1, EEXIST); break; CASE_TEST(unlink_root); EXPECT_SYSER(1, unlink("/"), -1, EISDIR); break; From patchwork Thu Jun 29 23:25:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhangjin Wu X-Patchwork-Id: 114482 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp9981781vqr; Thu, 29 Jun 2023 16:35:39 -0700 (PDT) X-Google-Smtp-Source: APBJJlEd+XcKHyfhYTm1gBDcOFRSTnYQs6Dqnj3yMPKN8RgEWAo4+yGkwdO8dKRM4yj58jT4BOAS X-Received: by 2002:a17:902:e5c5:b0:1b8:17e8:5472 with SMTP id u5-20020a170902e5c500b001b817e85472mr716277plf.1.1688081739533; Thu, 29 Jun 2023 16:35:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688081739; cv=none; d=google.com; s=arc-20160816; b=W2eRTuN5MHdjNCDRnJT5Hsl8JPrsV4HlnrQa4/N+SBN198brm0JCsmB2g5rGQ3ZlrQ zBtyq3nFCbdBHP+cyxLQctvKYoroZV1Ib9NzcW8fxnFMlYa/qCwvk8OgJuoT/lXKzcuv bXyWJvcsLR46lJMa5pAUbZSfj5xCqDvVrS5vGQsJWTIIZQtHEGUROPw6DIteb5Fi9EF+ edSiRp1JlfePOfjJdxNayflnQRfuA9nf8ziTnlxkDb3qWbkrd0+m1KIb2rL1UHY5wFzl 60EKfQIOvuI/5yEan+iSXoeDOoedW7sultikNiThIQPkG5HJuE/t71RL8Kdb1KGYDv6D RlhA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:feedback-id:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from; bh=BGCm4ip//KLyY26801dAv0VNbwdQYmdx5DU+JsGL53Y=; fh=GzghTQzqgly4pZn8BwQ4U8bZ8zCadAK8Sl/utskeyEs=; b=NzOAA6xCn70c3I+ql7t4zeyZxsgOyXIx8DXn5xMjKNMj5wJZH3BRZyeiCfl+c0dUNY 2boCzWjFBozQGuI/n10nRcynJ2ct0nyQES86gO3M99cwg0cZ1BomellSzpjzu+0LhLLY FWLaekKknvDT37nsLl7+lqWRQX5a3mcRG0T04STzPqgM9Hk9NUDmL4FD6d1KCsF6nZKD KMWrx2Ms0YYv/4SPPEh/sI3MQ5Fd9l6qo/fXHiUep2iFGtMPerIsHg/QC9RizHcUkmMW jv1rCP2JFOzP+JfJDm5xXPQZyiRGa+785iY2/A+qkCjdFuBlo/WGlcuneibNWoFXkd7Z 8rqg== ARC-Authentication-Results: i=1; mx.google.com; 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a1-20020a170902ecc100b001b5585f945asi2185654plh.352.2023.06.29.16.35.24; Thu, 29 Jun 2023 16:35:39 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231508AbjF2X0L (ORCPT + 99 others); Thu, 29 Jun 2023 19:26:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60362 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231953AbjF2X0F (ORCPT ); Thu, 29 Jun 2023 19:26:05 -0400 Received: from bg4.exmail.qq.com (bg4.exmail.qq.com [43.154.54.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A66FD1FE4; Thu, 29 Jun 2023 16:26:03 -0700 (PDT) X-QQ-mid: bizesmtp91t1688081154tyi55hnf Received: from linux-lab-host.localdomain ( [119.123.131.49]) by bizesmtp.qq.com (ESMTP) with id ; Fri, 30 Jun 2023 07:25:52 +0800 (CST) X-QQ-SSF: 01200000000000D0W000000A0000000 X-QQ-FEAT: 6aXALTFZqPuZikFTnD0XtTrqnijJVdsBQ+fxB4J0aSCn27CFnCwO6LrrmluGc rpV/PikWplX1NtR6o5wbyCcv6WlYJCsSsHhUrWWybJrEciGHc9kgBfM70mFeFNYeglnMGaR 8kBS1WA6Q4/vvjTcUxQL//bO5Mn1EJTJzocmcqmGvmgq8MovuFny2kYrND2di0t/ae2si6k 109qlRNSTq5XbQJp2wTmaL7ZX5Rjgx+UyLcnaw17iJFrYU343Cyv7rqi6hV2Y2LZVOQSE7e eCT6Z5+JLR3XMhW7o4gCnAQAkgPr6qWY9aNtjTcvynXUgcu82JGWCvCw6lg1FETscw+rksp 6s6sRAan4j8fts6W6DRZYa0tWkZ42qJoAMsqUqJ/6sX6qmg4pm+krnciMniTQ== X-QQ-GoodBg: 0 X-BIZMAIL-ID: 12284148764811659706 From: Zhangjin Wu To: thomas@t-8ch.de, w@1wt.eu Cc: falcon@tinylab.org, arnd@arndb.de, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: [PATCH v2 02/15] selftests/nolibc: gettid: restore for glibc and musl Date: Fri, 30 Jun 2023 07:25:14 +0800 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:tinylab.org:qybglogicsvrgz:qybglogicsvrgz5a-1 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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?1770081998182058298?= X-GMAIL-MSGID: =?utf-8?q?1770081998182058298?= As the gettid manpage [1] shows, glibc 2.30 has gettid support, so, let's enable the test for glibc >= 2.30. gettid works on musl too. [1]: https://man7.org/linux/man-pages/man2/gettid.2.html Signed-off-by: Zhangjin Wu --- tools/testing/selftests/nolibc/nolibc-test.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c index a2eacd6436d0..785b1f4cbdc5 100644 --- a/tools/testing/selftests/nolibc/nolibc-test.c +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -659,6 +659,7 @@ int run_syscall(int min, int max) int tmp; int ret = 0; void *p1, *p2; + int has_gettid = 1; /* indicates whether or not /proc is mounted */ proc = stat("/proc", &stat_buf) == 0; @@ -666,6 +667,11 @@ int run_syscall(int min, int max) /* this will be used to skip certain tests that can't be run unprivileged */ euid0 = geteuid() == 0; + /* from 2.30, glibc provides gettid() */ +#if defined(__GLIBC_MINOR__) && defined(__GLIBC__) + has_gettid = __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 30); +#endif + for (test = min; test >= 0 && test <= max; test++) { int llen = 0; /* line length */ @@ -675,9 +681,7 @@ int run_syscall(int min, int max) switch (test + __LINE__ + 1) { CASE_TEST(getpid); EXPECT_SYSNE(1, getpid(), -1); break; CASE_TEST(getppid); EXPECT_SYSNE(1, getppid(), -1); break; -#ifdef NOLIBC - CASE_TEST(gettid); EXPECT_SYSNE(1, gettid(), -1); break; -#endif + CASE_TEST(gettid); EXPECT_SYSNE(has_gettid, gettid(), -1); break; CASE_TEST(getpgid_self); EXPECT_SYSNE(1, getpgid(0), -1); break; CASE_TEST(getpgid_bad); EXPECT_SYSER(1, getpgid(-1), -1, ESRCH); break; CASE_TEST(kill_0); EXPECT_SYSZR(1, kill(getpid(), 0)); break; From patchwork Thu Jun 29 23:26:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Zhangjin Wu X-Patchwork-Id: 114485 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp9985299vqr; Thu, 29 Jun 2023 16:44:34 -0700 (PDT) X-Google-Smtp-Source: APBJJlH3f/VnykEOJfxowSj1b+6+RJOIxIdSq0t21loBVp3+tHiTBBC2SKAaJQ+nznfMwweKKao+ X-Received: by 2002:a05:6e02:12e3:b0:345:69b3:ba41 with SMTP id l3-20020a056e0212e300b0034569b3ba41mr895298iln.2.1688082274037; Thu, 29 Jun 2023 16:44:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688082274; cv=none; d=google.com; s=arc-20160816; b=dwc/boeKPJAbLvsM1afkxLBaHHwfZ94Lh2Rv4qSPgvFwOOHiXiYpHGFKfQJJ1SmEYm uGv1VVFOGUuMjRywEeHM9R5URUSQ+BlJ8GWRRma+QD3FcM7bzgw41ISJs3KGEFv1Rtyb TESLZIM9qizfQ4UCFRuhD4Gy/qS2M3xkI+mrVO6J0vFA5VLJjha43P+NlQvM60qaA5DP ajFr4ObwiuYujZT+5MnGZLnHIMAt69YCwvI4ZDEtLcnapQBopd/m9Hc73Mv25EM6gbgw +K3ojHYkWhakOAz7txUgtqXsIFfM4D+U3OYr4OQV25XDj141jxgYLVLnGA0uYvSHvjHy 2IoQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:feedback-id:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from; bh=HeV25QBvW7gHqhvdVMW2x1HgOgXy413kIAqriLFqtmY=; fh=GzghTQzqgly4pZn8BwQ4U8bZ8zCadAK8Sl/utskeyEs=; b=qsAdpJ0l92w1kivFP5EQ4cgxrYfLRxC18wHmMtfKrClh1AYCZB7yacHxcVzpsIUCa5 qT6qO627fIPqU6sh4uLYsmt3Zqf3SiOEcNctCYufSfaJRm4W61B7d96IKFx/Jl9LMB2c I8VSshz8ZuT1xXLd9NYCvjNq/HEZoMJJBqMUHBJY51HKbgiopT5/XmmIZI8CDxymfwKr qe9fMMgsKUSt0T34XNUkhnK1G5+UNsgxw+HO4GRSTGRcIrU3S9g0bYEjvuE0YMHI7ieD V14NXib9OW4qVgkPWVEpMAGkq/8MMgduUuzBlU679GL2Ns68VqFODJAiiPyTPz0EVhQm f3kQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o14-20020a63e34e000000b0053f32b910c1si11298652pgj.700.2023.06.29.16.44.19; Thu, 29 Jun 2023 16:44:34 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231617AbjF2X10 (ORCPT + 99 others); Thu, 29 Jun 2023 19:27:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60892 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230037AbjF2X1Y (ORCPT ); Thu, 29 Jun 2023 19:27:24 -0400 Received: from bg4.exmail.qq.com (bg4.exmail.qq.com [43.154.54.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AAD0A1FE7; Thu, 29 Jun 2023 16:27:22 -0700 (PDT) X-QQ-mid: bizesmtp71t1688081232ti5nzs9c Received: from linux-lab-host.localdomain ( [119.123.131.49]) by bizesmtp.qq.com (ESMTP) with id ; Fri, 30 Jun 2023 07:27:11 +0800 (CST) X-QQ-SSF: 00200000000000D0W000000A0000000 X-QQ-FEAT: q+EIYT+FhZp1QK6qVIW9/zys5/KvQqS+TKOloNFVdqbJx/9/bvxODLmCOphZz y9+f4YPiil1IcYvKMFJp05kBj1sxwVhflNVeqk1yCTzpfMR2Yv2gqiHtlQJDxWUsrO/9Pj3 WXlKB+g3MsWThlTe5KAmbSDgenTw/b7cG8nJ+q4xC1D7JWNs7FW2Bl/TNcPFS0m1hlrfbQs YRptoCHdUObycOZ8PikqrUOT5VZLLcJgcYLQetbfB5hdwO2pZs3Z4t/TZ0PAmpBgcx0PM70 CFWvfM9isuV0+nkhLbZkdZPk7Y0SYJ7KD+1eSNEfk2iWxGlcD5/62jPSRN4o0KYqgSFGLlz 4UcPV1x4z8UiIaqIO5kSsHF6Ut5+cYfLev2/gdn3UYcY3avkpnUgt7FUxGott8CbjdolC5t X-QQ-GoodBg: 0 X-BIZMAIL-ID: 1369624537871017279 From: Zhangjin Wu To: thomas@t-8ch.de, w@1wt.eu Cc: falcon@tinylab.org, arnd@arndb.de, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: [PATCH v2 03/15] selftests/nolibc: add _LARGEFILE64_SOURCE for musl Date: Fri, 30 Jun 2023 07:26:57 +0800 Message-Id: <7486b55751e388b7c532246f068a77a187f0abc0.1688078605.git.falcon@tinylab.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:tinylab.org:qybglogicsvrgz:qybglogicsvrgz5a-1 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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?1770082558565108214?= X-GMAIL-MSGID: =?utf-8?q?1770082558565108214?= _GNU_SOURCE Implies _LARGEFILE64_SOURCE in glibc, but in musl, the default configuration doesn't enable _LARGEFILE64_SOURCE. From include/dirent.h of musl, getdents64 is provided as getdents when _LARGEFILE64_SOURCE is defined. #if defined(_LARGEFILE64_SOURCE) ... #define getdents64 getdents #endif Let's define _LARGEFILE64_SOURCE to fix up this compile error: tools/testing/selftests/nolibc/nolibc-test.c: In function ‘test_getdents64’: tools/testing/selftests/nolibc/nolibc-test.c:453:8: warning: implicit declaration of function ‘getdents64’; did you mean ‘getdents’? [-Wimplicit-function-declaration] 453 | ret = getdents64(fd, (void *)buffer, sizeof(buffer)); | ^~~~~~~~~~ | getdents /usr/bin/ld: /tmp/ccKILm5u.o: in function `test_getdents64': nolibc-test.c:(.text+0xe3e): undefined reference to `getdents64' collect2: error: ld returned 1 exit status Signed-off-by: Zhangjin Wu --- tools/testing/selftests/nolibc/nolibc-test.c | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c index 785b1f4cbdc5..29c21880a198 100644 --- a/tools/testing/selftests/nolibc/nolibc-test.c +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -1,6 +1,7 @@ /* SPDX-License-Identifier: GPL-2.0 */ #define _GNU_SOURCE +#define _LARGEFILE64_SOURCE /* libc-specific include files * The program may be built in 3 ways: From patchwork Thu Jun 29 23:28:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Zhangjin Wu X-Patchwork-Id: 114490 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp9988808vqr; Thu, 29 Jun 2023 16:54:02 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7qhks74HEqnAojq00nvetSJtwd6O8x+llcP2jWPCxRqckjckPFTPkxiWSCQQsDakfoaoD7 X-Received: by 2002:a05:6a20:1456:b0:111:77cf:96dd with SMTP id a22-20020a056a20145600b0011177cf96ddmr1490614pzi.5.1688082842012; Thu, 29 Jun 2023 16:54:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688082841; cv=none; d=google.com; s=arc-20160816; b=vBYpyz47YWFvEduK3MZc+Pl682DryDdOgcOZLtKeQKJnJOBV+hlyJxepkDaG9icJR0 Ot2WqHv+jn4XT6n2sHe9VgxNfcS1LMjyI/2mUgY3uuGyk/YwiCm6Y1duVd3CNxG/nrZG dn0vXYRdQu45jx6uhbY3F71oioIbySOuqmHPDRq+HxH2SF67HGs1LTerjsWk7FXfFth/ eUAjKqhh77v/bwM+f0irVZSL0P1bNWcqpTF5L2uFOrr1GHn9YDdbIFxL5tNy98LcD3HX jsTmiZvtB27vnNPhhfV2BXH6jRVQDqi0Sq009LxyZ6pIVAhjy5I5oGviXYwawE+gSwQT BPHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:feedback-id:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from; bh=0SM+K0n1raxU8Rzi6yQFvm+fhjkj+goer8D5LPSLYZs=; fh=F5il0f38/OnR+6Lk4jyRbQDcrSTey2kQnNpdmJYq5RU=; b=d23t1vbayJzW8nElSqz92brSoC0mGeQEVPQXvozAcrcJJ57MrcuCPdRK8t3phmyp9R G62CJx2Ik59+ccmy1ijonioyKTpm/C1/PP8S1+1q2kQAo1oC7iPGNu7o04QY2Qr9RtZ7 ErrDxMDwOtmFQJQQXAwHEYqj+CcT0ELJQ1vyOr3lXFR5NRJszx5ZZN92q5LM523uHQgI h6X0lELxUYCR+FL96KOBcc4QA1YXZmiJUdzoBU/LNFcJExDhJmR6AnaOqyRl1uL4XMd0 rNPW1fwBI5UbFm9AaZG0G2uQgyG+wPMlf5/IniByl47vHVKuoLJPHKHFqZFNIfSfmFwY meaQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h3-20020a170902f54300b001b85a47d2b7si1829042plf.422.2023.06.29.16.53.49; Thu, 29 Jun 2023 16:54: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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231653AbjF2X2r (ORCPT + 99 others); Thu, 29 Jun 2023 19:28:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33194 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229720AbjF2X2q (ORCPT ); Thu, 29 Jun 2023 19:28:46 -0400 Received: from bg4.exmail.qq.com (bg4.exmail.qq.com [43.154.54.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6667B1BC6; Thu, 29 Jun 2023 16:28:44 -0700 (PDT) X-QQ-mid: bizesmtp86t1688081315tjycq55u Received: from linux-lab-host.localdomain ( [119.123.131.49]) by bizesmtp.qq.com (ESMTP) with id ; Fri, 30 Jun 2023 07:28:34 +0800 (CST) X-QQ-SSF: 01200000000000D0W000000A0000000 X-QQ-FEAT: RdkzUaxjIrfJY7jV7wFs1hXtoA3+Vv/lYMh4H2WNVuZBKAbd/xdTOxNXXKRtf jfuQ9QcCSu7QafjYL4xSTkK7jMt6OMdjr6isvrN3T2xAnU55eSqrebklnG681L/OmxI9bh/ VyTSb+V4G+WjUArncjMNhBb/stR9LJchLeOBeyLSC0JEbc40UBzcXTLFX7Fr0ZWMNyn5SK3 NeZXrnuqo7LLuDye+A7DzfLLeJbA37uc6Z7epdjB6GXts2/MgXM6eBl64d6n255EmoJoh+z Kv7dwv1d/SXpMqzqoxjuM+Oi7eY1LhE7373eSEKL9vh9IrCkyig/aa5RtSxLBDDHRGH/ril WlXDy6MFmIcm5IB0udI8ohjTkENOgGhI8PnpiL6OVYE5k10j5zom3w4LooGb3GtR/WSrbZi X-QQ-GoodBg: 0 X-BIZMAIL-ID: 15633995598629543478 From: Zhangjin Wu To: thomas@t-8ch.de, w@1wt.eu Cc: falcon@tinylab.org, arnd@arndb.de, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Subject: [PATCH v2 04/15] selftests/nolibc: fix up int_fast16/32_t test cases for musl Date: Fri, 30 Jun 2023 07:28:15 +0800 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:tinylab.org:qybglogicsvrgz:qybglogicsvrgz5a-1 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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?1770083153806025685?= X-GMAIL-MSGID: =?utf-8?q?1770083153806025685?= musl limits the fast signed int in 32bit, but glibc and nolibc don't, to let such test cases work on musl, let's provide the type based SINT_MAX_OF_TYPE(type) and SINT_MIN_OF_TYPE(type). Suggested-by: Thomas Weißschuh Link: https://lore.kernel.org/lkml/bc635c4f-67fe-4e86-bfdf-bcb4879b928d@t-8ch.de/ Signed-off-by: Zhangjin Wu --- tools/testing/selftests/nolibc/nolibc-test.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c index 29c21880a198..96d170cc9b47 100644 --- a/tools/testing/selftests/nolibc/nolibc-test.c +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -41,6 +41,10 @@ #endif #endif +/* for the type of int_fast16_t and int_fast32_t, musl differs from glibc and nolibc */ +#define SINT_MAX_OF_TYPE(type) (((type)1 << (sizeof(type) * 8 - 2)) - (type)1 + ((type)1 << (sizeof(type) * 8 - 2))) +#define SINT_MIN_OF_TYPE(type) (-SINT_MAX_OF_TYPE(type) - 1) + /* will be used by nolibc by getenv() */ char **environ; @@ -819,11 +823,11 @@ int run_stdlib(int min, int max) CASE_TEST(limit_int_fast8_max); EXPECT_EQ(1, INT_FAST8_MAX, (int_fast8_t) 0x7f); break; CASE_TEST(limit_int_fast8_min); EXPECT_EQ(1, INT_FAST8_MIN, (int_fast8_t) 0x80); break; CASE_TEST(limit_uint_fast8_max); EXPECT_EQ(1, UINT_FAST8_MAX, (uint_fast8_t) 0xff); break; - CASE_TEST(limit_int_fast16_min); EXPECT_EQ(1, INT_FAST16_MIN, (int_fast16_t) INTPTR_MIN); break; - CASE_TEST(limit_int_fast16_max); EXPECT_EQ(1, INT_FAST16_MAX, (int_fast16_t) INTPTR_MAX); break; + CASE_TEST(limit_int_fast16_min); EXPECT_EQ(1, INT_FAST16_MIN, (int_fast16_t) SINT_MIN_OF_TYPE(int_fast16_t)); break; + CASE_TEST(limit_int_fast16_max); EXPECT_EQ(1, INT_FAST16_MAX, (int_fast16_t) SINT_MAX_OF_TYPE(int_fast16_t)); break; CASE_TEST(limit_uint_fast16_max); EXPECT_EQ(1, UINT_FAST16_MAX, (uint_fast16_t) UINTPTR_MAX); break; - CASE_TEST(limit_int_fast32_min); EXPECT_EQ(1, INT_FAST32_MIN, (int_fast32_t) INTPTR_MIN); break; - CASE_TEST(limit_int_fast32_max); EXPECT_EQ(1, INT_FAST32_MAX, (int_fast32_t) INTPTR_MAX); break; + CASE_TEST(limit_int_fast32_min); EXPECT_EQ(1, INT_FAST32_MIN, (int_fast32_t) SINT_MIN_OF_TYPE(int_fast32_t)); break; + CASE_TEST(limit_int_fast32_max); EXPECT_EQ(1, INT_FAST32_MAX, (int_fast32_t) SINT_MAX_OF_TYPE(int_fast32_t)); break; CASE_TEST(limit_uint_fast32_max); EXPECT_EQ(1, UINT_FAST32_MAX, (uint_fast32_t) UINTPTR_MAX); break; CASE_TEST(limit_int_fast64_min); EXPECT_EQ(1, INT_FAST64_MIN, (int_fast64_t) INT64_MIN); break; CASE_TEST(limit_int_fast64_max); EXPECT_EQ(1, INT_FAST64_MAX, (int_fast64_t) INT64_MAX); break; From patchwork Thu Jun 29 23:29:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhangjin Wu X-Patchwork-Id: 114488 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp9987863vqr; Thu, 29 Jun 2023 16:51:19 -0700 (PDT) X-Google-Smtp-Source: APBJJlFiWgBmuJOIRX2e5Lk/HxlI3NMaMz3aZ9Ajg+MCFbPbiJtZEiQz3duSa24aCjyjj7jx/iyb X-Received: by 2002:a05:6a00:26dd:b0:66d:d03e:3493 with SMTP id p29-20020a056a0026dd00b0066dd03e3493mr1533514pfw.2.1688082679109; Thu, 29 Jun 2023 16:51:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688082679; cv=none; d=google.com; s=arc-20160816; b=ybdIoz6RwjeVDmSap2qJP5CTpYjtGjJAugdMZEz9nluOShJlb7YtPbwFQ4TDd53O1F mNjw+mOVKBpzTiR8ahn7UAOkWmMsQ7lEeqrgpXdoQ7Mxa5rDLOPcE3NvM4RQpROAV655 Xd6x0dRTM5ztT6J/zGbz2WHGTBabFxg8CUL7fA5PxELtlsc8ruRJTt5sgAWloCQXFFnt 7sZ6UmxjUuMTK7RByWPBgkXO29kc0dn+K4nJdEjb6bUJ65b4A4EckDNqKohpVrPt35EP 4aOVvyP60Qtdykz5vS1w+Aa42Cs8F0P1GC/M3ZkNM0YOJR2iC7smYRAVTGE/0LkI6z1a I7Kg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:feedback-id:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from; bh=b6nt0VtLN9PoDORpj3/mw2jx1EgRCIuW0ppt4XcES2A=; fh=GzghTQzqgly4pZn8BwQ4U8bZ8zCadAK8Sl/utskeyEs=; b=siWeIUccnlB36U9rkrH/IEKdlWE6anJJQwx60l+CczGfvTXSes+gSfrX4+NbLEEau6 y/6OubbrQpF/8vJLZg9oOdLEAyLidEwB+mw+dJKdAkuZMpuGDZTZTkabepRWjH4855zP rb8201ViwCM5aPfBQFtUocrRJc40oO6D/F4YAkq3/G35vnBZxKawdWegXV+s8vZePfL4 MmtwOhQ9n/23lqQgFQhCOaolGxfRJrvgskM0rHz192R/4I4ZDdRvkiUMOEyS0xLMEEaJ RP/U8dDVxdBWIXkJdJ5w4MbzWgxlMiBqnIPrlDHE46IT9898lp1U7eLblF/ZGqmgOhkO LcZg== ARC-Authentication-Results: i=1; mx.google.com; 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u11-20020a056a00158b00b006797c2c00besi8157256pfk.144.2023.06.29.16.51.06; Thu, 29 Jun 2023 16:51:19 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231766AbjF2Xaq (ORCPT + 99 others); Thu, 29 Jun 2023 19:30:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33968 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230036AbjF2Xam (ORCPT ); Thu, 29 Jun 2023 19:30:42 -0400 Received: from bg4.exmail.qq.com (bg4.exmail.qq.com [43.155.65.254]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 694EC1FE7; Thu, 29 Jun 2023 16:30:40 -0700 (PDT) X-QQ-mid: bizesmtp77t1688081430tg4lkoyb Received: from linux-lab-host.localdomain ( [119.123.131.49]) by bizesmtp.qq.com (ESMTP) with id ; Fri, 30 Jun 2023 07:30:29 +0800 (CST) X-QQ-SSF: 01200000000000D0W000000A0000000 X-QQ-FEAT: CR3LFp2JE4k2yCeR62ZuAGYUgkT1yq1gp7tSCx6PjhF/mNkyHruYzL79SeB7z CxTzPB7K2xFoUA/Ttaf/5FeV6L2uZdCkhc6XFd+y19TuqfuZXiEi8MxdsIwOmgQRqo4pRJU K9nE+AfOZFt1gnTXokRNuOjIyGH60R8MmM8qcVuceDH066+FiI3ebXS5ucV6i39M2LmgDgX jrMaXXzbKZXF1L/CX6tToO/a7QqbP3ZC94AEgLSNMjGkx1IUrGdvDHYo0t+4/y0ZadUrf9Q vKbj105VV3iJAVITKR8OC3793oJJQd58PXOK0m5ZJPs8AqexcipJTcZV9r6PDKW2fFm5tY3 UAyjZgTMxfiyqXCHysiWctOPNpjl1iIdiX5pdzoth3fQjGgjLzGMXhonNol+Q== X-QQ-GoodBg: 0 X-BIZMAIL-ID: 8005163360113825460 From: Zhangjin Wu To: thomas@t-8ch.de, w@1wt.eu Cc: falcon@tinylab.org, arnd@arndb.de, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: [PATCH v2 05/15] selftests/nolibc: fix up kernel parameters support Date: Fri, 30 Jun 2023 07:29:38 +0800 Message-Id: <582776208a75df19d09b8eaafcb6fdad7219abc8.1688078605.git.falcon@tinylab.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:tinylab.org:qybglogicsvrgz:qybglogicsvrgz5a-1 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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?1770082983038224382?= X-GMAIL-MSGID: =?utf-8?q?1770082983038224382?= kernel parameters allow pass two types of strings, one type is like 'noapic', another type is like 'panic=5', the first type is passed as arguments of the init program, the second type is passed as environment variables of the init program. when users pass kernel parameters like this: noapic NOLIBC_TEST=syscall our nolibc-test program will use the test setting from argv[1] and ignore the one from NOLIBC_TEST environment variable, and at last, it will print the following line and ignore the whole test setting. Ignoring unknown test name 'noapic' reversing the parsing order does solve the above issue: test = getenv("NOLIBC_TEST"); if (test) test = argv[1]; but it still doesn't work with such kernel parameters (without NOLIBC_TEST environment variable): noapic FOO=bar To support all of the potential kernel parameters, let's verify the test setting from both of argv[1] and NOLIBC_TEST environment variable. Signed-off-by: Zhangjin Wu --- tools/testing/selftests/nolibc/nolibc-test.c | 33 ++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c index 96d170cc9b47..223c00e83abf 100644 --- a/tools/testing/selftests/nolibc/nolibc-test.c +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -1063,6 +1063,35 @@ static const struct test test_names[] = { { 0 } }; +int is_setting_valid(char *test) +{ + int idx, len, test_len, valid = 0; + char delimiter; + + if (!test) + return valid; + + test_len = strlen(test); + + for (idx = 0; test_names[idx].name; idx++) { + len = strlen(test_names[idx].name); + if (test_len < len) + continue; + + if (strncmp(test, test_names[idx].name, len) != 0) + continue; + + delimiter = test[len]; + if (delimiter != ':' && delimiter != ',' && delimiter != '\0') + continue; + + valid = 1; + break; + } + + return valid; +} + int main(int argc, char **argv, char **envp) { int min = 0; @@ -1088,10 +1117,10 @@ int main(int argc, char **argv, char **envp) * syscall:5-15[:.*],stdlib:8-10 */ test = argv[1]; - if (!test) + if (!is_setting_valid(test)) test = getenv("NOLIBC_TEST"); - if (test) { + if (is_setting_valid(test)) { char *comma, *colon, *dash, *value; do { From patchwork Thu Jun 29 23:31:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhangjin Wu X-Patchwork-Id: 114484 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp9984880vqr; Thu, 29 Jun 2023 16:43:36 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7THzs6Sn//wQ2c6aMBl7ffW65POygC+I1Js2b38bd61njmk6p9EWI8mu6DzBste3lUPUid X-Received: by 2002:a6b:c897:0:b0:780:cb36:6f24 with SMTP id y145-20020a6bc897000000b00780cb366f24mr1216216iof.2.1688082216383; Thu, 29 Jun 2023 16:43:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688082216; cv=none; d=google.com; s=arc-20160816; b=aYPyOh+fa0vu2UsKPvYiDomyQ12fK66S6BImXI8rZu8ZERuWDdqCpUZyRvuhVkSciO zfd41kZQjp1HO7pPY2za3D1SyQwXLrim6QVx930okzlHGNaRm6EqQaI0jzEzIeA/xsv9 xzWMuUceDCfrcIBEq1xPJIsbatvZjtOsGrDSSvwbtyODw86f6Yh+wiAa1PWoX2CCxGMv yB3l6Ww0UF2UcgPTrU+izNoEryAY01AEeM6/uQ7qv4yZuwCGO9D/wo7CqmI4tkQgCcgs HGAH7Q0+hAjq9CM8Zc4m7RdTBepy3DCniIpVz1C96bJbmRJj2WE+qHCAysebmArNcYqU 8qFQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:feedback-id:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from; bh=4bjDI+xCO6zCjdxMmYEm/USzb7hvzifsJf3AcnsnP7I=; fh=GzghTQzqgly4pZn8BwQ4U8bZ8zCadAK8Sl/utskeyEs=; b=X22kPzz7qE4yuecF34I2p0D7AYp7ggQJDCD6uPw+HSyckKuaetmmU6a+WPk11okir0 06F7jrDmyZ6XjiXM5FVgwCZf5o8aWepc9EzsUySiGT3SNdMCiNekDa1IkFTIHaSU89GF +RKgok9rk3w1+xlh/JPZrgT/lpM9zAwZFBdTaIMP4g6H02G/+VhC3YntG5SL1WPyxrMK AaTbRxjBkvBIL/snurouKBXgizw1r9hdhwoOrzREgv7C7dhpw7s6YLSebQr8pfk9L4my oajh0WXEvoQU3q7iYFAJTzdvhsp+YH6Co9nnEP2bBe2/EnSEIPZKPejnCYdR1r43Zpv2 BC/Q== ARC-Authentication-Results: i=1; mx.google.com; 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l5-20020a654485000000b0055398c3184esi11489596pgq.6.2023.06.29.16.43.21; Thu, 29 Jun 2023 16:43:36 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229646AbjF2XgM (ORCPT + 99 others); Thu, 29 Jun 2023 19:36:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35268 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229459AbjF2XgK (ORCPT ); Thu, 29 Jun 2023 19:36:10 -0400 Received: from bg4.exmail.qq.com (bg4.exmail.qq.com [43.154.54.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4D3A51713; Thu, 29 Jun 2023 16:36:08 -0700 (PDT) X-QQ-mid: bizesmtp64t1688081757tnqk2bme Received: from linux-lab-host.localdomain ( [119.123.131.49]) by bizesmtp.qq.com (ESMTP) with id ; Fri, 30 Jun 2023 07:35:56 +0800 (CST) X-QQ-SSF: 01200000000000D0W000000A0000000 X-QQ-FEAT: 3M0okmaRx3jzXUNZYCjF22Yt5q5NFwMgmhuWKlNMBfQ9f40ThEIsT/5lI1O4U WTU+lHNIjWl6hrnW7p4jSjiM7agpdRFqQPOYCLhDNV+lu8Gw8Ix+6NWlvPgvzPOA03J22Hs xnOaKbUZegQkWE2vf+3+hpyASl6yde1FbI7BjKOd3RWr64jv3jC7X/FKkiY+gbl0I2iV2vp abwjKmGuqvzJszYtKQcASRVuIKUcNRXdwsuK3jMwUIECfGliZDnizInZnNeglxZ0Hh15PpQ 9Zdle0TebbOIE/kaNpct8qijh366/xn6vycmfsA8M9NqWBuOsRh5KNxHkAp2Lfpk/7q+4HP 20AiePlmwg77191+LbqegPp1akzdiPRWn4wvBFR5rBZWkLxit/0Xzf4+I2sfQ== X-QQ-GoodBg: 0 X-BIZMAIL-ID: 10916663048857480056 From: Zhangjin Wu To: thomas@t-8ch.de, w@1wt.eu Cc: falcon@tinylab.org, arnd@arndb.de, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: [PATCH v2 06/15] selftests/nolibc: stat_timestamps: remove procfs dependency Date: Fri, 30 Jun 2023 07:31:33 +0800 Message-Id: <6fae777966cf710321a8d8369a9194e00b72ecf6.1688078605.git.falcon@tinylab.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:tinylab.org:qybglogicsvrgz:qybglogicsvrgz5a-1 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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?1770082497941165308?= X-GMAIL-MSGID: =?utf-8?q?1770082497941165308?= '/proc/self/' is a good path which doesn't have stale time info but it is only available for CONFIG_PROC_FS=y. For CONFIG_PROC_FS=n, Let's try '/init' for initramfs and '/' for the others. Signed-off-by: Zhangjin Wu --- tools/testing/selftests/nolibc/nolibc-test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c index 223c00e83abf..1d2be52d44a5 100644 --- a/tools/testing/selftests/nolibc/nolibc-test.c +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -582,7 +582,7 @@ static int test_stat_timestamps(void) if (sizeof(st.st_atim.tv_sec) != sizeof(st.st_atime)) return 1; - if (stat("/proc/self/", &st)) + if (stat("/proc/self/", &st) && stat("/init", &st) && stat("/", &st)) return 1; if (st.st_atim.tv_sec != st.st_atime || st.st_atim.tv_nsec > 1000000000) From patchwork Thu Jun 29 23:37:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhangjin Wu X-Patchwork-Id: 114506 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp10004516vqr; Thu, 29 Jun 2023 17:26:27 -0700 (PDT) X-Google-Smtp-Source: APBJJlGL4CcNOWKOUUduI+Sfj3Y28ZwoH4DsQ2bHIEJzvS/FwhxEA1xMWo1YKZQJCxMuQXMkDK1N X-Received: by 2002:a17:902:7611:b0:1b8:2ba0:c9a8 with SMTP id k17-20020a170902761100b001b82ba0c9a8mr758834pll.2.1688084786826; Thu, 29 Jun 2023 17:26:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688084786; cv=none; d=google.com; s=arc-20160816; b=lky0CXRLKOrObUxoTsnAej7vp/IHU/uiNx3FSrH/MkuujB21ACWR5hEnbAJ5pp63gN LfwnzOg1Jmr16oj27hMtK3XBBUCvYAqdAByq8dwdxDNlDqutJRRpdKcLKdWvX5rzZPZH apZZmq7Rznzi3RVVSOg9wOyKBl9kVOyWtrVLcpPjE2sh8die9Riu3tDdaOVajUp8gf8g xd+Ou7YZYjHqLPcX37A5+Zc4Ll9r32ZRMNLqtLSn/2HQolQI1RSxQqnToUj6uNBiquuO RWexQxSLEkTyqL1k/oo6NYiLL5an+akTHef35XcdrC3o7Rg83Ql+XN09wOp9u7GV5tqZ gFtQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:feedback-id:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from; bh=zJBMgIZzkvV/07tyq/MOZIA5ADvpkqvVkS3ZW9wNYh4=; fh=GzghTQzqgly4pZn8BwQ4U8bZ8zCadAK8Sl/utskeyEs=; b=wWM6atX+JCkt9tzBs0Flg2t6nlKgxLp3Jp5BwEpTs8R10v3eabtUwKOicj4uPbf6ZM K1uvDAiUBmoVLQGKZ491g+dqJhHyhLU33v7OaesFuYrbVRb1V68InRowL+W5UhEgww5I ry/ZwRfFGEfcK81NHfY0hz7HQYNFL1P3PIYytF4Mme9XiKmYRbbDD8UPF0JtxVhCwww4 1uekF1whZH4JW094sa8qUTois9zg0iXtyPyTFtow+sgRCyIFbvliq3OW+/mBnfUWzKBt 8qc99N9umpNgRwvarJcY952ma8mxTbKQwdpwzMfsDRwIpFgxDnR623vHBavgngkPzzk6 E4Pg== ARC-Authentication-Results: i=1; mx.google.com; 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f11-20020a170902ce8b00b001b694ecf48esi4225379plg.100.2023.06.29.17.26.14; Thu, 29 Jun 2023 17:26:26 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232212AbjF2XpQ (ORCPT + 99 others); Thu, 29 Jun 2023 19:45:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37468 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232358AbjF2Xo6 (ORCPT ); Thu, 29 Jun 2023 19:44:58 -0400 Received: from bg4.exmail.qq.com (bg4.exmail.qq.com [43.154.54.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 068843A9E; Thu, 29 Jun 2023 16:44:31 -0700 (PDT) X-QQ-mid: bizesmtp71t1688082237td2r7nrs Received: from linux-lab-host.localdomain ( [119.123.131.49]) by bizesmtp.qq.com (ESMTP) with id ; Fri, 30 Jun 2023 07:43:57 +0800 (CST) X-QQ-SSF: 01200000000000D0W000000A0000000 X-QQ-FEAT: 9fp+MOMfZT3B2+27Lz2FTtpHEdP5j3lylTTpTlkY+1W9tYtMODtQHajOyUa+u KjzLT8Qc3eQVG5pPIeHgQ5dEURdQ2cV62nDeE9XHkM2MvowgrDTcEq1J+MR+p2lBpjqDlHc tmi8mq8yEz4+BD0xkYc1YeDmRD++G0w1cUIY9KI046I1CS8lX0PcziIAYWisMdC9QHlVUwM hR+oTfgO3MsLZfc3/7PNuAUYridqhYq4hM/1uuCK1ba9SyEP7nnM6tmkOtQ0vVt/NgPqU3U 3FHxEbPs/Dv4lcsYnMSZJ+xCqVW1y3+NJe4pF1nK122Bh9r3H7TYDjwy/7O9s3fM9xmypyg I3b3Aw9jgd9IHLy+5b7dY2iJnlWWr+OA/fedR4Ss3GD+2BOQy3BrmSl9H/qoA== X-QQ-GoodBg: 0 X-BIZMAIL-ID: 15543981623249164707 From: Zhangjin Wu To: thomas@t-8ch.de, w@1wt.eu Cc: falcon@tinylab.org, arnd@arndb.de, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: [PATCH v2 07/15] selftests/nolibc: link_cross: use /proc/self/cmdline Date: Fri, 30 Jun 2023 07:37:00 +0800 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:tinylab.org:qybglogicsvrgz:qybglogicsvrgz5a-1 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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?1770085193652422900?= X-GMAIL-MSGID: =?utf-8?q?1770085193652422900?= For CONFIG_NET=n, there would be no /proc/self/net, so, use /proc/self/cmdline instead. Signed-off-by: Zhangjin Wu --- tools/testing/selftests/nolibc/nolibc-test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c index 1d2be52d44a5..0bb222eaafca 100644 --- a/tools/testing/selftests/nolibc/nolibc-test.c +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -724,7 +724,7 @@ int run_syscall(int min, int max) CASE_TEST(link_root1); EXPECT_SYSER(1, link("/", "/"), -1, EEXIST); break; CASE_TEST(link_blah); EXPECT_SYSER(1, link("/proc/self/blah", "/blah"), -1, ENOENT); break; CASE_TEST(link_dir); EXPECT_SYSER(euid0, link("/", "/blah"), -1, EPERM); break; - CASE_TEST(link_cross); EXPECT_SYSER(proc, link("/proc/self/net", "/blah"), -1, EXDEV); break; + CASE_TEST(link_cross); EXPECT_SYSER(proc, link("/proc/self/cmdline", "/blah"), -1, EXDEV); break; CASE_TEST(lseek_m1); EXPECT_SYSER(1, lseek(-1, 0, SEEK_SET), -1, EBADF); break; CASE_TEST(lseek_0); EXPECT_SYSER(1, lseek(0, 0, SEEK_SET), -1, ESPIPE); break; CASE_TEST(mkdir_root); EXPECT_SYSER(1, mkdir("/", 0755), -1, EEXIST); break; From patchwork Thu Jun 29 23:45:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhangjin Wu X-Patchwork-Id: 114499 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp9991015vqr; Thu, 29 Jun 2023 16:59:53 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4cXtHUELhA2gx7/vWXu9Zi2T02BwO/28zc5Q0SgLO2VA3Y5oPM9rnGhO+5loCE76JFhJsj X-Received: by 2002:a05:6a21:9989:b0:12c:bbd3:a0dd with SMTP id ve9-20020a056a21998900b0012cbbd3a0ddmr1559009pzb.0.1688083193118; Thu, 29 Jun 2023 16:59:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688083193; cv=none; d=google.com; s=arc-20160816; b=ATC30DGhcuIBAEdkYsO6+kpCANiXGJYMQgb5zDT9bL6aSM6FWqHc3wGoDo9N5Eg7sc Wpdk+JkTRDEYsf8jBjeG6pHx+cfF5iDax7O4kj8iyw7m72s5ND6CizRrUqmtnYIoSPzi YENk1OCQ4+yJ/9jab6LDJzJx1pGnJ1stoLk4wvXpAAvZmd3/PWoPhSjqDTCnyK6lwml9 AUAe+qcP/89EZWaICvJbfWgP6FQLsMsi33rT7YYNOJTcQWJNSHzECiSEDnTLHoaXQ8OL 6dgwPRWG3fp85MXA+sYMcujY4DNw8QnPnNUCgL4ybrBVUXWnPZyvuokDaoP+RJ3zr1p9 QhUQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:feedback-id:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from; bh=+EoVjUE7v3hZEWXVg9wi2LLgIA8+AS+JwsiPQ8E2RI4=; fh=GzghTQzqgly4pZn8BwQ4U8bZ8zCadAK8Sl/utskeyEs=; b=sPIHplKoCF/sKxBCCdRI3G3exZoWX9Ko1HqEUOJMlJ7LHTB/sWQxWU0urm53uEdpRC mcw5LiysXHgTDUTn8DZYXQBarif8fEhWhgVSaPppfZAOvbac7egt+DbOIW5tmKZ5hQZe Jqju8fMNE6dVNR/lSj8xO0/FN0wIx4nT0iVQCZI96oX5AlF3G8fKaNSKKDPYJzqK1Vtu 28nAS5Mm84KOj+PvDzkqok3VYubgxSqt+2sEbq0LEN8Zg2rIavkUDeDWKEUrrbVyEtWk WdMCZaA094DN6J5owIHs57Sw2mKzTpm4mwu9RvBfCVq29Ii+zp8Qdxjy1ng2I+4yCp84 0v6Q== ARC-Authentication-Results: i=1; mx.google.com; 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v184-20020a6389c1000000b0055b5de06f07si531099pgd.219.2023.06.29.16.59.40; Thu, 29 Jun 2023 16:59:53 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231282AbjF2Xrm (ORCPT + 99 others); Thu, 29 Jun 2023 19:47:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39536 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229646AbjF2Xri (ORCPT ); Thu, 29 Jun 2023 19:47:38 -0400 Received: from bg4.exmail.qq.com (bg4.exmail.qq.com [43.154.54.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 947382D50; Thu, 29 Jun 2023 16:47:36 -0700 (PDT) X-QQ-mid: bizesmtp69t1688082446tioisu3e Received: from linux-lab-host.localdomain ( [119.123.131.49]) by bizesmtp.qq.com (ESMTP) with id ; Fri, 30 Jun 2023 07:47:25 +0800 (CST) X-QQ-SSF: 01200000000000D0W000000A0000000 X-QQ-FEAT: GUznYiACrGRXU/PHOEhZV4uIpp/gsrUe2qnOFpSTSF4MU1t9SCpp/PEXkGLnU X5sOQhdKVk9smFzAGQFaDLeDEwaVOpwCjMZ/QvMIpG5KF3300XxhHvoQpm6rFYpTpMhdbWa gielDawdT0Lm8wppHPUNs30pHHLYDJozuaT+A5bC2vX6H5DIQHD2GRfibL9k1GlUy1sL7iw U2L0h/dLPqID9hcbsmNDXA/PNc+YmKx8l6rpH7i7qkRkeUeLDZtU5S8PXbXWE5Vuf2jW2WT IQtTG3PqUOW8AttwjOR41SezOEo15azPYbN7wfChYvXhPFoUf362D8B7WwnbHY3pS1qAFbX T2mZ380MafeGj9Wbhzx8/WUCYI8pfecB1ICzTqF3SXKkLsgfhQ= X-QQ-GoodBg: 0 X-BIZMAIL-ID: 1361039155256738211 From: Zhangjin Wu To: thomas@t-8ch.de, w@1wt.eu Cc: falcon@tinylab.org, arnd@arndb.de, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: [PATCH v2 08/15] tools/nolibc: add rmdir() support Date: Fri, 30 Jun 2023 07:45:00 +0800 Message-Id: <7a2cde610506ca288742b4e52833572c4341ac20.1688078605.git.falcon@tinylab.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:tinylab.org:qybglogicsvrgz:qybglogicsvrgz5a-1 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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?1770083522101404383?= X-GMAIL-MSGID: =?utf-8?q?1770083522101404383?= a reverse operation of mkdir() is meaningful, add rmdir() here. required by nolibc-test to remove /proc while CONFIG_PROC_FS is not enabled. Signed-off-by: Zhangjin Wu --- tools/include/nolibc/sys.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tools/include/nolibc/sys.h b/tools/include/nolibc/sys.h index b6c33c40c037..7b052958e2ae 100644 --- a/tools/include/nolibc/sys.h +++ b/tools/include/nolibc/sys.h @@ -610,6 +610,28 @@ int mkdir(const char *path, mode_t mode) return __sysret(sys_mkdir(path, mode)); } +/* + * int rmdir(const char *path); + */ + +static __attribute__((unused)) +int sys_rmdir(const char *path) +{ +#ifdef __NR_rmdir + return my_syscall1(__NR_rmdir, path); +#elif defined(__NR_unlinkat) + return my_syscall3(__NR_unlinkat, AT_FDCWD, path, AT_REMOVEDIR); +#else + return -ENOSYS; +#endif +} + +static __attribute__((unused)) +int rmdir(const char *path) +{ + return __sysret(sys_rmdir(path)); +} + /* * int mknod(const char *path, mode_t mode, dev_t dev); From patchwork Thu Jun 29 23:48:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhangjin Wu X-Patchwork-Id: 114498 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp9990621vqr; Thu, 29 Jun 2023 16:58:51 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4FuTc/IxP02j9zWKSiF6Ft2CMxaVFPQoWBVeNe7CD6WCOVJceHqbnOWT2/f4RN6Fzi5W6b X-Received: by 2002:a05:6602:358b:b0:77a:ee79:652 with SMTP id bi11-20020a056602358b00b0077aee790652mr1378050iob.1.1688083130989; Thu, 29 Jun 2023 16:58:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688083130; cv=none; d=google.com; s=arc-20160816; b=K0vYWaX7sRmcD003gQ9i4TZx3bjMdR3g7LxU0HxqmYF7KkKd0/Ov4eAWjVHRyFoDH0 7SyP+rvfmWA1kgvx5lUm9jaQOWBjnyCIHS8k+62JFjItYDRCc5DsPkAiQSueACv/iB6x 2AVyYrMJnJmIo/EJ+GgqqTr/JmdQsAWxYMGs7lwLobrZTy+9vcNrP2p9hicXiiGd2OrY WzkKfvuEW2eDguWRzzMoDBRnrPf7lYWXOINsLUeO6fk2ma0Wcdg46Q4yw0o40M8HGdqv Dlmh9uwJYFr/k2j2Y8NR5hi4MKk3pucAf5pkv2GZ5iTWpZHmtYdkeaYIqq7Pkf+YlUkb 20FA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:feedback-id:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from; bh=cPb3qzjXoKgApxQu8tjtcUZjoeOTGtU0KL6LjN9vEqg=; fh=GzghTQzqgly4pZn8BwQ4U8bZ8zCadAK8Sl/utskeyEs=; b=k/F1fJQe/CuoOo/pUARGqHt4m1nuBjDS8rvHcOn4OPmLexo3lgRiw4Ay3/SXQG5m3Y u3g8MqGzmMEzJ2YMZkt2fTj5BrJUsFvkrwg6TESf31pg/JEHagkz1i5vD5HUBb1QoQsk 5o8GtCnfSacIkPCFVDAqaMjI2atezSI3ymuOdO2VQxG9iTKZNOnd8PBiv+xyajwCIl1U fUeq/lOderP0IB9C22xCO1xddoP3szpyNWuwhEZuecev6KkNV4up00MzP1hNjvqIUivA nPIF+W3wNlTZsXH5i7vWoo42RN/twHU6arZXMZSk8YnAfxsaT7Bd6bZKYDQcW/hdTLgz oX5g== ARC-Authentication-Results: i=1; mx.google.com; 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t62-20020a638141000000b00543d33304e6si11567219pgd.667.2023.06.29.16.58.38; Thu, 29 Jun 2023 16:58:50 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230012AbjF2Xs5 (ORCPT + 99 others); Thu, 29 Jun 2023 19:48:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39942 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229522AbjF2Xsv (ORCPT ); Thu, 29 Jun 2023 19:48:51 -0400 Received: from bg4.exmail.qq.com (bg4.exmail.qq.com [43.155.65.254]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A8B952D55; Thu, 29 Jun 2023 16:48:49 -0700 (PDT) X-QQ-mid: bizesmtp73t1688082520tj99e1ey Received: from linux-lab-host.localdomain ( [119.123.131.49]) by bizesmtp.qq.com (ESMTP) with id ; Fri, 30 Jun 2023 07:48:39 +0800 (CST) X-QQ-SSF: 01200000000000D0W000000A0000000 X-QQ-FEAT: rZJGTgY0+YPV5/jLlL1r2TTowp9VzAJ/QuZsdkm5XOB79yntw54lelBhGFGBW +iDCR+bq5zuGY1Fb5AOm9nx/s2lzObBrLIU6hKpbs2UAer50DRPUX5SXgyRxGcGoeAj4hLE ZeKdJH9pzNzvsarmvs3DCR53UszQvhXaLbg4dp20rANnIT0/3bXQEFJYUINdfEY5uYn18gq u9ksw5IB8zjOinFLQFFb9AuiAFpF2HoQxoPVaS2/Uhz2MaX8tb6sbRf1nDxkcWLFqUrwA20 msOXABk2XcYTB7yww0XiP5gppsd/tXgth9vLou2iZhqKqV42WH1UKjxu82NVmaDS51d5vO3 StbtwR6MAldUGm6M3EglvM8DTmqRzi64SQ+8y8VHJ3FStWMmcAADDmXyBZjzQ== X-QQ-GoodBg: 0 X-BIZMAIL-ID: 1596370371220799989 From: Zhangjin Wu To: thomas@t-8ch.de, w@1wt.eu Cc: falcon@tinylab.org, arnd@arndb.de, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: [PATCH v2 09/15] selftests/nolibc: add a new rmdir() test case Date: Fri, 30 Jun 2023 07:48:29 +0800 Message-Id: <652efe216f732c88bd275b597924c4d106741c6b.1688078605.git.falcon@tinylab.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:tinylab.org:qybglogicsvrgz:qybglogicsvrgz5a-1 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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?1770083457428470490?= X-GMAIL-MSGID: =?utf-8?q?1770083457428470490?= A new rmdir_blah test case is added to remove a non-existing /blah, which expects failure with ENOENT errno. Signed-off-by: Zhangjin Wu --- tools/testing/selftests/nolibc/nolibc-test.c | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c index 0bb222eaafca..2725d3dbfaf0 100644 --- a/tools/testing/selftests/nolibc/nolibc-test.c +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -738,6 +738,7 @@ int run_syscall(int min, int max) CASE_TEST(poll_fault); EXPECT_SYSER(1, poll((void *)1, 1, 0), -1, EFAULT); break; CASE_TEST(prctl); EXPECT_SYSER(1, prctl(PR_SET_NAME, (unsigned long)NULL, 0, 0, 0), -1, EFAULT); break; CASE_TEST(read_badf); EXPECT_SYSER(1, read(-1, &tmp, 1), -1, EBADF); break; + CASE_TEST(rmdir_blah); EXPECT_SYSER(1, rmdir("/blah"), -1, ENOENT); break; CASE_TEST(sched_yield); EXPECT_SYSZR(1, sched_yield()); break; CASE_TEST(select_null); EXPECT_SYSZR(1, ({ struct timeval tv = { 0 }; select(0, NULL, NULL, NULL, &tv); })); break; CASE_TEST(select_stdout); EXPECT_SYSNE(1, ({ fd_set fds; FD_ZERO(&fds); FD_SET(1, &fds); select(2, NULL, &fds, NULL, NULL); }), -1); break; From patchwork Thu Jun 29 23:49:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhangjin Wu X-Patchwork-Id: 114505 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp10003910vqr; Thu, 29 Jun 2023 17:25:04 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6uI+OEvWJYwku5HucABKSAoN1AVipPN0QO1suQBmlnGJ7ymIzG5np3m7tks22ByRDTtncZ X-Received: by 2002:a05:6a20:1446:b0:111:ee3b:59a7 with SMTP id a6-20020a056a20144600b00111ee3b59a7mr1599169pzi.5.1688084704520; Thu, 29 Jun 2023 17:25:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688084704; cv=none; d=google.com; s=arc-20160816; b=T0lD9X8bns5ltoBXE/B7aqhyosPRJ+GkYPV3Xaa/aT5h/c+vRs4Hb8HBGWsvny8/y5 3Ee5mQttHj+wr/7IHFAz4NiyqooRw0Jt6wCjSUuKaj3LXU4D20qwhlR7VNoZZZ8jAAym +HRR4czyveSCWQtiV3uDvr2IfiedVOmUWgIPo8uxh5YMTXLD7uV9+IvjlqquZ8f03Rbu LkR7m0VFU0th+oCf+dtn5Lqik69yaxtZqBF5ZfjNezykydfs2oMCe6OhneBFunhPRLVx lzGKk2RdrvsmrQ23E0THOxBp5KX01nKI/iCpf0wZ+ElqrrCJy/oCHYzVpzEBjaUdYAm7 7NkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:feedback-id:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from; bh=upspyDq1/ll+yZphJ8mrEvzCmBaZDOBHIpgg402v3Z8=; fh=GzghTQzqgly4pZn8BwQ4U8bZ8zCadAK8Sl/utskeyEs=; b=wtyA7tDYHRs0VtzIQ86iFb463LFmbeThRYPLWuPi9DvHILoCTuOmYVxuiMATHTylxP Y8mRxSbhF5HviwljED9CMHel1fInKJlk+5aMaOYUZ0yW/sgLedUNsoyXGdyPlvACdEYp ANdsyTvM5u2Z4eMp3aPfgFrnsQJVoHRryeS9yfsIkXPN1hI8KsDbZJx7VMbWcM6VOWtt y5T8QLyFkqozC391WQaSa4ct5SLORZsTxEXDCzBDS1LXnq7+zoynznl5p8wjFtyjWsqG 7Sgw3pQvsEQ6SxRJJNqOCTisQkQ/7HEs5/48hiIYnc23i7pmQmJ/bF+N+DLQwROuS7kU UiDQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i9-20020a170902c94900b001b02390367fsi11907601pla.595.2023.06.29.17.24.52; Thu, 29 Jun 2023 17:25:04 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230286AbjF2XvY (ORCPT + 99 others); Thu, 29 Jun 2023 19:51:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40630 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231176AbjF2XvT (ORCPT ); Thu, 29 Jun 2023 19:51:19 -0400 Received: from bg4.exmail.qq.com (bg4.exmail.qq.com [43.155.65.254]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9B3592D56; Thu, 29 Jun 2023 16:51:10 -0700 (PDT) X-QQ-mid: bizesmtp83t1688082660twu7a8ef Received: from linux-lab-host.localdomain ( [119.123.131.49]) by bizesmtp.qq.com (ESMTP) with id ; Fri, 30 Jun 2023 07:50:58 +0800 (CST) X-QQ-SSF: 01200000000000D0W000000A0000000 X-QQ-FEAT: D2GZf6M6C/i23X3okTEDyY7sY3qClIpPp5F6NuS/AEEIAEVpfzZOlfZdTUae/ 8CfRQul6j18UQzkvZt4EsG5DY7/jNUNQinzpFR6x/BTidUBNAu9H2aVgrxP7o2Q7pS7SCfg w5kxfiqw3cg2/Olv9TybUurx+SRkjOzWzeDs/NRYj3Q5/ToQPoACfSxqmES7ywPwYJabr2g 0g6EM//dSBgtZRsUVY5Bc4/1Vw1kaRxeEiQ7/prMFw7/U1s7lOJqskt9aYv3ariLgg5Q8t/ KW9cw0ditY8PZiICS5z9ENmLuWC56RUovXsksri2oZLW9rd07Bvtrx0qYtrw3KdX2junOQT +7T0Y8lW34Z+6nDzkXxM9rGwCchPB4d3xzAqiL5qMR17heqzC0iW53NX0FHnQ== X-QQ-GoodBg: 0 X-BIZMAIL-ID: 18297835509952804073 From: Zhangjin Wu To: thomas@t-8ch.de, w@1wt.eu Cc: falcon@tinylab.org, arnd@arndb.de, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: [PATCH v2 10/15] selftests/nolibc: fix up failures when CONFIG_PROC_FS=n Date: Fri, 30 Jun 2023 07:49:42 +0800 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:tinylab.org:qybglogicsvrgz:qybglogicsvrgz5a-1 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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?1770085107187855930?= X-GMAIL-MSGID: =?utf-8?q?1770085107187855930?= For CONFIG_PROC_FS=n, the /proc is not mountable, but the /proc directory has been created in the prepare() stage whenever /proc is there or not. so, the checking of /proc in the run_syscall() stage will be always true and at last it will fail all of the procfs dependent test cases, which deviates from the 'cond' check design of the EXPECT_xx macros, without procfs, these test cases should be skipped instead of failed. To solve this issue, one method is checking /proc/self instead of /proc, another method is removing the /proc directory completely for CONFIG_PROC_FS=n, we apply the second method to avoid misleading the users. Signed-off-by: Zhangjin Wu --- tools/testing/selftests/nolibc/nolibc-test.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c index 2725d3dbfaf0..c0f5302ada5d 100644 --- a/tools/testing/selftests/nolibc/nolibc-test.c +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -1047,8 +1047,11 @@ int prepare(void) /* try to mount /proc if not mounted. Silently fail otherwise */ if (stat("/proc/.", &stat_buf) == 0 || mkdir("/proc", 0755) == 0) { - if (stat("/proc/self", &stat_buf) != 0) - mount("/proc", "/proc", "proc", 0, 0); + if (stat("/proc/self", &stat_buf) != 0) { + /* If not mountable, remove /proc completely to avoid misuse */ + if (mount("none", "/proc", "proc", 0, 0) != 0) + rmdir("/proc"); + } } return 0; From patchwork Thu Jun 29 23:52:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhangjin Wu X-Patchwork-Id: 114507 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp10004602vqr; Thu, 29 Jun 2023 17:26:35 -0700 (PDT) X-Google-Smtp-Source: APBJJlHKvcpt1A1u423Cl9SeuzMUfrPtavy2UxXqJUMWkxhcnv5BCDGXbIcr4RPDCk1VRTFUKGlD X-Received: by 2002:a17:902:ec88:b0:1a6:6bdb:b548 with SMTP id x8-20020a170902ec8800b001a66bdbb548mr792012plg.1.1688084795344; Thu, 29 Jun 2023 17:26:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688084795; cv=none; d=google.com; s=arc-20160816; b=cNXftu73TLdBllJkRo9weKknyQKJwL/e+kOoiJMA6UFRnFnRfq1tdoskJ277QWBeyp UKcALOasvRTxKDlfg1FeVZE9tAf+zINpQ7o+AgLJlmcStMhTfMTm+feNdEcYsG21Lhr3 eH9VaAp5sqRoCLrEjKCGAoMsJgBh0KF+NN4M7IsNXu4kHcmXBnucNq4plrsSl1+4qiQo lPmeE76cBpwPJPNGDGIfUTbQRrXFeNMNnyok/og6T1bDt6szn1fioBmGzB8hbJ5HMHPT NjcANiWoyF73tv1ExNIhlKSAZDHXHs3i/DJfmOLbUvtvy+AiIsi+xF0G2eZkzcS70WUm HI/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:feedback-id:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from; bh=sorbPGL5wCAbm6CukBd2LmFBGr8sFCmv3UnH7gB3weI=; fh=GzghTQzqgly4pZn8BwQ4U8bZ8zCadAK8Sl/utskeyEs=; b=qsNTN0Ae/Y3ciB3atSh/o+9CUYWI5EV2BhIfLASyYTWVbcsCRRpsfBr79469pNZaGx uLrvjjGCtKo+ts4rrqSt9FFAnI84rhds92RE6sXqpEAv9aILHcPXKTk+u+WMbLo8Ee+5 0WU8HDPYj51UIPUM9Nh24S5iUdffOLwkiVaMNr/MzakKuvrF5IKxTC1wSTe4vv1HD0// UmtJpLuT/VwhKxJdsLzoZpMnH3BGK78qSTRWXBhWs++yXC1PHca90LSunDD8zmbAznyz dX42PX2eN4HQoDlQe0CdGOuNX5JtMjgAFDpjhVZXTrSVXMkulYK/TuBjh3UeX8V6qoty 9Czg== ARC-Authentication-Results: i=1; mx.google.com; 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i12-20020a17090332cc00b0019ca7d69673si12572096plr.196.2023.06.29.17.26.21; Thu, 29 Jun 2023 17:26:35 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230488AbjF2Xxq (ORCPT + 99 others); Thu, 29 Jun 2023 19:53:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42456 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229936AbjF2Xxo (ORCPT ); Thu, 29 Jun 2023 19:53:44 -0400 Received: from bg4.exmail.qq.com (bg4.exmail.qq.com [43.155.65.254]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 85236C3; Thu, 29 Jun 2023 16:53:42 -0700 (PDT) X-QQ-mid: bizesmtp62t1688082813tkl23r8i Received: from linux-lab-host.localdomain ( [119.123.131.49]) by bizesmtp.qq.com (ESMTP) with id ; Fri, 30 Jun 2023 07:53:32 +0800 (CST) X-QQ-SSF: 01200000000000D0W000000A0000000 X-QQ-FEAT: SdugMSrl+IPAzXWq+rfJBOyleIPNwAJP1BnWuXjvrOgozUJpjkblZ040nbM0V 4nYGY8mJHgC1InPwQxd66pwy39Ncw2l3U1VAq3Exy6G8vo5XDg/2ht6XP8d2wYbESG8lrA6 uSJqxqrWSrWxsAY9JcffJxCcyO/dpYdQlb2N693wOs2t5z86w3JMJ8vj+nz0kd9q//1DQ8J hb5IppBq9Qot4Koo5KkS9x/7oaCb7FcZSgJWBZgfggO/5UtJe4z7N1DEwSHWJRlQH3Pnp66 xuXtRV+1rRqBOREkItMdGFJck4pnjXpgCWm16Kf4OnQKi4lWcuXEFWuZCnvYnlrKCI2nEwz rOVbx8w+ne0rx0ByPHIAwpoVVvs5XdhaNvbMK5Phj+Itt1nE1g1sv9pbnY75g== X-QQ-GoodBg: 0 X-BIZMAIL-ID: 11952200826971950609 From: Zhangjin Wu To: thomas@t-8ch.de, w@1wt.eu Cc: falcon@tinylab.org, arnd@arndb.de, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: [PATCH v2 11/15] selftests/nolibc: prepare /tmp for tmpfs or ramfs Date: Fri, 30 Jun 2023 07:52:03 +0800 Message-Id: <9dc032064dde254a03e2111da1e58344deca6522.1688078605.git.falcon@tinylab.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:tinylab.org:qybglogicsvrgz:qybglogicsvrgz5a-1 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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?1770085202213232078?= X-GMAIL-MSGID: =?utf-8?q?1770085202213232078?= Let's create a /tmp directory and mount tmpfs there, if tmpfs is not mountable, use ramfs as tmpfs. tmpfs will be used instead of procfs for some tests. Signed-off-by: Zhangjin Wu --- tools/testing/selftests/nolibc/nolibc-test.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c index c0f5302ada5d..8e3e2792f5e3 100644 --- a/tools/testing/selftests/nolibc/nolibc-test.c +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -1054,6 +1054,10 @@ int prepare(void) } } + /* try to mount /tmp if not mounted, if not mountable, use ramfs as tmpfs */ + if (stat("/tmp/.", &stat_buf) == 0 || mkdir("/tmp", 0755) == 0) + mount("none", "/tmp", "tmpfs", 0, 0); + return 0; } From patchwork Thu Jun 29 23:54:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhangjin Wu X-Patchwork-Id: 114503 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp10002885vqr; Thu, 29 Jun 2023 17:22:26 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7DQTRFJdBUIQayDrMcxDkW2OOomrjBX82q+kE2rgfEPK5mUDjg6DKtxCccKkB6oFphb550 X-Received: by 2002:a05:6830:388a:b0:6b8:356d:f844 with SMTP id bq10-20020a056830388a00b006b8356df844mr1840467otb.1.1688084546540; Thu, 29 Jun 2023 17:22:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688084546; cv=none; d=google.com; s=arc-20160816; b=lQKHX5kFlGV/DqPT0Vmi0SgyhTUM3uCS42T3Xb2cZMtPreEbA29PiJj+IbqxNRlEyq F1mE7XPU7trs22aMf0gNa/qr54IN8aAZyfBCReCBCc0XQqFzcRxEEo5/ocjSV/20P1js 535RV8AkVVWfvKbVpoF8DHd1rpwZDGEypoUKlViJRj33djGR9R5HVG/XRC1C44++bjK/ B7DW3j5O8FcuFokdxWDZhSJA3KQ7aZ9j0DccCJh2DJDqyTFUrXc/PbflNxpoBmcJeoEt aGEdQeFc3Y8bg5PxBQDpRSZZe84t3uKuQ5n+m+qLefA+DR+bU/wEq25ZgVEi8VV5qkV0 TS2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:feedback-id:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from; bh=xvPw67Bmt3MOqa905bjkXPRSm1z7b6cNqTPIIkh46Gg=; fh=GzghTQzqgly4pZn8BwQ4U8bZ8zCadAK8Sl/utskeyEs=; b=gTZf6eXfOOGBxEZrv2si6MBUc47vLKZ6iJzthe77wYEJ6j0MUAuYxB9eR+hope/+4q WEmV8fPP+u5HZ535ZcSDC/90cTA/R5B3LiO/jVylYWe6JKNv9ZM3aCwWUcLq1wzPFAR/ c67X6kYEe7EZvpWpH+Qb3MyTkbyJ4XdLyaKqmuFKQY9b/26G3WmY2RNrLM8j7RrPtU4T ZdgZ9ITzZtlCpTELQIXoxfKxq3Peu+oP6bOaKQqq40moOFd5aj9VkPqkVBD+u4TrsQql rEwzaJpYN+YC7rbtsf637D5COpYn5KlJ2uXB3zpOvTnRrG/YIVGBYM70o/Qap5H4wJmR s/nw== ARC-Authentication-Results: i=1; mx.google.com; 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j35-20020a63fc23000000b005538c82b70fsi11169979pgi.166.2023.06.29.17.22.10; Thu, 29 Jun 2023 17:22:26 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231294AbjF2X7i (ORCPT + 99 others); Thu, 29 Jun 2023 19:59:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44290 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230054AbjF2X7h (ORCPT ); Thu, 29 Jun 2023 19:59:37 -0400 Received: from bg4.exmail.qq.com (bg4.exmail.qq.com [43.154.54.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1C9482972; Thu, 29 Jun 2023 16:59:34 -0700 (PDT) X-QQ-mid: bizesmtp86t1688083165t6ieamo4 Received: from linux-lab-host.localdomain ( [119.123.131.49]) by bizesmtp.qq.com (ESMTP) with id ; Fri, 30 Jun 2023 07:59:24 +0800 (CST) X-QQ-SSF: 01200000000000D0W000000A0000000 X-QQ-FEAT: i75H2eCteEhF1p4iQc3BY/8OPWOM3oRV+m1q8nMuW55lIXGl3BcbML5es10ms jUJ47FoEB9w1RrMiQT5qOoUDc73bYdvwB9sPxtmeszNifC+0YMKarlKsKsVlF09ESf6D0pE j0CkAw8/zC9q/WERC2PIYa2YBnc+l9ualw7CIwHzQ6BqgC1ol46rzAJamJJAUOCL+u6ksZr SxkovQ7MYlGasGHmhyCHvCw9O0rfuDylF/FehTVIFRHmU5HgP2pvT1XxfNuktS9M4bOGj48 qK/4a/evfIeN8GrXBPtYXm1HYuPUS+ZUrpNmjbMAdxXF7T8GX1E2J7N1Umee4jfYVUUla6a FgYc2Ny0mVYD33BQNKsS0am2tDuk58hX+iozREosjyq6NS97Mw= X-QQ-GoodBg: 0 X-BIZMAIL-ID: 10255374307051264272 From: Zhangjin Wu To: thomas@t-8ch.de, w@1wt.eu Cc: falcon@tinylab.org, arnd@arndb.de, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: [PATCH v2 12/15] selftests/nolibc: add common get_tmpfile() Date: Fri, 30 Jun 2023 07:54:35 +0800 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:tinylab.org:qybglogicsvrgz:qybglogicsvrgz5a-1 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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?1770084941118426871?= X-GMAIL-MSGID: =?utf-8?q?1770084941118426871?= allow create and get a temporary file from tmpfs. Signed-off-by: Zhangjin Wu --- tools/testing/selftests/nolibc/nolibc-test.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c index 8e3e2792f5e3..1002e0267515 100644 --- a/tools/testing/selftests/nolibc/nolibc-test.c +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -54,6 +54,23 @@ struct test { int (*func)(int min, int max); /* handler */ }; +static const char *get_tmpfile(const char *tmpfile) +{ + struct stat stat_buf; + int fd; + + if (stat(tmpfile, &stat_buf) == 0) + return tmpfile; + + fd = open(tmpfile, O_CREAT, 0600); + if (fd != -1) { + close(fd); + return tmpfile; + } + + return NULL; +} + #ifndef _NOLIBC_STDLIB_H char *itoa(int i) { From patchwork Fri Jun 30 00:00:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhangjin Wu X-Patchwork-Id: 114500 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp9997678vqr; Thu, 29 Jun 2023 17:10:43 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6GK28gIKd7l+PO21C7bV/ueQiWRmpTQsTmiCwMZcJ/CMh4dw8KtWQeM/K6JTqJCivUJFwA X-Received: by 2002:a05:6830:b84:b0:6b4:57ad:3d19 with SMTP id a4-20020a0568300b8400b006b457ad3d19mr1666901otv.2.1688083843557; Thu, 29 Jun 2023 17:10:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688083843; cv=none; d=google.com; s=arc-20160816; b=N/T0RftjIupUemm9jq0/RfzzX9rqPpafGvTdSqWj7Uq6VEAUiUX9GFkfhMuj4RU4XL 0YVgVo/r/P1Eb57VZUITN+schl9xzW16iHV0VO16jIZvJJpgZJavzMRrV9BaHepgSe4X hj35rMolDZB3FAYpj1VVf6wpGZlVBgsk2O8bYlluOrdU5H6ik5OZEkNs+bEv7cqo4qBv 60nJjU+r+ZqTdjxS4Hc/EKJeOv5v1Y4MOB5lBn2E/PUuzr0XiJeHKuiIH2jMz34CveXr B7I6PdM1Q6tP+6CCz06SoRgirRxTLAje9vgTmEQ07p4TaDIM9Ymckj652tviyhkixpc0 7tRA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:feedback-id:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from; bh=KErcoTDhwOzWkH5uneST6Xp7xTYjcMG/8WG6s/kGzLo=; fh=GzghTQzqgly4pZn8BwQ4U8bZ8zCadAK8Sl/utskeyEs=; b=EnbUCwPTv586bFVNOd6c4UJ/LnB8FhfpuGwFkMPs1ZwWxVhaZua7SRtOTZWY+uJVGe eL/FC1ygmppe43PPE2UZ/kLmTsmXBSm955YJoxYtLLjMxQLPcpRkvC+mMHSTvfPOZNNr PbMUT+03NQzPtv+nuKo71nmMYlrfEJA4Q6cmIXVESFltX5jZh5cjiKecmNOSk6UXgx4M G28xsI8T8hUwJMjkASDnZdDaD7+ARktoVeJNv9ZJ9FavAyWoGdlHZiY5KDoFD5Dm6C0n BzhQNYkag7LJmBxfPQ5c1vN/DKwEMX+79mfx01b8Oi//aKcZgi+yaGWy9DmAwvkfFsdJ HWJQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c20-20020a631c14000000b0054fe3c820dcsi11301227pgc.102.2023.06.29.17.10.24; Thu, 29 Jun 2023 17:10:43 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231653AbjF3AA4 (ORCPT + 99 others); Thu, 29 Jun 2023 20:00:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44728 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229727AbjF3AAz (ORCPT ); Thu, 29 Jun 2023 20:00:55 -0400 Received: from bg4.exmail.qq.com (bg4.exmail.qq.com [43.154.54.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9B0252972; Thu, 29 Jun 2023 17:00:53 -0700 (PDT) X-QQ-mid: bizesmtp70t1688083243tc6q58s1 Received: from linux-lab-host.localdomain ( [119.123.131.49]) by bizesmtp.qq.com (ESMTP) with id ; Fri, 30 Jun 2023 08:00:43 +0800 (CST) X-QQ-SSF: 01200000000000D0W000000A0000000 X-QQ-FEAT: CR3LFp2JE4kswbijyT8FSHr/m5Ro1TRCzo0a8RfheEUvcf/BVZGX2KLlH6E/+ ShX8DywmRJ9ILMpomwp/MCmci/hDinkPesyIEF8m1z95RH4xr+UNw7Yg9ulHwl3Jt/BEuwK wY3rSTi9866Fog1s2TtL6YySRzzpuWzkghoVs58pDr48HYz2G6BLHsnKSvBnuCK3bNxBdn5 ljA/Au8aGriHhAlDjLeRl6iTzcX0CoK1GI0ozDFMjE4Q9SztOGzJOUw96JOZtXYGlaITQxc bkb+eW2apV54E40wx7aRPpITa7SqGh7wpSvibt119O/MtmCGbqN99YMlET+fYnYEA1R1AQI cSxavE7nLz/r3EOrqvur7xG9QFph5o5xFoNwERFkEopWHVlaymMKulc5hiamQ== X-QQ-GoodBg: 0 X-BIZMAIL-ID: 14245471600300813277 From: Zhangjin Wu To: thomas@t-8ch.de, w@1wt.eu Cc: falcon@tinylab.org, arnd@arndb.de, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: [PATCH v2 13/15] selftests/nolibc: rename chroot_exe to chroot_tmpfile Date: Fri, 30 Jun 2023 08:00:28 +0800 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:tinylab.org:qybglogicsvrgz:qybglogicsvrgz5a-1 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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?1770084204363049459?= X-GMAIL-MSGID: =?utf-8?q?1770084204363049459?= For CONFIG_PROC_FS=n, let's use tmpfs and create a tmp file for chroot_exe test. Since chroot_exe is mainly testing the not directory case (ENOTDIR), so, rename it to chroot_tmpfile may be better. Signed-off-by: Zhangjin Wu --- tools/testing/selftests/nolibc/nolibc-test.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c index 1002e0267515..2e9eaa7efa6e 100644 --- a/tools/testing/selftests/nolibc/nolibc-test.c +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -682,6 +682,8 @@ int run_syscall(int min, int max) int ret = 0; void *p1, *p2; int has_gettid = 1; + const char *tmpfile = get_tmpfile("/tmp/dummy"); + int has_tmpfile = tmpfile != NULL; /* indicates whether or not /proc is mounted */ proc = stat("/proc", &stat_buf) == 0; @@ -720,7 +722,7 @@ int run_syscall(int min, int max) CASE_TEST(chown_self); EXPECT_SYSER(proc, chown("/proc/self", 0, 0), -1, EPERM); break; CASE_TEST(chroot_root); EXPECT_SYSZR(euid0, chroot("/")); break; CASE_TEST(chroot_blah); EXPECT_SYSER(1, chroot("/proc/self/blah"), -1, ENOENT); break; - CASE_TEST(chroot_exe); EXPECT_SYSER(proc, chroot("/proc/self/exe"), -1, ENOTDIR); break; + CASE_TEST(chroot_tmpfile); EXPECT_SYSER(has_tmpfile, chroot(tmpfile), -1, ENOTDIR); break; CASE_TEST(close_m1); EXPECT_SYSER(1, close(-1), -1, EBADF); break; CASE_TEST(close_dup); EXPECT_SYSZR(1, close(dup(0))); break; CASE_TEST(dup_0); tmp = dup(0); EXPECT_SYSNE(1, tmp, -1); close(tmp); break; From patchwork Fri Jun 30 00:01:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhangjin Wu X-Patchwork-Id: 114502 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp10002353vqr; Thu, 29 Jun 2023 17:21:07 -0700 (PDT) X-Google-Smtp-Source: APBJJlE3DeSENjvSs6LiMedwpOSH15ZtrUZwf8fg11ocsoq3hnflN7s/KIDEnKvYahrEsJulTJli X-Received: by 2002:a05:6a00:1d9b:b0:681:ed30:32e5 with SMTP id z27-20020a056a001d9b00b00681ed3032e5mr1558002pfw.0.1688084467318; Thu, 29 Jun 2023 17:21:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688084467; cv=none; d=google.com; s=arc-20160816; b=aldJtteeD5aqEqjWk+BDcRwLVJLVM0RyFUtlyqyQmtVX13kxtpRV+vR9og/5lqruf6 5wpxi6SScYEaYOM1K4Z3G2Zq13csILFiLtJTcNKo6N3ui5/gWol3MLyVIBB16tpj9uMI EuPCSES8BjbHxP/noM/STAS+my0mpvUlsp6PuG/maOIipUiTEwTBrsvdvZ/X5ay20yVx Y7NDqBx5JaqrdVQDSSoXSTTEB1Cg39Rfb8kWcx1Odt+dg6r3SV2tqgbknTuybqZGZfVr JOnSeS4JESnhq8wMzO8PZe2u38ETxeieVbliMB1d13m4QtPjrXx4qWZ7WmfDFk6Z5BTl qN6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:feedback-id:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from; bh=muGJuQ5v3Lk/K0K/sJA5DZjb3Ta/geUuMs2HIcHV1Lk=; fh=GzghTQzqgly4pZn8BwQ4U8bZ8zCadAK8Sl/utskeyEs=; b=HGsaufISM1xwAmPB0R+hJrfflbUjA0A1gM9QSY8/GwL6o+6QjpM1rW3atmpJRasE6j YvOXQe5LyA4eK4O8CxAEfLOhy7AWUvBUTmTRhR7PjXAW/CkLJS6BKwFIVqEsWEgvywMC vhlEzJtMegUNvPyuD6Y7GOoZIk4I9wi1pQP90v2heqWi/cfnNCOaAaRADVCU0TY23+Wb 3ei5oJ/Cb+gx1jH8EuCAKeh9dn4m5pvLfQuzGHCEGNKszKO26TeIARfObJK/WWllO1XW EVf100PZC5ySr+AR+Fam50lcOJYzXiiq5lWPVKQJNaanh4l37bqpRb6Ee83g/2vW+OF8 E+Rg== ARC-Authentication-Results: i=1; mx.google.com; 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cl7-20020a056a0032c700b0067e18c6d2d2si5226763pfb.14.2023.06.29.17.20.50; Thu, 29 Jun 2023 17:21:07 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231950AbjF3ACa (ORCPT + 99 others); Thu, 29 Jun 2023 20:02:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45442 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231953AbjF3ACX (ORCPT ); Thu, 29 Jun 2023 20:02:23 -0400 Received: from bg4.exmail.qq.com (bg4.exmail.qq.com [43.154.54.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5D5B83588; Thu, 29 Jun 2023 17:02:21 -0700 (PDT) X-QQ-mid: bizesmtp73t1688083331t4dhfelf Received: from linux-lab-host.localdomain ( [119.123.131.49]) by bizesmtp.qq.com (ESMTP) with id ; Fri, 30 Jun 2023 08:02:10 +0800 (CST) X-QQ-SSF: 01200000000000D0W000000A0000000 X-QQ-FEAT: eSZ1CZgv+JACTc0WzG4h74YvHe3gYF2XyV6HOEkcVE0utw0p/IA1Z5qToF1SM 3RioGCvD1BnB7phTtW7YUGkLu/mO4OLtLuJtK9lcbL1Wjv1fHbWItWGhIUokSs7aA1G6RmO iWqNAcsY1vABTHLrGflhEGYSlrXuqFUmkROxHdV5zxKFqyPNRDFlkIUjEa7cBj+/1kubjDh Vkc21XSo9YgqVB8wJwRykJpc1f4bpDrmIaIHkVbIa70aTwJSs82UHnS1IsSS49VrDbQc8Ew MkRPNOwLf+bR2SIpfKT+20lSlA6kQZOH3fsiMHvsH8voRT3tPqDCWobmkXTcRfS2KqpsWQc F9+jJROZtG5A/m81h/Tk7Sjl2cCnoGIRIf0+BDU6yZSIX1DdiwNkTwMaTctAw== X-QQ-GoodBg: 0 X-BIZMAIL-ID: 5863286306713928212 From: Zhangjin Wu To: thomas@t-8ch.de, w@1wt.eu Cc: falcon@tinylab.org, arnd@arndb.de, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: [PATCH v2 14/15] selftests/nolibc: add chmod_tmpfile test Date: Fri, 30 Jun 2023 08:01:46 +0800 Message-Id: <02a08c64cd16ea03101e271527c5573453e9195f.1688078605.git.falcon@tinylab.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:tinylab.org:qybglogicsvrgz:qybglogicsvrgz5a-1 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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?1770084858462549825?= X-GMAIL-MSGID: =?utf-8?q?1770084858462549825?= allow test chmod with tmpfs even when procfs is not there. Signed-off-by: Zhangjin Wu --- tools/testing/selftests/nolibc/nolibc-test.c | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c index 2e9eaa7efa6e..0ca7d011765a 100644 --- a/tools/testing/selftests/nolibc/nolibc-test.c +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -719,6 +719,7 @@ int run_syscall(int min, int max) CASE_TEST(chdir_blah); EXPECT_SYSER(1, chdir("/blah"), -1, ENOENT); break; CASE_TEST(chmod_net); EXPECT_SYSZR(proc, chmod("/proc/self/net", 0555)); break; CASE_TEST(chmod_self); EXPECT_SYSER(proc, chmod("/proc/self", 0555), -1, EPERM); break; + CASE_TEST(chmod_tmpfile); EXPECT_SYSZR(has_tmpfile, chmod(tmpfile, 0555)); break; CASE_TEST(chown_self); EXPECT_SYSER(proc, chown("/proc/self", 0, 0), -1, EPERM); break; CASE_TEST(chroot_root); EXPECT_SYSZR(euid0, chroot("/")); break; CASE_TEST(chroot_blah); EXPECT_SYSER(1, chroot("/proc/self/blah"), -1, ENOENT); break; From patchwork Fri Jun 30 00:03:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Zhangjin Wu X-Patchwork-Id: 114504 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp10003412vqr; Thu, 29 Jun 2023 17:23:45 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5o4Ux0wtt6tTFeE+tmzWR62hL9ZUBCg5K4/tlMUPwbUDNBWvNpbPgIb7WAD2nMmX4aDHbw X-Received: by 2002:a05:6830:461a:b0:6b4:26c5:7eab with SMTP id ba26-20020a056830461a00b006b426c57eabmr1342533otb.2.1688084624884; Thu, 29 Jun 2023 17:23:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688084624; cv=none; d=google.com; s=arc-20160816; b=tjwjp2MeLPq0tmdhDlpVkQYCy+/cUAdann3zy9KcqXmOJ/lNRBNePgAaYWZmV4JmQW WznmmKFXtbtygEol94yR30JLGy13d1DPOV39VWxf7OunGLyYs/MPr4+tRQNXXF0quQM5 QrIfHqQyHuS6ckI1ek6DLZq3hV1E7qmPkzC4YsuyosbaP3jh6Kms9dGE9TqErF5BNCFD 1z/8qa6fBYUjFNHiE4CH/5E5nasvLfe80ujSKgVoHmfn/WsAxHleka6vr4lNAl3KKVXE 0S/uMf4A82kKVyDsoHCyyF9ZwZAhWsKKdtubea/oOn598mOJufU4kwYiRBnhaYFMM+5/ W4eg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:feedback-id:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from; bh=2cll6BazXa4gYWpdvQqgFKIokCBz+IxPe4n9DGCZSOU=; fh=F5il0f38/OnR+6Lk4jyRbQDcrSTey2kQnNpdmJYq5RU=; b=kIN+/3EEipT0cia41r7jNjGxuZXeTXGGmcEHd5whqcNSQ+e+zo8UF0+louHeZAElDQ gWQuT4MHyjYGHSBkrXfLYU2NmjY3vtH+4R6Vi+H9Jz1k5lOdi5f4KzR9XaiVkisotgUy jzSVdeOLD0LhDLBtmEIizGJRVoISLb5RyfASVzlv8kQLlO08dgRxOV4qzrL3D1bfJfWv L4d/kk5Ee6Buxv6mM+C7HVatR/KtrZVqtLf/QvVx1s+wO1S5TSA2pZfLcv7AniEcCK9Q L56YbJkShzRAgU1LHHGa8p/UIfF3l8UPFgjcoZb2U16ctLOq7NSCd3S3Jv65T6e0DnSG i7Hg== ARC-Authentication-Results: i=1; mx.google.com; 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j35-20020a63fc23000000b005538c82b70fsi11169979pgi.166.2023.06.29.17.23.32; Thu, 29 Jun 2023 17:23:44 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231681AbjF3AGT (ORCPT + 99 others); Thu, 29 Jun 2023 20:06:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46224 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230385AbjF3AGR (ORCPT ); Thu, 29 Jun 2023 20:06:17 -0400 Received: from bg4.exmail.qq.com (bg4.exmail.qq.com [43.155.65.254]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 724C3199B; Thu, 29 Jun 2023 17:06:15 -0700 (PDT) X-QQ-mid: bizesmtp71t1688083565twklsj26 Received: from linux-lab-host.localdomain ( [119.123.131.49]) by bizesmtp.qq.com (ESMTP) with id ; Fri, 30 Jun 2023 08:06:04 +0800 (CST) X-QQ-SSF: 01200000000000D0W000000A0000000 X-QQ-FEAT: RFp2QSjOiS7beTcSYXt1iawYE5VBFE+qfrFikOGIrZGU78FGQ//+XBNHlkTeb TF9bjq4tqANTGj/eXrmZuqrAjBtKHg7Qp+Y5VIjCUePqDup95utpa2bac+We01QQ5iHPhta /zN6i6ZKv9IPOPTajq6hPE+XEVU+Lc/QRz7szyfrDSQ+kksByTKk20N1o8F2uxrCJJgmE8O 5hVrAJvv3KqNUx9SLoQ8ngwmbNGFK5DTN0cZ+Pps0q5ox1rTJREprqRx/RBPItazmUbDH6I DiikY/83T+T6cmW/kAnmW8Lt1Q+wE8q+79BlUAdoStWwD1jLD+RDCQ49SpArKwT3WIn1hz4 1yCFJtTzqJcQzfMvymdKAYqjfJxUixP6hjv/1KgL7SqVmysltewh2BBbP4TtbvBUY+HKAA3 X-QQ-GoodBg: 0 X-BIZMAIL-ID: 527216731131771503 From: Zhangjin Wu To: thomas@t-8ch.de, w@1wt.eu Cc: falcon@tinylab.org, arnd@arndb.de, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Subject: [PATCH v2 15/15] selftests/nolibc: vfprintf: remove MEMFD_CREATE dependency Date: Fri, 30 Jun 2023 08:03:14 +0800 Message-Id: <2438cf7e4ecb2444a79f838437c149dd7d5bdde6.1688078605.git.falcon@tinylab.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:tinylab.org:qybglogicsvrgz:qybglogicsvrgz5a-1 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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?1770085023551817337?= X-GMAIL-MSGID: =?utf-8?q?1770085023551817337?= The vfprintf test case require to open a temporary file to write, the old memfd_create() method is perfect but has strong dependency on MEMFD_CREATE and also TMPFS or HUGETLBFS (see fs/Kconfig): config MEMFD_CREATE def_bool TMPFS || HUGETLBFS And from v6.2, MFD_NOEXEC_SEAL must be passed for the non-executable memfd, otherwise, The kernel warning will be output to the test result like this: Running test 'vfprintf' 0 emptymemfd_create() without MFD_EXEC nor MFD_NOEXEC_SEAL, pid=1 'init' "" = "" [OK] To avoid such warning and also to remove the MEMFD_CREATE dependency, let's open a file from tmpfs directly. The /tmp directory is used to detect the existing of tmpfs, if not there, skip instead of fail. And further, for pid == 1, the initramfs is loaded as ramfs, which can be used as tmpfs, so, it is able to further remove TMPFS dependency too. Suggested-by: Thomas Weißschuh Link: https://lore.kernel.org/lkml/9ad51430-b7c0-47dc-80af-20c86539498d@t-8ch.de Signed-off-by: Zhangjin Wu --- tools/testing/selftests/nolibc/nolibc-test.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c index 0ca7d011765a..0847813d756c 100644 --- a/tools/testing/selftests/nolibc/nolibc-test.c +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -888,10 +888,10 @@ static int expect_vfprintf(int llen, size_t c, const char *expected, const char FILE *memfile; va_list args; - fd = memfd_create("vfprintf", 0); + fd = open("/tmp", O_TMPFILE | O_EXCL | O_RDWR, 0600); if (fd == -1) { - pad_spc(llen, 64, "[FAIL]\n"); - return 1; + pad_spc(llen, 64, "[SKIPPED]\n"); + return 0; } memfile = fdopen(fd, "w+");