diff --git a/misc/http_response.c b/misc/http_response.c
index 3cecc4f..231ab1c 100644
--- a/misc/http_response.c
+++ b/misc/http_response.c
@@ -3,19 +3,12 @@
#include <assert.h>
#include "../http/types.h"
-// Function to calculate and print offsets
-void print_offsets() {
- printf("Offset of protocol: %zu\n", offsetof(struct http_response, protocol));
- printf("Offset of code: %zu\n", offsetof(struct http_response, code));
- printf("Offset of message: %zu\n", offsetof(struct http_response, message));
- printf("Offset of headers: %zu\n", offsetof(struct http_response, headers));
- printf("Offset of body: %zu\n", offsetof(struct http_response, body));
-}
-
-// Main function
int main() {
- // Print offsets
- print_offsets();
-
- return 0;
-}
\ No newline at end of file
+ printf("offsetof(s_http_response, protocol) = %zu\n", offsetof(s_http_response, protocol));
+ printf("offsetof(s_http_response, code) = %zu\n", offsetof(s_http_response, code));
+ printf("offsetof(s_http_response, message) = %zu\n", offsetof(s_http_response, message));
+ printf("offsetof(s_http_response, headers) = %zu\n", offsetof(s_http_response, headers));
+ printf("offsetof(s_http_response, body) = %zu\n", offsetof(s_http_response, body));
+ printf("sizeof(s_http_response) = %zu\n", sizeof(s_http_response));
+ return 0;
+}
diff --git a/test/configure b/test/configure
index 9f98f67..9272dfe 100755
--- a/test/configure
+++ b/test/configure
@@ -41,6 +41,7 @@ OBJECTS_DEBUG="$(c2ext .debug.lo "$SOURCES")"
echo "OBJECTS_DEBUG = $OBJECTS_DEBUG" >> ${CONFIG_MK}
# Common config for all targets
+CPPFLAGS="$CPPFLAGS -I.."
CFLAGS="$CFLAGS -W -Wall -Werror -std=c11 -pedantic -pipe"
LDFLAGS="$LDFLAGS -rdynamic"
config_asan
@@ -54,6 +55,7 @@ config_lib dl -ldl 2>/dev/null
LIBS="$LIBS -pthread -lm"
# Asan config
+CPPFLAGS_ASAN="$CPPFLAGS"
CFLAGS_ASAN="$CFLAGS -fsanitize=address -O1 -fno-omit-frame-pointer -g"
LDFLAGS_ASAN="$LDFLAGS"
LIBKC3_ASAN=../libkc3/libkc3_asan.la
@@ -61,6 +63,7 @@ LOCAL_LIBS_ASAN="$LIBKC3_ASAN"
LIBS_ASAN="$LOCAL_LIBS_ASAN $LIBS"
# Coverage config
+CPPFLAGS_COV="$CPPFLAGS"
CFLAGS_COV="$CFLAGS -fprofile-arcs -ftest-coverage"
LDFLAGS_COV="$LDFLAGS --coverage"
LIBKC3_COV=../libkc3/libkc3_cov.la
@@ -68,6 +71,7 @@ LOCAL_LIBS_COV="$LIBKC3_COV"
LIBS_COV="$LOCAL_LIBS_COV $LIBS -lgcov"
# Debug config
+CPPFLAGS_DEBUG="$CPPFLAGS"
CFLAGS_DEBUG="$CFLAGS -DDEBUG -O0 -g"
LDFLAGS_DEBUG="$LDFLAGS"
LIBKC3_DEBUG=../libkc3/libkc3_debug.la
@@ -90,14 +94,17 @@ echo "CFLAGS = $CFLAGS" >> ${CONFIG_MK}
echo "LDFLAGS = $LDFLAGS" >> ${CONFIG_MK}
echo "LIBS = $LIBS" >> ${CONFIG_MK}
echo >> ${CONFIG_MK}
+echo "CPPFLAGS_ASAN = $CPPFLAGS_ASAN" >> ${CONFIG_MK}
echo "CFLAGS_ASAN = $CFLAGS_ASAN" >> ${CONFIG_MK}
echo "LDFLAGS_ASAN = $LDFLAGS_ASAN" >> ${CONFIG_MK}
echo "LIBS_ASAN = $LIBS_ASAN" >> ${CONFIG_MK}
echo >> ${CONFIG_MK}
+echo "CPPFLAGS_COV = $CPPFLAGS_COV" >> ${CONFIG_MK}
echo "CFLAGS_COV = $CFLAGS_COV" >> ${CONFIG_MK}
echo "LDFLAGS_COV = $LDFLAGS_COV" >> ${CONFIG_MK}
echo "LIBS_COV = $LIBS_COV" >> ${CONFIG_MK}
echo >> ${CONFIG_MK}
+echo "CPPFLAGS_DEBUG = $CPPFLAGS_DEBUG" >> ${CONFIG_MK}
echo "CFLAGS_DEBUG = $CFLAGS_DEBUG" >> ${CONFIG_MK}
echo "LDFLAGS_DEBUG = $LDFLAGS_DEBUG" >> ${CONFIG_MK}
echo "LIBS_DEBUG = $LIBS_DEBUG" >> ${CONFIG_MK}
diff --git a/test/struct_test.c b/test/struct_test.c
index 566e147..ecf9f38 100644
--- a/test/struct_test.c
+++ b/test/struct_test.c
@@ -13,6 +13,7 @@
#include "../libkc3/kc3_main.h"
#include "../libkc3/struct.h"
#include "../libkc3/sym.h"
+#include "../http/types.h"
#include "test.h"
#define STRUCT_TEST_OFFSETOF(type, module, key) \
@@ -41,10 +42,14 @@
} while (0)
TEST_CASE_PROTOTYPE(struct_test_fact_w);
+TEST_CASE_PROTOTYPE(struct_test_http_request);
+TEST_CASE_PROTOTYPE(struct_test_http_response);
void struct_test (void)
{
TEST_CASE_RUN(struct_test_fact_w);
+ TEST_CASE_RUN(struct_test_http_request);
+ TEST_CASE_RUN(struct_test_http_response);
}
TEST_CASE(struct_test_fact_w)
@@ -56,3 +61,24 @@ TEST_CASE(struct_test_fact_w)
STRUCT_TEST_SIZEOF( s_fact_w, FactW);
}
TEST_CASE_END(struct_test_fact_w)
+
+TEST_CASE(struct_test_http_request)
+{
+ STRUCT_TEST_OFFSETOF(s_http_request, HTTP.Request, method);
+ STRUCT_TEST_OFFSETOF(s_http_request, HTTP.Request, url);
+ STRUCT_TEST_OFFSETOF(s_http_request, HTTP.Request, protocol);
+ STRUCT_TEST_OFFSETOF(s_http_request, HTTP.Request, headers);
+ STRUCT_TEST_SIZEOF( s_http_request, HTTP.Request);
+}
+TEST_CASE_END(struct_test_http_request)
+
+TEST_CASE(struct_test_http_response)
+{
+ STRUCT_TEST_OFFSETOF(s_http_response, HTTP.Response, protocol);
+ STRUCT_TEST_OFFSETOF(s_http_response, HTTP.Response, code);
+ STRUCT_TEST_OFFSETOF(s_http_response, HTTP.Response, message);
+ STRUCT_TEST_OFFSETOF(s_http_response, HTTP.Response, headers);
+ STRUCT_TEST_OFFSETOF(s_http_response, HTTP.Response, body);
+ STRUCT_TEST_SIZEOF( s_http_response, HTTP.Response);
+}
+TEST_CASE_END(struct_test_http_response)
diff --git a/test/test.c b/test/test.c
index e8e3019..077f5c3 100644
--- a/test/test.c
+++ b/test/test.c
@@ -100,7 +100,7 @@ void test_init (char *argv0, int *argc, char ***argv)
}
else {
const char *env_target;
- env_target = getenv("C3_TEST_TARGET");
+ env_target = getenv("KC3_TEST");
if (env_target) {
char **ap;
size_t len = 0;
@@ -112,9 +112,9 @@ void test_init (char *argv0, int *argc, char ***argv)
memcpy(target, env_target, len + 1);
ap = g_test_targets_env_v;
while (ap < g_test_targets_env_v + TARGETS_MAX &&
- (*ap = test_strsep(&target, " \t")) != NULL)
- if (**ap != '\0')
- ap++;
+ (*ap = test_strsep(&target, " \t")) != NULL &&
+ **ap)
+ ap++;
*ap = NULL;
g_test_targets = (const char **) g_test_targets_env_v;
}