xref: /aosp_15_r20/external/ltp/testcases/kernel/syscalls/fchdir/fchdir02.c (revision 49cdfc7efb34551c7342be41a7384b9c40d7cab7)
1*49cdfc7eSAndroid Build Coastguard Worker // SPDX-License-Identifier: GPL-2.0-or-later
2*49cdfc7eSAndroid Build Coastguard Worker /*
3*49cdfc7eSAndroid Build Coastguard Worker  *   Copyright (c) International Business Machines  Corp., 2001
4*49cdfc7eSAndroid Build Coastguard Worker  */
5*49cdfc7eSAndroid Build Coastguard Worker 
6*49cdfc7eSAndroid Build Coastguard Worker /*
7*49cdfc7eSAndroid Build Coastguard Worker  * DESCRIPTION
8*49cdfc7eSAndroid Build Coastguard Worker  *	fchdir02 - try to cd into a bad directory (bad fd).
9*49cdfc7eSAndroid Build Coastguard Worker  */
10*49cdfc7eSAndroid Build Coastguard Worker 
11*49cdfc7eSAndroid Build Coastguard Worker #include "tst_test.h"
12*49cdfc7eSAndroid Build Coastguard Worker 
verify_fchdir(void)13*49cdfc7eSAndroid Build Coastguard Worker static void verify_fchdir(void)
14*49cdfc7eSAndroid Build Coastguard Worker {
15*49cdfc7eSAndroid Build Coastguard Worker 	const int bad_fd = -5;
16*49cdfc7eSAndroid Build Coastguard Worker 
17*49cdfc7eSAndroid Build Coastguard Worker 	TST_EXP_FAIL(fchdir(bad_fd), EBADF);
18*49cdfc7eSAndroid Build Coastguard Worker }
19*49cdfc7eSAndroid Build Coastguard Worker 
20*49cdfc7eSAndroid Build Coastguard Worker static struct tst_test test = {
21*49cdfc7eSAndroid Build Coastguard Worker 	.test_all = verify_fchdir,
22*49cdfc7eSAndroid Build Coastguard Worker };
23