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