Skip to content

Commit

Permalink
Fix tests makefile.
Browse files Browse the repository at this point in the history
The tests makefile only supports simple test programs.
Use include instead of additional object files.

Signed-off-by: Achim Kraus <[email protected]>
  • Loading branch information
boaks committed Dec 5, 2022
1 parent 789f63b commit a29015a
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
4 changes: 2 additions & 2 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ cmake_minimum_required(VERSION 3.5)

project(tinydtls-tests)

add_executable(dtls-server dtls-server.c dtls_ciphers_util.c)
add_executable(dtls-server dtls-server.c)
target_link_libraries(dtls-server LINK_PUBLIC tinydtls)
target_compile_options(dtls-server PUBLIC -Wall -DTEST_INCLUDE -DDTLSv12 -DWITH_SHA256)
if(${WARNING_TO_ERROR})
Expand All @@ -37,7 +37,7 @@ if(${WARNING_TO_ERROR})
target_compile_options(ccm-test PUBLIC -Werror)
endif()

add_executable(dtls-client dtls-client.c dtls_ciphers_util.c)
add_executable(dtls-client dtls-client.c)
target_link_libraries(dtls-client LINK_PUBLIC tinydtls)
target_compile_options(dtls-client PUBLIC -Wall -DTEST_INCLUDE -DDTLSv12 -DWITH_SHA256)
if(${WARNING_TO_ERROR})
Expand Down
1 change: 1 addition & 0 deletions tests/dtls-client.c
Original file line number Diff line number Diff line change
Expand Up @@ -568,3 +568,4 @@ main(int argc, char **argv) {
exit(0);
}

#include "dtls_ciphers_util.c"
3 changes: 3 additions & 0 deletions tests/dtls-server.c
Original file line number Diff line number Diff line change
Expand Up @@ -428,3 +428,6 @@ main(int argc, char **argv) {
dtls_free_context(the_context);
exit(0);
}

#include "dtls_ciphers_util.c"

4 changes: 2 additions & 2 deletions tests/dtls_ciphers_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ static const struct cipher_entry map[] = {
static dtls_cipher_t ciphers_table[ARRAY_LENGTH] = { TLS_NULL_WITH_NULL_NULL };

static dtls_cipher_t find_cipher_suite(const char *arg) {
for (int index=0; index < ARRAY_LENGTH - 1; ++index) {
for (size_t index=0; index < ARRAY_LENGTH - 1; ++index) {
size_t len = strlen(map[index].name);
if (strncmp(arg, map[index].name, len) == 0 && (arg[len] == 0 || arg[len] == SEP)) {
return map[index].cipher;
Expand All @@ -51,7 +51,7 @@ static dtls_cipher_t find_cipher_suite(const char *arg) {
}

static void add_cipher_suite(dtls_cipher_t cipher) {
for (int index=0; index < ARRAY_LENGTH - 1; ++index) {
for (size_t index=0; index < ARRAY_LENGTH - 1; ++index) {
if (ciphers_table[index] == cipher) {
return;
}
Expand Down

0 comments on commit a29015a

Please sign in to comment.