|
| 1 | +cmake_minimum_required(VERSION 3.0.0 FATAL_ERROR) |
| 2 | +cmake_policy(SET CMP0057 NEW) |
| 3 | + |
| 4 | +project(regression_test LANGUAGES C) |
| 5 | + |
| 6 | +get_filename_component( |
| 7 | + SOURCE_DIR |
| 8 | + ${CMAKE_CURRENT_LIST_DIR}/../../../regression/interoperability_test/mqtt_test |
| 9 | + ABSOLUTE) |
| 10 | + |
| 11 | +if(NOT "-DNXD_MQTT_REQUIRE_TLS" IN_LIST ${CMAKE_BUILD_TYPE}) |
| 12 | + list(APPEND mqtt_test_cases mqtt_subscriber_test) |
| 13 | + set(mqtt_subscriber_test_file_list |
| 14 | + ${SOURCE_DIR}/linux_mqtt_subscriber_test_entry.c |
| 15 | + ${SOURCE_DIR}/linux_mqtt_subscriber_test_server.c |
| 16 | + ${SOURCE_DIR}/linux_mqtt_subscriber_test_publisher.c |
| 17 | + ${SOURCE_DIR}/netx_mqtt_subscriber_test.c) |
| 18 | + list(APPEND mqtt_test_cases mqtt_subscriber_empty_message_test) |
| 19 | + set(mqtt_subscriber_empty_message_test_file_list |
| 20 | + ${SOURCE_DIR}/linux_mqtt_subscriber_test_entry.c |
| 21 | + ${SOURCE_DIR}/linux_mqtt_subscriber_test_server.c |
| 22 | + ${SOURCE_DIR}/linux_mqtt_subscriber_empty_message_test_publisher.c |
| 23 | + ${SOURCE_DIR}/netx_mqtt_subscriber_empty_message_test.c) |
| 24 | +endif() |
| 25 | + |
| 26 | +if("-DNX_SECURE_ENABLE" IN_LIST ${CMAKE_BUILD_TYPE}) |
| 27 | + list(APPEND mqtt_test_cases mqtt_tls_subscriber_twice_test) |
| 28 | + set(mqtt_tls_subscriber_twice_test_file_list |
| 29 | + ${SOURCE_DIR}/linux_mqtt_tls_subscriber_test_entry.c |
| 30 | + ${SOURCE_DIR}/linux_mqtt_tls_subscriber_test_server.c |
| 31 | + ${SOURCE_DIR}/linux_mqtt_tls_subscriber_twice_test_publisher.c |
| 32 | + ${SOURCE_DIR}/netx_mqtt_tls_subscriber_twice_test.c) |
| 33 | + |
| 34 | + list(APPEND mqtt_test_cases mqtt_double_subscribers_test) |
| 35 | + set(mqtt_double_subscribers_test_file_list |
| 36 | + ${SOURCE_DIR}/linux_mqtt_tls_subscriber_test_entry.c |
| 37 | + ${SOURCE_DIR}/linux_mqtt_tls_subscriber_test_server.c |
| 38 | + ${SOURCE_DIR}/linux_mqtt_tls_subscriber_test_publisher.c |
| 39 | + ${SOURCE_DIR}/netx_mqtt_double_subscribers_test.c) |
| 40 | + |
| 41 | + list(APPEND mqtt_test_cases mqtt_tls_subscriber_test) |
| 42 | + set(mqtt_tls_subscriber_test_file_list |
| 43 | + ${SOURCE_DIR}/linux_mqtt_tls_subscriber_test_entry.c |
| 44 | + ${SOURCE_DIR}/linux_mqtt_tls_subscriber_test_server.c |
| 45 | + ${SOURCE_DIR}/linux_mqtt_tls_subscriber_test_publisher.c |
| 46 | + ${SOURCE_DIR}/netx_mqtt_tls_subscriber_test.c) |
| 47 | + |
| 48 | + list(APPEND debug_secure_build_mqtt_test_cases mqtt_tls_debug_test) |
| 49 | + set(mqtt_tls_debug_test_file_list |
| 50 | + ${SOURCE_DIR}/netx_mqtt_tls_subscriber_test.c) |
| 51 | +endif() |
| 52 | + |
| 53 | +set(test_utility_files |
| 54 | + ${SOURCE_DIR}/netxtestcontrol.c |
| 55 | + ${SOURCE_DIR}/nx_crypto_ciphersuites_regression.c |
| 56 | + ${SOURCE_DIR}/nx_ram_network_driver_test_1500.c |
| 57 | + ${SOURCE_DIR}/nx_secure_fips_test_utility.c) |
| 58 | + |
| 59 | +get_filename_component( |
| 60 | + UTILITY_SOURCE_DIR |
| 61 | + ${CMAKE_CURRENT_LIST_DIR}/../../../regression/interoperability_test/test_frame |
| 62 | + ABSOLUTE) |
| 63 | +add_library( |
| 64 | + test_utility |
| 65 | + ${UTILITY_SOURCE_DIR}/tls_test_get_external_test_process_output.c |
| 66 | + ${UTILITY_SOURCE_DIR}/tls_test_launch_external_test_process.c |
| 67 | + ${UTILITY_SOURCE_DIR}/tls_test_launch_external_test_process_in_background.c |
| 68 | + ${UTILITY_SOURCE_DIR}/tls_test_director_clean_all.c |
| 69 | + ${UTILITY_SOURCE_DIR}/tls_test_director_cleanup_registered_instances.c |
| 70 | + ${UTILITY_SOURCE_DIR}/tls_test_director_create.c |
| 71 | + ${UTILITY_SOURCE_DIR}/tls_test_director_destroy.c |
| 72 | + ${UTILITY_SOURCE_DIR}/tls_test_director_register_test_instance.c |
| 73 | + ${UTILITY_SOURCE_DIR}/tls_test_director_test_start.c |
| 74 | + ${UTILITY_SOURCE_DIR}/tls_test_instance_attributes_access.c |
| 75 | + ${UTILITY_SOURCE_DIR}/tls_test_instance_append.c |
| 76 | + ${UTILITY_SOURCE_DIR}/tls_test_instance_create.c |
| 77 | + ${UTILITY_SOURCE_DIR}/tls_test_instance_destroy.c |
| 78 | + ${UTILITY_SOURCE_DIR}/tls_test_instance_find_next.c |
| 79 | + ${UTILITY_SOURCE_DIR}/tls_test_instance_set_exit_status.c |
| 80 | + ${UTILITY_SOURCE_DIR}/tls_test_instance_shared_buffer_manipulate.c |
| 81 | + ${UTILITY_SOURCE_DIR}/tls_test_kill_external_test_process.c |
| 82 | + ${UTILITY_SOURCE_DIR}/tls_test_semaphore_create.c |
| 83 | + ${UTILITY_SOURCE_DIR}/tls_test_semaphore_destroy.c |
| 84 | + ${UTILITY_SOURCE_DIR}/tls_test_semaphore_post.c |
| 85 | + ${UTILITY_SOURCE_DIR}/tls_test_semaphore_wait.c |
| 86 | + ${UTILITY_SOURCE_DIR}/tls_test_wait_all_child_process.c |
| 87 | + ${UTILITY_SOURCE_DIR}/tls_test_wait_external_test_process.c |
| 88 | + ${UTILITY_SOURCE_DIR}/tls_test_uninterruptable_wait.c) |
| 89 | +target_link_libraries(test_utility PUBLIC azrtos::netxduo) |
| 90 | +target_include_directories(test_utility PUBLIC ${UTILITY_SOURCE_DIR}) |
| 91 | + |
| 92 | +include(network_config.cmake) |
| 93 | + |
| 94 | +set(PCAP_SOURCE |
| 95 | + ${CMAKE_CURRENT_LIST_DIR}/../../../regression/interoperability_test/nx_pcap_network_driver.c |
| 96 | +) |
| 97 | +foreach(test_case ${mqtt_test_cases}) |
| 98 | + add_executable(${test_case} ${${test_case}_file_list} ${PCAP_SOURCE}) |
| 99 | + network_config(${test_case}) |
| 100 | + target_link_libraries(${test_case} PRIVATE test_utility pcap) |
| 101 | + add_test( |
| 102 | + NAME ${CMAKE_BUILD_TYPE}::${test_case} |
| 103 | + COMMAND |
| 104 | + bash -c |
| 105 | + "export PATH=${SOURCE_DIR}/test_scripts/:$PATH; |
| 106 | + ip link del ${${test_case}_interface}>/dev/null 2>&1; |
| 107 | + ip link add ${${test_case}_interface} type veth peer name ${${test_case}_remote_interface} || exit 1; |
| 108 | + ifconfig ${${test_case}_interface} up || { ip link del ${${test_case}_interface}; exit 1; }; |
| 109 | + ifconfig ${${test_case}_remote_interface} ${${test_case}_remote_ip} up netmask ${TEST_NETMASK} || { ip link del ${${test_case}_interface};exit 1; }; |
| 110 | + ethtool --offload ${${test_case}_remote_interface} tx off || { ip link del ${${test_case}_interface}; exit 1; }; |
| 111 | + tcpdump -i ${${test_case}_remote_interface} -s 0 -w ${CMAKE_CURRENT_BINARY_DIR}/${test_case}.pcap& |
| 112 | + pid=$! |
| 113 | + ${CMAKE_CURRENT_BINARY_DIR}/${test_case}; |
| 114 | + exit_code=$? |
| 115 | + sleep 1; |
| 116 | + kill -TERM $pid |
| 117 | + ip link del ${${test_case}_interface} || exit 1; |
| 118 | + [[ $exit_code = 0 ]] || [[ $exit_code = 233 ]] || { echo Exit code: $exit_code; exit $exit_code; };" |
| 119 | + WORKING_DIRECTORY ${SOURCE_DIR}) |
| 120 | +endforeach() |
0 commit comments