diff --git a/tests/Makefile.am b/tests/Makefile.am index 61a82c72..bb270b75 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -30,38 +30,41 @@ check_PROGRAMS = \ # Basic includes AM_CFLAGS = -I$(top_srcdir)/src -I$(top_srcdir)/lib -I$(top_srcdir)/tinycrypt/lib/include -I$(top_srcdir)/tinycrypt/lib/source -# TinyCrypt object files (in .objs directory) +# TinyCrypt source files +TINYCRYPT_SRCDIR = $(top_srcdir)/tinycrypt/lib/source + +# TinyCrypt object files (with utun- prefix as built by automake) TINYCRYPT_OBJS = \ - $(TINYCRYPT_OBJDIR)/aes_encrypt.o \ - $(TINYCRYPT_OBJDIR)/aes_decrypt.o \ - $(TINYCRYPT_OBJDIR)/ccm_mode.o \ - $(TINYCRYPT_OBJDIR)/cmac_mode.o \ - $(TINYCRYPT_OBJDIR)/ctr_mode.o \ - $(TINYCRYPT_OBJDIR)/ecc.o \ - $(TINYCRYPT_OBJDIR)/ecc_dh.o \ - $(TINYCRYPT_OBJDIR)/ecc_dsa.o \ - $(TINYCRYPT_OBJDIR)/sha256.o \ - $(TINYCRYPT_OBJDIR)/ecc_platform_specific.o \ - $(TINYCRYPT_OBJDIR)/utils.o + $(TINYCRYPT_OBJDIR)/utun-aes_encrypt.o \ + $(TINYCRYPT_OBJDIR)/utun-aes_decrypt.o \ + $(TINYCRYPT_OBJDIR)/utun-ccm_mode.o \ + $(TINYCRYPT_OBJDIR)/utun-cmac_mode.o \ + $(TINYCRYPT_OBJDIR)/utun-ctr_mode.o \ + $(TINYCRYPT_OBJDIR)/utun-ecc.o \ + $(TINYCRYPT_OBJDIR)/utun-ecc_dh.o \ + $(TINYCRYPT_OBJDIR)/utun-ecc_dsa.o \ + $(TINYCRYPT_OBJDIR)/utun-sha256.o \ + $(TINYCRYPT_OBJDIR)/utun-ecc_platform_specific.o \ + $(TINYCRYPT_OBJDIR)/utun-utils.o # Secure channel and CRC objects -SECURE_CHANNEL_OBJS = $(SRC_OBJDIR)/secure_channel.o $(SRC_OBJDIR)/crc32.o +SECURE_CHANNEL_OBJS = $(SRC_OBJDIR)/utun-secure_channel.o $(SRC_OBJDIR)/utun-crc32.o # ETCP core objects ETCP_CORE_OBJS = \ - $(SRC_OBJDIR)/etcp.o \ - $(SRC_OBJDIR)/etcp_connections.o \ - $(SRC_OBJDIR)/etcp_loadbalancer.o \ - $(SRC_OBJDIR)/pkt_normalizer.o + $(SRC_OBJDIR)/utun-etcp.o \ + $(SRC_OBJDIR)/utun-etcp_connections.o \ + $(SRC_OBJDIR)/utun-etcp_loadbalancer.o \ + $(SRC_OBJDIR)/utun-pkt_normalizer.o # Full ETCP objects ETCP_FULL_OBJS = \ - $(SRC_OBJDIR)/config_parser.o \ - $(SRC_OBJDIR)/config_updater.o \ - $(SRC_OBJDIR)/route_lib.o \ - $(SRC_OBJDIR)/routing.o \ - $(SRC_OBJDIR)/tun_if.o \ - $(SRC_OBJDIR)/utun_instance.o \ + $(SRC_OBJDIR)/utun-config_parser.o \ + $(SRC_OBJDIR)/utun-config_updater.o \ + $(SRC_OBJDIR)/utun-route_lib.o \ + $(SRC_OBJDIR)/utun-routing.o \ + $(SRC_OBJDIR)/utun-tun_if.o \ + $(SRC_OBJDIR)/utun-utun_instance.o \ $(ETCP_CORE_OBJS) # Common libraries @@ -70,13 +73,41 @@ COMMON_LIBS = $(top_builddir)/lib/libuasync.a -lpthread # Crypto libraries (conditional) if USE_OPENSSL CRYPTO_LIBS = -lcrypto +TINYCRYPT_BUILT = else CRYPTO_LIBS = $(TINYCRYPT_OBJS) +TINYCRYPT_BUILT = tinycrypt-objects endif # Register tests TESTS = $(check_PROGRAMS) +# Build TinyCrypt objects as a group +tinycrypt-objects: $(TINYCRYPT_OBJS) + +# Explicit rules for TinyCrypt objects - NOTE: no newlines in recipe +$(TINYCRYPT_OBJDIR)/utun-aes_encrypt.o: $(TINYCRYPT_SRCDIR)/aes_encrypt.c ; @$(MKDIR_P) $(TINYCRYPT_OBJDIR) ; $(AM_V_CC)$(COMPILE) -c -o $@ $< + +$(TINYCRYPT_OBJDIR)/utun-aes_decrypt.o: $(TINYCRYPT_SRCDIR)/aes_decrypt.c ; @$(MKDIR_P) $(TINYCRYPT_OBJDIR) ; $(AM_V_CC)$(COMPILE) -c -o $@ $< + +$(TINYCRYPT_OBJDIR)/utun-ccm_mode.o: $(TINYCRYPT_SRCDIR)/ccm_mode.c ; @$(MKDIR_P) $(TINYCRYPT_OBJDIR) ; $(AM_V_CC)$(COMPILE) -c -o $@ $< + +$(TINYCRYPT_OBJDIR)/utun-cmac_mode.o: $(TINYCRYPT_SRCDIR)/cmac_mode.c ; @$(MKDIR_P) $(TINYCRYPT_OBJDIR) ; $(AM_V_CC)$(COMPILE) -c -o $@ $< + +$(TINYCRYPT_OBJDIR)/utun-ctr_mode.o: $(TINYCRYPT_SRCDIR)/ctr_mode.c ; @$(MKDIR_P) $(TINYCRYPT_OBJDIR) ; $(AM_V_CC)$(COMPILE) -c -o $@ $< + +$(TINYCRYPT_OBJDIR)/utun-ecc.o: $(TINYCRYPT_SRCDIR)/ecc.c ; @$(MKDIR_P) $(TINYCRYPT_OBJDIR) ; $(AM_V_CC)$(COMPILE) -c -o $@ $< + +$(TINYCRYPT_OBJDIR)/utun-ecc_dh.o: $(TINYCRYPT_SRCDIR)/ecc_dh.c ; @$(MKDIR_P) $(TINYCRYPT_OBJDIR) ; $(AM_V_CC)$(COMPILE) -c -o $@ $< + +$(TINYCRYPT_OBJDIR)/utun-ecc_dsa.o: $(TINYCRYPT_SRCDIR)/ecc_dsa.c ; @$(MKDIR_P) $(TINYCRYPT_OBJDIR) ; $(AM_V_CC)$(COMPILE) -c -o $@ $< + +$(TINYCRYPT_OBJDIR)/utun-sha256.o: $(TINYCRYPT_SRCDIR)/sha256.c ; @$(MKDIR_P) $(TINYCRYPT_OBJDIR) ; $(AM_V_CC)$(COMPILE) -c -o $@ $< + +$(TINYCRYPT_OBJDIR)/utun-ecc_platform_specific.o: $(TINYCRYPT_SRCDIR)/ecc_platform_specific.c ; @$(MKDIR_P) $(TINYCRYPT_OBJDIR) ; $(AM_V_CC)$(COMPILE) -c -o $@ $< + +$(TINYCRYPT_OBJDIR)/utun-utils.o: $(TINYCRYPT_SRCDIR)/utils.c ; @$(MKDIR_P) $(TINYCRYPT_OBJDIR) ; $(AM_V_CC)$(COMPILE) -c -o $@ $< + # Test definitions with standard automake variables test_etcp_crypto_SOURCES = test_etcp_crypto.c test_etcp_crypto_CFLAGS = -I$(top_srcdir)/src -I$(top_srcdir)/lib -I$(top_srcdir)/tinycrypt/lib/include -I$(top_srcdir)/tinycrypt/lib/source @@ -108,7 +139,7 @@ test_pkt_normalizer_etcp_LDADD = $(ETCP_FULL_OBJS) $(SECURE_CHANNEL_OBJS) $(CRYP test_pkt_normalizer_standalone_SOURCES = test_pkt_normalizer_standalone.c test_pkt_normalizer_standalone_CFLAGS = -I$(top_srcdir)/src -I$(top_srcdir)/lib -I$(top_srcdir)/tinycrypt/lib/include -I$(top_srcdir)/tinycrypt/lib/source -test_pkt_normalizer_standalone_LDADD = $(SRC_OBJDIR)/pkt_normalizer.o $(SRC_OBJDIR)/route_lib.o $(SRC_OBJDIR)/routing.o $(TINYCRYPT_OBJS) $(COMMON_LIBS) +test_pkt_normalizer_standalone_LDADD = $(SRC_OBJDIR)/utun-pkt_normalizer.o $(SRC_OBJDIR)/utun-route_lib.o $(SRC_OBJDIR)/utun-routing.o $(TINYCRYPT_OBJS) $(COMMON_LIBS) test_ll_queue_SOURCES = test_ll_queue.c test_ll_queue_CFLAGS = -I$(top_srcdir)/src -I$(top_srcdir)/lib @@ -144,7 +175,7 @@ test_debug_categories_LDADD = $(COMMON_LIBS) test_config_debug_SOURCES = test_config_debug.c test_config_debug_CFLAGS = -I$(top_srcdir)/src -I$(top_srcdir)/lib -test_config_debug_LDADD = $(SRC_OBJDIR)/config_parser.o $(COMMON_LIBS) +test_config_debug_LDADD = $(SRC_OBJDIR)/utun-config_parser.o $(COMMON_LIBS) bench_timeout_heap_SOURCES = bench_timeout_heap.c bench_timeout_heap_CFLAGS = -I$(top_srcdir)/lib @@ -154,6 +185,9 @@ bench_uasync_timeouts_SOURCES = bench_uasync_timeouts.c bench_uasync_timeouts_CFLAGS = -I$(top_srcdir)/lib bench_uasync_timeouts_LDADD = $(COMMON_LIBS) +# Build tinycrypt objects before tests that need them +BUILT_SOURCES = $(TINYCRYPT_BUILT) + # After building tests, move their object files to shadow directory all-local: shadow-test-objects diff --git a/tests/bench_timeout_heap b/tests/bench_timeout_heap new file mode 100755 index 00000000..a0b97efb Binary files /dev/null and b/tests/bench_timeout_heap differ diff --git a/tests/bench_uasync_timeouts b/tests/bench_uasync_timeouts new file mode 100755 index 00000000..4bfba104 Binary files /dev/null and b/tests/bench_uasync_timeouts differ diff --git a/tests/test_config_debug b/tests/test_config_debug new file mode 100755 index 00000000..e2a6b184 Binary files /dev/null and b/tests/test_config_debug differ diff --git a/tests/test_crypto b/tests/test_crypto new file mode 100755 index 00000000..043da279 Binary files /dev/null and b/tests/test_crypto differ diff --git a/tests/test_debug_categories b/tests/test_debug_categories new file mode 100755 index 00000000..d8f80ece Binary files /dev/null and b/tests/test_debug_categories differ diff --git a/tests/test_ecc_encrypt b/tests/test_ecc_encrypt new file mode 100755 index 00000000..7b28462c Binary files /dev/null and b/tests/test_ecc_encrypt differ diff --git a/tests/test_etcp_100_packets b/tests/test_etcp_100_packets new file mode 100755 index 00000000..72a68281 Binary files /dev/null and b/tests/test_etcp_100_packets differ diff --git a/tests/test_etcp_100_packets.c b/tests/test_etcp_100_packets.c index 0a576b31..27b9cbfd 100644 --- a/tests/test_etcp_100_packets.c +++ b/tests/test_etcp_100_packets.c @@ -92,7 +92,7 @@ static void send_packets_fwd(void) { generate_packet_data(current_packet_seq_fwd, packet_buffer, PACKET_SIZE); - if (etcp_send(conn, packet_buffer, PACKET_SIZE) == 0) { + if (etcp_int_send(conn, packet_buffer, PACKET_SIZE) == 0) { packets_sent_fwd++; current_packet_seq_fwd++; } else { @@ -129,7 +129,7 @@ static void send_packets_back(void) { generate_packet_data(current_packet_seq_back, packet_buffer, PACKET_SIZE); - if (etcp_send(conn, packet_buffer, PACKET_SIZE) == 0) { + if (etcp_int_send(conn, packet_buffer, PACKET_SIZE) == 0) { packets_sent_back++; current_packet_seq_back++; } else { diff --git a/tests/test_etcp_crypto b/tests/test_etcp_crypto new file mode 100755 index 00000000..b1557609 Binary files /dev/null and b/tests/test_etcp_crypto differ diff --git a/tests/test_etcp_minimal b/tests/test_etcp_minimal new file mode 100755 index 00000000..57b18794 Binary files /dev/null and b/tests/test_etcp_minimal differ diff --git a/tests/test_etcp_simple_traffic b/tests/test_etcp_simple_traffic new file mode 100755 index 00000000..aff92cba Binary files /dev/null and b/tests/test_etcp_simple_traffic differ diff --git a/tests/test_etcp_simple_traffic.c b/tests/test_etcp_simple_traffic.c index 4c2b0a8e..105ebf6c 100644 --- a/tests/test_etcp_simple_traffic.c +++ b/tests/test_etcp_simple_traffic.c @@ -118,22 +118,22 @@ static void send_test_packet(void) { DEBUG_DEBUG(DEBUG_CATEGORY_ETCP, "send_test_packet: Created test data, first byte=%02X, last byte=%02X", test_packet_data[0], test_packet_data[PACKET_SIZE-1]); - // Use new etcp_send function - much simpler API - printf("[DEBUG] send_test_packet: Calling etcp_send with len=%d\n", PACKET_SIZE); + // Use etcp_int_send function + printf("[DEBUG] send_test_packet: Calling etcp_int_send with len=%d\n", PACKET_SIZE); fflush(stdout); - DEBUG_DEBUG(DEBUG_CATEGORY_ETCP, "send_test_packet: Calling etcp_send with len=%d", PACKET_SIZE); - int result = etcp_send(conn, test_packet_data, PACKET_SIZE); - printf("[DEBUG] send_test_packet: etcp_send returned %d\n", result); + DEBUG_DEBUG(DEBUG_CATEGORY_ETCP, "send_test_packet: Calling etcp_int_send with len=%d", PACKET_SIZE); + int result = etcp_int_send(conn, test_packet_data, PACKET_SIZE); + printf("[DEBUG] send_test_packet: etcp_int_send returned %d\n", result); fflush(stdout); - DEBUG_DEBUG(DEBUG_CATEGORY_ETCP, "send_test_packet: etcp_send returned %d", result); - + DEBUG_DEBUG(DEBUG_CATEGORY_ETCP, "send_test_packet: etcp_int_send returned %d", result); + if (result != 0) { - DEBUG_ERROR(DEBUG_CATEGORY_ETCP, "send_test_packet: Failed to send packet via etcp_send"); + DEBUG_ERROR(DEBUG_CATEGORY_ETCP, "send_test_packet: Failed to send packet via etcp_int_send"); return; } - + packet_sent = 1; - DEBUG_INFO(DEBUG_CATEGORY_ETCP, "send_test_packet: SUCCESS - Test packet sent via etcp_send (%d bytes)", PACKET_SIZE); + DEBUG_INFO(DEBUG_CATEGORY_ETCP, "send_test_packet: SUCCESS - Test packet sent via etcp_int_send (%d bytes)", PACKET_SIZE); } // Function to check if packet received in server's output queue diff --git a/tests/test_etcp_two_instances b/tests/test_etcp_two_instances new file mode 100755 index 00000000..28dc72af Binary files /dev/null and b/tests/test_etcp_two_instances differ diff --git a/tests/test_intensive_memory_pool b/tests/test_intensive_memory_pool new file mode 100755 index 00000000..7bb8e164 Binary files /dev/null and b/tests/test_intensive_memory_pool differ diff --git a/tests/test_ll_queue b/tests/test_ll_queue new file mode 100755 index 00000000..368fa1ad Binary files /dev/null and b/tests/test_ll_queue differ diff --git a/tests/test_memory_pool_and_config b/tests/test_memory_pool_and_config new file mode 100755 index 00000000..6e40e75f Binary files /dev/null and b/tests/test_memory_pool_and_config differ diff --git a/tests/test_packet_dump b/tests/test_packet_dump new file mode 100755 index 00000000..05a18202 Binary files /dev/null and b/tests/test_packet_dump differ diff --git a/tests/test_pkt_normalizer_etcp b/tests/test_pkt_normalizer_etcp new file mode 100755 index 00000000..520198f3 Binary files /dev/null and b/tests/test_pkt_normalizer_etcp differ diff --git a/tests/test_pkt_normalizer_standalone b/tests/test_pkt_normalizer_standalone new file mode 100755 index 00000000..3cfb5661 Binary files /dev/null and b/tests/test_pkt_normalizer_standalone differ diff --git a/tests/test_u_async_comprehensive b/tests/test_u_async_comprehensive new file mode 100755 index 00000000..f84e1cfd Binary files /dev/null and b/tests/test_u_async_comprehensive differ diff --git a/tests/test_u_async_performance b/tests/test_u_async_performance new file mode 100755 index 00000000..4a8b2aa4 Binary files /dev/null and b/tests/test_u_async_performance differ