* [LTP] [PATCH v4] syscalls/getdents: Add parameter to test getdents64 syscall
@ 2013-03-18 10:54 Markos Chandras
2013-03-18 12:15 ` chrubis
2013-03-18 18:18 ` Mike Frysinger
0 siblings, 2 replies; 10+ messages in thread
From: Markos Chandras @ 2013-03-18 10:54 UTC (permalink / raw)
To: ltp-list
From: Markos Chandras <markos.chandras@imgtec.com>
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
Signed-off-by: Markos Chandras <markos.chandras@imgtec.com>
---
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(-)
diff --git a/runtest/syscalls b/runtest/syscalls
index c70bcbd..191ad10 100644
--- a/runtest/syscalls
+++ b/runtest/syscalls
@@ -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
diff --git a/testcases/kernel/syscalls/getdents/Makefile b/testcases/kernel/syscalls/getdents/Makefile
index df7b63f..ebcbc4f 100644
--- a/testcases/kernel/syscalls/getdents/Makefile
+++ b/testcases/kernel/syscalls/getdents/Makefile
@@ -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
diff --git a/testcases/kernel/syscalls/getdents/getdents.h b/testcases/kernel/syscalls/getdents/getdents.h
index 1d5e584..ee19ad0 100644
--- a/testcases/kernel/syscalls/getdents/getdents.h
+++ b/testcases/kernel/syscalls/getdents/getdents.h
@@ -25,10 +25,13 @@
#define __GETDENTS_H 1
#include <dirent.h>
+#include <features.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <sys/syscall.h>
+#include "test.h"
+#include "linux_syscall_numbers.h"
/*
* The dirent struct that the C library exports is not the same
@@ -45,6 +48,13 @@ struct linux_dirent {
char d_name[];
};
+struct linux_dirent64 {
+ unsigned long long d_ino;
+ long long d_off;
+ unsigned short d_reclen;
+ char d_name[];
+};
+
static inline int
getdents(unsigned int fd, struct dirent *dirp, unsigned int count)
{
@@ -57,7 +67,43 @@ getdents(unsigned int fd, struct dirent *dirp, unsigned int count)
unsigned int i;
ptrs.buf = buf;
- ret = syscall(SYS_getdents, fd, buf, count);
+ ret = ltp_syscall(__NR_getdents, fd, buf, count);
+ if (ret < 0)
+ return ret;
+
+#define kdircpy(field) memcpy(&dirp[i].field, &ptrs.dirp->field, sizeof(dirp[i].field))
+
+ i = 0;
+ while (i < count && i < ret) {
+ unsigned long reclen;
+
+ kdircpy(d_ino);
+ kdircpy(d_reclen);
+ reclen = dirp[i].d_reclen;
+ kdircpy(d_off);
+ strcpy(dirp[i].d_name, ptrs.dirp->d_name);
+
+ ptrs.buf += reclen;
+
+ i += reclen;
+ }
+
+ return ret;
+}
+
+static inline int
+getdents64(unsigned int fd, struct dirent64 *dirp, unsigned int count)
+{
+ union {
+ struct linux_dirent64 *dirp;
+ char *buf;
+ } ptrs;
+ char buf[count];
+ long ret;
+ unsigned int i;
+
+ ptrs.buf = buf;
+ ret = ltp_syscall(__NR_getdents64, fd, buf, count);
if (ret < 0)
return ret;
diff --git a/testcases/kernel/syscalls/getdents/getdents01.c b/testcases/kernel/syscalls/getdents/getdents01.c
index af0ac1a..b9cd28c 100644
--- a/testcases/kernel/syscalls/getdents/getdents01.c
+++ b/testcases/kernel/syscalls/getdents/getdents01.c
@@ -44,10 +44,12 @@
* -f : Turn off functionality Testing.
* -i n : Execute test n times.
* -I x : Execute test for x seconds.
+ * -l : Test the getdents64 system call.
* -P x : Pause for x seconds between iterations.
* -t : Turn on syscall timing.
*
* HISTORY
+ * 03/2013 - Added -l option by Markos Chandras
* 03/2001 - Written by Wayne Boyer
*
* RESTRICTIONS
@@ -71,6 +73,18 @@ void setup(void);
char *TCID = "getdents01";
int TST_TOTAL = 1;
+static int longsyscall;
+
+option_t Options[] = {
+ {"l", &longsyscall, NULL}, /* -l long option. Tests getdents64 */
+ {NULL, NULL, NULL}
+};
+
+void help(void)
+{
+ printf(" -l Test the getdents64 system call\n");
+}
+
int main(int ac, char **av)
{
int lc;
@@ -79,13 +93,28 @@ int main(int ac, char **av)
int count;
size_t size = 0;
char *dir_name = NULL;
- struct dirent *dirp;
+ struct dirent64 *dirp64 = NULL;
+ struct dirent *dirp = NULL;
- if ((msg = parse_opts(ac, av, NULL, NULL)) != NULL)
+ if ((msg = parse_opts(ac, av, Options, &help)) != NULL)
tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
setup();
+ /*
+ * Set up count to be equal to the sizeof struct dirent,
+ * just to pick a decent size.
+ */
+ if (longsyscall) {
+ if ((dirp64 = malloc(sizeof(struct dirent64))) == NULL)
+ tst_brkm(TBROK, cleanup, "malloc failed");
+ count = (int)sizeof(struct dirent64);
+ } else {
+ if ((dirp = malloc(sizeof(struct dirent))) == NULL)
+ tst_brkm(TBROK, cleanup, "malloc failed");
+ count = (int)sizeof(struct dirent);
+ }
+
for (lc = 0; TEST_LOOPING(lc); lc++) {
tst_count = 0;
@@ -93,20 +122,14 @@ int main(int ac, char **av)
tst_brkm(TBROK, cleanup, "Can not get current "
"directory name");
- if ((dirp = malloc(sizeof(struct dirent))) == NULL)
- tst_brkm(TBROK, cleanup, "malloc failed");
-
- /*
- * Set up count to be equal to the sizeof struct dirent,
- * just to pick a decent size.
- */
-
- count = (int)sizeof(struct dirent);
-
if ((fd = open(dir_name, O_RDONLY)) == -1)
tst_brkm(TBROK, cleanup, "open of directory failed");
- rval = getdents(fd, dirp, count);
+ if (longsyscall)
+ rval = getdents64(fd, dirp64, count);
+ else
+ rval = getdents(fd, dirp, count);
+
if (rval < 0) {
TEST_ERROR_LOG(errno);
@@ -127,12 +150,15 @@ int main(int ac, char **av)
free(dir_name);
dir_name = NULL;
- free(dirp);
-
if ((rval = close(fd)) == -1)
tst_brkm(TBROK, cleanup, "file close failed");
}
+ if (longsyscall)
+ free(dirp64);
+ else
+ free(dirp);
+
cleanup();
tst_exit();
diff --git a/testcases/kernel/syscalls/getdents/getdents02.c b/testcases/kernel/syscalls/getdents/getdents02.c
index ee34de2..971b755 100644
--- a/testcases/kernel/syscalls/getdents/getdents02.c
+++ b/testcases/kernel/syscalls/getdents/getdents02.c
@@ -40,10 +40,12 @@
* -e : Turn on errno logging.
* -i n : Execute test n times.
* -I x : Execute test for x seconds.
+ * -l : Test the getdents64 system call.
* -P x : Pause for x seconds between iterations.
* -t : Turn on syscall timing.
*
* HISTORY
+ * 03/2013 - Added -l option by Markos Chandras
* 03/2001 - Written by Wayne Boyer
*
* RESTRICTIONS
@@ -69,6 +71,18 @@ int TST_TOTAL = 1;
int exp_enos[] = { EBADF, 0 }; /* 0 terminated list of expected errnos */
+static int longsyscall;
+
+option_t Options[] = {
+ {"l", &longsyscall, NULL}, /* -l long option. Tests getdents64 */
+ {NULL, NULL, NULL}
+};
+
+void help(void)
+{
+ printf(" -l Test the getdents64 system call\n");
+}
+
int main(int ac, char **av)
{
int lc;
@@ -77,13 +91,24 @@ int main(int ac, char **av)
int count;
size_t size = 0;
char *dir_name = NULL;
- struct dirent *dirp;
+ struct dirent64 *dirp64 = NULL;
+ struct dirent *dirp = NULL;
- if ((msg = parse_opts(ac, av, NULL, NULL)) != NULL)
+ if ((msg = parse_opts(ac, av, Options, &help)) != NULL)
tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
setup();
+ if (longsyscall) {
+ if ((dirp64 = malloc(sizeof(struct dirent))) == NULL)
+ tst_brkm(TBROK, cleanup, "malloc failed");
+ count = (int)sizeof(struct dirent64);
+ } else {
+ if ((dirp = malloc(sizeof(struct dirent))) == NULL)
+ tst_brkm(TBROK, cleanup, "malloc failed");
+ count = (int)sizeof(struct dirent);
+ }
+
for (lc = 0; TEST_LOOPING(lc); lc++) {
tst_count = 0;
@@ -91,16 +116,14 @@ int main(int ac, char **av)
tst_brkm(TBROK, cleanup, "Can not get current "
"directory name");
- if ((dirp = malloc(sizeof(struct dirent))) == NULL)
- tst_brkm(TBROK, cleanup, "malloc failed");
-
- count = (int)sizeof(struct dirent);
-
/* set up a bad file descriptor */
fd = -5;
- rval = getdents(fd, dirp, count);
+ if (longsyscall)
+ rval = getdents64(fd, dirp64, count);
+ else
+ rval = getdents(fd, dirp, count);
/*
* Hopefully we get an error due to the bad file descriptor.
@@ -124,9 +147,13 @@ int main(int ac, char **av)
free(dir_name);
dir_name = NULL;
- free(dirp);
}
+ if (longsyscall)
+ free(dirp64);
+ else
+ free(dirp);
+
cleanup();
tst_exit();
diff --git a/testcases/kernel/syscalls/getdents/getdents03.c b/testcases/kernel/syscalls/getdents/getdents03.c
index 700e54b..6b4f88b 100644
--- a/testcases/kernel/syscalls/getdents/getdents03.c
+++ b/testcases/kernel/syscalls/getdents/getdents03.c
@@ -43,10 +43,12 @@
* -e : Turn on errno logging.
* -i n : Execute test n times.
* -I x : Execute test for x seconds.
+ * -l : Test the getdents64 system call.
* -P x : Pause for x seconds between iterations.
* -t : Turn on syscall timing.
*
* HISTORY
+ * 03/2013 - Added -l option by Markos Chandras
* 03/2001 - Written by Wayne Boyer
*
* RESTRICTIONS
@@ -72,6 +74,18 @@ int TST_TOTAL = 1;
int exp_enos[] = { EINVAL, 0 }; /* 0 terminated list of expected errnos */
+static int longsyscall;
+
+option_t Options[] = {
+ {"l", &longsyscall, NULL}, /* -l long option. Tests getdents64 */
+ {NULL, NULL, NULL}
+};
+
+void help(void)
+{
+ printf(" -l Test the getdents64 system call\n");
+}
+
int main(int ac, char **av)
{
int lc;
@@ -80,13 +94,22 @@ int main(int ac, char **av)
int count;
size_t size = 0;
char *dir_name = NULL;
- struct dirent *dirp;
+ struct dirent64 *dirp64 = NULL;
+ struct dirent *dirp = NULL;
- if ((msg = parse_opts(ac, av, NULL, NULL)) != NULL)
+ if ((msg = parse_opts(ac, av, Options, &help)) != NULL)
tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
setup();
+ if (longsyscall) {
+ if ((dirp64 = malloc(sizeof(struct dirent64))) == NULL)
+ tst_brkm(TBROK, cleanup, "malloc failed");
+ } else {
+ if ((dirp = malloc(sizeof(struct dirent))) == NULL)
+ tst_brkm(TBROK, cleanup, "malloc failed");
+ }
+
for (lc = 0; TEST_LOOPING(lc); lc++) {
tst_count = 0;
@@ -94,9 +117,6 @@ int main(int ac, char **av)
tst_brkm(TBROK, cleanup, "Can not get current "
"directory name");
- if ((dirp = malloc(sizeof(struct dirent))) == NULL)
- tst_brkm(TBROK, cleanup, "malloc failed");
-
/* Set count to be very small. The result should be EINVAL */
count = 1;
@@ -104,7 +124,10 @@ int main(int ac, char **av)
if ((fd = open(dir_name, O_RDONLY)) == -1)
tst_brkm(TBROK, cleanup, "open of directory failed");
- rval = getdents(fd, dirp, count);
+ if (longsyscall)
+ rval = getdents64(fd, dirp64, count);
+ else
+ rval = getdents(fd, dirp, count);
/*
* Hopefully we get an error due to the small buffer.
@@ -129,12 +152,15 @@ int main(int ac, char **av)
free(dir_name);
dir_name = NULL;
- free(dirp);
-
if ((rval = close(fd)) == -1)
tst_brkm(TBROK, cleanup, "fd close failed");
}
+ if (longsyscall)
+ free(dirp64);
+ else
+ free(dirp);
+
cleanup();
tst_exit();
diff --git a/testcases/kernel/syscalls/getdents/getdents04.c b/testcases/kernel/syscalls/getdents/getdents04.c
index 89479a4..3dc1030 100644
--- a/testcases/kernel/syscalls/getdents/getdents04.c
+++ b/testcases/kernel/syscalls/getdents/getdents04.c
@@ -43,10 +43,12 @@
* -e : Turn on errno logging.
* -i n : Execute test n times.
* -I x : Execute test for x seconds.
+ * -l : Test the getdents64 system call.
* -P x : Pause for x seconds between iterations.
* -t : Turn on syscall timing.
*
* HISTORY
+ * 03/2013 - Added -l option by Markos Chandras
* 03/2001 - Written by Wayne Boyer
*
* RESTRICTIONS
@@ -73,6 +75,18 @@ int TST_TOTAL = 1;
int exp_enos[] = { ENOTDIR, 0 }; /* 0 terminated list of expected errnos */
+static int longsyscall;
+
+option_t Options[] = {
+ {"l", &longsyscall, NULL}, /* -l long option. Tests getdents64 */
+ {NULL, NULL, NULL}
+};
+
+void help(void)
+{
+ printf(" -l Test the getdents64 system call\n");
+}
+
int main(int ac, char **av)
{
int lc;
@@ -80,15 +94,26 @@ int main(int ac, char **av)
int count, rval, fd;
size_t size = 0;
char *dir_name = NULL;
- struct dirent *dirp;
struct stat *sbuf;
char *newfile;
+ struct dirent64 *dirp64 = NULL;
+ struct dirent *dirp = NULL;
- if ((msg = parse_opts(ac, av, NULL, NULL)) != NULL)
+ if ((msg = parse_opts(ac, av, Options, &help)) != NULL)
tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
setup();
+ if (longsyscall) {
+ if ((dirp64 = malloc(sizeof(struct dirent64))) == NULL)
+ tst_brkm(TBROK, cleanup, "malloc failed");
+ count = (int)sizeof(struct dirent64);
+ } else {
+ if ((dirp = malloc(sizeof(struct dirent))) == NULL)
+ tst_brkm(TBROK, cleanup, "malloc failed");
+ count = (int)sizeof(struct dirent);
+ }
+
for (lc = 0; TEST_LOOPING(lc); lc++) {
tst_count = 0;
@@ -96,11 +121,6 @@ int main(int ac, char **av)
tst_brkm(TBROK, cleanup, "Can not get current "
"directory name");
- if ((dirp = malloc(sizeof(struct dirent))) == NULL)
- tst_brkm(TBROK, cleanup, "malloc failed");
-
- count = (int)sizeof(struct dirent);
-
/* set up some space for a file name */
if ((newfile = malloc(sizeof(char) * 20)) == NULL)
tst_brkm(TBROK, cleanup, "newfile malloc failed");
@@ -123,7 +143,10 @@ int main(int ac, char **av)
if (S_ISDIR(sbuf->st_mode))
tst_brkm(TBROK, cleanup, "fd is a directory");
- rval = getdents(fd, dirp, count);
+ if (longsyscall)
+ rval = getdents64(fd, dirp64, count);
+ else
+ rval = getdents(fd, dirp, count);
/*
* Calling with a non directory file descriptor should give
@@ -149,14 +172,17 @@ int main(int ac, char **av)
free(dir_name);
dir_name = NULL;
- free(dirp);
-
if ((rval = close(fd)) == -1)
tst_brkm(TBROK, cleanup, "fd close failed");
if ((rval = unlink(newfile)) == -1)
tst_brkm(TBROK, cleanup, "file unlink failed");
}
+ if (longsyscall)
+ free(dirp64);
+ else
+ free(dirp);
+
cleanup();
tst_exit();
--
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
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [LTP] [PATCH v4] syscalls/getdents: Add parameter to test getdents64 syscall
2013-03-18 10:54 [LTP] [PATCH v4] syscalls/getdents: Add parameter to test getdents64 syscall Markos Chandras
@ 2013-03-18 12:15 ` chrubis
[not found] ` <CAG2jQ8gAOvbKsoggS3o1a_9zDfVhUU9WUpxgY0g_Mp-ZcCC99w@mail.gmail.com>
[not found] ` <1004735862.20216185.1363612313920.JavaMail.root@redhat.com>
2013-03-18 18:18 ` Mike Frysinger
1 sibling, 2 replies; 10+ messages in thread
From: chrubis @ 2013-03-18 12:15 UTC (permalink / raw)
To: Markos Chandras; +Cc: ltp-list
Hi!
> + 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.
--
Cyril Hrubis
chrubis@suse.cz
------------------------------------------------------------------------------
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
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [LTP] [PATCH v4] syscalls/getdents: Add parameter to test getdents64 syscall
[not found] ` <CAG2jQ8gAOvbKsoggS3o1a_9zDfVhUU9WUpxgY0g_Mp-ZcCC99w@mail.gmail.com>
@ 2013-03-18 12:29 ` chrubis
2013-03-18 13:21 ` chrubis
0 siblings, 1 reply; 10+ messages in thread
From: chrubis @ 2013-03-18 12:29 UTC (permalink / raw)
To: Markos Chandras; +Cc: ltp-list
Hi!
> >> + 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.
> >
> > --
> > Cyril Hrubis
> > chrubis@suse.cz
>
> Hi Cyril,
>
> I understand. Should I send a new patch or maybe you could fix it
> before committing it?
I will fix that.
--
Cyril Hrubis
chrubis@suse.cz
------------------------------------------------------------------------------
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
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [LTP] [PATCH v4] syscalls/getdents: Add parameter to test getdents64 syscall
2013-03-18 12:29 ` chrubis
@ 2013-03-18 13:21 ` chrubis
0 siblings, 0 replies; 10+ messages in thread
From: chrubis @ 2013-03-18 13:21 UTC (permalink / raw)
To: Markos Chandras; +Cc: ltp-list
Hi!
> > 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).
--
Cyril Hrubis
chrubis@suse.cz
------------------------------------------------------------------------------
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
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [LTP] [PATCH v4] syscalls/getdents: Add parameter to test getdents64 syscall
[not found] ` <1004735862.20216185.1363612313920.JavaMail.root@redhat.com>
@ 2013-03-18 13:26 ` chrubis
[not found] ` <1209119378.20265155.1363614409485.JavaMail.root@redhat.com>
0 siblings, 1 reply; 10+ messages in thread
From: chrubis @ 2013-03-18 13:26 UTC (permalink / raw)
To: Jan Stancek; +Cc: ltp-list
Hi!
> > 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?
--
Cyril Hrubis
chrubis@suse.cz
------------------------------------------------------------------------------
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
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [LTP] [PATCH v4] syscalls/getdents: Add parameter to test getdents64 syscall
[not found] ` <1209119378.20265155.1363614409485.JavaMail.root@redhat.com>
@ 2013-03-18 14:06 ` chrubis
[not found] ` <CAG2jQ8i1oovEVtF2hayXzeBzpWb78q=ntN_EJ3w0KJ3KpeXCzQ@mail.gmail.com>
1 sibling, 0 replies; 10+ messages in thread
From: chrubis @ 2013-03-18 14:06 UTC (permalink / raw)
To: Jan Stancek; +Cc: ltp-list
Hi!
> > > > 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?
>
> 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...
--
Cyril Hrubis
chrubis@suse.cz
------------------------------------------------------------------------------
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
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [LTP] [PATCH v4] syscalls/getdents: Add parameter to test getdents64 syscall
[not found] ` <CAG2jQ8i1oovEVtF2hayXzeBzpWb78q=ntN_EJ3w0KJ3KpeXCzQ@mail.gmail.com>
@ 2013-03-18 14:37 ` chrubis
2013-03-18 17:08 ` chrubis
0 siblings, 1 reply; 10+ messages in thread
From: chrubis @ 2013-03-18 14:37 UTC (permalink / raw)
To: Markos Chandras; +Cc: ltp-list
Hi!
> >> > > 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?
> >
> > 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.
--
Cyril Hrubis
chrubis@suse.cz
------------------------------------------------------------------------------
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
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [LTP] [PATCH v4] syscalls/getdents: Add parameter to test getdents64 syscall
2013-03-18 14:37 ` chrubis
@ 2013-03-18 17:08 ` chrubis
0 siblings, 0 replies; 10+ messages in thread
From: chrubis @ 2013-03-18 17:08 UTC (permalink / raw)
To: Markos Chandras; +Cc: ltp-list
Hi!
> > >> > 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? :-).
> > >
> >
> > 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.
--
Cyril Hrubis
chrubis@suse.cz
------------------------------------------------------------------------------
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
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [LTP] [PATCH v4] syscalls/getdents: Add parameter to test getdents64 syscall
2013-03-18 10:54 [LTP] [PATCH v4] syscalls/getdents: Add parameter to test getdents64 syscall Markos Chandras
2013-03-18 12:15 ` chrubis
@ 2013-03-18 18:18 ` Mike Frysinger
2013-03-18 18:30 ` chrubis
1 sibling, 1 reply; 10+ messages in thread
From: Mike Frysinger @ 2013-03-18 18:18 UTC (permalink / raw)
To: ltp-list
[-- Attachment #1.1: Type: Text/Plain, Size: 330 bytes --]
On Monday 18 March 2013 06:54:53 Markos Chandras wrote:
> --- a/testcases/kernel/syscalls/getdents/getdents.h
> +++ b/testcases/kernel/syscalls/getdents/getdents.h
>
> +#include <features.h>
this header is not portable. why do you need to include it explicitly ?
glibc will include it automatically as needed.
-mike
[-- Attachment #1.2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
[-- Attachment #2: Type: text/plain, Size: 238 bytes --]
------------------------------------------------------------------------------
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
[-- Attachment #3: Type: text/plain, Size: 155 bytes --]
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [LTP] [PATCH v4] syscalls/getdents: Add parameter to test getdents64 syscall
2013-03-18 18:18 ` Mike Frysinger
@ 2013-03-18 18:30 ` chrubis
0 siblings, 0 replies; 10+ messages in thread
From: chrubis @ 2013-03-18 18:30 UTC (permalink / raw)
To: Mike Frysinger; +Cc: ltp-list
Hi!
> 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.
--
Cyril Hrubis
chrubis@suse.cz
------------------------------------------------------------------------------
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
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2013-03-18 18:30 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-18 10:54 [LTP] [PATCH v4] syscalls/getdents: Add parameter to test getdents64 syscall Markos Chandras
2013-03-18 12:15 ` chrubis
[not found] ` <CAG2jQ8gAOvbKsoggS3o1a_9zDfVhUU9WUpxgY0g_Mp-ZcCC99w@mail.gmail.com>
2013-03-18 12:29 ` chrubis
2013-03-18 13:21 ` chrubis
[not found] ` <1004735862.20216185.1363612313920.JavaMail.root@redhat.com>
2013-03-18 13:26 ` chrubis
[not found] ` <1209119378.20265155.1363614409485.JavaMail.root@redhat.com>
2013-03-18 14:06 ` chrubis
[not found] ` <CAG2jQ8i1oovEVtF2hayXzeBzpWb78q=ntN_EJ3w0KJ3KpeXCzQ@mail.gmail.com>
2013-03-18 14:37 ` chrubis
2013-03-18 17:08 ` chrubis
2013-03-18 18:18 ` Mike Frysinger
2013-03-18 18:30 ` chrubis
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox