Skip to contentSkip to conversation

syscalls/getdents: Add parameter to test getdents64 syscall

PATCH In review Markos Chandras 3 participants 10 messages Mar 18, 2013 4 messages not in the archive

lore
Share & tools
lore
#0 lore raw

PATCH v4 1/1 syscalls/getdents: Add parameter to test getdents64 syscall

From: Markos Chandras <[email protected]>

Add new "-l" parameter to test the getdents64 syscall along with the getdents one. Use ltp_syscall() to call the system call to get proper return values when an architecture does not support any of the getdents{,64} syscalls. Modify runtest/syscalls to call getdentsXX tests with and without the "-l" parameter

---
 runtest/syscalls                                |    9 ++++
 testcases/kernel/syscalls/getdents/Makefile     |    2 +
 testcases/kernel/syscalls/getdents/getdents.h   |   48 +++++++++++++++++++-
 testcases/kernel/syscalls/getdents/getdents01.c |   56 +++++++++++++++++------
 testcases/kernel/syscalls/getdents/getdents02.c |   45 +++++++++++++++----
 testcases/kernel/syscalls/getdents/getdents03.c |   42 ++++++++++++++---
 testcases/kernel/syscalls/getdents/getdents04.c |   46 +++++++++++++++----
 7 files changed, 205 insertions(+), 43 deletions(-)
runtest/syscalls +9 -0
index c70bcbd..191ad10 100644
@@ -331,6 +331,15 @@ getdents03_64 getdents03_64
 getdents04 getdents04
 getdents04_64 getdents04_64
 
+getdents01_long getdents01 -l
+getdents01_64_long getdents01_64 -l
+getdents02_long getdents02 -l
+getdents02_64_long getdents02_64 -l
+getdents03_long getdents03 -l
+getdents03_64_long getdents03_64 -l
+getdents04_long getdents04 -l
+getdents04_64_long getdents04_64 -l
+
 getdomainname01 getdomainname01
 
 getdtablesize01 getdtablesize01
testcases/kernel/syscalls/getdents/Makefile +2 -0
index df7b63f..ebcbc4f 100644
@@ -21,6 +21,8 @@ top_srcdir		?= ../../../..
 include $(top_srcdir)/include/mk/testcases.mk
 include $(abs_srcdir)/../utils/newer_64.mk
 
+CPPFLAGS += -D_LARGEFILE64_SOURCE
+
 %_64: CPPFLAGS += -D_FILE_OFFSET_BITS=64 -DOFF_T=__off64_t
 
 include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/kernel/syscalls/getdents/getdents.h +47 -1

70 lines not on this page · raw message

testcases/kernel/syscalls/getdents/getdents01.c +41 -15

102 lines not on this page · raw message

testcases/kernel/syscalls/getdents/getdents02.c +36 -9

90 lines not on this page · raw message

testcases/kernel/syscalls/getdents/getdents03.c +34 -8

91 lines not on this page · raw message

testcases/kernel/syscalls/getdents/getdents04.c +36 -10

99 lines not on this page · raw message

Signature · 13 lines
1.7.1



------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_mar
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
#1 lore raw

Hi!

testcases/kernel/syscalls/getdents/getdents01.c int main(int ac, char **av) · line 164

Quoted 8 lines
testcases/kernel/syscalls/getdents/getdents01.c +5 -0
+	if (longsyscall)
+		free(dirp64);
+	else
+		free(dirp);
+
 	cleanup();
 
 	tst_exit();

You don't need to bother to free the buffers when the next thing the test does is exit, the whole heap along with malloc data structures will be freed (unmapped) by the kernel anyway.

Signature · 12 lines
Cyril Hrubis
[email protected]

------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_mar
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

A message that is not in the archive (sent off-list or not yet received): CAG2jQ8gAOvbKsoggS3o1a_9zDfVhUU9WUpxgY0g_Mp-ZcCC99w@mail.gmail.com

#3 lore raw

Hi!

Quoted 13 lines
Quoted 13 lines

testcases/kernel/syscalls/getdents/getdents01.c int main(int ac, char **av) · line 164

Quoted 8 lines
testcases/kernel/syscalls/getdents/getdents01.c +5 -0
+     if (longsyscall)
+             free(dirp64);
+     else
+             free(dirp);
+
      cleanup();
 
      tst_exit();

You don't need to bother to free the buffers when the next thing the test does is exit, the whole heap along with malloc data structures will be freed (unmapped) by the kernel anyway.

Quoted 8 lines
Quoted 3 lines

--
Cyril Hrubis
[email protected]

Hi Cyril,

I understand. Should I send a new patch or maybe you could fix it before committing it?

I will fix that.

Signature · 12 lines
Cyril Hrubis
[email protected]

------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_mar
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
#4 lore raw

Hi!

Quoted 4 lines
Quoted 2 lines

I understand. Should I send a new patch or maybe you could fix it before committing it?

I will fix that.

Commited with a few style fixes (in separate patch).

Make sure not to overflow 80 chars next time (or just start using the checkpatch.pl script).

Signature · 12 lines
Cyril Hrubis
[email protected]

------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_mar
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

A message that is not in the archive (sent off-list or not yet received): [email protected]

#6 lore raw

Hi!

Quoted 8 lines
Quoted 4 lines

You don't need to bother to free the buffers when the next thing the test does is exit, the whole heap along with malloc data structures will
be freed (unmapped) by the kernel anyway.

I think it's nice thing to cleanup. Say, if test corrupted heap, free could alert you. Also there are tools, which may complain, that there's a leak now. I think LTP supports at least valgrind.

So what about compromise, defining them as variables instead of the allocation?

Signature · 12 lines
Cyril Hrubis
[email protected]

------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_mar
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

A message that is not in the archive (sent off-list or not yet received): [email protected]

#8 lore raw

Hi!

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines

You don't need to bother to free the buffers when the next thing the
test does is exit, the whole heap along with malloc data structures
will
be freed (unmapped) by the kernel anyway.

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines

I think it's nice thing to cleanup. Say, if test corrupted heap, free could alert you. Also there are tools, which may complain, that there's a leak now. I think LTP supports at least valgrind.

So what about compromise, defining them as variables instead of the allocation?

That would work. You really want that free() gone, don't you? :-).

I hate when there is unnecessary complexity in the tests that is not really needed for the testing itself...

Signature · 12 lines
Cyril Hrubis
[email protected]

------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_mar
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

A message that is not in the archive (sent off-list or not yet received): CAG2jQ8i1oovEVtF2hayXzeBzpWb78q=ntN_EJ3w0KJ3KpeXCzQ@mail.gmail.com

#10 lore raw

Hi!

Quoted 14 lines
Quoted 14 lines
Quoted 13 lines
Quoted 10 lines
Quoted 6 lines

You don't need to bother to free the buffers when the next thing the
test does is exit, the whole heap along with malloc data structures
will
be freed (unmapped) by the kernel anyway.

I think it's nice thing to cleanup. Say, if test corrupted heap, free could alert you. Also there are tools, which may complain, that there's a leak now. I think LTP supports at least valgrind.

So what about compromise, defining them as variables instead of the allocation?

Quoted 6 lines
Quoted 2 lines

That would work. You really want that free() gone, don't you? :-).

Yeah I was about to ask the same thing. I see no problem with keeping free() around and I don't think there is an urgent need to convert these pointers to variables.

I've changed them to be variables and the getdents64 now seems to segfault randomly. I will look closely at the code, my guess is that the size of the structure is counted/propagated wrongly somewhere.

Signature · 12 lines
Cyril Hrubis
[email protected]

------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_mar
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
#11 lore raw

Hi!

Quoted 10 lines
Quoted 10 lines
Quoted 9 lines
Quoted 6 lines
Quoted 3 lines

I think it's nice thing to cleanup. Say, if test corrupted heap, free could alert you. Also there are tools, which may complain, that there's a leak now. I think LTP supports at least valgrind.

So what about compromise, defining them as variables instead of the allocation?

That would work. You really want that free() gone, don't you? :-).

Quoted 7 lines
Quoted 3 lines

Yeah I was about to ask the same thing. I see no problem with keeping free() around and I don't think there is an urgent need to convert these pointers to variables.

I've changed them to be variables and the getdents64 now seems to segfault randomly. I will look closely at the code, my guess is that the size of the structure is counted/propagated wrongly somewhere.

The problem is the part where the memcpy is used to copy the members of the kernel structure to the userspace structure, which is the place where it segfaults. The problem seems to be that the memcpy may read bytes after the linux_dirent structure, which doesn't cause problems when the buffer is allocated (as malloc internal data are placed there) but makes the testcase segfault randomly when the structure is declared on the stack.

I've reviewed the testcases and it doesn't make sense to use the userspace dirent at all as the tests care about return values from the syscall and doesn't use the result in any other way.

I'll rewrite them to use the linux_dirent only which will fix all the issues.

Signature · 12 lines
Cyril Hrubis
[email protected]

------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_mar
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
#12 lore raw
In reply to Markos Chandras

testcases/kernel/syscalls/getdents/getdents.h line 28

Quoted 4 lines · On Monday 18 March 2013 06:54:53 Markos Chandras wrote:
testcases/kernel/syscalls/getdents/getdents.h +1 -0
 
+#include <features.h>

this header is not portable. why do you need to include it explicitly ? glibc will include it automatically as needed.
-mike

------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_mar

_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

#13 lore raw

Hi!

Quoted 2 lines

this header is not portable. why do you need to include it explicitly ? glibc will include it automatically as needed.

I've rewritten the tests not to do the dirent translation (which was causing random segfaults). See latest git commit.

Signature · 12 lines
Cyril Hrubis
[email protected]

------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_mar
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list