File tree Expand file tree Collapse file tree 1 file changed +7
-27
lines changed
testcases/kernel/syscalls/dup Expand file tree Collapse file tree 1 file changed +7
-27
lines changed Original file line number Diff line number Diff line change 2
2
/*
3
3
* Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
4
4
* Copyright (c) 2020 SUSE LLC
5
- *
6
5
* 03/30/1992 AUTHOR: Richard Logan CO-PILOT: William Roske
7
- *
8
6
*/
7
+
9
8
/*\
10
9
* [Description]
11
- * Negative test for dup(2) with bad fds.
12
10
*
13
- * [Algorithm]
14
- * Call dup(2) with invalid argument and make sure it returns -1 with errno set
15
- * to EBADF.
11
+ * Verify that dup(2) syscall fails with errno EBADF when called with
12
+ * invalid value for oldfd argument.
16
13
*/
17
14
18
15
#include "tst_test.h"
19
16
20
17
static struct tcase {
21
18
int fd ;
22
- int expected_errno ;
19
+ int exp_err ;
23
20
} tcases [] = {
24
21
{-1 , EBADF },
25
22
{1500 , EBADF },
@@ -29,27 +26,10 @@ static void run(unsigned int n)
29
26
{
30
27
struct tcase * tc = & tcases [n ];
31
28
32
- TEST (dup (tc -> fd ));
33
-
34
- if (TST_RET < -1 ) {
35
- tst_res (TFAIL | TTERRNO , "Invalid dup() return value %ld" ,
36
- TST_RET );
37
- return ;
38
- }
39
-
40
- if (TST_RET == -1 ) {
41
- if (tc -> expected_errno == TST_ERR ) {
42
- tst_res (TPASS | TTERRNO , "dup(%d) failed as expected" ,
43
- tc -> fd );
44
- } else {
45
- tst_res (TFAIL | TTERRNO , "dup(%d) failed unexpectedly" ,
46
- tc -> fd );
47
- }
48
- return ;
49
- }
29
+ TST_EXP_FAIL2 (dup (tc -> fd ), tc -> exp_err , "dup(%d)" , tc -> fd );
50
30
51
- tst_res ( TFAIL , "dup(%d) succeeded unexpectedly" , tc -> fd );
52
- SAFE_CLOSE (TST_RET );
31
+ if ( TST_RET != -1 )
32
+ SAFE_CLOSE (TST_RET );
53
33
}
54
34
55
35
static struct tst_test test = {
You can’t perform that action at this time.
0 commit comments