diff options
author | Lorenz Kästle <lorenz.kaestle@netways.de> | 2024-10-17 15:57:50 (GMT) |
---|---|---|
committer | Lorenz Kästle <lorenz.kaestle@netways.de> | 2024-10-17 15:57:50 (GMT) |
commit | ee1ba3209993b72e90f5fe30a16ad951f1e2402d (patch) | |
tree | 24b9cb0130f89892ea71562f09197d95c269048c /lib/tests/test_tcp.c | |
parent | 7fb58ce783285a983964d219fff18eba9b12e1e4 (diff) | |
download | monitoring-plugins-ee1ba3209993b72e90f5fe30a16ad951f1e2402d.tar.gz |
lib: clang-format
Diffstat (limited to 'lib/tests/test_tcp.c')
-rw-r--r-- | lib/tests/test_tcp.c | 66 |
1 files changed, 27 insertions, 39 deletions
diff --git a/lib/tests/test_tcp.c b/lib/tests/test_tcp.c index 1954b0f..b09c005 100644 --- a/lib/tests/test_tcp.c +++ b/lib/tests/test_tcp.c | |||
@@ -1,58 +1,46 @@ | |||
1 | /***************************************************************************** | 1 | /***************************************************************************** |
2 | * | 2 | * |
3 | * This program is free software: you can redistribute it and/or modify | 3 | * This program is free software: you can redistribute it and/or modify |
4 | * it under the terms of the GNU General Public License as published by | 4 | * it under the terms of the GNU General Public License as published by |
5 | * the Free Software Foundation, either version 3 of the License, or | 5 | * the Free Software Foundation, either version 3 of the License, or |
6 | * (at your option) any later version. | 6 | * (at your option) any later version. |
7 | * | 7 | * |
8 | * This program is distributed in the hope that it will be useful, | 8 | * This program is distributed in the hope that it will be useful, |
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
11 | * GNU General Public License for more details. | 11 | * GNU General Public License for more details. |
12 | * | 12 | * |
13 | * You should have received a copy of the GNU General Public License | 13 | * You should have received a copy of the GNU General Public License |
14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
15 | * | 15 | * |
16 | * | 16 | * |
17 | *****************************************************************************/ | 17 | *****************************************************************************/ |
18 | 18 | ||
19 | #include "common.h" | 19 | #include "common.h" |
20 | #include "utils_tcp.h" | 20 | #include "utils_tcp.h" |
21 | #include "tap.h" | 21 | #include "tap.h" |
22 | 22 | ||
23 | int | 23 | int main(void) { |
24 | main(void) | ||
25 | { | ||
26 | char **server_expect; | 24 | char **server_expect; |
27 | int server_expect_count = 3; | 25 | int server_expect_count = 3; |
28 | 26 | ||
29 | plan_tests(9); | 27 | plan_tests(9); |
30 | 28 | ||
31 | server_expect = malloc(sizeof(char*) * server_expect_count); | 29 | server_expect = malloc(sizeof(char *) * server_expect_count); |
32 | 30 | ||
33 | server_expect[0] = strdup("AA"); | 31 | server_expect[0] = strdup("AA"); |
34 | server_expect[1] = strdup("bb"); | 32 | server_expect[1] = strdup("bb"); |
35 | server_expect[2] = strdup("CC"); | 33 | server_expect[2] = strdup("CC"); |
36 | 34 | ||
37 | ok(np_expect_match("AA bb CC XX", server_expect, server_expect_count, NP_MATCH_EXACT) == NP_MATCH_SUCCESS, | 35 | ok(np_expect_match("AA bb CC XX", server_expect, server_expect_count, NP_MATCH_EXACT) == NP_MATCH_SUCCESS, "Test matching any string at the beginning (first expect string)"); |
38 | "Test matching any string at the beginning (first expect string)"); | 36 | ok(np_expect_match("bb AA CC XX", server_expect, server_expect_count, NP_MATCH_EXACT) == NP_MATCH_SUCCESS, "Test matching any string at the beginning (second expect string)"); |
39 | ok(np_expect_match("bb AA CC XX", server_expect, server_expect_count, NP_MATCH_EXACT) == NP_MATCH_SUCCESS, | 37 | ok(np_expect_match("b", server_expect, server_expect_count, NP_MATCH_EXACT) == NP_MATCH_RETRY, "Test matching any string at the beginning (substring match)"); |
40 | "Test matching any string at the beginning (second expect string)"); | 38 | ok(np_expect_match("XX bb AA CC XX", server_expect, server_expect_count, NP_MATCH_EXACT) == NP_MATCH_FAILURE, "Test with strings not matching at the beginning"); |
41 | ok(np_expect_match("b", server_expect, server_expect_count, NP_MATCH_EXACT) == NP_MATCH_RETRY, | 39 | ok(np_expect_match("XX CC XX", server_expect, server_expect_count, NP_MATCH_EXACT) == NP_MATCH_FAILURE, "Test matching any string"); |
42 | "Test matching any string at the beginning (substring match)"); | 40 | ok(np_expect_match("XX", server_expect, server_expect_count, 0) == NP_MATCH_RETRY, "Test not matching any string"); |
43 | ok(np_expect_match("XX bb AA CC XX", server_expect, server_expect_count, NP_MATCH_EXACT) == NP_MATCH_FAILURE, | 41 | ok(np_expect_match("XX AA bb CC XX", server_expect, server_expect_count, NP_MATCH_ALL) == NP_MATCH_SUCCESS, "Test matching all strings"); |
44 | "Test with strings not matching at the beginning"); | 42 | ok(np_expect_match("XX bb CC XX", server_expect, server_expect_count, NP_MATCH_ALL) == NP_MATCH_RETRY, "Test not matching all strings"); |
45 | ok(np_expect_match("XX CC XX", server_expect, server_expect_count, NP_MATCH_EXACT) == NP_MATCH_FAILURE, | 43 | ok(np_expect_match("XX XX", server_expect, server_expect_count, NP_MATCH_ALL) == NP_MATCH_RETRY, "Test not matching any string (testing all)"); |
46 | "Test matching any string"); | ||
47 | ok(np_expect_match("XX", server_expect, server_expect_count, 0) == NP_MATCH_RETRY, | ||
48 | "Test not matching any string"); | ||
49 | ok(np_expect_match("XX AA bb CC XX", server_expect, server_expect_count, NP_MATCH_ALL) == NP_MATCH_SUCCESS, | ||
50 | "Test matching all strings"); | ||
51 | ok(np_expect_match("XX bb CC XX", server_expect, server_expect_count, NP_MATCH_ALL) == NP_MATCH_RETRY, | ||
52 | "Test not matching all strings"); | ||
53 | ok(np_expect_match("XX XX", server_expect, server_expect_count, NP_MATCH_ALL) == NP_MATCH_RETRY, | ||
54 | "Test not matching any string (testing all)"); | ||
55 | |||
56 | 44 | ||
57 | return exit_status(); | 45 | return exit_status(); |
58 | } | 46 | } |