From 40083f1cb7e3f2c96dc54893a215bbce0e6dc9d8 Mon Sep 17 00:00:00 2001 From: Max Lv Date: Sat, 7 Feb 2026 16:55:58 +0800 Subject: [PATCH] Fix Linux build: link libm for test_buffer and test_crypto, fix warnings Both test_buffer and test_crypto link libbloom.so which uses log() from libm. Also fix unused variable warnings in test_json.c that would fail with -Werror. Co-Authored-By: Claude Opus 4.6 --- tests/CMakeLists.txt | 4 ++-- tests/test_json.c | 14 +++++--------- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index b64e5b78..f6dc75f8 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -99,7 +99,7 @@ ss_add_test(test_jconf # test_buffer - needs sodium and mbedtls for crypto.c buffer functions ss_add_test(test_buffer "test_buffer.c;${PROJECT_SOURCE_DIR}/src/crypto.c;${PROJECT_SOURCE_DIR}/src/utils.c;${PROJECT_SOURCE_DIR}/src/base64.c;${PROJECT_SOURCE_DIR}/src/aead.c;${PROJECT_SOURCE_DIR}/src/stream.c;${PROJECT_SOURCE_DIR}/src/ppbloom.c;${PROJECT_SOURCE_DIR}/src/cache.c" - "${LIBSODIUM_SHARED};${LIBMBEDTLS_SHARED};${LIBMBEDCRYPTO_SHARED};${LIBEV_SHARED};${TEST_PPBLOOM_LIBS}") + "${LIBSODIUM_SHARED};${LIBMBEDTLS_SHARED};${LIBMBEDCRYPTO_SHARED};${LIBEV_SHARED};${TEST_PPBLOOM_LIBS};m") # test_crypto - full crypto test set(TEST_CRYPTO_LIBS @@ -115,4 +115,4 @@ else() endif() ss_add_test(test_crypto "test_crypto.c;${PROJECT_SOURCE_DIR}/src/crypto.c;${PROJECT_SOURCE_DIR}/src/aead.c;${PROJECT_SOURCE_DIR}/src/stream.c;${PROJECT_SOURCE_DIR}/src/ppbloom.c;${PROJECT_SOURCE_DIR}/src/cache.c;${PROJECT_SOURCE_DIR}/src/base64.c;${PROJECT_SOURCE_DIR}/src/utils.c" - "${TEST_CRYPTO_LIBS}") + "${TEST_CRYPTO_LIBS};m") diff --git a/tests/test_json.c b/tests/test_json.c index 5198ab4a..9606284d 100644 --- a/tests/test_json.c +++ b/tests/test_json.c @@ -55,9 +55,8 @@ test_parse_nested(void) assert(outer->type == json_object); assert(outer->u.object.length == 1); - json_value *inner = outer->u.object.values[0].value; - assert(inner->type == json_boolean); - assert(inner->u.boolean != 0); + assert(outer->u.object.values[0].value->type == json_boolean); + assert(outer->u.object.values[0].value->u.boolean != 0); json_value_free(val); } @@ -86,16 +85,13 @@ static void test_parse_invalid(void) { /* Missing closing brace */ - json_value *val = json_parse("{\"key\": 1", 9); - assert(val == NULL); + assert(json_parse("{\"key\": 1", 9) == NULL); /* Empty string */ - val = json_parse("", 0); - assert(val == NULL); + assert(json_parse("", 0) == NULL); /* Just garbage */ - val = json_parse("not json", 8); - assert(val == NULL); + assert(json_parse("not json", 8) == NULL); } static void