xref: /aosp_15_r20/external/ltp/testcases/kernel/syscalls/open/open03.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) Linux Test Project, 2001-2022
4*49cdfc7eSAndroid Build Coastguard Worker  * Copyright (c) 2000 Silicon Graphics, Inc.  All Rights Reserved.
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  * Testcase to check open() with O_RDWR | O_CREAT.
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 #define TEST_FILE "testfile"
16*49cdfc7eSAndroid Build Coastguard Worker 
verify_open(void)17*49cdfc7eSAndroid Build Coastguard Worker static void verify_open(void)
18*49cdfc7eSAndroid Build Coastguard Worker {
19*49cdfc7eSAndroid Build Coastguard Worker 	TST_EXP_FD(open(TEST_FILE, O_RDWR | O_CREAT, 0700));
20*49cdfc7eSAndroid Build Coastguard Worker 	SAFE_CLOSE(TST_RET);
21*49cdfc7eSAndroid Build Coastguard Worker 	SAFE_UNLINK(TEST_FILE);
22*49cdfc7eSAndroid Build Coastguard Worker }
23*49cdfc7eSAndroid Build Coastguard Worker 
24*49cdfc7eSAndroid Build Coastguard Worker 
25*49cdfc7eSAndroid Build Coastguard Worker 
26*49cdfc7eSAndroid Build Coastguard Worker static struct tst_test test = {
27*49cdfc7eSAndroid Build Coastguard Worker 	.needs_tmpdir = 1,
28*49cdfc7eSAndroid Build Coastguard Worker 	.test_all = verify_open,
29*49cdfc7eSAndroid Build Coastguard Worker };
30