1f08c3bdfSopenharmony_ci// SPDX-License-Identifier: GPL-2.0-or-later 2f08c3bdfSopenharmony_ci/* 3f08c3bdfSopenharmony_ci * Copyright (c) 2014 Fujitsu Ltd. 4f08c3bdfSopenharmony_ci * 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 * [Description] 9f08c3bdfSopenharmony_ci * 10f08c3bdfSopenharmony_ci * This test verifies that: 11f08c3bdfSopenharmony_ci * - clockid argument is neither CLOCK_MONOTONIC nor CLOCK_REALTIME, 12f08c3bdfSopenharmony_ci * EINVAL would return. 13f08c3bdfSopenharmony_ci * - flags is invalid, EINVAL would return. 14f08c3bdfSopenharmony_ci */ 15f08c3bdfSopenharmony_ci 16f08c3bdfSopenharmony_ci#include <errno.h> 17f08c3bdfSopenharmony_ci 18f08c3bdfSopenharmony_ci#include "tst_test.h" 19f08c3bdfSopenharmony_ci#include "tst_safe_timerfd.h" 20f08c3bdfSopenharmony_ci 21f08c3bdfSopenharmony_cistatic struct test_case_t { 22f08c3bdfSopenharmony_ci int clockid; 23f08c3bdfSopenharmony_ci int flags; 24f08c3bdfSopenharmony_ci int exp_errno; 25f08c3bdfSopenharmony_ci} tcases[] = { 26f08c3bdfSopenharmony_ci { -1, 0, EINVAL }, 27f08c3bdfSopenharmony_ci { 0, -1, EINVAL }, 28f08c3bdfSopenharmony_ci}; 29f08c3bdfSopenharmony_ci 30f08c3bdfSopenharmony_cistatic void run(unsigned int i) 31f08c3bdfSopenharmony_ci{ 32f08c3bdfSopenharmony_ci struct test_case_t *test = &tcases[i]; 33f08c3bdfSopenharmony_ci 34f08c3bdfSopenharmony_ci TST_EXP_FAIL(timerfd_create(test->clockid, test->flags), test->exp_errno); 35f08c3bdfSopenharmony_ci} 36f08c3bdfSopenharmony_ci 37f08c3bdfSopenharmony_cistatic struct tst_test test = { 38f08c3bdfSopenharmony_ci .test = run, 39f08c3bdfSopenharmony_ci .tcnt = ARRAY_SIZE(tcases), 40f08c3bdfSopenharmony_ci}; 41