1 /* libcoap unit tests 2 * 3 * Copyright (C) 2012-2023 Olaf Bergmann <bergmann@tzi.org> 4 * 5 * SPDX-License-Identifier: BSD-2-Clause 6 * 7 * This file is part of the CoAP library libcoap. Please see 8 * README for terms of use. 9 */ 10 11 #include <stdio.h> 12 13 #include <CUnit/CUnit.h> 14 #include <CUnit/Basic.h> 15 16 #include "test_common.h" 17 #include "test_uri.h" 18 #include "test_encode.h" 19 #include "test_options.h" 20 #include "test_pdu.h" 21 #include "test_error_response.h" 22 #include "test_session.h" 23 #include "test_sendqueue.h" 24 #include "test_wellknown.h" 25 #include "test_tls.h" 26 #if COAP_OSCORE_SUPPORT && COAP_SERVER_SUPPORT 27 #include "test_oscore.h" 28 #endif /* COAP_OSCORE_SUPPORT && COAP_CLIENT_SUPPORT */ 29 30 int main(int argc COAP_UNUSED, char **argv COAP_UNUSED)31main(int argc COAP_UNUSED, char **argv COAP_UNUSED) { 32 CU_ErrorCode result; 33 CU_BasicRunMode run_mode = CU_BRM_VERBOSE; 34 35 if (CU_initialize_registry() != CUE_SUCCESS) { 36 fprintf(stderr, "E: test framework initialization failed\n"); 37 return -2; 38 } 39 40 coap_startup(); 41 t_init_uri_tests(); 42 t_init_encode_tests(); 43 t_init_option_tests(); 44 t_init_pdu_tests(); 45 t_init_error_response_tests(); 46 #if COAP_CLIENT_SUPPORT 47 t_init_session_tests(); 48 t_init_sendqueue_tests(); 49 #endif /* COAP_CLIENT_SUPPORT */ 50 #if COAP_SERVER_SUPPORT && COAP_CLIENT_SUPPORT 51 t_init_wellknown_tests(); 52 #endif /* COAP_SERVER_SUPPORT && COAP_CLIENT_SUPPORT */ 53 t_init_tls_tests(); 54 #if COAP_OSCORE_SUPPORT && COAP_SERVER_SUPPORT 55 t_init_oscore_tests(); 56 #endif /* COAP_OSCORE_SUPPORT && COAP_CLIENT_SUPPORT */ 57 58 CU_basic_set_mode(run_mode); 59 result = CU_basic_run_tests(); 60 61 CU_cleanup_registry(); 62 coap_cleanup(); 63 64 return result; 65 } 66