1f08c3bdfSopenharmony_ci// SPDX-License-Identifier: GPL-2.0-or-later
2f08c3bdfSopenharmony_ci/*
3f08c3bdfSopenharmony_ci * Copyright (c) 2017 Cyril Hrubis <chrubis@suse.cz>
4f08c3bdfSopenharmony_ci */
5f08c3bdfSopenharmony_ci#include <sys/select.h>
6f08c3bdfSopenharmony_ci#include <sys/time.h>
7f08c3bdfSopenharmony_ci#include <sys/types.h>
8f08c3bdfSopenharmony_ci#include <errno.h>
9f08c3bdfSopenharmony_ci
10f08c3bdfSopenharmony_ci#include "tst_timer_test.h"
11f08c3bdfSopenharmony_ci
12f08c3bdfSopenharmony_ciint sample_fn(int clk_id, long long usec)
13f08c3bdfSopenharmony_ci{
14f08c3bdfSopenharmony_ci	fd_set readfds;
15f08c3bdfSopenharmony_ci	struct timespec tv = tst_timespec_from_us(usec);
16f08c3bdfSopenharmony_ci
17f08c3bdfSopenharmony_ci	FD_ZERO(&readfds);
18f08c3bdfSopenharmony_ci	FD_SET(0, &readfds);
19f08c3bdfSopenharmony_ci
20f08c3bdfSopenharmony_ci	tst_timer_start(clk_id);
21f08c3bdfSopenharmony_ci	TEST(pselect(0, &readfds, NULL, NULL, &tv, NULL));
22f08c3bdfSopenharmony_ci	tst_timer_stop();
23f08c3bdfSopenharmony_ci	tst_timer_sample();
24f08c3bdfSopenharmony_ci
25f08c3bdfSopenharmony_ci	if (TST_RET != 0) {
26f08c3bdfSopenharmony_ci		tst_res(TFAIL | TTERRNO,
27f08c3bdfSopenharmony_ci			"pselect() returned %li on timeout", TST_RET);
28f08c3bdfSopenharmony_ci		return 1;
29f08c3bdfSopenharmony_ci	}
30f08c3bdfSopenharmony_ci
31f08c3bdfSopenharmony_ci	return 0;
32f08c3bdfSopenharmony_ci}
33f08c3bdfSopenharmony_ci
34f08c3bdfSopenharmony_cistatic struct tst_test test = {
35f08c3bdfSopenharmony_ci	.scall = "pselect()",
36f08c3bdfSopenharmony_ci	.sample = sample_fn,
37f08c3bdfSopenharmony_ci};
38