2 * This file is part of the PCEPlib, a PCEP protocol library.
4 * Copyright (C) 2020 Volta Networks https://voltanet.io/
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 * Author : Brady Johnson <brady@voltanet.io>
24 * This module is built into a separate library, and is used by several
25 * other modules for unit testing, so that real sockets dont have to be
29 #ifndef PCEP_SOCKET_COMM_MOCK_SOCKET_COMM_H_
30 #define PCEP_SOCKET_COMM_MOCK_SOCKET_COMM_H_
34 #include "pcep_utils_double_linked_list.h"
36 typedef struct mock_socket_comm_info_
{
37 int socket_comm_initialize_external_infra_times_called
;
38 int socket_comm_session_initialize_times_called
;
39 int socket_comm_session_initialize_src_times_called
;
40 int socket_comm_session_teardown_times_called
;
41 int socket_comm_session_connect_tcp_times_called
;
42 int socket_comm_session_send_message_times_called
;
43 int socket_comm_session_close_tcp_after_write_times_called
;
44 int socket_comm_session_close_tcp_times_called
;
45 int destroy_socket_comm_loop_times_called
;
47 /* TODO later if necessary, we can add return values for
48 * those functions that return something */
50 /* Used to access messages sent with socket_comm_session_send_message()
52 bool send_message_save_message
;
53 double_linked_list
*sent_message_list
;
55 } mock_socket_comm_info
;
57 void setup_mock_socket_comm_info(void);
58 void teardown_mock_socket_comm_info(void);
59 void reset_mock_socket_comm_info(void);
60 bool destroy_socket_comm_loop(void);
62 mock_socket_comm_info
*get_mock_socket_comm_info(void);
63 void verify_socket_comm_times_called(int initialized
, int teardown
, int connect
,
64 int send_message
, int close_after_write
,
65 int close
, int destroy
);
67 #endif /* PCEP_SOCKET_COMM_MOCK_SOCKET_COMM_H_ */