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 test for timer_delete(2) 12f08c3bdfSopenharmony_ci * 13f08c3bdfSopenharmony_ci * Creates a timer for each available clock and then tries 14f08c3bdfSopenharmony_ci * to delete them again. 15f08c3bdfSopenharmony_ci * 16f08c3bdfSopenharmony_ci * This is also regression test for commit: 17f08c3bdfSopenharmony_ci * f18ddc13af98 ("alarmtimer: Use EOPNOTSUPP instead of ENOTSUPP") 18f08c3bdfSopenharmony_ci */ 19f08c3bdfSopenharmony_ci 20f08c3bdfSopenharmony_ci#include <errno.h> 21f08c3bdfSopenharmony_ci#include <time.h> 22f08c3bdfSopenharmony_ci#include "tst_test.h" 23f08c3bdfSopenharmony_ci#include "lapi/common_timers.h" 24f08c3bdfSopenharmony_ci 25f08c3bdfSopenharmony_cistatic void run(void) 26f08c3bdfSopenharmony_ci{ 27f08c3bdfSopenharmony_ci unsigned int i; 28f08c3bdfSopenharmony_ci kernel_timer_t timer_id; 29f08c3bdfSopenharmony_ci 30f08c3bdfSopenharmony_ci for (i = 0; i < CLOCKS_DEFINED; ++i) { 31f08c3bdfSopenharmony_ci clock_t clock = clock_list[i]; 32f08c3bdfSopenharmony_ci 33f08c3bdfSopenharmony_ci tst_res(TINFO, "Testing %s", get_clock_str(clock)); 34f08c3bdfSopenharmony_ci 35f08c3bdfSopenharmony_ci TEST(tst_syscall(__NR_timer_create, clock, NULL, &timer_id)); 36f08c3bdfSopenharmony_ci if (TST_RET != 0) { 37f08c3bdfSopenharmony_ci if (possibly_unsupported(clock) && 38f08c3bdfSopenharmony_ci (TST_ERR == EINVAL || TST_ERR == ENOTSUP)) { 39f08c3bdfSopenharmony_ci tst_res(TCONF | TTERRNO, "%s unsupported", 40f08c3bdfSopenharmony_ci get_clock_str(clock)); 41f08c3bdfSopenharmony_ci } else { 42f08c3bdfSopenharmony_ci tst_res(TFAIL | TTERRNO, 43f08c3bdfSopenharmony_ci "Aborting test - timer_create(%s) failed", 44f08c3bdfSopenharmony_ci get_clock_str(clock)); 45f08c3bdfSopenharmony_ci } 46f08c3bdfSopenharmony_ci continue; 47f08c3bdfSopenharmony_ci } 48f08c3bdfSopenharmony_ci 49f08c3bdfSopenharmony_ci TEST(tst_syscall(__NR_timer_delete, timer_id)); 50f08c3bdfSopenharmony_ci if (TST_RET == 0) 51f08c3bdfSopenharmony_ci tst_res(TPASS, "Timer deleted successfully!"); 52f08c3bdfSopenharmony_ci else 53f08c3bdfSopenharmony_ci tst_res(TFAIL | TTERRNO, "Timer deletion failed!"); 54f08c3bdfSopenharmony_ci } 55f08c3bdfSopenharmony_ci} 56f08c3bdfSopenharmony_ci 57f08c3bdfSopenharmony_cistatic struct tst_test test = { 58f08c3bdfSopenharmony_ci .test_all = run, 59f08c3bdfSopenharmony_ci .needs_root = 1, 60f08c3bdfSopenharmony_ci .tags = (const struct tst_tag[]) { 61f08c3bdfSopenharmony_ci {"linux-git", "f18ddc13af98"}, 62f08c3bdfSopenharmony_ci {} 63f08c3bdfSopenharmony_ci } 64f08c3bdfSopenharmony_ci}; 65