UNITTEST_OBJ=$(addprefix $(BUILD),$(UNITTEST_SRC:.c=.o))
DAEMON_SRC=$(wildcard daemon/*.c)
DAEMON_OBJ=$(addprefix $(BUILD),$(DAEMON_SRC:.c=.o))
-TESTBOUND_SRC=testcode/testbound.c testcode/ldns-testpkts.c daemon/worker.c testcode/replay.c
+TESTBOUND_SRC=testcode/testbound.c testcode/ldns-testpkts.c daemon/worker.c testcode/replay.c testcode/fake_event.c
TESTBOUND_OBJ=$(addprefix $(BUILD),$(TESTBOUND_SRC:.c=.o))
ALL_SRC=$(COMMON_SRC) $(UNITTEST_SRC) $(DAEMON_SRC) $(TESTBOUND_SRC)
ALL_OBJ=$(addprefix $(BUILD),$(ALL_SRC:.c=.o) $(LIBOBJS))
8 February 2007: Wouter
- added tcp test.
- replay storage.
+ - testcode/fake_event work.
7 February 2007: Wouter
- return answer with the same ID as query was sent with.
--- /dev/null
+/*
+ * testcode/fake_event.c - fake event handling that replays existing scenario.
+ *
+ * Copyright (c) 2007, NLnet Labs. All rights reserved.
+ *
+ * This software is open source.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * Neither the name of the NLNET LABS nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/**
+ * \file
+ * Event service that replays a scenario.
+ * This implements the same exported symbols as the files:
+ * util/netevent.c
+ * services/listen_dnsport.c
+ * services/outside_network.c
+ * But these do not actually access the network or events, instead
+ * the scenario is played.
+ */
+
+#include "config.h"
+#include "testcode/fake_event.h"
+#include "util/netevent.h"
+#include "services/listen_dnsport.h"
+#include "services/outside_network.h"
+#include "testcode/replay.h"
+
+/** Global variable: the scenario */
+static struct replay_scenario* scenario = NULL;
+
+void
+fake_event_init(struct replay_scenario* scen)
+{
+ scenario = scen;
+}
+
+void
+fake_event_cleanup()
+{
+ replay_scenario_delete(scenario);
+ scenario = NULL;
+}
+
+/*********** Dummy routines ***********/
+
+/*********** End of Dummy routines ***********/
--- /dev/null
+/*
+ * testcode/fake_event.h - fake event handling that replays existing scenario.
+ *
+ * Copyright (c) 2007, NLnet Labs. All rights reserved.
+ *
+ * This software is open source.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * Neither the name of the NLNET LABS nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/**
+ * \file
+ * Event service that replays a scenario.
+ * This implements the same exported symbols as the files:
+ * util/netevent.c
+ * services/listen_dnsport.c
+ * services/outside_network.c
+ * But these do not actually access the network or events, instead
+ * the scenario is played.
+ */
+
+#ifndef TESTCODE_FAKE_EVENT_H
+#define TESTCODE_FAKE_EVENT_H
+struct replay_scenario;
+
+/**
+ * Initialise fake event services.
+ *
+ * @param scen: Set the scenario to use for upcoming event handling.
+ */
+void fake_event_init(struct replay_scenario* scen);
+
+/**
+ * Deinit fake event services.
+ */
+void fake_event_cleanup();
+
+#endif /* TESTCODE_FAKE_EVENT_H */
#include "config.h"
#include "testcode/replay.h"
+struct replay_scenario*
+replay_scenario_read(FILE* in)
+{
+ return NULL;
+}
+void
+replay_scenario_delete(struct replay_scenario* scen)
+{
+}
* File format for replay files.
*
* ; comment line.
- * And then a number of entries:
+ * SCENARIO_BEGIN
+ * TITLE name_of_scenario
* RANGE start_time end_time
* match_entries
* END_RANGE
+ * ; more RANGE items.
* ; go to the next moment
* STEP time_step event_type
* ; event_type can be:
* o CHECK_OUT_QUERY - followed by entry
* o REPLY - followed by entry
* o TIMEOUT
+ * o ERROR
* ; following entry starts on the next line, ENTRY_BEGIN.
+ * SCENARIO_END
*
*
* ; Example file
+ * SCENARIO_BEGIN
+ * TITLE Example scenario
* RANGE 0 100
* ENTRY_BEGIN
* ; precoded answers to queries.
* ; what the reply should look like
* ENTRY_END
* ; successful termination. (if the answer was OK).
+ * SCENARIO_END
*
* </pre>
*/
struct replay_range;
struct entry;
+
/**
* A replay scenario.
*/
struct replay_scenario {
+ /** name of replay scenario. malloced string. */
+ const char* title;
/** The list of replay moments. Linked list. Time increases in list. */
struct replay_moment* mom_first;
* So: timestep, parts of query, destination --> answer.
*/
struct replay_range* range_list;
-
- /**
- * List of pending queries in order they were sent out. First
- * one has been sent out most recently. Last one in list is oldest.
- */
- struct fake_pending* pending_list;
-
- /**
- * List of answers from the matching list, that need to be returned
- * to the program.
- */
- struct replay_answer* answer_list;
-
- /** callback for incoming queries */
- comm_point_callback_t* callback_query;
- /** user argument for incoming query callback */
- void *cb_arg;
};
/**
repevt_back_reply,
/** test fails if query to the network does not match */
repevt_back_query,
+ /** an error happens to outbound query */
+ repevt_error,
} evt_type;
/** The sent packet must match this. Incoming events, the data. */
ldns_rr* qname;
};
+/**
+ * Range of timesteps, and canned replies to matching queries.
+ */
+struct replay_range {
+ /** time range when this is valid. Including start and end step. */
+ size_t start_step;
+ /** end step of time range. */
+ size_t end_step;
+
+ /** Matching list */
+ struct entry* match;
+
+ /** next in list of time ranges. */
+ struct replay_range* next_range;
+};
+
+/**
+ * Replay storage of runtime information.
+ */
+struct replay_runtime {
+ /**
+ * List of pending queries in order they were sent out. First
+ * one has been sent out most recently. Last one in list is oldest.
+ */
+ struct fake_pending* pending_list;
+
+ /**
+ * List of answers from the matching list, that need to be returned
+ * to the program.
+ */
+ struct replay_answer* answer_list;
+
+ /** callback for incoming queries */
+ comm_point_callback_t* callback_query;
+ /** user argument for incoming query callback */
+ void *cb_arg;
+};
+
/**
* Pending queries to network, fake replay version.
*/
struct sockaddr_storage addr;
/** len of addr */
socklen_t addrlen;
- /** The callback function to call */
+ /** The callback function to call when answer arrives (or timeout) */
comm_point_callback_t* callback;
/** callback user argument */
void* cb_arg;
};
/**
- * Range of timesteps, and canned replies to matching queries.
+ * Read a replay scenario from the file.
+ * @param in: file to read from.
+ * @return: Scenario. NULL if no scenario read.
*/
-struct replay_range {
- /** time range when this is valid. Including start and end step. */
- size_t start_step;
- /** end step of time range. */
- size_t end_step;
+struct replay_scenario* replay_scenario_read(FILE* in);
- /** Matching list */
- struct entry* match;
-
- /** next in list of time ranges. */
- struct replay_range* next_range;
-};
+/**
+ * Delete scenario.
+ * @param scen: to delete.
+ */
+void replay_scenario_delete(struct replay_scenario* scen);
#endif /* TESTCODE_REPLAY_H */