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 22/*
33 * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
44 * Copyright (c) 2020 SUSE LLC
5- *
65 * 03/30/1992 AUTHOR: Richard Logan CO-PILOT: William Roske
7- *
86 */
7+
98/*\
109 * [Description]
11- * Negative test for dup(2) with bad fds.
1210 *
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.
1613 */
1714
1815#include "tst_test.h"
1916
2017static struct tcase {
2118 int fd ;
22- int expected_errno ;
19+ int exp_err ;
2320} tcases [] = {
2421 {-1 , EBADF },
2522 {1500 , EBADF },
@@ -29,27 +26,10 @@ static void run(unsigned int n)
2926{
3027 struct tcase * tc = & tcases [n ];
3128
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 );
5030
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 );
5333}
5434
5535static struct tst_test test = {
You can’t perform that action at this time.
0 commit comments