1f08c3bdfSopenharmony_ci// SPDX-License-Identifier: GPL-2.0-or-later
2f08c3bdfSopenharmony_ci/*
3f08c3bdfSopenharmony_ci * Copyright (c) 2014 Fujitsu Ltd.
4f08c3bdfSopenharmony_ci *   Author: Zeng Linggang <zenglg.jy@cn.fujitsu.com>
5f08c3bdfSopenharmony_ci * Copyright (C) 2023 SUSE LLC Andrea Cervesato <andrea.cervesato@suse.com>
6f08c3bdfSopenharmony_ci */
7f08c3bdfSopenharmony_ci
8f08c3bdfSopenharmony_ci/*\
9f08c3bdfSopenharmony_ci * [Description]
10f08c3bdfSopenharmony_ci *
11f08c3bdfSopenharmony_ci * This test verifies that mq_notify() fails with EINVAL when invalid input
12f08c3bdfSopenharmony_ci * arguments are given.
13f08c3bdfSopenharmony_ci */
14f08c3bdfSopenharmony_ci
15f08c3bdfSopenharmony_ci#include <mqueue.h>
16f08c3bdfSopenharmony_ci#include "tst_test.h"
17f08c3bdfSopenharmony_ci
18f08c3bdfSopenharmony_cistatic struct test_case_t {
19f08c3bdfSopenharmony_ci	struct sigevent sevp;
20f08c3bdfSopenharmony_ci	int exp_errno;
21f08c3bdfSopenharmony_ci} tcase[] = {
22f08c3bdfSopenharmony_ci	{{.sigev_notify = -1}, EINVAL},
23f08c3bdfSopenharmony_ci	{{.sigev_notify = SIGEV_SIGNAL, .sigev_signo = _NSIG + 1}, EINVAL},
24f08c3bdfSopenharmony_ci};
25f08c3bdfSopenharmony_ci
26f08c3bdfSopenharmony_cistatic void run(unsigned int i)
27f08c3bdfSopenharmony_ci{
28f08c3bdfSopenharmony_ci	struct test_case_t *test = &tcase[i];
29f08c3bdfSopenharmony_ci
30f08c3bdfSopenharmony_ci	TST_EXP_FAIL(mq_notify(0, &(test->sevp)), test->exp_errno);
31f08c3bdfSopenharmony_ci}
32f08c3bdfSopenharmony_ci
33f08c3bdfSopenharmony_cistatic struct tst_test test = {
34f08c3bdfSopenharmony_ci	.tcnt = ARRAY_SIZE(tcase),
35f08c3bdfSopenharmony_ci	.test = run,
36f08c3bdfSopenharmony_ci};
37