1f08c3bdfSopenharmony_ci// SPDX-License-Identifier: GPL-2.0
2f08c3bdfSopenharmony_ci/*
3f08c3bdfSopenharmony_ci * Copyright (c) Wipro Technologies Ltd, 2002.  All Rights Reserved.
4f08c3bdfSopenharmony_ci * AUTHOR: Saji Kumar.V.R <saji.kumar@wipro.com>
5f08c3bdfSopenharmony_ci * Copyright (c) 2021 Xie Ziyao <xieziyao@huawei.com>
6f08c3bdfSopenharmony_ci */
7f08c3bdfSopenharmony_ci
8f08c3bdfSopenharmony_ci/*\
9f08c3bdfSopenharmony_ci * [Description]
10f08c3bdfSopenharmony_ci *
11f08c3bdfSopenharmony_ci * Test that getrusage() with RUSAGE_SELF and RUSAGE_CHILDREN succeeds.
12f08c3bdfSopenharmony_ci */
13f08c3bdfSopenharmony_ci
14f08c3bdfSopenharmony_ci#include "tst_test.h"
15f08c3bdfSopenharmony_ci
16f08c3bdfSopenharmony_cistatic struct rusage *usage;
17f08c3bdfSopenharmony_ci
18f08c3bdfSopenharmony_cistruct test_case_t {
19f08c3bdfSopenharmony_ci	int who;
20f08c3bdfSopenharmony_ci	char *desc;
21f08c3bdfSopenharmony_ci} tc[] = {
22f08c3bdfSopenharmony_ci	{RUSAGE_SELF, "RUSAGE_SELF"},
23f08c3bdfSopenharmony_ci	{RUSAGE_CHILDREN, "RUSAGE_CHILDREN"},
24f08c3bdfSopenharmony_ci};
25f08c3bdfSopenharmony_ci
26f08c3bdfSopenharmony_cistatic void run(unsigned int i)
27f08c3bdfSopenharmony_ci{
28f08c3bdfSopenharmony_ci
29f08c3bdfSopenharmony_ci	TST_EXP_PASS(getrusage(tc[i].who, usage), "getrusage(%s, %p)", tc[i].desc, usage);
30f08c3bdfSopenharmony_ci}
31f08c3bdfSopenharmony_ci
32f08c3bdfSopenharmony_cistatic struct tst_test test = {
33f08c3bdfSopenharmony_ci	.tcnt = ARRAY_SIZE(tc),
34f08c3bdfSopenharmony_ci	.test = run,
35f08c3bdfSopenharmony_ci	.bufs = (struct tst_buffers[]) {
36f08c3bdfSopenharmony_ci		{&usage, .size = sizeof(struct rusage)},
37f08c3bdfSopenharmony_ci		{}
38f08c3bdfSopenharmony_ci	}
39f08c3bdfSopenharmony_ci};
40