syslog-ng source
transport-mapper-lib.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013 Balabit
3  * Copyright (c) 2013 Balázs Scheidler
4  *
5  * This program is free software; you can redistribute it and/or modify it
6  * under the terms of the GNU General Public License version 2 as published
7  * by the Free Software Foundation, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17  *
18  * As an additional exemption you are allowed to compile & link against the
19  * OpenSSL libraries as published by the OpenSSL project. See the file
20  * COPYING for details.
21  *
22  */
23 
24 #ifndef AFSOCKET_OPTIONS_LIB_H_INCLUDED
25 #define AFSOCKET_OPTIONS_LIB_H_INCLUDED
26 
27 #include <criterion/criterion.h>
28 
29 #include "transport-mapper.h"
30 
31 extern TransportMapper *transport_mapper;
32 
33 static inline void
34 assert_transport_mapper_apply(TransportMapper *self, const gchar *transport)
35 {
36  if (transport)
37  transport_mapper_set_transport(self, transport);
38  cr_assert(transport_mapper_apply_transport(self, configuration), "afsocket_apply_transport() failed");
39 }
40 
41 static inline void
42 assert_transport_mapper_apply_fails(TransportMapper *self, const gchar *transport)
43 {
44  if (transport)
45  transport_mapper_set_transport(self, transport);
46  cr_assert_not(transport_mapper_apply_transport(self, configuration),
47  "afsocket_apply_transport() succeeded while we expected failure");
48 }
49 
50 static inline void
51 assert_transport_mapper_transport(TransportMapper *options, const gchar *expected_transport)
52 {
53  cr_assert_str_eq(options->transport, expected_transport, "TransportMapper contains a mismatching transport name");
54 }
55 
56 static inline void
57 assert_transport_mapper_logproto(TransportMapper *options, const gchar *expected_logproto)
58 {
59  cr_assert_str_eq(options->logproto, expected_logproto, "TransportMapper contains a mismatching log_proto name");
60 }
61 
62 static inline void
63 assert_transport_mapper_stats_source(TransportMapper *options, gint stats_source)
64 {
65  cr_assert_eq(options->stats_source, stats_source, "TransportMapper contains a mismatching stats_source");
66 }
67 
68 static inline void
69 assert_transport_mapper_address_family(TransportMapper *options, gint address_family)
70 {
71  cr_assert_eq(options->address_family, address_family, "TransportMapper address family mismatch");
72 }
73 
74 static inline void
75 assert_transport_mapper_sock_type(TransportMapper *options, gint sock_type)
76 {
77  cr_assert_eq(options->sock_type, sock_type, "TransportMapper sock_type mismatch");
78 }
79 
80 static inline void
81 assert_transport_mapper_sock_proto(TransportMapper *options, gint sock_proto)
82 {
83  cr_assert_eq(options->sock_proto, sock_proto, "TransportMapper sock_proto mismatch");
84 }
85 
86 static inline void
87 assert_transport_mapper_transport_name(TransportMapper *options, const gchar *expected_transport_name)
88 {
89  gsize len;
90  const gchar *transport_name;
91 
92  transport_name = transport_mapper_get_transport_name(options, &len);
93  cr_assert_str_eq(transport_name, expected_transport_name,
94  "TransportMapper transport_name mismatch %s <> %s",
95  transport_name, expected_transport_name);
96 }
97 
98 #endif
GlobalConfig * configuration
Definition: globals.c:27
CSVScannerOptions options
Definition: test_csv_scanner.c:30
TransportMapper * transport_mapper
Definition: transport-mapper-lib.c:25
void transport_mapper_set_transport(TransportMapper *self, const gchar *transport)
Definition: transport-mapper.c:102