1f08c3bdfSopenharmony_ci// SPDX-License-Identifier: GPL-2.0
2f08c3bdfSopenharmony_ci/*
3f08c3bdfSopenharmony_ci * Copyright (c) Wipro Technologies Ltd, 2003.  All Rights Reserved.
4f08c3bdfSopenharmony_ci *
5f08c3bdfSopenharmony_ci * Author: Aniruddha Marathe <aniruddha.marathe@wipro.com>
6f08c3bdfSopenharmony_ci *
7f08c3bdfSopenharmony_ci * Ported to new library:
8f08c3bdfSopenharmony_ci * 07/2019      Christian Amann <camann@suse.com>
9f08c3bdfSopenharmony_ci */
10f08c3bdfSopenharmony_ci/*
11f08c3bdfSopenharmony_ci * Basic error handling test for timer_delete(2):
12f08c3bdfSopenharmony_ci *
13f08c3bdfSopenharmony_ci *	This test case checks whether timer_delete(2) returns an appropriate
14f08c3bdfSopenharmony_ci *	error (EINVAL) for an invalid timerid parameter
15f08c3bdfSopenharmony_ci */
16f08c3bdfSopenharmony_ci
17f08c3bdfSopenharmony_ci#include <errno.h>
18f08c3bdfSopenharmony_ci#include <time.h>
19f08c3bdfSopenharmony_ci#include "tst_test.h"
20f08c3bdfSopenharmony_ci#include "lapi/common_timers.h"
21f08c3bdfSopenharmony_ci
22f08c3bdfSopenharmony_ci#define INVALID_ID ((kernel_timer_t)-1)
23f08c3bdfSopenharmony_ci
24f08c3bdfSopenharmony_cistatic void run(void)
25f08c3bdfSopenharmony_ci{
26f08c3bdfSopenharmony_ci	TEST(tst_syscall(__NR_timer_delete, INVALID_ID));
27f08c3bdfSopenharmony_ci
28f08c3bdfSopenharmony_ci	if (TST_RET == -1 && TST_ERR == EINVAL) {
29f08c3bdfSopenharmony_ci		tst_res(TPASS | TTERRNO,
30f08c3bdfSopenharmony_ci			 "Failed as expected");
31f08c3bdfSopenharmony_ci	} else {
32f08c3bdfSopenharmony_ci		tst_res(TFAIL | TTERRNO,
33f08c3bdfSopenharmony_ci			 "Didn't fail with EINVAL as expected - got");
34f08c3bdfSopenharmony_ci	}
35f08c3bdfSopenharmony_ci}
36f08c3bdfSopenharmony_ci
37f08c3bdfSopenharmony_cistatic struct tst_test test = {
38f08c3bdfSopenharmony_ci	.test_all = run,
39f08c3bdfSopenharmony_ci};
40