Message ID | bfc3dba52300dcce03ae1c7c41f2bb8984cf459b.1685428087.git.falcon@tinylab.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp1979803vqr; Mon, 29 May 2023 23:46:17 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5l4u983iAGJo9Bk4MY4+/5/uiRQjuOUB1+DirL3dM3USm5dSIZIoHD/qanOz8Ps7Piyrtj X-Received: by 2002:a05:6a00:150f:b0:642:fbed:2808 with SMTP id q15-20020a056a00150f00b00642fbed2808mr1872434pfu.25.1685429177695; Mon, 29 May 2023 23:46:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685429177; cv=none; d=google.com; s=arc-20160816; b=wIbdl/WyrQ331UtnjehPcCLp0HvuoLVDi1pIWpi4Ffb/ZsqJP1dGEZWY2IwcevDI0K 9JLSyfU1j9P/fMbhAupJSiFPMk08lBVAq7gZ6OSImF45PktY1RLsV0zMDjhPK23EwsFw 8Eqdk2OdYCKpRP8mUJ6HCGt1wt1enY762erE3gF1cAn22vWr0NofD04ToHcT0mY27tIu K1pIOhqg0xu0Fkfk0gZ9I+Ng74/K6+zDrFS+fCWlzbx0WuGom+fw8xobfIKe4kQiJUbn GmucdyP9YWb7hmR1L8N4y+a3Nx5ZgXi+qf8DGQbFNRy7QFKGkTaAHEhrTSwJnFG7fw04 UOgg== 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=tktdQ5k9Gin7y4GTSVi9cniVN+DfIrYj55MM3GOlyaQ=; b=hbYLNz2Ee6AVFVP5msUVbQ7TUml2DTNi5dpbQgtxRGUHgqnknaSAhsTv0tZQrN50ze tmN7JLIrO0pr1BOdft2FGZ0DZLsZaD92Zyf7+DoSSpadcxV11fbfzJ3ZgONhdy94uZJZ FGYkRDxgAaywHY09NXK3/sFI01qorNLJdQSiaxX0iI4cROOmmmMOp4moYxAxmOXiAFlS 6b03WG6mTRrLEsnzkk31LmCO9O91TNPQQUI2q6KaIlCcbfG+W47MLbZDDHgjXMaX7Ihs WrCHYU+fr9uwOJsJ0xuQ7uqIKDZP89mJvrhWTDoc/FYkfbGdNSi1jhcH3oQhVYNIEX+H sYWA== 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 f127-20020a625185000000b0064cce871b49si1239274pfb.137.2023.05.29.23.46.03; Mon, 29 May 2023 23:46:17 -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 S230192AbjE3GiK (ORCPT <rfc822;andrewvogler123@gmail.com> + 99 others); Tue, 30 May 2023 02:38:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58962 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229934AbjE3GiH (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 30 May 2023 02:38:07 -0400 Received: from bg4.exmail.qq.com (bg4.exmail.qq.com [43.154.221.58]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 03B0292; Mon, 29 May 2023 23:38:05 -0700 (PDT) X-QQ-mid: bizesmtp79t1685428676txj83914 Received: from linux-lab-host.localdomain ( [119.123.130.226]) by bizesmtp.qq.com (ESMTP) with id ; Tue, 30 May 2023 14:37:55 +0800 (CST) X-QQ-SSF: 01200000000000D0V000000A0000000 X-QQ-FEAT: jXjag1m6xl6889Jpgjswy33PSiv3wgSWqoIFui+aUZWHp4mxjk63aUjgGRhFQ LMNAUVD9PsUqGVCwHm0hlN5+3sRmrdAVW2PozVMKCw9Db26XQE0Rh65aO20dBDmZGj3g4xj i0rY9p/BqHACni0/Ku/45kqRCIc8paxw41FdN7fY/4035HCnWNSJbxMVMhFOplBnbmzw8Uj 7H8k4Zi9eFlRPn45MvIkFwKtCXWWYCjKOBYpCJo6sBYqsqhYKgEE3ZMUhvXrDB4qltlfFcI eEYwBS++g4usHpxxiA4zwoqVlVzpjQpulO0AMmg4eRMb0Xyg9adG8t6O6FU1yxpRCC7RwvM WdoOxhFh2t5cqot1k+y9uv06H+ORfS64hQ0rQdFKcCI0nsoYxqCit5lHLyUIzyiFRTz6La0 X-QQ-GoodBg: 0 X-BIZMAIL-ID: 15317070203822882915 From: Zhangjin Wu <falcon@tinylab.org> To: w@1wt.eu Cc: falcon@tinylab.org, arnd@arndb.de, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-riscv@lists.infradead.org, thomas@t-8ch.de Subject: [PATCH 1/2] selftests/nolibc: add new gettimeofday test cases Date: Tue, 30 May 2023 14:37:49 +0800 Message-Id: <bfc3dba52300dcce03ae1c7c41f2bb8984cf459b.1685428087.git.falcon@tinylab.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <cover.1685428087.git.falcon@tinylab.org> References: <cover.1685428087.git.falcon@tinylab.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:tinylab.org:qybglogicsvrsz:qybglogicsvrsz3a-3 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1767300585313358774?= X-GMAIL-MSGID: =?utf-8?q?1767300585313358774?= |
Series |
nolibc: add part3 of support for rv32
|
|
Commit Message
Zhangjin Wu
May 30, 2023, 6:37 a.m. UTC
These 3 test cases are added to cover the normal using scenes of
gettimeofday().
They have been used to trigger and fix up such issue:
nolibc-test.c:(.text.gettimeofday+0x54): undefined reference to `__aeabi_ldivmod'
This issue happens while there is no "unsigned int" conversion in the
new clock_gettime / clock_gettime64 syscall path of gettimeofday():
tv->tv_usec = ts.tv_nsec / 1000;
Signed-off-by: Zhangjin Wu <falcon@tinylab.org>
---
tools/testing/selftests/nolibc/nolibc-test.c | 5 +++++
1 file changed, 5 insertions(+)
Comments
On 2023-05-30 14:37:49+0800, Zhangjin Wu wrote: > These 3 test cases are added to cover the normal using scenes of > gettimeofday(). > > They have been used to trigger and fix up such issue: > > nolibc-test.c:(.text.gettimeofday+0x54): undefined reference to `__aeabi_ldivmod' > > This issue happens while there is no "unsigned int" conversion in the > new clock_gettime / clock_gettime64 syscall path of gettimeofday(): > > tv->tv_usec = ts.tv_nsec / 1000; > > Signed-off-by: Zhangjin Wu <falcon@tinylab.org> > --- > tools/testing/selftests/nolibc/nolibc-test.c | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c > index 8ba8c2fc71a0..20d184da9a2b 100644 > --- a/tools/testing/selftests/nolibc/nolibc-test.c > +++ b/tools/testing/selftests/nolibc/nolibc-test.c > @@ -533,6 +533,8 @@ static int test_stat_timestamps(void) > */ > int run_syscall(int min, int max) > { > + struct timeval tv; > + struct timezone tz; > struct stat stat_buf; > int euid0; > int proc; > @@ -588,6 +590,9 @@ int run_syscall(int min, int max) > CASE_TEST(getdents64_root); EXPECT_SYSNE(1, test_getdents64("/"), -1); break; > CASE_TEST(getdents64_null); EXPECT_SYSER(1, test_getdents64("/dev/null"), -1, ENOTDIR); break; > CASE_TEST(gettimeofday_null); EXPECT_SYSZR(1, gettimeofday(NULL, NULL)); break; > + CASE_TEST(gettimeofday_tv); EXPECT_SYSZR(1, gettimeofday(&tv, NULL)); break; > + CASE_TEST(gettimeofday_tz); EXPECT_SYSZR(1, gettimeofday(NULL, &tz)); break; Calling gettimeofday(NULL, ...) will actually segfault on glibc. It works when calling through the VDSO, but not the logic in glibc itself, which is guess is allowed by POSIX. I propose to avoid doing it :-) Either we gate the existing test in #ifdef NOLIBC or we remove it. > + CASE_TEST(gettimeofday_tv_tz);EXPECT_SYSZR(1, gettimeofday(&tv, &tz)); break; > CASE_TEST(getpagesize); EXPECT_SYSZR(1, test_getpagesize()); break; > CASE_TEST(ioctl_tiocinq); EXPECT_SYSZR(1, ioctl(0, TIOCINQ, &tmp)); break; > CASE_TEST(ioctl_tiocinq); EXPECT_SYSZR(1, ioctl(0, TIOCINQ, &tmp)); break; > -- > 2.25.1 >
> On 2023-05-30 14:37:49+0800, Zhangjin Wu wrote: > > These 3 test cases are added to cover the normal using scenes of > > gettimeofday(). > > > > They have been used to trigger and fix up such issue: > > > > nolibc-test.c:(.text.gettimeofday+0x54): undefined reference to `__aeabi_ldivmod' > > > > This issue happens while there is no "unsigned int" conversion in the > > new clock_gettime / clock_gettime64 syscall path of gettimeofday(): > > > > tv->tv_usec = ts.tv_nsec / 1000; > > > > Signed-off-by: Zhangjin Wu <falcon@tinylab.org> > > --- > > tools/testing/selftests/nolibc/nolibc-test.c | 5 +++++ > > 1 file changed, 5 insertions(+) > > > > diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c > > index 8ba8c2fc71a0..20d184da9a2b 100644 > > --- a/tools/testing/selftests/nolibc/nolibc-test.c > > +++ b/tools/testing/selftests/nolibc/nolibc-test.c > > @@ -533,6 +533,8 @@ static int test_stat_timestamps(void) > > */ > > int run_syscall(int min, int max) > > { > > + struct timeval tv; > > + struct timezone tz; > > struct stat stat_buf; > > int euid0; > > int proc; > > @@ -588,6 +590,9 @@ int run_syscall(int min, int max) > > CASE_TEST(getdents64_root); EXPECT_SYSNE(1, test_getdents64("/"), -1); break; > > CASE_TEST(getdents64_null); EXPECT_SYSER(1, test_getdents64("/dev/null"), -1, ENOTDIR); break; > > CASE_TEST(gettimeofday_null); EXPECT_SYSZR(1, gettimeofday(NULL, NULL)); break; > > + CASE_TEST(gettimeofday_tv); EXPECT_SYSZR(1, gettimeofday(&tv, NULL)); break; > > + CASE_TEST(gettimeofday_tz); EXPECT_SYSZR(1, gettimeofday(NULL, &tz)); break; > > Calling gettimeofday(NULL, ...) will actually segfault on glibc. > It works when calling through the VDSO, but not the logic in glibc > itself, which is guess is allowed by POSIX. > In low level gettimeofday syscall, it should be ok, will check the non-vdso code of glibc later. in musl, it returns 0 when it is NULL (src/time/gettimeofday.c). > I propose to avoid doing it :-) Just checked it again, these two cases can also detect the issues (1): CASE_TEST(gettimeofday_tv); EXPECT_SYSZR(1, gettimeofday(&tv, NULL)); break; CASE_TEST(gettimeofday_tv_tz);EXPECT_SYSZR(1, gettimeofday(&tv, &tz)); break; (1) nolibc-test.c:(.text.gettimeofday+0x54): undefined reference to `__aeabi_ldivmod' we can directly remove the second one ;-) > > Either we gate the existing test in #ifdef NOLIBC or we remove it. so, we still need to check the original gettimeofday_null test case for glibc? Thanks, Zhangjin > > > + CASE_TEST(gettimeofday_tv_tz);EXPECT_SYSZR(1, gettimeofday(&tv, &tz)); break; > > CASE_TEST(getpagesize); EXPECT_SYSZR(1, test_getpagesize()); break; > > CASE_TEST(ioctl_tiocinq); EXPECT_SYSZR(1, ioctl(0, TIOCINQ, &tmp)); break; > > CASE_TEST(ioctl_tiocinq); EXPECT_SYSZR(1, ioctl(0, TIOCINQ, &tmp)); break;
On 2023-05-30 19:28:06+0800, Zhangjin Wu wrote: > > On 2023-05-30 14:37:49+0800, Zhangjin Wu wrote: > > > These 3 test cases are added to cover the normal using scenes of > > > gettimeofday(). > > > > > > They have been used to trigger and fix up such issue: > > > > > > nolibc-test.c:(.text.gettimeofday+0x54): undefined reference to `__aeabi_ldivmod' > > > > > > This issue happens while there is no "unsigned int" conversion in the > > > new clock_gettime / clock_gettime64 syscall path of gettimeofday(): > > > > > > tv->tv_usec = ts.tv_nsec / 1000; > > > > > > Signed-off-by: Zhangjin Wu <falcon@tinylab.org> > > > --- > > > tools/testing/selftests/nolibc/nolibc-test.c | 5 +++++ > > > 1 file changed, 5 insertions(+) > > > > > > diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c > > > index 8ba8c2fc71a0..20d184da9a2b 100644 > > > --- a/tools/testing/selftests/nolibc/nolibc-test.c > > > +++ b/tools/testing/selftests/nolibc/nolibc-test.c > > > @@ -533,6 +533,8 @@ static int test_stat_timestamps(void) > > > */ > > > int run_syscall(int min, int max) > > > { > > > + struct timeval tv; > > > + struct timezone tz; > > > struct stat stat_buf; > > > int euid0; > > > int proc; > > > @@ -588,6 +590,9 @@ int run_syscall(int min, int max) > > > CASE_TEST(getdents64_root); EXPECT_SYSNE(1, test_getdents64("/"), -1); break; > > > CASE_TEST(getdents64_null); EXPECT_SYSER(1, test_getdents64("/dev/null"), -1, ENOTDIR); break; > > > CASE_TEST(gettimeofday_null); EXPECT_SYSZR(1, gettimeofday(NULL, NULL)); break; > > > + CASE_TEST(gettimeofday_tv); EXPECT_SYSZR(1, gettimeofday(&tv, NULL)); break; > > > + CASE_TEST(gettimeofday_tz); EXPECT_SYSZR(1, gettimeofday(NULL, &tz)); break; > > > > Calling gettimeofday(NULL, ...) will actually segfault on glibc. > > It works when calling through the VDSO, but not the logic in glibc > > itself, which is guess is allowed by POSIX. > > > > In low level gettimeofday syscall, it should be ok, will check the non-vdso > code of glibc later. in musl, it returns 0 when it is NULL > (src/time/gettimeofday.c). It's fine for the Linux syscall, vdso, musl and nolibc. It's not fine for glibc and gnulib. > > I propose to avoid doing it :-) > > Just checked it again, these two cases can also detect the issues (1): > > CASE_TEST(gettimeofday_tv); EXPECT_SYSZR(1, gettimeofday(&tv, NULL)); break; > CASE_TEST(gettimeofday_tv_tz);EXPECT_SYSZR(1, gettimeofday(&tv, &tz)); break; > > (1) nolibc-test.c:(.text.gettimeofday+0x54): undefined reference to `__aeabi_ldivmod' To be honest this does not look like a nolibc issue, more a compiler setup problem. GCC generates calls to a function in libgcc that is not linked for some reason. Can you provide reproduction steps? Also I guess a testcase that tests at runtime that the compilation has worked is of limited use :-) It either works or it never executes. > we can directly remove the second one ;-) > > > > > Either we gate the existing test in #ifdef NOLIBC or we remove it. > > so, we still need to check the original gettimeofday_null test case for glibc? The original testcase also needs adaption, yes. > Thanks, > Zhangjin > > > > > > + CASE_TEST(gettimeofday_tv_tz);EXPECT_SYSZR(1, gettimeofday(&tv, &tz)); break; > > > CASE_TEST(getpagesize); EXPECT_SYSZR(1, test_getpagesize()); break; > > > CASE_TEST(ioctl_tiocinq); EXPECT_SYSZR(1, ioctl(0, TIOCINQ, &tmp)); break; > > > CASE_TEST(ioctl_tiocinq); EXPECT_SYSZR(1, ioctl(0, TIOCINQ, &tmp)); break;
On Tue, May 30, 2023 at 12:59:31PM +0200, Thomas Weißschuh wrote: > On 2023-05-30 14:37:49+0800, Zhangjin Wu wrote: > > These 3 test cases are added to cover the normal using scenes of > > gettimeofday(). > > > > They have been used to trigger and fix up such issue: > > > > nolibc-test.c:(.text.gettimeofday+0x54): undefined reference to `__aeabi_ldivmod' > > > > This issue happens while there is no "unsigned int" conversion in the > > new clock_gettime / clock_gettime64 syscall path of gettimeofday(): > > > > tv->tv_usec = ts.tv_nsec / 1000; > > > > Signed-off-by: Zhangjin Wu <falcon@tinylab.org> > > --- > > tools/testing/selftests/nolibc/nolibc-test.c | 5 +++++ > > 1 file changed, 5 insertions(+) > > > > diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c > > index 8ba8c2fc71a0..20d184da9a2b 100644 > > --- a/tools/testing/selftests/nolibc/nolibc-test.c > > +++ b/tools/testing/selftests/nolibc/nolibc-test.c > > @@ -533,6 +533,8 @@ static int test_stat_timestamps(void) > > */ > > int run_syscall(int min, int max) > > { > > + struct timeval tv; > > + struct timezone tz; > > struct stat stat_buf; > > int euid0; > > int proc; > > @@ -588,6 +590,9 @@ int run_syscall(int min, int max) > > CASE_TEST(getdents64_root); EXPECT_SYSNE(1, test_getdents64("/"), -1); break; > > CASE_TEST(getdents64_null); EXPECT_SYSER(1, test_getdents64("/dev/null"), -1, ENOTDIR); break; > > CASE_TEST(gettimeofday_null); EXPECT_SYSZR(1, gettimeofday(NULL, NULL)); break; > > + CASE_TEST(gettimeofday_tv); EXPECT_SYSZR(1, gettimeofday(&tv, NULL)); break; > > + CASE_TEST(gettimeofday_tz); EXPECT_SYSZR(1, gettimeofday(NULL, &tz)); break; > > Calling gettimeofday(NULL, ...) will actually segfault on glibc. > It works when calling through the VDSO, but not the logic in glibc > itself, which is guess is allowed by POSIX. Then that's shocking, because the man page says: If either tv or tz is NULL, the corresponding structure is not set or returned. (However, compilation warnings will result if tv is NULL.) I'd expect glibc to at least support what'd documented in the man page :-/ > I propose to avoid doing it :-) If you're certain that's the case, then I agree. > Either we gate the existing test in #ifdef NOLIBC or we remove it. Better not keep tests specific to nolibc if they aim at verifying some compatibliity. Willy
On Mai 30 2023, Willy Tarreau wrote: > On Tue, May 30, 2023 at 12:59:31PM +0200, Thomas Weißschuh wrote: >> On 2023-05-30 14:37:49+0800, Zhangjin Wu wrote: >> > These 3 test cases are added to cover the normal using scenes of >> > gettimeofday(). >> > >> > They have been used to trigger and fix up such issue: >> > >> > nolibc-test.c:(.text.gettimeofday+0x54): undefined reference to `__aeabi_ldivmod' >> > >> > This issue happens while there is no "unsigned int" conversion in the >> > new clock_gettime / clock_gettime64 syscall path of gettimeofday(): >> > >> > tv->tv_usec = ts.tv_nsec / 1000; >> > >> > Signed-off-by: Zhangjin Wu <falcon@tinylab.org> >> > --- >> > tools/testing/selftests/nolibc/nolibc-test.c | 5 +++++ >> > 1 file changed, 5 insertions(+) >> > >> > diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c >> > index 8ba8c2fc71a0..20d184da9a2b 100644 >> > --- a/tools/testing/selftests/nolibc/nolibc-test.c >> > +++ b/tools/testing/selftests/nolibc/nolibc-test.c >> > @@ -533,6 +533,8 @@ static int test_stat_timestamps(void) >> > */ >> > int run_syscall(int min, int max) >> > { >> > + struct timeval tv; >> > + struct timezone tz; >> > struct stat stat_buf; >> > int euid0; >> > int proc; >> > @@ -588,6 +590,9 @@ int run_syscall(int min, int max) >> > CASE_TEST(getdents64_root); EXPECT_SYSNE(1, test_getdents64("/"), -1); break; >> > CASE_TEST(getdents64_null); EXPECT_SYSER(1, test_getdents64("/dev/null"), -1, ENOTDIR); break; >> > CASE_TEST(gettimeofday_null); EXPECT_SYSZR(1, gettimeofday(NULL, NULL)); break; >> > + CASE_TEST(gettimeofday_tv); EXPECT_SYSZR(1, gettimeofday(&tv, NULL)); break; >> > + CASE_TEST(gettimeofday_tz); EXPECT_SYSZR(1, gettimeofday(NULL, &tz)); break; >> >> Calling gettimeofday(NULL, ...) will actually segfault on glibc. >> It works when calling through the VDSO, but not the logic in glibc >> itself, which is guess is allowed by POSIX. > > Then that's shocking, because the man page says: > > If either tv or tz is NULL, the corresponding structure is not set or > returned. (However, compilation warnings will result if tv is NULL.) > > I'd expect glibc to at least support what'd documented in the man > page :-/ The manual page is not part of glibc. Neither the glibc documentation nor the POSIX spec has ever supported NULL for the first argument. The generic POSIX implementation in glibc originally returned EINVAL for that case, though.
On 2023-05-30 14:05:00+0200, Willy Tarreau wrote: > On Tue, May 30, 2023 at 12:59:31PM +0200, Thomas Weißschuh wrote: > > On 2023-05-30 14:37:49+0800, Zhangjin Wu wrote: > > > These 3 test cases are added to cover the normal using scenes of > > > gettimeofday(). > > > > > > They have been used to trigger and fix up such issue: > > > > > > nolibc-test.c:(.text.gettimeofday+0x54): undefined reference to `__aeabi_ldivmod' > > > > > > This issue happens while there is no "unsigned int" conversion in the > > > new clock_gettime / clock_gettime64 syscall path of gettimeofday(): > > > > > > tv->tv_usec = ts.tv_nsec / 1000; > > > > > > Signed-off-by: Zhangjin Wu <falcon@tinylab.org> > > > --- > > > tools/testing/selftests/nolibc/nolibc-test.c | 5 +++++ > > > 1 file changed, 5 insertions(+) > > > > > > diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c > > > index 8ba8c2fc71a0..20d184da9a2b 100644 > > > --- a/tools/testing/selftests/nolibc/nolibc-test.c > > > +++ b/tools/testing/selftests/nolibc/nolibc-test.c > > > @@ -533,6 +533,8 @@ static int test_stat_timestamps(void) > > > */ > > > int run_syscall(int min, int max) > > > { > > > + struct timeval tv; > > > + struct timezone tz; > > > struct stat stat_buf; > > > int euid0; > > > int proc; > > > @@ -588,6 +590,9 @@ int run_syscall(int min, int max) > > > CASE_TEST(getdents64_root); EXPECT_SYSNE(1, test_getdents64("/"), -1); break; > > > CASE_TEST(getdents64_null); EXPECT_SYSER(1, test_getdents64("/dev/null"), -1, ENOTDIR); break; > > > CASE_TEST(gettimeofday_null); EXPECT_SYSZR(1, gettimeofday(NULL, NULL)); break; > > > + CASE_TEST(gettimeofday_tv); EXPECT_SYSZR(1, gettimeofday(&tv, NULL)); break; > > > + CASE_TEST(gettimeofday_tz); EXPECT_SYSZR(1, gettimeofday(NULL, &tz)); break; > > > > Calling gettimeofday(NULL, ...) will actually segfault on glibc. > > It works when calling through the VDSO, but not the logic in glibc > > itself, which is guess is allowed by POSIX. > > Then that's shocking, because the man page says: > > If either tv or tz is NULL, the corresponding structure is not set or > returned. (However, compilation warnings will result if tv is NULL.) > > I'd expect glibc to at least support what'd documented in the man > page :-/ That is gettimeofday(2), which comes from the Linux man-pages project. gettimeofday(3p) which specifies the posix function does not have that wording. It also specifies that there is no way to indicate errors... Seems to be a weird situation. > > I propose to avoid doing it :-) > > If you're certain that's the case, then I agree. > > > Either we gate the existing test in #ifdef NOLIBC or we remove it. > > Better not keep tests specific to nolibc if they aim at verifying some > compatibliity. Thomas
diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c index 8ba8c2fc71a0..20d184da9a2b 100644 --- a/tools/testing/selftests/nolibc/nolibc-test.c +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -533,6 +533,8 @@ static int test_stat_timestamps(void) */ int run_syscall(int min, int max) { + struct timeval tv; + struct timezone tz; struct stat stat_buf; int euid0; int proc; @@ -588,6 +590,9 @@ int run_syscall(int min, int max) CASE_TEST(getdents64_root); EXPECT_SYSNE(1, test_getdents64("/"), -1); break; CASE_TEST(getdents64_null); EXPECT_SYSER(1, test_getdents64("/dev/null"), -1, ENOTDIR); break; CASE_TEST(gettimeofday_null); EXPECT_SYSZR(1, gettimeofday(NULL, NULL)); break; + CASE_TEST(gettimeofday_tv); EXPECT_SYSZR(1, gettimeofday(&tv, NULL)); break; + CASE_TEST(gettimeofday_tz); EXPECT_SYSZR(1, gettimeofday(NULL, &tz)); break; + CASE_TEST(gettimeofday_tv_tz);EXPECT_SYSZR(1, gettimeofday(&tv, &tz)); break; CASE_TEST(getpagesize); EXPECT_SYSZR(1, test_getpagesize()); break; CASE_TEST(ioctl_tiocinq); EXPECT_SYSZR(1, ioctl(0, TIOCINQ, &tmp)); break; CASE_TEST(ioctl_tiocinq); EXPECT_SYSZR(1, ioctl(0, TIOCINQ, &tmp)); break;