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 <noreply@anthropic.com>
This commit is contained in:
Max Lv
2026-02-07 16:55:58 +08:00
co-authored by Claude Opus 4.6
parent 9ec2620599
commit 40083f1cb7
2 changed files with 7 additions and 11 deletions
+2 -2
View File
@@ -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")
+5 -9
View File
@@ -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