Skip to content

Commit 911ff30

Browse files
Avineshpevik
authored andcommitted
dup04.c: use TST_EXP_FD macro and make check fixes
+ updade copyright Reviewed-by: Petr Vorel <[email protected]> Signed-off-by: Avinesh Kumar <[email protected]>
1 parent d09b1eb commit 911ff30

File tree

1 file changed

+12
-32
lines changed
  • testcases/kernel/syscalls/dup

1 file changed

+12
-32
lines changed

testcases/kernel/syscalls/dup/dup04.c

Lines changed: 12 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
// SPDX-License-Identifier: GPL-2.0-only
22
/*
33
* Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
4-
*
54
* 06/1994 AUTHOR: Richard Logan CO-PILOT: William Roske
5+
* Copyright (c) 2023 SUSE LLC
66
*/
77

88
/*\
9-
* [DESCRIPTION]
9+
* [Description]
1010
*
1111
* Basic test for dup(2) of a system pipe descriptor.
1212
*/
@@ -17,46 +17,26 @@
1717

1818
#include "tst_test.h"
1919

20-
int fd[2];
20+
static int fd[2];
2121

2222
static void run(void)
2323
{
24-
TEST(dup(fd[0]));
25-
26-
if (TST_RET == -1)
27-
tst_res(TFAIL | TTERRNO,
28-
"dup of read side of pipe failed");
29-
else {
30-
tst_res(TPASS,
31-
"dup(%d) read side of syspipe returned %ld",
32-
fd[0], TST_RET);
33-
34-
SAFE_CLOSE(TST_RET);
35-
}
36-
37-
TEST(dup(fd[1]));
38-
39-
if (TST_RET == -1) {
40-
tst_res(TFAIL | TTERRNO,
41-
"dup of write side of pipe failed");
42-
} else {
43-
tst_res(TPASS,
44-
"dup(%d) write side of syspipe returned %ld",
45-
fd[1], TST_RET);
46-
47-
SAFE_CLOSE(TST_RET);
48-
}
24+
TST_EXP_FD(dup(fd[0]), "dup(%d) read end of the pipe", fd[0]);
25+
SAFE_CLOSE(TST_RET);
26+
27+
TST_EXP_FD(dup(fd[1]), "dup(%d) write end of the pipe", fd[1]);
28+
SAFE_CLOSE(TST_RET);
4929
}
5030

51-
void setup(void)
31+
static void setup(void)
5232
{
5333
fd[0] = -1;
5434

5535
SAFE_PIPE(fd);
5636
}
5737

5838
static struct tst_test test = {
59-
.test_all = run,
60-
.setup = setup,
61-
.needs_tmpdir = 1,
39+
.test_all = run,
40+
.setup = setup,
41+
.needs_tmpdir = 1,
6242
};

0 commit comments

Comments
 (0)