android13/external/ltp/testcases/kernel/syscalls/nanosleep/nanosleep01.c

39 lines
799 B
C

// SPDX-License-Identifier: GPL-2.0-or-later
/*
* Copyright (c) International Business Machines Corp., 2001
* 07/2001 Ported by Wayne Boyer
* Copyright (C) 2015-2017 Cyril Hrubis <chrubis@suse.cz>
*/
/*
* Test Description:
* nanosleep() should return with value 0 and the process should be
* suspended for time specified by timespec structure.
*/
#include <errno.h>
#include "tst_timer_test.h"
int sample_fn(int clk_id, long long usec)
{
struct timespec t = tst_timespec_from_us(usec);
tst_timer_start(clk_id);
TEST(nanosleep(&t, NULL));
tst_timer_stop();
tst_timer_sample();
if (TST_RET != 0) {
tst_res(TFAIL | TTERRNO,
"nanosleep() returned %li", TST_RET);
return 1;
}
return 0;
}
static struct tst_test test = {
.scall = "nanosleep()",
.sample = sample_fn,
};