1*49cdfc7eSAndroid Build Coastguard Worker // SPDX-License-Identifier: GPL-2.0-only
2*49cdfc7eSAndroid Build Coastguard Worker /*
3*49cdfc7eSAndroid Build Coastguard Worker * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
4*49cdfc7eSAndroid Build Coastguard Worker * Copyright (c) Linux Test Project, 2003-2024
5*49cdfc7eSAndroid Build Coastguard Worker */
6*49cdfc7eSAndroid Build Coastguard Worker
7*49cdfc7eSAndroid Build Coastguard Worker /*\
8*49cdfc7eSAndroid Build Coastguard Worker * [Description]
9*49cdfc7eSAndroid Build Coastguard Worker *
10*49cdfc7eSAndroid Build Coastguard Worker * Check the basic functionality of the fpathconf(2) system call.
11*49cdfc7eSAndroid Build Coastguard Worker */
12*49cdfc7eSAndroid Build Coastguard Worker
13*49cdfc7eSAndroid Build Coastguard Worker #include "tst_test.h"
14*49cdfc7eSAndroid Build Coastguard Worker
15*49cdfc7eSAndroid Build Coastguard Worker static struct tcase {
16*49cdfc7eSAndroid Build Coastguard Worker char *name;
17*49cdfc7eSAndroid Build Coastguard Worker int value;
18*49cdfc7eSAndroid Build Coastguard Worker } test_cases[] = {
19*49cdfc7eSAndroid Build Coastguard Worker {"_PC_MAX_CANON", _PC_MAX_CANON},
20*49cdfc7eSAndroid Build Coastguard Worker {"_PC_MAX_INPUT", _PC_MAX_INPUT},
21*49cdfc7eSAndroid Build Coastguard Worker {"_PC_VDISABLE", _PC_VDISABLE},
22*49cdfc7eSAndroid Build Coastguard Worker {"_PC_LINK_MAX", _PC_LINK_MAX},
23*49cdfc7eSAndroid Build Coastguard Worker {"_PC_NAME_MAX", _PC_NAME_MAX},
24*49cdfc7eSAndroid Build Coastguard Worker {"_PC_PATH_MAX", _PC_PATH_MAX},
25*49cdfc7eSAndroid Build Coastguard Worker {"_PC_PIPE_BUF", _PC_PIPE_BUF},
26*49cdfc7eSAndroid Build Coastguard Worker {"_PC_CHOWN_RESTRICTED", _PC_CHOWN_RESTRICTED},
27*49cdfc7eSAndroid Build Coastguard Worker {"_PC_NO_TRUNC", _PC_NO_TRUNC},
28*49cdfc7eSAndroid Build Coastguard Worker };
29*49cdfc7eSAndroid Build Coastguard Worker
30*49cdfc7eSAndroid Build Coastguard Worker static int fd;
31*49cdfc7eSAndroid Build Coastguard Worker
verify_fpathconf(unsigned int n)32*49cdfc7eSAndroid Build Coastguard Worker static void verify_fpathconf(unsigned int n)
33*49cdfc7eSAndroid Build Coastguard Worker {
34*49cdfc7eSAndroid Build Coastguard Worker struct tcase *tc = &test_cases[n];
35*49cdfc7eSAndroid Build Coastguard Worker
36*49cdfc7eSAndroid Build Coastguard Worker TST_EXP_POSITIVE(fpathconf(fd, tc->value));
37*49cdfc7eSAndroid Build Coastguard Worker }
38*49cdfc7eSAndroid Build Coastguard Worker
setup(void)39*49cdfc7eSAndroid Build Coastguard Worker static void setup(void)
40*49cdfc7eSAndroid Build Coastguard Worker {
41*49cdfc7eSAndroid Build Coastguard Worker fd = SAFE_OPEN("fpafile01", O_RDWR | O_CREAT, 0700);
42*49cdfc7eSAndroid Build Coastguard Worker }
43*49cdfc7eSAndroid Build Coastguard Worker
cleanup(void)44*49cdfc7eSAndroid Build Coastguard Worker static void cleanup(void)
45*49cdfc7eSAndroid Build Coastguard Worker {
46*49cdfc7eSAndroid Build Coastguard Worker if (fd > 0)
47*49cdfc7eSAndroid Build Coastguard Worker SAFE_CLOSE(fd);
48*49cdfc7eSAndroid Build Coastguard Worker }
49*49cdfc7eSAndroid Build Coastguard Worker
50*49cdfc7eSAndroid Build Coastguard Worker static struct tst_test test = {
51*49cdfc7eSAndroid Build Coastguard Worker .needs_tmpdir = 1,
52*49cdfc7eSAndroid Build Coastguard Worker .test = verify_fpathconf,
53*49cdfc7eSAndroid Build Coastguard Worker .tcnt = ARRAY_SIZE(test_cases),
54*49cdfc7eSAndroid Build Coastguard Worker .setup = setup,
55*49cdfc7eSAndroid Build Coastguard Worker .cleanup = cleanup,
56*49cdfc7eSAndroid Build Coastguard Worker };
57