Skip to contentSkip to conversation

dup3(2): add EINVAL error number test

PATCH In review Xiaoguang Wang 3 participants 5 messages Nov 21, 2013 – Nov 28, 2013 1 message not in the archive

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 dup3(2): add EINVAL error number test

add EINVAL error number test

---
 runtest/syscalls                         |   1 +
 testcases/kernel/syscalls/.gitignore     |   1 +
 testcases/kernel/syscalls/dup3/dup3_02.c | 123 +++++++++++++++++++++++++++++++
 3 files changed, 125 insertions(+)
 create mode 100644 testcases/kernel/syscalls/dup3/dup3_02.c
runtest/syscalls +1 -0
index fa01ff7..e7e8a9a 100644
@@ -118,6 +118,7 @@ dup204 dup204
 dup205 dup205
 
 dup3_01 dup3_01
+dup3_02 dup3_02
 
 epoll_create1_01 epoll_create1_01
 epoll01 epoll-ltp
testcases/kernel/syscalls/.gitignore +1 -0
index 0130a53..e100dd9 100644
@@ -96,6 +96,7 @@
 /dup2/dup204
 /dup2/dup205
 /dup3/dup3_01
+/dup3/dup3_02
 /epoll/epoll-ltp
 /epoll_create1/epoll_create1_01
 /eventfd/eventfd01
testcases/kernel/syscalls/dup3/dup3_02.c new file +123 -0

123 lines not on this page · raw message

Signature · 13 lines
1.8.2.1


------------------------------------------------------------------------------
Shape the Mobile Experience: Free Subscription
Software experts and developers: Be at the forefront of tech innovation.
Intel(R) Software Adrenaline delivers strategic insight and game-changing 
conversations that shape the rapidly evolving mobile landscape. Sign up now. 
http://pubads.g.doubleclick.net/gampad/clk?id=63431311&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
#1 lore raw

Hi!

testcases/kernel/syscalls/dup3/dup3_02.c line 120

Quoted 5 lines
testcases/kernel/syscalls/dup3/dup3_02.c new file +5 -0
+static void cleanup(void)
+{
+	TEST_CLEANUP;
+
+	SAFE_CLOSE(cleanup, old_fd);

Take care not to call cleanup() from within a cleanup()

If the close() here will fail, the cleanup will be called, then the close() will fail and the cleanup will be called... untill the end of the stack and the test will eventually SegFault.

Also if the SAFE_CREAT() in setup() will fail, the close() will fail too, because the old_fd will be set to -1.

I've fixed that this time and pushed (see diff bellow), thanks.

@@ -117,7 +117,8 @@ static void cleanup(void)

 {
        TEST_CLEANUP;

- SAFE_CLOSE(cleanup, old_fd);
+ if (old_fd > 0)
+ SAFE_CLOSE(NULL, old_fd);

        tst_rmdir();

}

Signature · 13 lines
Cyril Hrubis
[email protected]

------------------------------------------------------------------------------
Rapidly troubleshoot problems before they affect your business. Most IT 
organizations don't have a clear picture of how application performance 
affects their revenue. With AppDynamics, you get 100% visibility into your 
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349351&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
#2 lore raw
Quoted 21 lines · On 11/28/2013 02:35 PM, [email protected] wrote:

Hi!

testcases/kernel/syscalls/dup3/dup3_02.c line 120

Quoted 5 lines
testcases/kernel/syscalls/dup3/dup3_02.c new file +5 -0
+static void cleanup(void)
+{
+	TEST_CLEANUP;
+
+	SAFE_CLOSE(cleanup, old_fd);

Take care not to call cleanup() from within a cleanup()

If the close() here will fail, the cleanup will be called, then the close() will fail and the cleanup will be called... untill the end of the stack and the test will eventually SegFault.

Also if the SAFE_CREAT() in setup() will fail, the close() will fail too, because the old_fd will be set to -1.

I've fixed that this time and pushed (see diff bellow), thanks.

Review static void cleanup(void) · line 124

Quoted 9 lines
(quoted diff) +2 -1
@@ -117,7 +117,8 @@ static void cleanup(void)
  {
         TEST_CLEANUP;
 
-       SAFE_CLOSE(cleanup, old_fd);
+       if (old_fd > 0)
+               SAFE_CLOSE(NULL, old_fd);
 
         tst_rmdir();
  }

Hello,

This test does not seem to compile on uClibc based systems

I am getting this:
dup3_02.c:53: error: 'O_CLOEXEC' undeclared here (not in a function)

Signature · 13 lines
markos


------------------------------------------------------------------------------
Rapidly troubleshoot problems before they affect your business. Most IT 
organizations don't have a clear picture of how application performance 
affects their revenue. With AppDynamics, you get 100% visibility into your 
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349351&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
#3 lore raw

Hi!

Quoted 32 lines
Quoted 20 lines

testcases/kernel/syscalls/dup3/dup3_02.c line 120

Quoted 5 lines
testcases/kernel/syscalls/dup3/dup3_02.c new file +5 -0
+static void cleanup(void)
+{
+	TEST_CLEANUP;
+
+	SAFE_CLOSE(cleanup, old_fd);

Take care not to call cleanup() from within a cleanup()

If the close() here will fail, the cleanup will be called, then the close() will fail and the cleanup will be called... untill the end of the stack and the test will eventually SegFault.

Also if the SAFE_CREAT() in setup() will fail, the close() will fail too, because the old_fd will be set to -1.

I've fixed that this time and pushed (see diff bellow), thanks.

Review static void cleanup(void) · line 124

Quoted 9 lines
(quoted diff) +2 -1
@@ -117,7 +117,8 @@ static void cleanup(void)
  {
         TEST_CLEANUP;
 
-       SAFE_CLOSE(cleanup, old_fd);
+       if (old_fd > 0)
+               SAFE_CLOSE(NULL, old_fd);
 
         tst_rmdir();
  }

Hello,

Quoted 4 lines

This test does not seem to compile on uClibc based systems

I am getting this:
dup3_02.c:53: error: 'O_CLOEXEC' undeclared here (not in a function)

Looking at fcntl.h in uClibc git the O_CLOEXEC is defined only on __USE_GNU

Does adding

#define _GNU_SOURCE

before the includes help?

If not, your uClibc version does not yet support it and we will have to add:

#ifndef O_CLOEXEC

# define O_CLOEXEC 02000000
#endif

To fix it.

Signature · 13 lines
Cyril Hrubis
[email protected]

------------------------------------------------------------------------------
Rapidly troubleshoot problems before they affect your business. Most IT 
organizations don't have a clear picture of how application performance 
affects their revenue. With AppDynamics, you get 100% visibility into your 
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349351&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
#5 lore raw
In reply to a message not in the archive

Hi!

Quoted 9 lines
Quoted 9 lines
Quoted 5 lines

This test does not seem to compile on uClibc based systems

I am getting this:
dup3_02.c:53: error: 'O_CLOEXEC' undeclared here (not in a function)

Looking at fcntl.h in uClibc git the O_CLOEXEC is defined only on __USE_GNU

Quoted 8 lines
Quoted 5 lines

Does adding

#define _GNU_SOURCE

before the includes help?

Yeah that fixes it. Thanks!

Fix is pushed.

Signature · 13 lines
Cyril Hrubis
[email protected]

------------------------------------------------------------------------------
Rapidly troubleshoot problems before they affect your business. Most IT 
organizations don't have a clear picture of how application performance 
affects their revenue. With AppDynamics, you get 100% visibility into your 
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349351&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list