Refactor mq_notify02 using new LTP API
PATCH 1/1 Refactor mq_notify02 using new LTP API
From: Andrea Cervesato <[email protected]>
Signed-off-by Andrea Cervesato <[email protected]>
--- .../kernel/syscalls/mq_notify/mq_notify02.c | 93 ++++--------------- 1 file changed, 19 insertions(+), 74 deletions(-)
testcases/kernel/syscalls/mq_notify/mq_notify02.c +19 -74
@@ -1,91 +1,36 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * Copyright (c) 2014 Fujitsu Ltd. -* Author: Zeng Linggang <[email protected]> -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of version 2 of the GNU General Public License as -* published by the Free Software Foundation. -* -* This program is distributed in the hope that it would be useful, but -* WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -* -* You should have received a copy of the GNU General Public License along -* with this program. +* Author: Zeng Linggang <[email protected]> +* Copyright (C) 2023 SUSE LLC Andrea Cervesato <[email protected]> */ -/* -* ALGORITHM -* test 1: -* sevp->sigev_notify = -1, EINVAL should be returned. -* test 2: -* sevp->sigev_notify = SIGEV_SIGNAL and sevp->sigev_signo > _NSG, -* EINVAL should be returned. + +/*\ +* [Description] +* +* This test verifies that mq_notify() fails with EINVAL when invalid input +* arguments are given. */ -#include <errno.h> #include <mqueue.h> -#include "test.h" - -char *TCID ="mq_notify02" ; -static void setup (void ); -static void cleanup (void ); +#include "tst_test.h" static struct test_case_t {struct sigevent sevp;int exp_errno; -} test_cases[] = { +} tcase[] = { {{.sigev_notify =-1 },EINVAL }, - {{.sigev_notify =SIGEV_SIGNAL , .sigev_signo = _NSIG+1 },EINVAL }, + {{.sigev_notify =SIGEV_SIGNAL , .sigev_signo = _NSIG +1 },EINVAL }, }; -int TST_TOTAL =ARRAY_SIZE (test_cases); -static void mq_notify_verify (struct test_case_t *); - -int main (int argc,char **argv) -{ -int lc; -int i; - -tst_parse_opts (argc, argv,NULL ,NULL ); - -setup (); - -for (lc =0 ;TEST_LOOPING (lc); lc++) { - tst_count =0 ; -for (i =0 ; i <TST_TOTAL ; i++) -mq_notify_verify (&test_cases[i]); - } -cleanup (); -tst_exit (); -} - -static void setup (void ) +static void run (unsigned int i) { -tst_sig (NOFORK ,DEF_HANDLER , cleanup); +struct test_case_t *test = &tcase[i]; -TEST_PAUSE ; +TST_EXP_FAIL (mq_notify (0 , &(test->sevp)), test->exp_errno); } -static void mq_notify_verify (struct test_case_t *test) -{ -TEST (mq_notify (0 , &(test->sevp))); - -if (TEST_RETURN !=-1 ) { -tst_resm (TFAIL ,"mq_notify() succeeded unexpectedly" ); -return ; - } - -if (TEST_ERRNO == test->exp_errno) { -tst_resm (TPASS |TTERRNO ,"mq_notify failed as expected" ); - }else if (TEST_ERRNO ==ENOSYS ) { -tst_resm (TCONF |TTERRNO ,"mq_notify not available" ); - }else { -tst_resm (TFAIL |TTERRNO , -"mq_notify failed unexpectedly; expected: %d - %s" , - test->exp_errno,strerror (test->exp_errno)); - } -} - -static void cleanup (void ) -{ -} +static struct tst_test test = { + .tcnt =ARRAY_SIZE (tcase), + .test = run, +};
Signature · 5 lines
2.35.3 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Hi!
Pushed, thanks.
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp