xref: /aosp_15_r20/external/ltp/testcases/kernel/syscalls/open/open06.c (revision 49cdfc7efb34551c7342be41a7384b9c40d7cab7)
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 
3 /*
4  * Copyright (c) International Business Machines  Corp., 2001
5  * Copyright (c) 2022 SUSE LLC Avinesh Kumar <[email protected]>
6  */
7 
8 /*\
9  * [Description]
10  *
11  * Verify that open(2) fails with ENXIO when
12  * O_NONBLOCK | O_WRONLY is set, the named file is a FIFO,
13  * and no process has the FIFO open for reading.
14  */
15 
16 #include "tst_test.h"
17 
18 #define TEMP_FIFO "tmpfile"
19 
setup(void)20 static void setup(void)
21 {
22 	SAFE_MKFIFO(TEMP_FIFO, 0644);
23 }
24 
run(void)25 static void run(void)
26 {
27 	TST_EXP_FAIL2(open(TEMP_FIFO, O_NONBLOCK | O_WRONLY), ENXIO);
28 }
29 
30 static struct tst_test test = {
31 	.test_all = run,
32 	.setup = setup,
33 	.needs_tmpdir = 1
34 };
35