File tree Expand file tree Collapse file tree 1 file changed +17
-29
lines changed
testcases/kernel/syscalls/dup Expand file tree Collapse file tree 1 file changed +17
-29
lines changed Original file line number Diff line number Diff line change 1
1
// SPDX-License-Identifier: GPL-2.0-only
2
2
/*
3
3
* Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
4
- *
5
4
* 06/1994 AUTHOR: Richard Logan CO-PILOT: William Roske
5
+ * Copyright (c) 2012-2023 SUSE LLC
6
6
*/
7
7
8
8
/*\
9
- * [DESCRIPTION ]
9
+ * [Description ]
10
10
*
11
- * Basic test for dup(2) of a named pipe descriptor
11
+ * Basic test for dup(2) of a named pipe descriptor.
12
12
*/
13
- #include <stdio.h>
13
+
14
14
#include "tst_test.h"
15
15
16
- char Fname [255 ];
17
- int fd ;
16
+ #define FNAME "dupfile"
17
+
18
+ static int fd = -1 ;
18
19
19
20
static void run (void )
20
21
{
21
- TEST (dup (fd ));
22
-
23
- if (TST_RET == -1 ) {
24
- tst_res (TFAIL | TTERRNO , "dup failed" );
25
- } else {
26
- tst_res (TPASS , "dup returned %ld" ,
27
- TST_RET );
28
-
29
- SAFE_CLOSE (TST_RET );
30
- }
22
+ TST_EXP_FD (dup (fd ), "dup(%d)" , fd );
23
+ SAFE_CLOSE (TST_RET );
31
24
}
32
25
33
- void setup (void )
26
+ static void setup (void )
34
27
{
35
- fd = -1 ;
36
-
37
- sprintf (Fname , "dupfile" );
38
- SAFE_MKFIFO (Fname , 0777 );
39
- if ((fd = open (Fname , O_RDWR , 0700 )) == -1 )
40
- tst_brk (TBROK , "open failed" );
28
+ SAFE_MKFIFO (FNAME , 0777 );
29
+ fd = SAFE_OPEN (FNAME , O_RDWR , 0700 );
41
30
}
42
31
43
- void cleanup (void )
32
+ static void cleanup (void )
44
33
{
45
34
if (fd != -1 )
46
- if (close (fd ) == -1 )
47
- tst_res (TWARN | TERRNO , "close failed" );
35
+ SAFE_CLOSE (fd );
48
36
}
49
37
50
38
static struct tst_test test = {
51
- .test_all = run ,
52
- .setup = setup ,
53
- .cleanup = cleanup ,
39
+ .test_all = run ,
40
+ .setup = setup ,
41
+ .cleanup = cleanup ,
54
42
.needs_tmpdir = 1 ,
55
43
};
You can’t perform that action at this time.
0 commit comments