All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH conntrack 1/4] tests: conntrack: run testfiles in the correct order
@ 2016-01-25 10:40 Asbjørn Sloth Tønnesen
  2016-01-25 10:40 ` [PATCH conntrack 2/4] tests: conntrack: flush stdout to keep sync Asbjørn Sloth Tønnesen
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Asbjørn Sloth Tønnesen @ 2016-01-25 10:40 UTC (permalink / raw)
  To: Pablo Neira Ayuso; +Cc: netfilter-devel, Asbjørn Sloth Tønnesen

Use scandir(3) instead of opendir(3), so that the tests are
run in the expected order, otherwise it doesn't make
sense to prefix the testfiles with a two digit number,
giving the impression that they are run in order.

Signed-off-by: Asbjørn Sloth Tønnesen <ast@fiberby.dk>
---
 tests/conntrack/test-conntrack.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/tests/conntrack/test-conntrack.c b/tests/conntrack/test-conntrack.c
index c9097b6..8f1cea0 100644
--- a/tests/conntrack/test-conntrack.c
+++ b/tests/conntrack/test-conntrack.c
@@ -23,14 +23,16 @@ int main()
 {
 	int ret, ok = 0, bad = 0, line;
 	FILE *fp;
-	DIR *d;
 	char buf[1024];
+	struct dirent **dents;
 	struct dirent *dent;
 	char file[1024];
+	int i,n;
 
-	d = opendir("testsuite");
+	n = scandir("testsuite", &dents, NULL, alphasort);
 
-	while ((dent = readdir(d)) != NULL) {
+	for (i=0;i<n;i++) {
+		dent = dents[i];
 
 		sprintf(file, "testsuite/%s", dent->d_name);
 
@@ -88,7 +90,11 @@ int main()
 		}
 		fclose(fp);
 	}
-	closedir(d);
+
+	for (i=0;i<n;i++) {
+		free(dents[i]);
+	}
+	free(dents);
 
 	fprintf(stdout, "OK: %d BAD: %d\n", ok, bad);
 }
-- 
2.6.4

--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH conntrack 2/4] tests: conntrack: flush stdout to keep sync
  2016-01-25 10:40 [PATCH conntrack 1/4] tests: conntrack: run testfiles in the correct order Asbjørn Sloth Tønnesen
@ 2016-01-25 10:40 ` Asbjørn Sloth Tønnesen
  2016-02-01 10:59   ` Pablo Neira Ayuso
  2016-01-25 10:40 ` [PATCH conntrack 3/4] tests: conntrack: ignore dot files in testdir Asbjørn Sloth Tønnesen
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 8+ messages in thread
From: Asbjørn Sloth Tønnesen @ 2016-01-25 10:40 UTC (permalink / raw)
  To: Pablo Neira Ayuso; +Cc: netfilter-devel, Asbjørn Sloth Tønnesen

Signed-off-by: Asbjørn Sloth Tønnesen <ast@fiberby.dk>
---
 tests/conntrack/test-conntrack.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tests/conntrack/test-conntrack.c b/tests/conntrack/test-conntrack.c
index 8f1cea0..9d06a23 100644
--- a/tests/conntrack/test-conntrack.c
+++ b/tests/conntrack/test-conntrack.c
@@ -65,6 +65,7 @@ int main()
 			strcpy(tmp + strlen(CT_PROG) + 1, buf);
 			printf("(%d) Executing: %s\n", line, tmp);
 
+			fflush(stdout);
 			ret = system(tmp);
 
 			if (WIFEXITED(ret) &&
-- 
2.6.4

--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH conntrack 3/4] tests: conntrack: ignore dot files in testdir
  2016-01-25 10:40 [PATCH conntrack 1/4] tests: conntrack: run testfiles in the correct order Asbjørn Sloth Tønnesen
  2016-01-25 10:40 ` [PATCH conntrack 2/4] tests: conntrack: flush stdout to keep sync Asbjørn Sloth Tønnesen
@ 2016-01-25 10:40 ` Asbjørn Sloth Tønnesen
  2016-02-01 10:59   ` Pablo Neira Ayuso
  2016-01-25 10:40 ` [PATCH conntrack 4/4] tests: conntrack: use local conntrack binary Asbjørn Sloth Tønnesen
  2016-02-01 10:59 ` [PATCH conntrack 1/4] tests: conntrack: run testfiles in the correct order Pablo Neira Ayuso
  3 siblings, 1 reply; 8+ messages in thread
From: Asbjørn Sloth Tønnesen @ 2016-01-25 10:40 UTC (permalink / raw)
  To: Pablo Neira Ayuso; +Cc: netfilter-devel, Asbjørn Sloth Tønnesen

Got tired of having to exit the editor, before testing.

Signed-off-by: Asbjørn Sloth Tønnesen <ast@fiberby.dk>
---
 tests/conntrack/test-conntrack.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tests/conntrack/test-conntrack.c b/tests/conntrack/test-conntrack.c
index 9d06a23..e8d2eb3 100644
--- a/tests/conntrack/test-conntrack.c
+++ b/tests/conntrack/test-conntrack.c
@@ -34,6 +34,8 @@ int main()
 	for (i=0;i<n;i++) {
 		dent = dents[i];
 
+		if (dent->d_name[0] == '.') continue;
+
 		sprintf(file, "testsuite/%s", dent->d_name);
 
 		line = 0;
-- 
2.6.4

--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH conntrack 4/4] tests: conntrack: use local conntrack binary
  2016-01-25 10:40 [PATCH conntrack 1/4] tests: conntrack: run testfiles in the correct order Asbjørn Sloth Tønnesen
  2016-01-25 10:40 ` [PATCH conntrack 2/4] tests: conntrack: flush stdout to keep sync Asbjørn Sloth Tønnesen
  2016-01-25 10:40 ` [PATCH conntrack 3/4] tests: conntrack: ignore dot files in testdir Asbjørn Sloth Tønnesen
@ 2016-01-25 10:40 ` Asbjørn Sloth Tønnesen
  2016-02-01 11:00   ` Pablo Neira Ayuso
  2016-02-01 10:59 ` [PATCH conntrack 1/4] tests: conntrack: run testfiles in the correct order Pablo Neira Ayuso
  3 siblings, 1 reply; 8+ messages in thread
From: Asbjørn Sloth Tønnesen @ 2016-01-25 10:40 UTC (permalink / raw)
  To: Pablo Neira Ayuso; +Cc: netfilter-devel, Asbjørn Sloth Tønnesen

The binary under test should be the one, this ensures
that it is in sync with the tests performed, and that
users who build from source, can test the binary prior
to `make install`.

Signed-off-by: Asbjørn Sloth Tønnesen <ast@fiberby.dk>
---

This is my preference, others might prefer it as it is.
Maybe it should be possible to overwrite with an
enviromental variable or an argument, currently test-conntrack.c
doesn't take any arguments, but run-tests.sh passes the
testdir as an argument.

 tests/conntrack/test-conntrack.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/conntrack/test-conntrack.c b/tests/conntrack/test-conntrack.c
index e8d2eb3..f410c09 100644
--- a/tests/conntrack/test-conntrack.c
+++ b/tests/conntrack/test-conntrack.c
@@ -17,7 +17,7 @@
 #include <sys/wait.h>
 #include <dirent.h>
 
-#define CT_PROG "/usr/sbin/conntrack"
+#define CT_PROG "../../src/conntrack"
 
 int main()
 {
-- 
2.6.4

--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH conntrack 1/4] tests: conntrack: run testfiles in the correct order
  2016-01-25 10:40 [PATCH conntrack 1/4] tests: conntrack: run testfiles in the correct order Asbjørn Sloth Tønnesen
                   ` (2 preceding siblings ...)
  2016-01-25 10:40 ` [PATCH conntrack 4/4] tests: conntrack: use local conntrack binary Asbjørn Sloth Tønnesen
@ 2016-02-01 10:59 ` Pablo Neira Ayuso
  3 siblings, 0 replies; 8+ messages in thread
From: Pablo Neira Ayuso @ 2016-02-01 10:59 UTC (permalink / raw)
  To: Asbjørn Sloth Tønnesen; +Cc: netfilter-devel

On Mon, Jan 25, 2016 at 10:40:27AM +0000, Asbjørn Sloth Tønnesen wrote:
> Use scandir(3) instead of opendir(3), so that the tests are
> run in the expected order, otherwise it doesn't make
> sense to prefix the testfiles with a two digit number,
> giving the impression that they are run in order.

Applied, thanks.
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH conntrack 2/4] tests: conntrack: flush stdout to keep sync
  2016-01-25 10:40 ` [PATCH conntrack 2/4] tests: conntrack: flush stdout to keep sync Asbjørn Sloth Tønnesen
@ 2016-02-01 10:59   ` Pablo Neira Ayuso
  0 siblings, 0 replies; 8+ messages in thread
From: Pablo Neira Ayuso @ 2016-02-01 10:59 UTC (permalink / raw)
  To: Asbjørn Sloth Tønnesen; +Cc: netfilter-devel

Also applied, thanks.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH conntrack 3/4] tests: conntrack: ignore dot files in testdir
  2016-01-25 10:40 ` [PATCH conntrack 3/4] tests: conntrack: ignore dot files in testdir Asbjørn Sloth Tønnesen
@ 2016-02-01 10:59   ` Pablo Neira Ayuso
  0 siblings, 0 replies; 8+ messages in thread
From: Pablo Neira Ayuso @ 2016-02-01 10:59 UTC (permalink / raw)
  To: Asbjørn Sloth Tønnesen; +Cc: netfilter-devel

Applied, thanks.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH conntrack 4/4] tests: conntrack: use local conntrack binary
  2016-01-25 10:40 ` [PATCH conntrack 4/4] tests: conntrack: use local conntrack binary Asbjørn Sloth Tønnesen
@ 2016-02-01 11:00   ` Pablo Neira Ayuso
  0 siblings, 0 replies; 8+ messages in thread
From: Pablo Neira Ayuso @ 2016-02-01 11:00 UTC (permalink / raw)
  To: Asbjørn Sloth Tønnesen; +Cc: netfilter-devel

On Mon, Jan 25, 2016 at 10:40:30AM +0000, Asbjørn Sloth Tønnesen wrote:
> The binary under test should be the one, this ensures
> that it is in sync with the tests performed, and that
> users who build from source, can test the binary prior
> to `make install`.
> 
> Signed-off-by: Asbjørn Sloth Tønnesen <ast@fiberby.dk>
> ---
> 
> This is my preference, others might prefer it as it is.
> Maybe it should be possible to overwrite with an
> enviromental variable or an argument, currently test-conntrack.c
> doesn't take any arguments, but run-tests.sh passes the
> testdir as an argument.

I agree it makes sense to test what you have in your tree without
having to install it.

Applied, thanks!
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2016-02-01 11:00 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-25 10:40 [PATCH conntrack 1/4] tests: conntrack: run testfiles in the correct order Asbjørn Sloth Tønnesen
2016-01-25 10:40 ` [PATCH conntrack 2/4] tests: conntrack: flush stdout to keep sync Asbjørn Sloth Tønnesen
2016-02-01 10:59   ` Pablo Neira Ayuso
2016-01-25 10:40 ` [PATCH conntrack 3/4] tests: conntrack: ignore dot files in testdir Asbjørn Sloth Tønnesen
2016-02-01 10:59   ` Pablo Neira Ayuso
2016-01-25 10:40 ` [PATCH conntrack 4/4] tests: conntrack: use local conntrack binary Asbjørn Sloth Tønnesen
2016-02-01 11:00   ` Pablo Neira Ayuso
2016-02-01 10:59 ` [PATCH conntrack 1/4] tests: conntrack: run testfiles in the correct order Pablo Neira Ayuso

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.