1 // SPDX-License-Identifier: GPL-2.0 2 /* 3 * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved. 4 * AUTHOR : William Roske 5 * CO-PILOT : Dave Fenner 6 */ 7 8 /*\ 9 * [Description] 10 * 11 * Call getgid() and expects that the gid returned correctly. 12 */ 13 14 #include <pwd.h> 15 #include "tst_test.h" 16 #include "compat_tst_16.h" 17 18 static struct passwd *ltpuser; 19 run(void)20static void run(void) 21 { 22 TEST(GETGID()); 23 if (TST_RET != ltpuser->pw_gid) 24 tst_res(TFAIL, "getgid failed, returned %ld", TST_RET); 25 else 26 tst_res(TPASS, "getgid returned as expectedly"); 27 } 28 setup(void)29static void setup(void) 30 { 31 ltpuser = SAFE_GETPWNAM("nobody"); 32 SAFE_SETGID(ltpuser->pw_gid); 33 } 34 35 static struct tst_test test = { 36 .needs_root = 1, 37 .test_all = run, 38 .setup = setup, 39 }; 40