From 692fbac66d68e5e6beb9b1de340ad7310f2e4403 Mon Sep 17 00:00:00 2001 From: Simon Arlott Date: Sun, 6 Aug 2017 11:05:03 +0100 Subject: [PATCH] tests: send1: load modules in a predictable order So that tags are added in the same order every time. # wanted: @time=2017-07-14T02:40:00.000Z;account=test :LChanPeon!username@example.test TEST #placeholder :Hello World! # seen: @account=test;time=2017-07-14T02:40:00.000Z :LChanPeon!username@example.test TEST #placeholder :Hello World! --- tests/ircd_util.c | 17 ++++++++++++++--- tests/ircd_util.h | 1 + tests/send1.c | 4 ++++ 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/tests/ircd_util.c b/tests/ircd_util.c index b6e895d3..d22333aa 100644 --- a/tests/ircd_util.c +++ b/tests/ircd_util.c @@ -23,11 +23,11 @@ #include #include "tap/basic.h" -#include "stdinc.h" -#include "ircd_defs.h" +#include "ircd_util.h" + #include "defaults.h" #include "client.h" -#include "ircd_util.h" +#include "modules.h" #define MSG "%s:%d (%s)", __FILE__, __LINE__, __FUNCTION__ @@ -97,6 +97,17 @@ void ircd_util_init(const char *name) is_int(0, charybdis_main(ARRAY_SIZE(argv) - 1, argv), MSG); } +void ircd_util_reload_module(const char *name) +{ + struct module *mod = findmodule_byname(name); + + if (ok(mod != NULL, MSG)) { + if (ok(unload_one_module(name, false), MSG)) { + ok(load_one_module(name, mod->origin, mod->core), MSG); + } + } +} + void ircd_util_free(void) { } diff --git a/tests/ircd_util.h b/tests/ircd_util.h index 4f3dc879..0bea79c4 100644 --- a/tests/ircd_util.h +++ b/tests/ircd_util.h @@ -29,4 +29,5 @@ #define TEST_ME_ID "0AA" void ircd_util_init(const char *name); +void ircd_util_reload_module(const char *name); void ircd_util_free(void); diff --git a/tests/send1.c b/tests/send1.c index 538d0af0..1f9ffb92 100644 --- a/tests/send1.c +++ b/tests/send1.c @@ -2682,6 +2682,10 @@ int main(int argc, char *argv[]) ircd_util_init(__FILE__); client_util_init(); + // Load modules in a predictable order so that tags are added in the same order every time + ircd_util_reload_module("cap_account_tag"); + ircd_util_reload_module("cap_server_time"); + CAP_ACCOUNT_TAG = capability_get(cli_capindex, "account-tag", NULL); ok(CAP_ACCOUNT_TAG != 0, "CAP_ACCOUNT_TAG missing; " MSG);