2 This file is part of GNUnet.
3 Copyright (C) 2013 GNUnet e.V.
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version.
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
21 * @file regex/test_regex_api.c
22 * @brief base test case for regex api (and DHT functions)
23 * @author Christian Grothoff
26 #include "gnunet_util_lib.h"
27 #include "gnunet_testing_lib.h"
28 #include "gnunet_regex_service.h"
32 * How long until we really give up on a particular testcase portion?
34 #define TOTAL_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 600)
37 * How long until we give up on any particular operation (and retry)?
39 #define BASE_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 3)
42 static struct GNUNET_REGEX_Announcement *a;
44 static struct GNUNET_REGEX_Search *s;
48 static struct GNUNET_SCHEDULER_Task *die_task;
55 GNUNET_REGEX_announce_cancel (a);
57 GNUNET_REGEX_search_cancel (s);
67 FPRINTF (stderr, "%s", "Testcase failed (timeout).\n");
68 GNUNET_REGEX_announce_cancel (a);
70 GNUNET_REGEX_search_cancel (s);
77 * Search callback function, invoked for every result that was found.
79 * @param cls Closure provided in GNUNET_REGEX_search.
80 * @param id Peer providing a regex that matches the string.
81 * @param get_path Path of the get request.
82 * @param get_path_length Lenght of get_path.
83 * @param put_path Path of the put request.
84 * @param put_path_length Length of the put_path.
88 const struct GNUNET_PeerIdentity *id,
89 const struct GNUNET_PeerIdentity *get_path,
90 unsigned int get_path_length,
91 const struct GNUNET_PeerIdentity *put_path,
92 unsigned int put_path_length)
94 GNUNET_SCHEDULER_cancel (die_task);
96 GNUNET_SCHEDULER_add_now (&end, NULL);
102 const struct GNUNET_CONFIGURATION_Handle *cfg,
103 struct GNUNET_TESTING_Peer *peer)
106 GNUNET_SCHEDULER_add_delayed (TOTAL_TIMEOUT,
108 a = GNUNET_REGEX_announce (cfg,
109 "my long prefix - hello world(0|1)*",
110 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS,
113 s = GNUNET_REGEX_search (cfg,
114 "my long prefix - hello world0101",
120 main (int argc, char *argv[])
122 if (0 != GNUNET_TESTING_peer_run ("test-regex-api",
123 "test_regex_api_data.conf",
129 /* end of test_regex_api.c */