From ac6fc77f0b2e371f2d2cac2862415ee3df343780 Mon Sep 17 00:00:00 2001 From: "root (spook.local)" Date: Sun, 20 Mar 2011 18:14:16 +0200 Subject: [PATCH] raw: Modify tests messages & structure --- src/raw/test/Makefile | 2 +- src/raw/test/test.c | 22 +++++++++++----------- src/raw/test/test.h | 4 ++++ src/raw/test/test_dummy.c | 14 ++++++++++++-- src/raw/test/test_sw.h | 22 +++++++++++----------- src/raw/test/test_sw_bind.c | 10 +++++++++- src/raw/test/test_sw_close.c | 10 +++++++++- src/raw/test/test_sw_getsockname.c | 10 +++++++++- src/raw/test/test_sw_getsockopt.c | 10 +++++++++- src/raw/test/test_sw_recvfrom.c | 10 +++++++++- src/raw/test/test_sw_recvmsg.c | 10 +++++++++- src/raw/test/test_sw_sendmsg.c | 10 +++++++++- src/raw/test/test_sw_sendto.c | 10 +++++++++- src/raw/test/test_sw_shutdown.c | 12 ++++++++++-- src/raw/test/test_sw_socket.c | 10 +++++++++- 15 files changed, 130 insertions(+), 36 deletions(-) diff --git a/src/raw/test/Makefile b/src/raw/test/Makefile index 46ca48a..6137f0a 100644 --- a/src/raw/test/Makefile +++ b/src/raw/test/Makefile @@ -6,7 +6,7 @@ CFLAGS = -Wall -g all: test test: test.o test_sw_socket.o test_sw_bind.o test_sw_getsockname.o \ - test_sw_sendto.o test_sw_recvfrom.o test_sw_sendmsg.o \ + test_sw_getsockopt.o test_sw_sendto.o test_sw_recvfrom.o test_sw_sendmsg.o \ test_sw_recvmsg.o test_sw_setsockopt.o test_sw_getsockopt.o \ test_sw_shutdown.o test_sw_close.o test_dummy.o diff --git a/src/raw/test/test.c b/src/raw/test/test.c index 3364e05..df5bafb 100644 --- a/src/raw/test/test.c +++ b/src/raw/test/test.c @@ -13,17 +13,17 @@ static void (*test_fun_array[])(void) = { NULL, - dummy_1_eq_1, - dummy_1_neq_0, - socket_dummy, - bind_dummy, - getsockname_dummy, - sendto_dummy, - recvfrom_dummy, - sendmsg_dummy, - recvmsg_dummy, - shutdown_dummy, - close_dummy, + test_dummy, + socket_test_suite, + bind_test_suite, + getsockname_test_suite, + getsockopt_test_suite, + sendto_test_suite, + recvfrom_test_suite, + sendmsg_test_suite, + recvmsg_test_suite, + shutdown_test_suite, + close_test_suite, }; static void usage(const char *argv0) diff --git a/src/raw/test/test.h b/src/raw/test/test.h index 1de3cb1..a830632 100644 --- a/src/raw/test/test.h +++ b/src/raw/test/test.h @@ -54,6 +54,10 @@ extern "C" { fflush(stdout); \ } while (0) +#define start_suite() \ + do { \ + printf("\n==== Starting %s ====\n", __FUNCTION__); \ + } while (0) #ifdef __cplusplus } #endif diff --git a/src/raw/test/test_dummy.c b/src/raw/test/test_dummy.c index 99f29d2..3141301 100644 --- a/src/raw/test/test_dummy.c +++ b/src/raw/test/test_dummy.c @@ -4,12 +4,22 @@ #include "test.h" -void dummy_1_eq_1(void) +static void dummy_1_eq_1(void); +static void dummy_1_neq_0(void); + +void test_dummy(void) +{ + start_suite(); + dummy_1_eq_1(); + dummy_1_neq_0(); +} + +static void dummy_1_eq_1(void) { test(1 == 1); } -void dummy_1_neq_0(void) +static void dummy_1_neq_0(void) { test(1 != 0); } diff --git a/src/raw/test/test_sw.h b/src/raw/test/test_sw.h index 145fa45..c47f278 100644 --- a/src/raw/test/test_sw.h +++ b/src/raw/test/test_sw.h @@ -9,17 +9,17 @@ extern "C" { #endif -void dummy_1_eq_1(void); -void dummy_1_neq_0(void); -void socket_dummy(void); -void bind_dummy(void); -void getsockname_dummy(void); -void sendto_dummy(void); -void recvfrom_dummy(void); -void sendmsg_dummy(void); -void recvmsg_dummy(void); -void shutdown_dummy(void); -void close_dummy(void); +void test_dummy(void); +void socket_test_suite(void); +void bind_test_suite(void); +void getsockname_test_suite(void); +void getsockopt_test_suite(void); +void sendto_test_suite(void); +void recvfrom_test_suite(void); +void sendmsg_test_suite(void); +void recvmsg_test_suite(void); +void shutdown_test_suite(void); +void close_test_suite(void); /* TODO: fill with test function headers. */ diff --git a/src/raw/test/test_sw_bind.c b/src/raw/test/test_sw_bind.c index b3ee88e..27cabdf 100644 --- a/src/raw/test/test_sw_bind.c +++ b/src/raw/test/test_sw_bind.c @@ -5,7 +5,15 @@ #include "test_sw.h" #include "test.h" -void bind_dummy(void) +static void bind_dummy(void); + +void bind_test_suite(void) +{ + start_suite(); + bind_dummy(); +} + +static void bind_dummy(void) { test(1 == 1); } diff --git a/src/raw/test/test_sw_close.c b/src/raw/test/test_sw_close.c index 734bc43..11ad085 100644 --- a/src/raw/test/test_sw_close.c +++ b/src/raw/test/test_sw_close.c @@ -5,7 +5,15 @@ #include "test_sw.h" #include "test.h" -void close_dummy(void) +static void close_dummy(void); + +void close_test_suite(void) +{ + start_suite(); + close_dummy(); +} + +static void close_dummy(void) { test(1 == 1); } diff --git a/src/raw/test/test_sw_getsockname.c b/src/raw/test/test_sw_getsockname.c index e93ec0e..597b699 100644 --- a/src/raw/test/test_sw_getsockname.c +++ b/src/raw/test/test_sw_getsockname.c @@ -5,7 +5,15 @@ #include "test_sw.h" #include "test.h" -void getsockname_dummy(void) +static void getsockname_dummy(void); + +void getsockname_test_suite(void) +{ + start_suite(); + getsockname_dummy(); +} + +static void getsockname_dummy(void) { test(1 == 1); } diff --git a/src/raw/test/test_sw_getsockopt.c b/src/raw/test/test_sw_getsockopt.c index e727802..bce215c 100644 --- a/src/raw/test/test_sw_getsockopt.c +++ b/src/raw/test/test_sw_getsockopt.c @@ -5,7 +5,15 @@ #include "test_sw.h" #include "test.h" -void getsockopt_dummy(void) +static void getsockopt_dummy(void); + +void getsockopt_test_suite(void) +{ + start_suite(); + getsockopt_dummy(); +} + +static void getsockopt_dummy(void) { test(1 == 1); } diff --git a/src/raw/test/test_sw_recvfrom.c b/src/raw/test/test_sw_recvfrom.c index aec8cf1..031b839 100644 --- a/src/raw/test/test_sw_recvfrom.c +++ b/src/raw/test/test_sw_recvfrom.c @@ -5,7 +5,15 @@ #include "test_sw.h" #include "test.h" -void recvfrom_dummy(void) +static void recvfrom_dummy(void); + +void recvfrom_test_suite(void) +{ + start_suite(); + recvfrom_dummy(); +} + +static void recvfrom_dummy(void) { test(1 == 1); } diff --git a/src/raw/test/test_sw_recvmsg.c b/src/raw/test/test_sw_recvmsg.c index 8d07d18..0a25e2f 100644 --- a/src/raw/test/test_sw_recvmsg.c +++ b/src/raw/test/test_sw_recvmsg.c @@ -5,7 +5,15 @@ #include "test_sw.h" #include "test.h" -void recvmsg_dummy(void) +static void recvmsg_dummy(void); + +void recvmsg_test_suite(void) +{ + start_suite(); + recvmsg_dummy(); +} + +static void recvmsg_dummy(void) { test(1 == 1); } diff --git a/src/raw/test/test_sw_sendmsg.c b/src/raw/test/test_sw_sendmsg.c index 9be7d22..67348e1 100644 --- a/src/raw/test/test_sw_sendmsg.c +++ b/src/raw/test/test_sw_sendmsg.c @@ -5,7 +5,15 @@ #include "test_sw.h" #include "test.h" -void sendmsg_dummy(void) +static void sendmsg_dummy(void); + +void sendmsg_test_suite(void) +{ + start_suite(); + sendmsg_dummy(); +} + +static void sendmsg_dummy(void) { test(1 == 1); } diff --git a/src/raw/test/test_sw_sendto.c b/src/raw/test/test_sw_sendto.c index 97f8d29..2204d34 100644 --- a/src/raw/test/test_sw_sendto.c +++ b/src/raw/test/test_sw_sendto.c @@ -5,7 +5,15 @@ #include "test_sw.h" #include "test.h" -void sendto_dummy(void) +static void sendto_dummy(void); + +void sendto_test_suite(void) +{ + start_suite(); + sendto_dummy(); +} + +static void sendto_dummy(void) { test(1 == 1); } diff --git a/src/raw/test/test_sw_shutdown.c b/src/raw/test/test_sw_shutdown.c index 0777d80..93df05a 100644 --- a/src/raw/test/test_sw_shutdown.c +++ b/src/raw/test/test_sw_shutdown.c @@ -5,7 +5,15 @@ #include "test_sw.h" #include "test.h" -void shutdown_dummy(void) +static void shutdown_dummy(void); + +void shutdown_test_suite(void) { - test(1 == 1); + start_suite(); + shutdown_dummy(); } + +static void shutdown_dummy(void) +{ + test(1 == 1); +} diff --git a/src/raw/test/test_sw_socket.c b/src/raw/test/test_sw_socket.c index 89d4baa..c6f3f83 100644 --- a/src/raw/test/test_sw_socket.c +++ b/src/raw/test/test_sw_socket.c @@ -5,7 +5,15 @@ #include "test_sw.h" #include "test.h" -void socket_dummy(void) +static void socket_dummy(void); + +void socket_test_suite(void) +{ + start_suite(); + socket_dummy(); +} + +static void socket_dummy(void) { test(1 == 1); } -- 2.20.1