All of lore.kernel.org
 help / color / mirror / Atom feed
From: Zhangjin Wu <falcon@tinylab.org>
To: thomas@t-8ch.de
Cc: arnd@arndb.de, falcon@tinylab.org, linux-kernel@vger.kernel.org,
	linux-kselftest@vger.kernel.org, linux-riscv@lists.infradead.org,
	w@1wt.eu
Subject: Re: [PATCH 1/2] selftests/nolibc: add new gettimeofday test cases
Date: Tue, 30 May 2023 19:28:06 +0800	[thread overview]
Message-ID: <20230530112806.404017-1-falcon@tinylab.org> (raw)
In-Reply-To: <96f1134d-ce6e-4d82-ae00-1cd4038809c4@t-8ch.de>

> 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;

WARNING: multiple messages have this Message-ID (diff)
From: Zhangjin Wu <falcon@tinylab.org>
To: thomas@t-8ch.de
Cc: arnd@arndb.de, falcon@tinylab.org, linux-kernel@vger.kernel.org,
	linux-kselftest@vger.kernel.org, linux-riscv@lists.infradead.org,
	w@1wt.eu
Subject: Re: [PATCH 1/2] selftests/nolibc: add new gettimeofday test cases
Date: Tue, 30 May 2023 19:28:06 +0800	[thread overview]
Message-ID: <20230530112806.404017-1-falcon@tinylab.org> (raw)
In-Reply-To: <96f1134d-ce6e-4d82-ae00-1cd4038809c4@t-8ch.de>

> 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;

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

  reply	other threads:[~2023-05-30 11:28 UTC|newest]

Thread overview: 68+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-29 19:45 [PATCH v2 00/13] nolibc: add part2 of support for rv32 Zhangjin Wu
2023-05-29 19:45 ` Zhangjin Wu
2023-05-29 19:46 ` [PATCH v2 01/13] selftests/nolibc: remove gettimeofday_bad1/2 completely Zhangjin Wu
2023-05-29 19:46   ` Zhangjin Wu
2023-05-29 19:47 ` [PATCH v2 02/13] selftests/nolibc: support two errnos with EXPECT_SYSER2() Zhangjin Wu
2023-05-29 19:47   ` Zhangjin Wu
2023-05-29 19:49 ` [PATCH v2 03/13] selftests/nolibc: waitpid_min: add waitid syscall support Zhangjin Wu
2023-05-29 19:49   ` Zhangjin Wu
2023-05-29 19:50 ` [PATCH v2 04/13] tools/nolibc: add missing nanoseconds support for __NR_statx Zhangjin Wu
2023-05-29 19:50   ` Zhangjin Wu
2023-05-29 21:39   ` Thomas Weißschuh
2023-05-29 21:39     ` Thomas Weißschuh
2023-05-30  5:21     ` Zhangjin Wu
2023-05-30  5:21       ` Zhangjin Wu
2023-05-29 19:51 ` [PATCH v2 05/13] tools/nolibc: add more wait status related types Zhangjin Wu
2023-05-29 19:51   ` Zhangjin Wu
2023-05-29 19:53 ` [PATCH v2 06/13] tools/nolibc: add pure 64bit off_t, time_t and blkcnt_t Zhangjin Wu
2023-05-29 19:53   ` Zhangjin Wu
2023-05-29 19:54 ` [PATCH v2 07/13] tools/nolibc: sys_lseek: add pure 64bit lseek Zhangjin Wu
2023-05-29 19:54   ` Zhangjin Wu
2023-05-30  8:10   ` Arnd Bergmann
2023-05-30  8:10     ` Arnd Bergmann
2023-05-30 13:54     ` Zhangjin Wu
2023-05-30 13:54       ` Zhangjin Wu
2023-07-02 16:28       ` Willy Tarreau
2023-07-02 16:28         ` Willy Tarreau
2023-05-29 19:56 ` [PATCH v2 08/13] tools/nolibc: add pure 64bit time structs Zhangjin Wu
2023-05-29 19:56   ` Zhangjin Wu
2023-05-29 19:57 ` [PATCH v2 09/13] tools/nolibc: sys_select: add pure 64bit select Zhangjin Wu
2023-05-29 19:57   ` Zhangjin Wu
2023-05-29 19:58 ` [PATCH v2 10/13] tools/nolibc: sys_poll: add pure 64bit poll Zhangjin Wu
2023-05-29 19:58   ` Zhangjin Wu
2023-05-29 19:59 ` [PATCH v2 11/13] tools/nolibc: sys_gettimeofday: add pure 64bit gettimeofday Zhangjin Wu
2023-05-29 19:59   ` Zhangjin Wu
2023-05-29 20:01 ` [PATCH v2 12/13] tools/nolibc: sys_wait4: add waitid syscall support Zhangjin Wu
2023-05-29 20:01   ` Zhangjin Wu
2023-05-29 20:03 ` [PATCH v2 13/13] selftests/nolibc: riscv: customize makefile for rv32 Zhangjin Wu
2023-05-29 20:03   ` Zhangjin Wu
2023-06-02  4:06   ` Zhangjin Wu
2023-06-02  4:06     ` Zhangjin Wu
2023-06-02 10:33     ` Thomas Weißschuh
2023-06-02 10:33       ` Thomas Weißschuh
2023-06-02 11:56       ` Zhangjin Wu
2023-06-02 11:56         ` Zhangjin Wu
2023-05-30  6:33 ` [PATCH v2 0/2] nolibc: add part3 of support " Zhangjin Wu
2023-05-30  6:33   ` Zhangjin Wu
2023-05-30  6:37   ` [PATCH 1/2] selftests/nolibc: add new gettimeofday test cases Zhangjin Wu
2023-05-30  6:37     ` Zhangjin Wu
2023-05-30 10:59     ` Thomas Weißschuh
2023-05-30 10:59       ` Thomas Weißschuh
2023-05-30 11:28       ` Zhangjin Wu [this message]
2023-05-30 11:28         ` Zhangjin Wu
2023-05-30 11:54         ` Thomas Weißschuh
2023-05-30 11:54           ` Thomas Weißschuh
2023-05-30 12:05       ` Willy Tarreau
2023-05-30 12:05         ` Willy Tarreau
2023-05-30 12:31         ` Andreas Schwab
2023-05-30 12:31           ` Andreas Schwab
2023-05-30 12:35         ` Thomas Weißschuh
2023-05-30 12:35           ` Thomas Weißschuh
2023-05-30  6:42   ` [PATCH 2/2] selftests/nolibc: add sizeof test for the new 64bit data types Zhangjin Wu
2023-05-30  6:42     ` Zhangjin Wu
2023-05-30  9:18     ` Thomas Weißschuh
2023-05-30  9:18       ` Thomas Weißschuh
2023-05-30 11:17       ` Zhangjin Wu
2023-05-30 11:17         ` Zhangjin Wu
2023-06-02 19:44 ` [PATCH v2 00/13] nolibc: add part2 of support for rv32 Willy Tarreau
2023-06-02 19:44   ` Willy Tarreau

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230530112806.404017-1-falcon@tinylab.org \
    --to=falcon@tinylab.org \
    --cc=arnd@arndb.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=thomas@t-8ch.de \
    --cc=w@1wt.eu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.