All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] y2038: testsuite/smokey/y2038: Run tests on y2038 safe kernels only
@ 2021-08-27 10:02 Florian Bezdeka
  2021-08-27 12:57 ` Jan Kiszka
  0 siblings, 1 reply; 3+ messages in thread
From: Florian Bezdeka @ 2021-08-27 10:02 UTC (permalink / raw)
  To: xenomai

Especially 4.19 is not 2038 safe and 32 bit kernels do not have
CONFIG_64BIT_TIME set, which ends up in __kernel_timespec being defined
in a non y2038 safe way.

cobalt_get_timespec64 will copy the upper bytes of the sec field into
the nsec field, which is always zero.

Testing y2038 syscalls on a non y2038 safe kernel doesn't make sense,
hence limiting the test runs to kernels with 2038 support.

Signed-off-by: Florian Bezdeka <florian.bezdeka@siemens.com>
---
 testsuite/smokey/y2038/syscall-tests.c | 27 ++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/testsuite/smokey/y2038/syscall-tests.c b/testsuite/smokey/y2038/syscall-tests.c
index 8afedd7d1..c23a54f5d 100644
--- a/testsuite/smokey/y2038/syscall-tests.c
+++ b/testsuite/smokey/y2038/syscall-tests.c
@@ -11,6 +11,7 @@
  */
 #include <asm/xenomai/syscall.h>
 #include <smokey/smokey.h>
+#include <sys/utsname.h>
 #include <mqueue.h>
 
 smokey_test_plugin(y2038, SMOKEY_NOARGS, "Validate correct y2038 support");
@@ -989,10 +990,36 @@ static int test_sc_cobalt_event_wait64(void)
 	return 0;
 }
 
+static int check_kernel_version(void)
+{
+	int ret, major, minor;
+	struct utsname uts;
+
+	ret = smokey_check_errno(uname(&uts));
+	if (ret)
+		return ret;
+
+	ret = sscanf(uts.release, "%d.%d", &major, &minor);
+	if (!smokey_assert(ret == 2))
+		return -EINVAL;
+
+	/* We need a kernel with y2038 support, 5.4 onwards */
+	if (!(major > 5 || (major == 5 && minor >= 4))) {
+		smokey_note("y2038: skipped. (no y2038 safe kernel)");
+		return 1;
+	}
+
+	return 0;
+}
+
 static int run_y2038(struct smokey_test *t, int argc, char *const argv[])
 {
 	int ret;
 
+	ret = check_kernel_version();
+	if (ret)
+		return (ret < 0) ? ret : 0; /* skip if no y2038 safe kernel */
+
 	ret = test_sc_cobalt_sem_timedwait64();
 	if (ret)
 		return ret;
-- 
2.30.2



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] y2038: testsuite/smokey/y2038: Run tests on y2038 safe kernels only
  2021-08-27 10:02 [PATCH] y2038: testsuite/smokey/y2038: Run tests on y2038 safe kernels only Florian Bezdeka
@ 2021-08-27 12:57 ` Jan Kiszka
  2021-08-27 13:35   ` Bezdeka, Florian
  0 siblings, 1 reply; 3+ messages in thread
From: Jan Kiszka @ 2021-08-27 12:57 UTC (permalink / raw)
  To: Florian Bezdeka, xenomai

On 27.08.21 12:02, Florian Bezdeka wrote:
> Especially 4.19 is not 2038 safe and 32 bit kernels do not have
> CONFIG_64BIT_TIME set, which ends up in __kernel_timespec being defined
> in a non y2038 safe way.
> 
> cobalt_get_timespec64 will copy the upper bytes of the sec field into
> the nsec field, which is always zero.
> 
> Testing y2038 syscalls on a non y2038 safe kernel doesn't make sense,
> hence limiting the test runs to kernels with 2038 support.
> 
> Signed-off-by: Florian Bezdeka <florian.bezdeka@siemens.com>
> ---
>  testsuite/smokey/y2038/syscall-tests.c | 27 ++++++++++++++++++++++++++
>  1 file changed, 27 insertions(+)
> 
> diff --git a/testsuite/smokey/y2038/syscall-tests.c b/testsuite/smokey/y2038/syscall-tests.c
> index 8afedd7d1..c23a54f5d 100644
> --- a/testsuite/smokey/y2038/syscall-tests.c
> +++ b/testsuite/smokey/y2038/syscall-tests.c
> @@ -11,6 +11,7 @@
>   */
>  #include <asm/xenomai/syscall.h>
>  #include <smokey/smokey.h>
> +#include <sys/utsname.h>
>  #include <mqueue.h>
>  
>  smokey_test_plugin(y2038, SMOKEY_NOARGS, "Validate correct y2038 support");
> @@ -989,10 +990,36 @@ static int test_sc_cobalt_event_wait64(void)
>  	return 0;
>  }
>  
> +static int check_kernel_version(void)
> +{
> +	int ret, major, minor;
> +	struct utsname uts;
> +
> +	ret = smokey_check_errno(uname(&uts));
> +	if (ret)
> +		return ret;
> +
> +	ret = sscanf(uts.release, "%d.%d", &major, &minor);
> +	if (!smokey_assert(ret == 2))
> +		return -EINVAL;
> +
> +	/* We need a kernel with y2038 support, 5.4 onwards */
> +	if (!(major > 5 || (major == 5 && minor >= 4))) {
> +		smokey_note("y2038: skipped. (no y2038 safe kernel)");
> +		return 1;
> +	}
> +
> +	return 0;
> +}
> +
>  static int run_y2038(struct smokey_test *t, int argc, char *const argv[])
>  {
>  	int ret;
>  
> +	ret = check_kernel_version();
> +	if (ret)
> +		return (ret < 0) ? ret : 0; /* skip if no y2038 safe kernel */
> +
>  	ret = test_sc_cobalt_sem_timedwait64();
>  	if (ret)
>  		return ret;
> 

OK, will apply. But I'm also expected a patch that makes the test case
fail in cases of early shots. We only noticed this issue because you
read the logs of successful runs.

Jan

-- 
Siemens AG, T RDA IOT
Corporate Competence Center Embedded Linux


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] y2038: testsuite/smokey/y2038: Run tests on y2038 safe kernels only
  2021-08-27 12:57 ` Jan Kiszka
@ 2021-08-27 13:35   ` Bezdeka, Florian
  0 siblings, 0 replies; 3+ messages in thread
From: Bezdeka, Florian @ 2021-08-27 13:35 UTC (permalink / raw)
  To: xenomai, jan.kiszka

On Fri, 2021-08-27 at 14:57 +0200, Jan Kiszka wrote:
> On 27.08.21 12:02, Florian Bezdeka wrote:
> > Especially 4.19 is not 2038 safe and 32 bit kernels do not have
> > CONFIG_64BIT_TIME set, which ends up in __kernel_timespec being defined
> > in a non y2038 safe way.
> > 
> > cobalt_get_timespec64 will copy the upper bytes of the sec field into
> > the nsec field, which is always zero.
> > 
> > Testing y2038 syscalls on a non y2038 safe kernel doesn't make sense,
> > hence limiting the test runs to kernels with 2038 support.
> > 
> > Signed-off-by: Florian Bezdeka <florian.bezdeka@siemens.com>
> > ---
> >  testsuite/smokey/y2038/syscall-tests.c | 27 ++++++++++++++++++++++++++
> >  1 file changed, 27 insertions(+)
> > 
> > diff --git a/testsuite/smokey/y2038/syscall-tests.c b/testsuite/smokey/y2038/syscall-tests.c
> > index 8afedd7d1..c23a54f5d 100644
> > --- a/testsuite/smokey/y2038/syscall-tests.c
> > +++ b/testsuite/smokey/y2038/syscall-tests.c
> > @@ -11,6 +11,7 @@
> >   */
> >  #include <asm/xenomai/syscall.h>
> >  #include <smokey/smokey.h>
> > +#include <sys/utsname.h>
> >  #include <mqueue.h>
> >  
> >  smokey_test_plugin(y2038, SMOKEY_NOARGS, "Validate correct y2038 support");
> > @@ -989,10 +990,36 @@ static int test_sc_cobalt_event_wait64(void)
> >  	return 0;
> >  }
> >  
> > +static int check_kernel_version(void)
> > +{
> > +	int ret, major, minor;
> > +	struct utsname uts;
> > +
> > +	ret = smokey_check_errno(uname(&uts));
> > +	if (ret)
> > +		return ret;
> > +
> > +	ret = sscanf(uts.release, "%d.%d", &major, &minor);
> > +	if (!smokey_assert(ret == 2))
> > +		return -EINVAL;
> > +
> > +	/* We need a kernel with y2038 support, 5.4 onwards */
> > +	if (!(major > 5 || (major == 5 && minor >= 4))) {
> > +		smokey_note("y2038: skipped. (no y2038 safe kernel)");
> > +		return 1;
> > +	}
> > +
> > +	return 0;
> > +}
> > +
> >  static int run_y2038(struct smokey_test *t, int argc, char *const argv[])
> >  {
> >  	int ret;
> >  
> > +	ret = check_kernel_version();
> > +	if (ret)
> > +		return (ret < 0) ? ret : 0; /* skip if no y2038 safe kernel */
> > +
> >  	ret = test_sc_cobalt_sem_timedwait64();
> >  	if (ret)
> >  		return ret;
> > 
> 
> OK, will apply. But I'm also expected a patch that makes the test case
> fail in cases of early shots. We only noticed this issue because you
> read the logs of successful runs.

When we started we saw a lot of such warnings, especially on virtual
targets and decided not to fail the tests in such cases. Hopefully all
of such problems are now solved / completely understood, so we could
move forward and now fail if such a early shot happens.

We will take care of the "migration" from warning to error.

> 
> Jan
> 


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-08-27 13:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-27 10:02 [PATCH] y2038: testsuite/smokey/y2038: Run tests on y2038 safe kernels only Florian Bezdeka
2021-08-27 12:57 ` Jan Kiszka
2021-08-27 13:35   ` Bezdeka, Florian

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.