Commit 585030fc35b9b25073a173fd7c718425828ebd73

Thomas de Grivel 2023-11-15T00:54:03

configure and tests

diff --git a/config.subr b/config.subr
index b5e4a6c..b47437c 100644
--- a/config.subr
+++ b/config.subr
@@ -111,6 +111,13 @@ config_lib() {
     rm "$OUT"
 }
 
+env_reset() {
+    CPPFLAGS="$ENV_CPPFLAGS"
+    CFLAGS="$ENV_CFLAGS"
+    LDFLAGS="$ENV_LDFLAGS"
+    LIBS="$ENV_LIBS"
+}
+
 objc_o_rule() {
     echo "$1" | sed -e 's/^\(.*\)\.m$/\1.o: \1.c/'
     echo "$1" | sed -e 's/^\(.*\)\.m$/\1.o: Makefile config.mk/'
@@ -216,6 +223,11 @@ VER=0.1
 echo "VER = $VER" >> ${CONFIG_MK}
 echo "SRC_TOP = $SRC_TOP" >> ${CONFIG_MK}
 
+ENV_CPPFLAGS="$CPPFLAGS"
+ENV_CFLAGS="$CFLAGS"
+ENV_LDFLAGS="$LDFLAGS"
+ENV_LIBS="$LIBS"
+
 if [ "x$CC" = "x" ]; then
     if test -n $(which cc); then
         CC=cc
diff --git a/libc3/configure b/libc3/configure
index 5469566..a2ae971 100755
--- a/libc3/configure
+++ b/libc3/configure
@@ -30,12 +30,6 @@ OBJECTS_ASAN="$(c2ext .asan.lo "$LO_SOURCES")"
 OBJECTS_COV="$(c2ext .cov.lo "$LO_SOURCES")"
 OBJECTS_DEBUG="$(c2ext .debug.lo "$LO_SOURCES")"
 
-# Default config
-ENV_CPPFLAGS="$CPPFLAGS"
-ENV_CFLAGS="$CFLAGS"
-ENV_LDFLAGS="$LDFLAGS"
-ENV_LIBS="$LIBS"
-
 # Common config for all targets
 CPPFLAGS="$CPPFLAGS -I../libffi/include"
 CFLAGS="$CFLAGS -W -Wall -Werror -std=c99 -pedantic -fPIC"
@@ -143,10 +137,5 @@ for SRC in $SOURCES; do
 done
 
 update_config_mk
-
-CPPFLAGS="$ENV_CPPFLAGS"
-CFLAGS="$ENV_CFLAGS"
-LDFLAGS="$ENV_LDFLAGS"
-LIBS="$ENV_LIBS"
-
+env_reset
 ( cd window && ./configure; )
diff --git a/libc3/window/cairo/configure b/libc3/window/cairo/configure
index f8fba28..048492a 100755
--- a/libc3/window/cairo/configure
+++ b/libc3/window/cairo/configure
@@ -40,12 +40,6 @@ OBJECTS_ASAN="$(c2ext .asan.lo "$SOURCES")"
 OBJECTS_COV="$(c2ext .cov.lo "$SOURCES")"
 OBJECTS_DEBUG="$(c2ext .debug.lo "$SOURCES")"
 
-# Default config
-ENV_CPPFLAGS="$CPPFLAGS"
-ENV_CFLAGS="$CFLAGS"
-ENV_LDFLAGS="$LDFLAGS"
-ENV_LIBS="$LIBS"
-
 # Common config for all targets
 CPPFLAGS="$CPPFLAGS -I../../../libffi/include -I../../.."
 CFLAGS="$CFLAGS -W -Wall -Werror -std=c99 -pedantic -fPIC"
@@ -151,11 +145,7 @@ fi
 echo "HAVE_XCB = $HAVE_XCB" >> ${CONFIG_MK}
 
 update_config_mk
-
-CPPFLAGS="$ENV_CPPFLAGS"
-CFLAGS="$ENV_CFLAGS"
-LDFLAGS="$ENV_LDFLAGS"
-LIBS="$ENV_LIBS"
+env_reset
 
 if ${HAVE_SWIFT}; then
     ( cd quartz && ./configure; )
diff --git a/libc3/window/cairo/xcb/configure b/libc3/window/cairo/xcb/configure
index 3ed0c46..3fd18d2 100755
--- a/libc3/window/cairo/xcb/configure
+++ b/libc3/window/cairo/xcb/configure
@@ -40,17 +40,11 @@ OBJECTS_ASAN="$(c2ext .asan.lo "$SOURCES")"
 OBJECTS_COV="$(c2ext .cov.lo "$SOURCES")"
 OBJECTS_DEBUG="$(c2ext .debug.lo "$SOURCES")"
 
-# Default config
-ENV_CPPFLAGS="$CPPFLAGS"
-ENV_CFLAGS="$CFLAGS"
-ENV_LDFLAGS="$LDFLAGS"
-ENV_LIBS="$LIBS"
-LDFLAGS="--shared --no-undefined ${LDFLAGS}"
-LIBS="$LIBS -rpath ${PREFIX}/lib"
-
 # Common config for all targets
-CFLAGS="$CFLAGS -W -Wall -Werror -std=c99 -pedantic -fPIC"
 CPPFLAGS="$CPPFLAGS -I../../../../libffi/include -I../../../.."
+CFLAGS="$CFLAGS -W -Wall -Werror -std=c99 -pedantic -fPIC"
+LDFLAGS="--shared --no-undefined ${LDFLAGS}"
+LIBS="$LIBS -rpath ${PREFIX}/lib"
 config_asan
 config_gnu
 pkg_config xcb
@@ -147,10 +141,5 @@ for SRC in $SOURCES; do
 done
 
 update_config_mk
-
-CPPFLAGS="$ENV_CPPFLAGS"
-CFLAGS="$ENV_CFLAGS"
-LDFLAGS="$ENV_LDFLAGS"
-LIBS="$ENV_LIBS"
-
+env_reset
 ( cd demo && ./configure; )
diff --git a/libc3/window/cairo/xcb/demo/configure b/libc3/window/cairo/xcb/demo/configure
index cb9a4f9..f2bb344 100755
--- a/libc3/window/cairo/xcb/demo/configure
+++ b/libc3/window/cairo/xcb/demo/configure
@@ -43,12 +43,6 @@ fi
 OBJECTS_DEBUG="$(c2ext .debug.lo "$SOURCES")"
 echo "OBJECTS_DEBUG = $OBJECTS_DEBUG" >> ${CONFIG_MK}
 
-# Default config
-ENV_CPPFLAGS="${CPPFLAGS}"
-ENV_CFLAGS="${CFLAGS}"
-ENV_LDFLAGS="${LDFLAGS}"
-ENV_LIBS="${LIBS}"
-
 # Common config for all targets
 CFLAGS="$CFLAGS -W -Wall -Werror -std=c99 -pedantic"
 CPPFLAGS="$CPPFLAGS -I../../../../../libffi/include -I../../../../.."
diff --git a/libc3/window/configure b/libc3/window/configure
index 9d6f258..4f4cfdb 100755
--- a/libc3/window/configure
+++ b/libc3/window/configure
@@ -28,6 +28,7 @@ fi
 echo "HAVE_CAIRO = $HAVE_CAIRO" >> ${CONFIG_MK}
 
 update_config_mk
+env_reset
 
 if ${HAVE_CAIRO}; then
     ( cd cairo && ./configure; )
diff --git a/test/buf_test.c b/test/buf_test.c
index 93c2c67..0b5607a 100644
--- a/test/buf_test.c
+++ b/test/buf_test.c
@@ -22,13 +22,11 @@
 #define BUF_TEST_CLEAN(bufa)                                           \
   do {                                                                 \
     buf_clean(&bufa);                                                  \
-    test_ok();                                                         \
   } while(0)
 
 #define BUF_TEST_DELETE(buf)                                           \
   do {                                                                 \
     buf_delete(buf);                                                   \
-    test_ok();                                                         \
   } while(0)
 
 #define BUF_TEST_F(test, expected)                                     \
@@ -370,7 +368,7 @@ TEST_CASE(buf_peek_s16)
   s8 b[8];
   s_buf buf;
   s16 val;
-  buf_init(&buf, false, sizeof(b), b);          \
+  buf_init(&buf, false, sizeof(b), b);
   TEST_EQ(buf_write_s16(&buf, 0), 2);
   TEST_EQ(buf.rpos, 0);
   TEST_EQ(buf.wpos, 2);
diff --git a/test/str_test.c b/test/str_test.c
index 5b6b3d8..b2355bd 100644
--- a/test/str_test.c
+++ b/test/str_test.c
@@ -146,7 +146,6 @@ TEST_CASE(str_init_clean)
   TEST_EQ(stra.size, len);
   TEST_STRNCMP(stra.ptr.p, "test", len);
   str_clean(&stra);
-  test_ok();
   len = 4;
   m = malloc(len);
   assert(m);
@@ -155,7 +154,6 @@ TEST_CASE(str_init_clean)
   TEST_EQ(stra.size, len);
   TEST_STRNCMP(stra.ptr.p, "test", len);
   str_clean(&stra);
-  test_ok();
 }
 TEST_CASE_END(str_init_clean)
 
@@ -172,7 +170,6 @@ TEST_CASE(str_init_dup)
   TEST_EQ(str.size, len);
   TEST_STRNCMP(str.ptr.p, "test", len);
   str_clean(&str);
-  test_ok();
   len = 4;
   m = malloc(len);
   assert(m);
@@ -183,7 +180,6 @@ TEST_CASE(str_init_dup)
   TEST_EQ(str.size, len);
   TEST_STRNCMP(str.ptr.p, "test", len);
   str_clean(&str);
-  test_ok();
 }
 TEST_CASE_END(str_init_dup)
 
@@ -197,7 +193,6 @@ TEST_CASE(str_init_dup_1)
   TEST_EQ(str.size, len);
   TEST_STRNCMP(str.ptr.p, "test", len);
   str_clean(&str);
-  test_ok();
   len = 4;
   m = malloc(len + 1);
   assert(m);
@@ -207,7 +202,6 @@ TEST_CASE(str_init_dup_1)
   TEST_EQ(str.size, len);
   TEST_STRNCMP(str.ptr.p, "test", len);
   str_clean(&str);
-  test_ok();
 }
 TEST_CASE_END(str_init_dup_1)
 
@@ -308,7 +302,6 @@ TEST_CASE(str_new_delete)
   TEST_EQ(str->size, len);
   TEST_STRNCMP(str->ptr.p, "test", len);
   str_delete(str);
-  test_ok();
   len = 4;
   m = malloc(len);
   memcpy(m, "test", len);
@@ -316,7 +309,6 @@ TEST_CASE(str_new_delete)
   TEST_EQ(str->size, len);
   TEST_STRNCMP(str->ptr.p, "test", len);
   str_delete(str);
-  test_ok();
 }
 TEST_CASE_END(str_new_delete)
 
@@ -333,7 +325,6 @@ TEST_CASE(str_new_dup)
   TEST_EQ(str->size, len);
   TEST_STRNCMP(str->ptr.p, "test", len);
   str_delete(str);
-  test_ok();
   len = 4;
   m = malloc(len);
   memcpy(m, "test", len);
@@ -343,7 +334,6 @@ TEST_CASE(str_new_dup)
   TEST_EQ(str->size, len);
   TEST_STRNCMP(str->ptr.p, "test", len);
   str_delete(str);
-  test_ok();
 }
 TEST_CASE_END(str_new_dup)
 
diff --git a/test/tuple_test.c b/test/tuple_test.c
index 27cd644..2e94453 100644
--- a/test/tuple_test.c
+++ b/test/tuple_test.c
@@ -23,7 +23,6 @@
     test_context("tuple_init(" # test ")");                            \
     TEST_EQ(tuple_init(&tuple_test, (test)), &tuple_test);             \
     tuple_clean(&tuple_test);                                          \
-    test_ok();                                                         \
     test_context(NULL);                                                \
   } while (0)
 
@@ -68,7 +67,6 @@
     test_context("tuple_new(" # test ")");                             \
     TEST_ASSERT((tuple_test = tuple_new((test))));                     \
     tuple_delete(tuple_test);                                          \
-    test_ok();                                                         \
     test_context(NULL);                                                \
   } while (0)