diff options
Diffstat (limited to 'src/regex/test_regex_api.c')
-rw-r--r-- | src/regex/test_regex_api.c | 72 |
1 files changed, 36 insertions, 36 deletions
diff --git a/src/regex/test_regex_api.c b/src/regex/test_regex_api.c index 7016bf9c4..2ee24800a 100644 --- a/src/regex/test_regex_api.c +++ b/src/regex/test_regex_api.c | |||
@@ -11,12 +11,12 @@ | |||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Affero General Public License for more details. | 13 | Affero General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Affero General Public License | 15 | You should have received a copy of the GNU Affero General Public License |
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | 17 | ||
18 | SPDX-License-Identifier: AGPL3.0-or-later | 18 | SPDX-License-Identifier: AGPL3.0-or-later |
19 | */ | 19 | */ |
20 | /** | 20 | /** |
21 | * @file regex/test_regex_api.c | 21 | * @file regex/test_regex_api.c |
22 | * @brief base test case for regex api (and DHT functions) | 22 | * @brief base test case for regex api (and DHT functions) |
@@ -31,12 +31,12 @@ | |||
31 | /** | 31 | /** |
32 | * How long until we really give up on a particular testcase portion? | 32 | * How long until we really give up on a particular testcase portion? |
33 | */ | 33 | */ |
34 | #define TOTAL_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 600) | 34 | #define TOTAL_TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 600) |
35 | 35 | ||
36 | /** | 36 | /** |
37 | * How long until we give up on any particular operation (and retry)? | 37 | * How long until we give up on any particular operation (and retry)? |
38 | */ | 38 | */ |
39 | #define BASE_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 3) | 39 | #define BASE_TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 3) |
40 | 40 | ||
41 | 41 | ||
42 | static struct GNUNET_REGEX_Announcement *a; | 42 | static struct GNUNET_REGEX_Announcement *a; |
@@ -49,25 +49,25 @@ static struct GNUNET_SCHEDULER_Task *die_task; | |||
49 | 49 | ||
50 | 50 | ||
51 | static void | 51 | static void |
52 | end (void *cls) | 52 | end(void *cls) |
53 | { | 53 | { |
54 | die_task = NULL; | 54 | die_task = NULL; |
55 | GNUNET_REGEX_announce_cancel (a); | 55 | GNUNET_REGEX_announce_cancel(a); |
56 | a = NULL; | 56 | a = NULL; |
57 | GNUNET_REGEX_search_cancel (s); | 57 | GNUNET_REGEX_search_cancel(s); |
58 | s = NULL; | 58 | s = NULL; |
59 | ok = 0; | 59 | ok = 0; |
60 | } | 60 | } |
61 | 61 | ||
62 | 62 | ||
63 | static void | 63 | static void |
64 | end_badly () | 64 | end_badly() |
65 | { | 65 | { |
66 | die_task = NULL; | 66 | die_task = NULL; |
67 | fprintf (stderr, "%s", "Testcase failed (timeout).\n"); | 67 | fprintf(stderr, "%s", "Testcase failed (timeout).\n"); |
68 | GNUNET_REGEX_announce_cancel (a); | 68 | GNUNET_REGEX_announce_cancel(a); |
69 | a = NULL; | 69 | a = NULL; |
70 | GNUNET_REGEX_search_cancel (s); | 70 | GNUNET_REGEX_search_cancel(s); |
71 | s = NULL; | 71 | s = NULL; |
72 | ok = 1; | 72 | ok = 1; |
73 | } | 73 | } |
@@ -84,44 +84,44 @@ end_badly () | |||
84 | * @param put_path_length Length of the put_path. | 84 | * @param put_path_length Length of the put_path. |
85 | */ | 85 | */ |
86 | static void | 86 | static void |
87 | found_cb (void *cls, | 87 | found_cb(void *cls, |
88 | const struct GNUNET_PeerIdentity *id, | 88 | const struct GNUNET_PeerIdentity *id, |
89 | const struct GNUNET_PeerIdentity *get_path, | 89 | const struct GNUNET_PeerIdentity *get_path, |
90 | unsigned int get_path_length, | 90 | unsigned int get_path_length, |
91 | const struct GNUNET_PeerIdentity *put_path, | 91 | const struct GNUNET_PeerIdentity *put_path, |
92 | unsigned int put_path_length) | 92 | unsigned int put_path_length) |
93 | { | 93 | { |
94 | GNUNET_SCHEDULER_cancel (die_task); | 94 | GNUNET_SCHEDULER_cancel(die_task); |
95 | die_task = | 95 | die_task = |
96 | GNUNET_SCHEDULER_add_now (&end, NULL); | 96 | GNUNET_SCHEDULER_add_now(&end, NULL); |
97 | } | 97 | } |
98 | 98 | ||
99 | 99 | ||
100 | static void | 100 | static void |
101 | run (void *cls, | 101 | run(void *cls, |
102 | const struct GNUNET_CONFIGURATION_Handle *cfg, | 102 | const struct GNUNET_CONFIGURATION_Handle *cfg, |
103 | struct GNUNET_TESTING_Peer *peer) | 103 | struct GNUNET_TESTING_Peer *peer) |
104 | { | 104 | { |
105 | die_task = | 105 | die_task = |
106 | GNUNET_SCHEDULER_add_delayed (TOTAL_TIMEOUT, | 106 | GNUNET_SCHEDULER_add_delayed(TOTAL_TIMEOUT, |
107 | &end_badly, NULL); | 107 | &end_badly, NULL); |
108 | a = GNUNET_REGEX_announce (cfg, | 108 | a = GNUNET_REGEX_announce(cfg, |
109 | "my long prefix - hello world(0|1)*", | 109 | "my long prefix - hello world(0|1)*", |
110 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, | 110 | GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, |
111 | 5), | 111 | 5), |
112 | 1); | 112 | 1); |
113 | s = GNUNET_REGEX_search (cfg, | 113 | s = GNUNET_REGEX_search(cfg, |
114 | "my long prefix - hello world0101", | 114 | "my long prefix - hello world0101", |
115 | &found_cb, NULL); | 115 | &found_cb, NULL); |
116 | } | 116 | } |
117 | 117 | ||
118 | 118 | ||
119 | int | 119 | int |
120 | main (int argc, char *argv[]) | 120 | main(int argc, char *argv[]) |
121 | { | 121 | { |
122 | if (0 != GNUNET_TESTING_peer_run ("test-regex-api", | 122 | if (0 != GNUNET_TESTING_peer_run("test-regex-api", |
123 | "test_regex_api_data.conf", | 123 | "test_regex_api_data.conf", |
124 | &run, NULL)) | 124 | &run, NULL)) |
125 | return 1; | 125 | return 1; |
126 | return ok; | 126 | return ok; |
127 | } | 127 | } |