1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3 * Copyright (c) International Business Machines Corp., 2001
4 * Ported by Wayne Boyer
5 */
6
7 /*\
8 * [Description]
9 *
10 * Check that getuid() return value matches value from /proc/self/status.
11 */
12
13 #include "tst_test.h"
14 #include "compat_tst_16.h"
15
verify_getuid(void)16 static void verify_getuid(void)
17 {
18 long uid;
19
20 TST_EXP_POSITIVE(GETUID(), "getuid()");
21
22 if (!TST_PASS)
23 return;
24
25 SAFE_FILE_LINES_SCANF("/proc/self/status", "Uid: %ld", &uid);
26
27 if (TST_RET != uid) {
28 tst_res(TFAIL,
29 "getuid() ret %ld != /proc/self/status Uid: %ld",
30 TST_RET, uid);
31 } else {
32 tst_res(TPASS,
33 "getuid() ret == /proc/self/status Uid: %ld", uid);
34 }
35 }
36
37 static struct tst_test test = {
38 .test_all = verify_getuid,
39 };
40