diff options
author | Treehugger Robot <android-test-infra-autosubmit@system.gserviceaccount.com> | 2024-04-02 20:24:18 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2024-04-02 20:24:18 +0000 |
commit | cdb9cd95d819b7d394f63db8dd87804de5aa3e69 (patch) | |
tree | 21df5650189a18b6e92f11a618bac3deb1adf361 /testcases/kernel/syscalls/mq_notify/mq_notify02.c | |
parent | 26a125c969109073ae74a948b3d8e4035cda4f7c (diff) | |
parent | 74f79dc224f4a1e79829ddfa11fa9439bf561423 (diff) | |
download | ltp-android14-tests-dev.tar.gz |
Merge changes from topic "ltp-20230929-android14-tests" into android14-tests-devandroid14-tests-dev
* changes:
cgroup: Fix scanning V1 mount options
cgroup: Handle trailing new line in cgroup.controllers
compare_ltp_projects.py: Fix test sorting, adjust printing
madvise11: Allow test to skip if MADV_SOFT_OFFLINE is not supported
madvise11: Replace /etc/mtab with /proc/mounts
syscalls/process_madvise01: fix smaps scan and min_swap_avail
tst_clocks.c: Fix stack smashing on 32bit
tst_kvercmp: Handle larger kernel version numbers
getpgid01: On Android, pgid(1) is 0 instead of 1
pipe07: refactor exp_num_pipes
pipe07: close /proc/self/fd after counting fds
config.h: Compile with linux/ioprio.h to fix ioprio_set03
sched.h: Don't exclude clone_args_minimal when HAVE_STRUCT_CLONE_ARGS is set
ltp-version.h: Generate with genrule
mq_notify03: disable test because don't have mqueue
kvm: Disable kvm tests
make_parser.py: Handle as (gnu assembler) command in makefile
android_build_generator.py: Print more info when failing with compile target
LTP 20230929
Merge tag '20230929'
Diffstat (limited to 'testcases/kernel/syscalls/mq_notify/mq_notify02.c')
-rw-r--r-- | testcases/kernel/syscalls/mq_notify/mq_notify02.c | 93 |
1 files changed, 19 insertions, 74 deletions
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 <zenglg.jy@cn.fujitsu.com> - * - * 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 <zenglg.jy@cn.fujitsu.com> + * Copyright (C) 2023 SUSE LLC Andrea Cervesato <andrea.cervesato@suse.com> */ -/* - * 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, +}; |