• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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  * Copyright (c) 2021 Xie Ziyao <xieziyao@huawei.com>
7  */
8 
9 /*\
10  * [Description]
11  *
12  * Basic test for chown(). Calls chown() on a file and expects it to pass.
13  */
14 
15 #include "tst_test.h"
16 #include "compat_tst_16.h"
17 
18 #define FILENAME "chown01_testfile"
19 
20 static int uid, gid;
21 
run(void)22 static void run(void)
23 {
24 	TST_EXP_PASS(CHOWN(FILENAME, uid, gid), "chown(%s,%d,%d)",
25 		     FILENAME, uid, gid);
26 }
27 
setup(void)28 static void setup(void)
29 {
30 	UID16_CHECK((uid = geteuid()), "chown");
31 	GID16_CHECK((gid = getegid()), "chown");
32 	SAFE_FILE_PRINTF(FILENAME, "davef");
33 }
34 
35 static struct tst_test test = {
36 	.needs_tmpdir = 1,
37 	.setup = setup,
38 	.test_all = run,
39 };
40 
41