From afbbf61504d4fbd924c4d25d4c1f086bbf2c91ac Mon Sep 17 00:00:00 2001 From: Edward Liaw Date: Fri, 13 Oct 2023 22:40:40 +0000 Subject: Merge tag '20230929' Update LTP to 20230929 release. Bug: 305297408 Test: N/A Signed-off-by: Edward Liaw (cherry picked from https://android-review.googlesource.com/q/commit:4750afbdd3e27b386491f9544f484abe6e38c9f6) [edliaw: remove submodules] Change-Id: I5d31e9e04a69ad8178cc8c1350aa20236d688a4a Merged-In: I5d31e9e04a69ad8178cc8c1350aa20236d688a4a --- testcases/kernel/syscalls/mq_notify/mq_notify02.c | 93 +++++------------------ 1 file changed, 19 insertions(+), 74 deletions(-) (limited to 'testcases/kernel/syscalls/mq_notify/mq_notify02.c') diff --git a/testcases/kernel/syscalls/mq_notify/mq_notify02.c b/testcases/kernel/syscalls/mq_notify/mq_notify02.c index 3109fe345..d979a4e9d 100644 --- a/testcases/kernel/syscalls/mq_notify/mq_notify02.c +++ b/testcases/kernel/syscalls/mq_notify/mq_notify02.c @@ -1,91 +1,36 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * Copyright (c) 2014 Fujitsu Ltd. - * Author: Zeng Linggang - * - * 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 + * Copyright (C) 2023 SUSE LLC Andrea Cervesato */ -/* - * 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 #include -#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, +}; -- cgit v1.2.3