1f08c3bdfSopenharmony_ci// SPDX-License-Identifier: GPL-2.0-or-later 2f08c3bdfSopenharmony_ci/* 3f08c3bdfSopenharmony_ci * Copyright (c) International Business Machines Corp., 2001 4f08c3bdfSopenharmony_ci * 07/2001 Ported by Wayne Boyer 5f08c3bdfSopenharmony_ci * Copyright (C) 2015-2017 Cyril Hrubis <chrubis@suse.cz> 6f08c3bdfSopenharmony_ci */ 7f08c3bdfSopenharmony_ci 8f08c3bdfSopenharmony_ci/* 9f08c3bdfSopenharmony_ci * Test Description: 10f08c3bdfSopenharmony_ci * nanosleep() should return with value 0 and the process should be 11f08c3bdfSopenharmony_ci * suspended for time specified by timespec structure. 12f08c3bdfSopenharmony_ci */ 13f08c3bdfSopenharmony_ci 14f08c3bdfSopenharmony_ci#include <errno.h> 15f08c3bdfSopenharmony_ci#include "tst_timer_test.h" 16f08c3bdfSopenharmony_ci 17f08c3bdfSopenharmony_ciint sample_fn(int clk_id, long long usec) 18f08c3bdfSopenharmony_ci{ 19f08c3bdfSopenharmony_ci struct timespec t = tst_timespec_from_us(usec); 20f08c3bdfSopenharmony_ci 21f08c3bdfSopenharmony_ci tst_timer_start(clk_id); 22f08c3bdfSopenharmony_ci TEST(nanosleep(&t, NULL)); 23f08c3bdfSopenharmony_ci tst_timer_stop(); 24f08c3bdfSopenharmony_ci tst_timer_sample(); 25f08c3bdfSopenharmony_ci 26f08c3bdfSopenharmony_ci if (TST_RET != 0) { 27f08c3bdfSopenharmony_ci tst_res(TFAIL | TTERRNO, 28f08c3bdfSopenharmony_ci "nanosleep() returned %li", TST_RET); 29f08c3bdfSopenharmony_ci return 1; 30f08c3bdfSopenharmony_ci } 31f08c3bdfSopenharmony_ci 32f08c3bdfSopenharmony_ci return 0; 33f08c3bdfSopenharmony_ci} 34f08c3bdfSopenharmony_ci 35f08c3bdfSopenharmony_cistatic struct tst_test test = { 36f08c3bdfSopenharmony_ci .scall = "nanosleep()", 37f08c3bdfSopenharmony_ci .sample = sample_fn, 38f08c3bdfSopenharmony_ci}; 39