diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 83bac5b68..8ee1045d3 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -38,12 +38,7 @@ jobs: autoreconf -i ./configure --enable-debug --enable-code-coverage --enable-sanitize \ --enable-build-raft --enable-dqlite-next=${{ matrix.dqlite-next }} - make -j4 unit-test integration-test \ - raft-core-fuzzy-test \ - raft-core-integration-test \ - raft-core-unit-test \ - raft-uv-integration-test \ - raft-uv-unit-test + make -j$(nproc) check-norun - name: Test env: @@ -51,14 +46,11 @@ jobs: LIBDQLITE_TRACE: 1 run: | # TODO: return to just `make check` once the mysterious hang is fixed - tests="integration-test \ - raft-core-fuzzy-test \ - raft-core-integration-test \ - raft-core-unit-test \ - raft-uv-integration-test \ - raft-uv-unit-test" + tests="$(make print-test-programs | tr ' ' '\n' | grep -v '^unit-test$')" make check TESTS="$tests" + # Grab backtraces when the unit-test binary hangs (this is a heisenbug + # that we've only been able to trigger in GHA jobs) ./unit-test --no-fork & pid=$! bash -c "sleep 10m; sudo gdb -p $pid -batch -ex 'thread apply all bt' -ex quit; false" & diff --git a/.github/workflows/static.yml b/.github/workflows/static.yml new file mode 100644 index 000000000..1a0c9011c --- /dev/null +++ b/.github/workflows/static.yml @@ -0,0 +1,22 @@ +name: CI Tests (musl build) + +on: + - push + - pull_request + +jobs: + build-and-test: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Install dependencies + run: | + sudo apt install -y build-essential automake libtool gettext autopoint tclsh tcl libsqlite3-dev pkg-config git + + - name: Build and test + env: + LIBDQLITE_TRACE: 1 + run: | + contrib/build-static.sh || (cat ./test-suite.log && false) diff --git a/Makefile.am b/Makefile.am index bb780ae1c..96fbeb963 100644 --- a/Makefile.am +++ b/Makefile.am @@ -2,7 +2,16 @@ ACLOCAL_AMFLAGS = -I m4 AM_CFLAGS += $(CODE_COVERAGE_CFLAGS) AM_CFLAGS += $(SQLITE_CFLAGS) $(UV_CFLAGS) $(PTHREAD_CFLAGS) -AM_LDFLAGS = $(UV_LIBS) $(PTHREAD_LIBS) + +if WITH_STATIC_DEPS +AM_CFLAGS += -DDQLITE_STATIC_LIBC +static = -all-static +else +static = +endif + +AM_LDFLAGS = $(static) +AM_LDFLAGS += $(UV_LIBS) $(PTHREAD_LIBS) if DQLITE_NEXT_ENABLED AM_CFLAGS += -DDQLITE_NEXT @@ -216,7 +225,7 @@ libtest_la_SOURCES += \ test/raft/lib/loop.c libraft_la_CFLAGS = $(AM_CFLAGS) -libraft_la_LDFLAGS = $(UV_LIBS) +libraft_la_LDFLAGS = $(static) $(UV_LIBS) raft_core_unit_test_SOURCES = \ $(libraft_la_SOURCES) \ @@ -260,7 +269,7 @@ raft_core_integration_test_SOURCES = \ test/raft/integration/test_transfer.c \ test/raft/integration/test_voter_contacts.c raft_core_integration_test_CFLAGS = $(AM_CFLAGS) -Wno-conversion -raft_core_integration_test_LDFLAGS = -no-install +raft_core_integration_test_LDFLAGS = $(static) -no-install raft_core_integration_test_LDADD = libtest.la libraft.la raft_core_fuzzy_test_SOURCES = \ @@ -273,7 +282,7 @@ raft_core_fuzzy_test_SOURCES = \ test/raft/fuzzy/test_membership.c \ test/raft/fuzzy/test_replication.c raft_core_fuzzy_test_CFLAGS = $(AM_CFLAGS) -Wno-conversion -raft_core_fuzzy_test_LDFLAGS = -no-install +raft_core_fuzzy_test_LDFLAGS = $(static) -no-install raft_core_fuzzy_test_LDADD = libtest.la libraft.la raft_uv_unit_test_SOURCES = \ @@ -315,14 +324,14 @@ raft_uv_integration_test_SOURCES = \ test/raft/integration/test_uv_truncate_snapshot.c \ test/raft/integration/test_uv_work.c raft_uv_integration_test_CFLAGS = $(AM_CFLAGS) -Wno-type-limits -Wno-conversion -raft_uv_integration_test_LDFLAGS = -no-install +raft_uv_integration_test_LDFLAGS = $(static) -no-install raft_uv_integration_test_LDADD = libtest.la $(UV_LIBS) if LZ4_AVAILABLE libdqlite_la_CFLAGS += -DLZ4_AVAILABLE $(LZ4_CFLAGS) libdqlite_la_LDFLAGS += $(LZ4_LIBS) raft_core_unit_test_CFLAGS += -DLZ4_AVAILABLE $(LZ4_CFLAGS) -raft_core_unit_test_LDFLAGS = $(LZ4_LIBS) +raft_core_unit_test_LDFLAGS = $(static) $(LZ4_LIBS) libraft_la_CFLAGS += -DLZ4_AVAILABLE $(LZ4_CFLAGS) libraft_la_LDFLAGS += $(LZ4_LIBS) raft_uv_integration_test_CFLAGS += -DLZ4_AVAILABLE @@ -351,6 +360,14 @@ endif TESTS = $(check_PROGRAMS) +check-norun: $(TESTS) + +# Sometimes we want to run the test binaries manually. This target allows us to +# get the list of binaries out of the build system for that use-case, +# maintaining a single source of truth. +print-test-programs: + @echo '$(TESTS)' + if CODE_COVERAGE_ENABLED include $(top_srcdir)/aminclude_static.am diff --git a/configure.ac b/configure.ac index 1d7839441..bd59fabd7 100644 --- a/configure.ac +++ b/configure.ac @@ -6,8 +6,7 @@ AC_CONFIG_AUX_DIR([ac]) AM_INIT_AUTOMAKE([subdir-objects -Wall -Werror -Wno-portability foreign]) AM_SILENT_RULES([yes]) -# Without this line, AC_PROG_CC boneheadedly adds `-g -O2` to our CFLAGS. -AC_SUBST(CFLAGS, "") +AC_SUBST(AM_CFLAGS) AC_PROG_CC AC_USE_SYSTEM_EXTENSIONS @@ -43,6 +42,11 @@ AC_ARG_ENABLE(dqlite-next, AS_HELP_STRING([--enable-dqlite-next[=ARG]], [build w AM_CONDITIONAL(DQLITE_NEXT_ENABLED, test "x$enable_dqlite_next" = "xyes") AS_IF([test "x$enable_build_raft" != "xyes" -a "x$enable_dqlite_next" = "xyes"], [AC_MSG_ERROR([dqlite-next requires bundled raft])], []) +AC_ARG_WITH(static-deps, + AS_HELP_STRING([--with-static-deps[=ARG]], + [skip building a shared library and link test binaries statically])) +AM_CONDITIONAL(WITH_STATIC_DEPS, test "x$with_static_deps" = "xyes") + # Whether to enable code coverage. AX_CODE_COVERAGE @@ -96,10 +100,8 @@ CC_CHECK_FLAGS_APPEND([AM_CFLAGS],[CFLAGS],[ \ -pipe \ -fno-strict-aliasing \ -fdiagnostics-color \ - -fexceptions \ -fstack-clash-protection \ -fstack-protector-strong \ - -fasynchronous-unwind-tables \ -fdiagnostics-show-option \ -Wall \ -Wextra \ diff --git a/contrib/build-static.sh b/contrib/build-static.sh new file mode 100755 index 000000000..6a8b73f91 --- /dev/null +++ b/contrib/build-static.sh @@ -0,0 +1,143 @@ +#!/bin/bash -xeu + +DIR="${DIR:=$(realpath `dirname "${0}"`)}" + +REPO_MUSL="https://git.launchpad.net/musl" +REPO_LIBTIRPC="https://salsa.debian.org/debian/libtirpc.git" +REPO_LIBNSL="https://github.com/thkukuk/libnsl.git" +REPO_LIBUV="https://github.com/libuv/libuv.git" +REPO_LIBLZ4="https://github.com/lz4/lz4.git" +REPO_SQLITE="https://github.com/sqlite/sqlite.git" + +TAG_MUSL="${TAG_MUSL:-v1.2.4}" +DQLITE_PATH="${DQLITE_PATH:-$DIR/..}" + +BUILD_DIR="${DIR}/build" +INSTALL_DIR="${DIR}/prefix" +mkdir -p "${BUILD_DIR}" "${INSTALL_DIR}" "${INSTALL_DIR}/lib" "${INSTALL_DIR}/include" +BUILD_DIR="$(realpath "${BUILD_DIR}")" +INSTALL_DIR="$(realpath "${INSTALL_DIR}")" + +export CFLAGS="" +MACHINE_TYPE="$(uname -m)" +if [ "${MACHINE_TYPE}" = "ppc64le" ]; then + MACHINE_TYPE="powerpc64le" + export CFLAGS="-mlong-double-64" +fi +export PKG_CONFIG_PATH="${INSTALL_DIR}/lib/pkgconfig" + +clone-latest-tag() { + name="$1" + repo="$2" + tagpattern="${3:-.*}" + mkdir "${name}" + pushd "${name}" + git init + git remote add upstream "${repo}" + git fetch upstream 'refs/tags/*:refs/tags/*' + tag="$(git tag | grep "${tagpattern}" | sort -V -r | head -n1)" + echo "Selected $name tag ${tag}" + git checkout "${tag}" + popd +} + +# build musl +if [ ! -f "${INSTALL_DIR}/musl/bin/musl-gcc" ]; then + ( + cd "${BUILD_DIR}" + rm -rf musl + git clone "${REPO_MUSL}" --depth 1 --branch "${TAG_MUSL}" musl + cd musl + ./configure --prefix="${INSTALL_DIR}/musl" + make -j + make -j install + + # missing musl header files + ln -s "/usr/include/${MACHINE_TYPE}-linux-gnu/sys/queue.h" "${INSTALL_DIR}/musl/include/sys/queue.h" || true + ln -s "/usr/include/${MACHINE_TYPE}-linux-gnu/asm" "${INSTALL_DIR}/musl/include/asm" || true + ln -s /usr/include/asm-generic "${INSTALL_DIR}/musl/include/asm-generic" || true + ln -s /usr/include/linux "${INSTALL_DIR}/musl/include/linux" || true + ) +fi + +export PATH="${PATH}:${INSTALL_DIR}/musl/bin" +export CFLAGS="${CFLAGS} -isystem ${INSTALL_DIR}/musl/include" +export CC=musl-gcc +export LDFLAGS=-static + +# build libtirpc +if [ ! -f "${BUILD_DIR}/libtirpc/src/libtirpc.la" ]; then + ( + cd "${BUILD_DIR}" + rm -rf libtirpc + clone-latest-tag libtirpc "${REPO_LIBTIRPC}" upstream + cd libtirpc + chmod +x autogen.sh + ./autogen.sh + ./configure --disable-shared --disable-gssapi --prefix="${INSTALL_DIR}" + make -j install + ) +fi + +# build libnsl +if [ ! -f "${BUILD_DIR}/libnsl/src/libnsl.la" ]; then + ( + cd "${BUILD_DIR}" + rm -rf libnsl + clone-latest-tag libnsl "${REPO_LIBNSL}" + cd libnsl + ./autogen.sh + autoreconf -i + autoconf + ./configure --disable-shared --prefix="${INSTALL_DIR}" + make -j install + ) +fi + +# build libuv +if [ ! -f "${BUILD_DIR}/libuv/libuv.la" ]; then + ( + cd "${BUILD_DIR}" + rm -rf libuv + clone-latest-tag libuv "${REPO_LIBUV}" + cd libuv + ./autogen.sh + ./configure --disable-shared --prefix="${INSTALL_DIR}" + make -j install + ) +fi + +# build liblz4 +if [ ! -f "${BUILD_DIR}/lz4/lib/liblz4.a" ] || [ ! -f "${BUILD_DIR}/lz4/lib/liblz4.so" ]; then + ( + cd "${BUILD_DIR}" + rm -rf lz4 + clone-latest-tag lz4 "${REPO_LIBLZ4}" + cd lz4 + make install -j PREFIX="${INSTALL_DIR}" BUILD_SHARED=no + ) +fi + +# build sqlite3 +if [ ! -f "${BUILD_DIR}/sqlite/libsqlite3.la" ]; then + ( + cd "${BUILD_DIR}" + rm -rf sqlite + clone-latest-tag sqlite "${REPO_SQLITE}" + cd sqlite + ./configure --disable-shared --disable-readline --prefix="${INSTALL_DIR}" \ + CFLAGS="${CFLAGS} -DSQLITE_ENABLE_DBSTAT_VTAB=1" + make install -j BCC="${CC} -g -O2 ${CFLAGS} ${LDFLAGS}" + ) +fi + +# build dqlite +if [ ! -f "${BUILD_DIR}/dqlite/libdqlite.la" ]; then + ( + cd "${DQLITE_PATH}" + autoreconf -i + ./configure --enable-build-raft --with-static-deps --prefix="${INSTALL_DIR}" + make -j check-norun + make check + ) +fi diff --git a/test/integration/test_vfs.c b/test/integration/test_vfs.c index 3335c228c..61f80046d 100644 --- a/test/integration/test_vfs.c +++ b/test/integration/test_vfs.c @@ -88,7 +88,7 @@ static void tearDownRestorePendingByte(void *data) tearDown(data); } -#define PAGE_SIZE 512 +#define DB_PAGE_SIZE 512 #define PRAGMA(DB, COMMAND) \ _rv = sqlite3_exec(DB, "PRAGMA " COMMAND, NULL, NULL, NULL); \ @@ -216,12 +216,12 @@ struct tx if (_frames != NULL) { \ TX.page_numbers = \ munit_malloc(sizeof *TX.page_numbers * TX.n); \ - TX.frames = munit_malloc(PAGE_SIZE * TX.n); \ + TX.frames = munit_malloc(DB_PAGE_SIZE * TX.n); \ for (_i = 0; _i < TX.n; _i++) { \ dqlite_vfs_frame *_frame = &_frames[_i]; \ TX.page_numbers[_i] = _frame->page_number; \ - memcpy(TX.frames + _i * PAGE_SIZE, \ - _frame->data, PAGE_SIZE); \ + memcpy(TX.frames + _i * DB_PAGE_SIZE, \ + _frame->data, DB_PAGE_SIZE); \ sqlite3_free(_frame->data); \ } \ sqlite3_free(_frames); \ @@ -1502,7 +1502,7 @@ TEST(vfs, snapshotInitialDatabase, setUp, tearDown, 0, vfs_params) SNAPSHOT("1", snapshot); - munit_assert_int(snapshot.n, ==, PAGE_SIZE); + munit_assert_int(snapshot.n, ==, DB_PAGE_SIZE); page = snapshot.data; munit_assert_int(memcmp(&page[16], page_size, 2), ==, 0); @@ -1536,7 +1536,7 @@ TEST(vfs, snapshotAfterFirstTransaction, setUp, tearDown, 0, vfs_params) SNAPSHOT("1", snapshot); - munit_assert_int(snapshot.n, ==, PAGE_SIZE + 32 + (24 + PAGE_SIZE) * 2); + munit_assert_int(snapshot.n, ==, DB_PAGE_SIZE + 32 + (24 + DB_PAGE_SIZE) * 2); page = snapshot.data; munit_assert_int(memcmp(&page[16], page_size, 2), ==, 0); @@ -1571,7 +1571,7 @@ TEST(vfs, snapshotAfterCheckpoint, setUp, tearDown, 0, vfs_params) SNAPSHOT("1", snapshot); - munit_assert_int(snapshot.n, ==, PAGE_SIZE * 2); + munit_assert_int(snapshot.n, ==, DB_PAGE_SIZE * 2); page = snapshot.data; munit_assert_int(memcmp(&page[16], page_size, 2), ==, 0); diff --git a/test/lib/runner.h b/test/lib/runner.h index 784066321..f798c2bb8 100644 --- a/test/lib/runner.h +++ b/test/lib/runner.h @@ -4,7 +4,6 @@ #define TEST_RUNNER_H #include -#include #include #include diff --git a/test/raft/integration/test_uv_tcp_connect.c b/test/raft/integration/test_uv_tcp_connect.c index 7efc68c60..9fc578903 100644 --- a/test/raft/integration/test_uv_tcp_connect.c +++ b/test/raft/integration/test_uv_tcp_connect.c @@ -192,7 +192,7 @@ TEST(tcp_connect, connectByName, setUp, tearDown, 0, NULL) } /* Successfully connect to the peer by first IP */ -TEST(tcp_connect, firstIP, setUp, tearDown, 0, NULL) +ADDRINFO_TEST(tcp_connect, firstIP, setUp, tearDown, 0, NULL) { struct fixture *f = data; const struct AddrinfoResult results[] = {{"127.0.0.1", TCP_SERVER_PORT}, @@ -203,7 +203,7 @@ TEST(tcp_connect, firstIP, setUp, tearDown, 0, NULL) } /* Successfully connect to the peer by second IP */ -TEST(tcp_connect, secondIP, setUp, tearDown, 0, NULL) +ADDRINFO_TEST(tcp_connect, secondIP, setUp, tearDown, 0, NULL) { struct fixture *f = data; const struct AddrinfoResult results[] = {{"127.0.0.1", .6666}, @@ -332,7 +332,7 @@ TEST(tcp_connect, closeDuringConnectAbort, setUp, tearDownDeps, 0, NULL) /* The transport gets closed right after the first connection attempt failed, * while doing a second connection attempt. */ -TEST(tcp_connect, closeDuringSecondConnect, setUp, tearDownDeps, 0, NULL) +ADDRINFO_TEST(tcp_connect, closeDuringSecondConnect, setUp, tearDownDeps, 0, NULL) { struct fixture *f = data; struct uv_check_s check; diff --git a/test/raft/integration/test_uv_tcp_listen.c b/test/raft/integration/test_uv_tcp_listen.c index b239cfa87..e4ec757bc 100644 --- a/test/raft/integration/test_uv_tcp_listen.c +++ b/test/raft/integration/test_uv_tcp_listen.c @@ -237,7 +237,7 @@ TEST(tcp_listen, invalidAddress, setUp, tearDown, 0, invalidTcpListenParams) /* Check success with addrinfo resolve to mutiple IP and first one is used to * connect */ -TEST(tcp_listen, firstOfTwo, setUp, tearDown, 0, NULL) +ADDRINFO_TEST(tcp_listen, firstOfTwo, setUp, tearDown, 0, NULL) { const struct AddrinfoResult results[] = {{"127.0.0.1", 9000}, {"127.0.0.2", 9000}}; @@ -252,7 +252,7 @@ TEST(tcp_listen, firstOfTwo, setUp, tearDown, 0, NULL) /* Check success with addrinfo resolve to mutiple IP and second one is used to * connect */ -TEST(tcp_listen, secondOfTwo, setUp, tearDown, 0, NULL) +ADDRINFO_TEST(tcp_listen, secondOfTwo, setUp, tearDown, 0, NULL) { const struct AddrinfoResult results[] = {{"127.0.0.2", 9000}, {"127.0.0.1", 9000}}; @@ -268,7 +268,7 @@ TEST(tcp_listen, secondOfTwo, setUp, tearDown, 0, NULL) /* Simulate port already in use error by addrinfo response contain the same IP * twice */ -TEST(tcp_listen, alreadyBound, setUp, tearDown, 0, NULL) +ADDRINFO_TEST(tcp_listen, alreadyBound, setUp, tearDown, 0, NULL) { /* We need to use the same endpoint three times as a simple duplicate will * be skipped due to a glib strange behavior @@ -282,7 +282,7 @@ TEST(tcp_listen, alreadyBound, setUp, tearDown, 0, NULL) } /* Error in bind first IP address */ -TEST(tcp_listen, cannotBindFirst, setUp, tearDown, 0, NULL) +ADDRINFO_TEST(tcp_listen, cannotBindFirst, setUp, tearDown, 0, NULL) { const struct AddrinfoResult results[] = {{"192.0.2.0", 9000}, {"127.0.0.1", 9000}}; @@ -293,7 +293,7 @@ TEST(tcp_listen, cannotBindFirst, setUp, tearDown, 0, NULL) } /* Error in bind of second IP address */ -TEST(tcp_listen, cannotBindSecond, setUp, tearDown, 0, NULL) +ADDRINFO_TEST(tcp_listen, cannotBindSecond, setUp, tearDown, 0, NULL) { const struct AddrinfoResult results[] = {{"127.0.0.1", 9000}, {"192.0.2.0", 9000}}; @@ -304,7 +304,7 @@ TEST(tcp_listen, cannotBindSecond, setUp, tearDown, 0, NULL) } /* Check error on general dns server failure */ -TEST(tcp_listen, resolveFailure, setUp, tearDown, 0, NULL) +ADDRINFO_TEST(tcp_listen, resolveFailure, setUp, tearDown, 0, NULL) { struct fixture *f = data; AddrinfoInjectSetResponse(EAI_FAIL, 0, NULL); diff --git a/test/raft/lib/addrinfo.c b/test/raft/lib/addrinfo.c index 532ddab5f..62fac96ce 100644 --- a/test/raft/lib/addrinfo.c +++ b/test/raft/lib/addrinfo.c @@ -7,6 +7,28 @@ #include #include +#ifdef DQLITE_STATIC_LIBC + +void AddrinfoInjectSetResponse(int rv, + int num_results, + const struct AddrinfoResult *results) +{ + (void)rv; + (void)num_results; + (void)results; +} + +void AddrinfoInjectSetUp(const MunitParameter params[]) +{ + (void)params; +} + +void AddrinfoInjectTearDown(void) +{ +} + +#else /* ifndef DQLITE_STATIC_LIBC */ + bool addrinfo_mock_enabled = false; enum addrinfo_mock_state { MockResultSet, MockResultReturned, SystemResult }; @@ -171,3 +193,5 @@ void freeaddrinfo(struct addrinfo *res) } free(response); } + +#endif /* ifdef DQLITE_STATIC_LIBC ... else */ diff --git a/test/raft/lib/addrinfo.h b/test/raft/lib/addrinfo.h index cc29d5864..beff503a7 100644 --- a/test/raft/lib/addrinfo.h +++ b/test/raft/lib/addrinfo.h @@ -1,14 +1,16 @@ -/* Support for getaddrinfo injection for test purpose +/* Support for getaddrinfo mocking for test purposes. * - * Provide a local bound version to capture teh getaddrinfo/freeaddrinfo - * incovation The helper may operate in three different modes: a) Transparent - * forward calls to system getaddrinfo/freeaddrinfo function, if the - * SET_UP_ADDRINFO/TEAR_DOWN_ADDRINFO is not added to the test test case setup - * teardown. b) Check, if all results requested by getaddrinfo are freed using - * freeaddrinfo. Activated by adding the SET_UP_ADDRINFO/SET_UP_ADDRINFO macros - * to the test fixture. c) Inject artifical responses into the the getaddrinfo - * requests for test purpose additionally to b) by using - * AddrinfoInjectSetResponse before triggering the getaddrinfo calls. + * The addrinfo.c test fixture includes definitions of getaddrinfo and + * freeaddinfo that override the libc definitions, adding usage checks and the + * ability to inject responses. These additional features are activated by + * adding SET_UP_ADDRINFO/TEAR_DOWN_ADDRINFO to the fixture constructor and + * destructor. + * + * The overriding definitions of getaddrinfo and freeaddrinfo affect all code + * that's linked with addrinfo.c, and we rely on being able to retrieve the + * original libc definitions using dlsym. When libc is statically linked, this + * is not possible, so we just arrange for the overriding definitions not to be + * compiled and skip any tests that rely on getaddrinfo result injection. */ #ifndef TEST_ADDRINFO_H @@ -16,6 +18,25 @@ #include "munit.h" +#ifdef DQLITE_STATIC_LIBC + +/* Trickery to cause tests that use getaddrinfo result injection to be skipped + * when building with WITH_STATIC_DEPS. */ +#define ADDRINFO_TEST(S, C, SETUP, TEAR_DOWN, OPTIONS, PARAMS) \ + TEST(S, C, SETUP, TEAR_DOWN, OPTIONS, PARAMS) \ + { \ + return MUNIT_SKIP; \ + } \ + static MUNIT_UNUSED MunitResult test_unused_##S##_##C( \ + MUNIT_UNUSED const MunitParameter params[], MUNIT_UNUSED void *data) + +#else /* ifndef DQLITE_STATIC_LIBC */ + +#define ADDRINFO_TEST(S, C, SETUP, TEAR_DOWN, OPTIONS, PARAMS) \ + TEST(S, C, SETUP, TEAR_DOWN, OPTIONS, PARAMS) + +#endif /* ifdef DQLITE_STATIC_LIBC ... else */ + #define SET_UP_ADDRINFO AddrinfoInjectSetUp(params) #define TEAR_DOWN_ADDRINFO AddrinfoInjectTearDown() diff --git a/test/unit/test_vfs2.c b/test/unit/test_vfs2.c index 62c332de9..82dd77818 100644 --- a/test/unit/test_vfs2.c +++ b/test/unit/test_vfs2.c @@ -15,8 +15,8 @@ #include #include -#define PAGE_SIZE 512 -#define PAGE_SIZE_STR "512" +#define DB_PAGE_SIZE 512 +#define DB_PAGE_SIZE_STR "512" SUITE(vfs2); @@ -111,7 +111,7 @@ TEST(vfs2, basic, set_up, tear_down, 0, NULL) munit_assert_int(rv, ==, SQLITE_OK); rv = sqlite3_exec(db, - "PRAGMA page_size=" PAGE_SIZE_STR ";" + "PRAGMA page_size=" DB_PAGE_SIZE_STR ";" "PRAGMA journal_mode=WAL;" "PRAGMA wal_autocheckpoint=0", NULL, NULL, NULL); @@ -215,7 +215,7 @@ TEST(vfs2, basic, set_up, tear_down, 0, NULL) return MUNIT_OK; } -#define WAL_SIZE_FROM_FRAMES(n) (32 + (24 + PAGE_SIZE) * (n)) +#define WAL_SIZE_FROM_FRAMES(n) (32 + (24 + DB_PAGE_SIZE) * (n)) static void make_wal_hdr(uint8_t *buf, uint32_t ckpoint_seqno, uint32_t salt1, uint32_t salt2) { @@ -226,7 +226,7 @@ static void make_wal_hdr(uint8_t *buf, uint32_t ckpoint_seqno, uint32_t salt1, u p += 4; BytePutBe32(3007000, p); p += 4; - BytePutBe32(PAGE_SIZE, p); + BytePutBe32(DB_PAGE_SIZE, p); p += 4; BytePutBe32(ckpoint_seqno, p); p += 4; @@ -275,7 +275,7 @@ TEST(vfs2, startup_one_nonempty, set_up, tear_down, 0, NULL) munit_assert_int(rv, ==, SQLITE_OK); tracef("setup..."); rv = sqlite3_exec(db, - "PRAGMA page_size=" PAGE_SIZE_STR ";" + "PRAGMA page_size=" DB_PAGE_SIZE_STR ";" "PRAGMA journal_mode=WAL;" "PRAGMA wal_autocheckpoint=0", NULL, NULL, NULL); @@ -315,7 +315,7 @@ TEST(vfs2, startup_both_nonempty, set_up, tear_down, 0, NULL) int rv = sqlite3_open(buf, &db); munit_assert_int(rv, ==, SQLITE_OK); rv = sqlite3_exec(db, - "PRAGMA page_size=" PAGE_SIZE_STR ";" + "PRAGMA page_size=" DB_PAGE_SIZE_STR ";" "PRAGMA journal_mode=WAL;" "PRAGMA wal_autocheckpoint=0", NULL, NULL, NULL);