xref: /aosp_15_r20/external/ltp/testcases/kernel/syscalls/times/times01.c (revision 49cdfc7efb34551c7342be41a7384b9c40d7cab7)
1*49cdfc7eSAndroid Build Coastguard Worker // SPDX-License-Identifier: GPL-2.0-or-later
2*49cdfc7eSAndroid Build Coastguard Worker /*
3*49cdfc7eSAndroid Build Coastguard Worker  * Copyright (c) 2000 Silicon Graphics, Inc.  All Rights Reserved.
4*49cdfc7eSAndroid Build Coastguard Worker  */
5*49cdfc7eSAndroid Build Coastguard Worker /*\
6*49cdfc7eSAndroid Build Coastguard Worker  * [Description]
7*49cdfc7eSAndroid Build Coastguard Worker  *
8*49cdfc7eSAndroid Build Coastguard Worker  * This is a Phase I test for the times(2) system call.  It is intended to
9*49cdfc7eSAndroid Build Coastguard Worker  * provide a limited exposure of the system call.
10*49cdfc7eSAndroid Build Coastguard Worker  */
11*49cdfc7eSAndroid Build Coastguard Worker 
12*49cdfc7eSAndroid Build Coastguard Worker #include <sys/times.h>
13*49cdfc7eSAndroid Build Coastguard Worker #include <errno.h>
14*49cdfc7eSAndroid Build Coastguard Worker #include "tst_test.h"
15*49cdfc7eSAndroid Build Coastguard Worker 
verify_times(void)16*49cdfc7eSAndroid Build Coastguard Worker static void verify_times(void)
17*49cdfc7eSAndroid Build Coastguard Worker {
18*49cdfc7eSAndroid Build Coastguard Worker 	struct tms mytimes;
19*49cdfc7eSAndroid Build Coastguard Worker 
20*49cdfc7eSAndroid Build Coastguard Worker 	TEST(times(&mytimes));
21*49cdfc7eSAndroid Build Coastguard Worker 
22*49cdfc7eSAndroid Build Coastguard Worker 	if (TST_RET == -1)
23*49cdfc7eSAndroid Build Coastguard Worker 		tst_res(TFAIL | TTERRNO, "times failed");
24*49cdfc7eSAndroid Build Coastguard Worker 	else
25*49cdfc7eSAndroid Build Coastguard Worker 		tst_res(TPASS, "times(&mytimes) returned %ld", TST_RET);
26*49cdfc7eSAndroid Build Coastguard Worker }
27*49cdfc7eSAndroid Build Coastguard Worker 
28*49cdfc7eSAndroid Build Coastguard Worker static struct tst_test test = {
29*49cdfc7eSAndroid Build Coastguard Worker 	.test_all = verify_times,
30*49cdfc7eSAndroid Build Coastguard Worker };
31