All of lore.kernel.org
 help / color / mirror / Atom feed
From: Richard Palethorpe <rpalethorpe@suse.de>
To: Andrea Cervesato <andrea.cervesato@suse.de>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH v2] Refactor timer_getoverrun test using new LTP API
Date: Mon, 02 Oct 2023 11:43:33 +0100	[thread overview]
Message-ID: <878r8l2th7.fsf@suse.de> (raw)
In-Reply-To: <20230904111940.26824-1-andrea.cervesato@suse.de>

Hello,

Test looks fine apart from the issues I have with any test which fails
if a different error number is returned. I already started that
discussion here:

https://patchwork.ozlabs.org/project/ltp/patch/20230901144433.2526-1-chrubis@suse.cz/#3191079

Andrea Cervesato <andrea.cervesato@suse.de> writes:

> From: Andrea Cervesato <andrea.cervesato@suse.com>
>
> Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.com>
> ---
> Added glibc variant
>
>  .../kernel/syscalls/timer_getoverrun/Makefile |   2 +
>  .../timer_getoverrun/timer_getoverrun01.c     | 117 ++++++------------
>  2 files changed, 43 insertions(+), 76 deletions(-)
>
> diff --git a/testcases/kernel/syscalls/timer_getoverrun/Makefile b/testcases/kernel/syscalls/timer_getoverrun/Makefile
> index 1273a4e9c..58376e379 100644
> --- a/testcases/kernel/syscalls/timer_getoverrun/Makefile
> +++ b/testcases/kernel/syscalls/timer_getoverrun/Makefile
> @@ -5,4 +5,6 @@ top_srcdir		?= ../../../..
>  
>  include $(top_srcdir)/include/mk/testcases.mk
>  
> +LDLIBS			:= -lrt $(LDLIBS)
> +
>  include $(top_srcdir)/include/mk/generic_leaf_target.mk
> diff --git a/testcases/kernel/syscalls/timer_getoverrun/timer_getoverrun01.c b/testcases/kernel/syscalls/timer_getoverrun/timer_getoverrun01.c
> index aa9881f27..28cba8214 100644
> --- a/testcases/kernel/syscalls/timer_getoverrun/timer_getoverrun01.c
> +++ b/testcases/kernel/syscalls/timer_getoverrun/timer_getoverrun01.c
> @@ -1,88 +1,53 @@
> -/******************************************************************************
> - * Copyright (c) Crackerjack Project., 2007                                   *
> - * Porting from Crackerjack to LTP is done by:                                *
> - *              Manas Kumar Nayak <maknayak@in.ibm.com>                       *
> - * Copyright (c) 2013 Cyril Hrubis <chrubis@suse.cz>                          *
> - *                                                                            *
> - * This program is free software;  you can redistribute it and/or modify      *
> - * it under the terms of the GNU General Public License as published by       *
> - * the Free Software Foundation; either version 2 of the License, or          *
> - * (at your option) any later version.                                        *
> - *                                                                            *
> - * This program is distributed in the hope that it will be useful,            *
> - * but WITHOUT ANY WARRANTY;  without even the implied warranty of            *
> - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See                  *
> - * the GNU General Public License for more details.                           *
> - *                                                                            *
> - * You should have received a copy of the GNU General Public License          *
> - * along with this program;  if not, write to the Free Software Foundation,   *
> - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA           *
> - *                                                                            *
> - ******************************************************************************/
> +// SPDX-License-Identifier: GPL-2.0-or-later
> +/*
> + * Copyright (c) International Business Machines Corp., 2001
> + * Porting from Crackerjack to LTP is done by:
> + *              Manas Kumar Nayak <maknayak@in.ibm.com>
> + *
> + * Copyright (c) Linux Test Project, 2009-2023
> + * Copyright (c) 2013 Cyril Hrubis <chrubis@suse.cz>
> + * Copyright (C) 2023 SUSE LLC Andrea Cervesato <andrea.cervesato@suse.com>
> + */
> +
> +/*\
> + * [Description]
> + *
> + * This test checks base timer_getoverrun() functionality.
> + */
>  
> -#include <stdio.h>
> -#include <errno.h>
> -#include <time.h>
>  #include <signal.h>
> -#include <sys/syscall.h>
> -
> -#include "test.h"
> +#include "tst_test.h"
> +#include "tst_safe_clocks.h"
>  #include "lapi/syscalls.h"
>  
> -char *TCID = "timer_getoverrun01";
> -int TST_TOTAL = 1;
> -
> -static void cleanup(void)
> -{
> -
> -	tst_rmdir();
> -}
> -
> -static void setup(void)
> -{
> -	TEST_PAUSE;
> -	tst_tmpdir();
> -}
> -
> -int main(int ac, char **av)
> +static void run(void)
>  {
> -	int lc;
> -	int timer;
> +	timer_t timer;
>  	struct sigevent ev;
>  
> -	tst_parse_opts(ac, av, NULL, NULL);
> -
> -	setup();
> -
>  	ev.sigev_value = (union sigval) 0;
> -	ev.sigev_signo = SIGALRM;
>  	ev.sigev_notify = SIGEV_SIGNAL;
> -	TEST(tst_syscall(__NR_timer_create, CLOCK_REALTIME, &ev, &timer));
> -
> -	if (TEST_RETURN != 0)
> -		tst_brkm(TBROK | TTERRNO, cleanup, "Failed to create timer");
> -
> -	for (lc = 0; TEST_LOOPING(lc); ++lc) {
> -		tst_count = 0;
> -
> -		TEST(tst_syscall(__NR_timer_getoverrun, timer));
> -		if (TEST_RETURN == 0) {
> -			tst_resm(TPASS,
> -			         "timer_getoverrun(CLOCK_REALTIME) Passed");
> -		} else {
> -			tst_resm(TFAIL | TTERRNO,
> -			         "timer_getoverrun(CLOCK_REALTIME) Failed");
> -		}
> +	ev.sigev_signo = SIGALRM;
>  
> -		TEST(tst_syscall(__NR_timer_getoverrun, -1));
> -		if (TEST_RETURN == -1 && TEST_ERRNO == EINVAL) {
> -			tst_resm(TPASS,	"timer_gettime(-1) Failed: EINVAL");
> -		} else {
> -			tst_resm(TFAIL | TTERRNO,
> -			         "timer_gettime(-1) = %li", TEST_RETURN);
> -		}
> +	switch (tst_variant) {
> +	case 0:
> +		SAFE_TIMER_CREATE(CLOCK_REALTIME, &ev, &timer);
> +		TST_EXP_POSITIVE(timer_getoverrun(timer));
> +
> +		/* glibc causes SIGSEGV where timer_getoverrun() fails with EINVAL */
> +#ifndef __GLIBC__
> +		TST_EXP_FAIL(timer_getoverrun((timer_t)-1), EINVAL);
> +#endif
> +		break;
> +	case 1:
> +		tst_syscall(__NR_timer_create, CLOCK_REALTIME, &ev, &timer);
> +		TST_EXP_POSITIVE(tst_syscall(__NR_timer_getoverrun, timer));
> +		TST_EXP_FAIL(tst_syscall(__NR_timer_getoverrun, -1), EINVAL);
> +		break;
>  	}
> -
> -	cleanup();
> -	tst_exit();
>  }
> +
> +static struct tst_test test = {
> +	.test_all = run,
> +	.test_variants = 2,
> +};
> -- 
> 2.35.3


-- 
Thank you,
Richard.

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

  reply	other threads:[~2023-10-02 10:45 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-04 11:19 [LTP] [PATCH v2] Refactor timer_getoverrun test using new LTP API Andrea Cervesato
2023-10-02 10:43 ` Richard Palethorpe [this message]
2023-10-30 13:34   ` Cyril Hrubis
2023-10-30 13:56 ` Cyril Hrubis
2023-11-16 15:13   ` Andrea Cervesato via ltp

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=878r8l2th7.fsf@suse.de \
    --to=rpalethorpe@suse.de \
    --cc=andrea.cervesato@suse.de \
    --cc=ltp@lists.linux.it \
    /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.