File tree Expand file tree Collapse file tree 1 file changed +15
-10
lines changed
testcases/kernel/syscalls/dup Expand file tree Collapse file tree 1 file changed +15
-10
lines changed Original file line number Diff line number Diff line change 7
7
*
8
8
*/
9
9
10
+ /*\
11
+ * [Description]
12
+ *
13
+ * Verify that dup(2) syscall executes successfully and allocates
14
+ * a new file descriptor which refers to the same open file as oldfd.
15
+ */
16
+
10
17
#include "tst_test.h"
11
18
12
19
static int fd ;
20
+ static struct stat buf1 , buf2 ;
13
21
14
22
static void verify_dup (void )
15
23
{
16
- TEST (dup (fd ));
17
-
18
- if (TST_RET < -1 ) {
19
- tst_res (TFAIL , "Invalid dup() return value %ld" , TST_RET );
20
- } else if (TST_RET == -1 ) {
21
- tst_res (TFAIL | TTERRNO , "dup(%d) Failed" , fd );
22
- } else {
23
- tst_res (TPASS , "dup(%d) returned %ld" , fd , TST_RET );
24
- SAFE_CLOSE (TST_RET );
25
- }
24
+ TST_EXP_FD (dup (fd ));
25
+
26
+ SAFE_FSTAT (TST_RET , & buf2 );
27
+ TST_EXP_EQ_LU (buf1 .st_ino , buf2 .st_ino );
28
+
29
+ SAFE_CLOSE (TST_RET );
26
30
}
27
31
28
32
static void setup (void )
29
33
{
30
34
fd = SAFE_OPEN ("dupfile" , O_RDWR | O_CREAT , 0700 );
35
+ SAFE_FSTAT (fd , & buf1 );
31
36
}
32
37
33
38
static void cleanup (void )
You can’t perform that action at this time.
0 commit comments