diff options
author | Vsevolod Stakhov <vsevolod@rspamd.com> | 2024-03-18 18:56:33 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@rspamd.com> | 2024-03-18 18:56:33 +0000 |
commit | 14c13854d3cae9d93c3d148be30fb72f1eaffe55 (patch) | |
tree | 7b1a3e41b75490fac4d45722c90a1847543c6796 /test | |
parent | 6b2b4167187fee09365271cca182866ecb029af3 (diff) | |
download | rspamd-14c13854d3cae9d93c3d148be30fb72f1eaffe55.tar.gz rspamd-14c13854d3cae9d93c3d148be30fb72f1eaffe55.zip |
[Rework] Further types conversion (no functional changes)
Diffstat (limited to 'test')
-rw-r--r-- | test/rspamd_cryptobox_test.c | 22 | ||||
-rw-r--r-- | test/rspamd_dkim_test.c | 14 | ||||
-rw-r--r-- | test/rspamd_dns_test.c | 2 | ||||
-rw-r--r-- | test/rspamd_heap_test.c | 20 | ||||
-rw-r--r-- | test/rspamd_lua_pcall_vs_resume_test.c | 48 | ||||
-rw-r--r-- | test/rspamd_lua_test.c | 20 | ||||
-rw-r--r-- | test/rspamd_radix_test.c | 36 | ||||
-rw-r--r-- | test/rspamd_rrd_test.c | 8 | ||||
-rw-r--r-- | test/rspamd_shingles_test.c | 20 | ||||
-rw-r--r-- | test/rspamd_test_suite.c | 6 | ||||
-rw-r--r-- | test/rspamd_upstream_test.c | 10 |
11 files changed, 103 insertions, 103 deletions
diff --git a/test/rspamd_cryptobox_test.c b/test/rspamd_cryptobox_test.c index e6c68fb6a..b32b2822b 100644 --- a/test/rspamd_cryptobox_test.c +++ b/test/rspamd_cryptobox_test.c @@ -27,7 +27,7 @@ static const int random_fuzz_cnt = 10000; enum rspamd_cryptobox_mode mode = RSPAMD_CRYPTOBOX_MODE_25519; static void * -create_mapping(int mapping_len, guchar **beg, guchar **end) +create_mapping(int mapping_len, unsigned char **beg, unsigned char **end) { void *map; int psize = getpagesize(); @@ -38,7 +38,7 @@ create_mapping(int mapping_len, guchar **beg, guchar **end) memset(map, 0, mapping_len + psize * 3); mprotect(map, psize, PROT_NONE); /* Misalign pointer */ - *beg = ((guchar *) map) + psize + 1; + *beg = ((unsigned char *) map) + psize + 1; *end = *beg + mapping_len; mprotect(*beg + mapping_len - 1 + psize, psize, PROT_NONE); @@ -47,7 +47,7 @@ create_mapping(int mapping_len, guchar **beg, guchar **end) static void check_result(const rspamd_nm_t key, const rspamd_nonce_t nonce, - const rspamd_mac_t mac, guchar *begin, guchar *end) + const rspamd_mac_t mac, unsigned char *begin, unsigned char *end) { uint64_t *t = (uint64_t *) begin; @@ -62,10 +62,10 @@ check_result(const rspamd_nm_t key, const rspamd_nonce_t nonce, static int create_random_split(struct rspamd_cryptobox_segment *seg, int mseg, - guchar *begin, guchar *end) + unsigned char *begin, unsigned char *end) { gsize remain = end - begin; - gint used = 0; + int used = 0; while (remain > 0 && used < mseg - 1) { seg->data = begin; @@ -88,10 +88,10 @@ create_random_split(struct rspamd_cryptobox_segment *seg, int mseg, static int create_realistic_split(struct rspamd_cryptobox_segment *seg, int mseg, - guchar *begin, guchar *end) + unsigned char *begin, unsigned char *end) { gsize remain = end - begin; - gint used = 0; + int used = 0; static const int small_seg = 512, medium_seg = 2048; while (remain > 0 && used < mseg - 1) { @@ -126,10 +126,10 @@ create_realistic_split(struct rspamd_cryptobox_segment *seg, int mseg, static int create_constrained_split(struct rspamd_cryptobox_segment *seg, int mseg, int constraint, - guchar *begin, guchar *end) + unsigned char *begin, unsigned char *end) { gsize remain = end - begin; - gint used = 0; + int used = 0; while (remain > 0 && used < mseg - 1) { seg->data = begin; @@ -155,13 +155,13 @@ create_constrained_split(struct rspamd_cryptobox_segment *seg, int mseg, void rspamd_cryptobox_test_func(void) { void *map; - guchar *begin, *end; + unsigned char *begin, *end; rspamd_nm_t key; rspamd_nonce_t nonce; rspamd_mac_t mac; struct rspamd_cryptobox_segment *seg; double t1, t2; - gint i, cnt, ms; + int i, cnt, ms; gboolean checked_openssl = FALSE; map = create_mapping(mapping_size, &begin, &end); diff --git a/test/rspamd_dkim_test.c b/test/rspamd_dkim_test.c index 57e4d5a2f..0797f15dd 100644 --- a/test/rspamd_dkim_test.c +++ b/test/rspamd_dkim_test.c @@ -18,13 +18,13 @@ #include "rspamd.h" #include "dkim.h" -static const gchar test_dkim_sig[] = "v=1; a=rsa-sha256; c=relaxed/relaxed; " - "d=highsecure.ru; s=dkim; t=1410516996; " - "bh=guFoWYHWVzFRqVyAQebnvPcdm7bUQo7pRHt/uIHD7gs=; " - "h=Message-ID:Date:From:MIME-Version:To:Subject:Content-Type:Content-Transfer-Encoding; " - "b=PCiECkOaPFb99DW+gApgfmdlTUo6XN6YXjnj52Cxoz2FoA857B0ZHFgeQe4JAKHuhW" - "oq3BLHap0GcMTTpSOgfQOKa8Df35Ns11JoOFjdBQ8GpM99kOrJP+vZcT8b7AMfthYm0Kwy" - "D9TjlkpScuoY5LjsWVnijh9dSNVLFqLatzg=;"; +static const char test_dkim_sig[] = "v=1; a=rsa-sha256; c=relaxed/relaxed; " + "d=highsecure.ru; s=dkim; t=1410516996; " + "bh=guFoWYHWVzFRqVyAQebnvPcdm7bUQo7pRHt/uIHD7gs=; " + "h=Message-ID:Date:From:MIME-Version:To:Subject:Content-Type:Content-Transfer-Encoding; " + "b=PCiECkOaPFb99DW+gApgfmdlTUo6XN6YXjnj52Cxoz2FoA857B0ZHFgeQe4JAKHuhW" + "oq3BLHap0GcMTTpSOgfQOKa8Df35Ns11JoOFjdBQ8GpM99kOrJP+vZcT8b7AMfthYm0Kwy" + "D9TjlkpScuoY5LjsWVnijh9dSNVLFqLatzg=;"; extern struct ev_loop *event_loop; #if 0 diff --git a/test/rspamd_dns_test.c b/test/rspamd_dns_test.c index d77919342..d041351df 100644 --- a/test/rspamd_dns_test.c +++ b/test/rspamd_dns_test.c @@ -7,7 +7,7 @@ #include "async_session.h" #include "cfg_file.h" -static guint requests = 0; +static unsigned int requests = 0; extern struct ev_loop *event_loop; struct rspamd_dns_resolver *resolver; diff --git a/test/rspamd_heap_test.c b/test/rspamd_heap_test.c index dcc7bbc4d..711ad6aca 100644 --- a/test/rspamd_heap_test.c +++ b/test/rspamd_heap_test.c @@ -19,11 +19,11 @@ #include "heap.h" #include "ottery.h" -static const guint niter = 100500; -static const guint nrem = 100; +static const unsigned int niter = 100500; +static const unsigned int nrem = 100; static inline struct rspamd_min_heap_elt * -new_elt(guint pri) +new_elt(unsigned int pri) { struct rspamd_min_heap_elt *elt; @@ -33,13 +33,13 @@ new_elt(guint pri) return elt; } -static gdouble -heap_nelts_test(guint nelts) +static double +heap_nelts_test(unsigned int nelts) { struct rspamd_min_heap *heap; struct rspamd_min_heap_elt *elts; - gdouble t1, t2; - guint i; + double t1, t2; + unsigned int i; heap = rspamd_min_heap_create(nelts); /* Preallocate all elts */ @@ -70,9 +70,9 @@ void rspamd_heap_test_func(void) { struct rspamd_min_heap *heap; struct rspamd_min_heap_elt *elt, *telt; - guint i; - guint prev; - gdouble t[16]; + unsigned int i; + unsigned int prev; + double t[16]; /* Push + update */ heap = rspamd_min_heap_create(32); diff --git a/test/rspamd_lua_pcall_vs_resume_test.c b/test/rspamd_lua_pcall_vs_resume_test.c index 0502378c9..82de9bb8b 100644 --- a/test/rspamd_lua_pcall_vs_resume_test.c +++ b/test/rspamd_lua_pcall_vs_resume_test.c @@ -20,18 +20,18 @@ #include "unix-std.h" static const char *lua_src_name = "lua/pcall_test.lua"; -extern gchar *argv0_dirname; +extern char *argv0_dirname; extern struct rspamd_main *rspamd_main; const int N = 20000; -static gdouble -test_pcall(lua_State *L, gint function_call) +static double +test_pcall(lua_State *L, int function_call) { - gdouble t1, t2; - gint i; + double t1, t2; + int i; t1 = rspamd_get_virtual_ticks(); for (i = 0; i < N; i++) { @@ -45,11 +45,11 @@ test_pcall(lua_State *L, gint function_call) return t2 - t1; } -static gdouble -test_resume(lua_State *L, gint function_call) +static double +test_resume(lua_State *L, int function_call) { - gdouble t1, t2; - gint i; + double t1, t2; + int i; t1 = rspamd_get_virtual_ticks(); for (i = 0; i < N; i++) { @@ -69,11 +69,11 @@ test_resume(lua_State *L, gint function_call) return t2 - t1; } -static gdouble -test_resume_get_thread(gint function_call) +static double +test_resume_get_thread(int function_call) { - gdouble t1, t2; - gint i; + double t1, t2; + int i; struct thread_entry *ent; t1 = rspamd_get_virtual_ticks(); @@ -99,11 +99,11 @@ test_resume_get_thread(gint function_call) return t2 - t1; } -static gdouble -test_resume_get_new_thread(gint function_call) +static double +test_resume_get_new_thread(int function_call) { - gdouble t1, t2; - gint i; + double t1, t2; + int i; struct thread_entry *ent; t1 = rspamd_get_virtual_ticks(); @@ -132,8 +132,8 @@ test_resume_get_new_thread(gint function_call) void rspamd_lua_lua_pcall_vs_resume_test_func(void) { lua_State *L = rspamd_main->cfg->lua_state; - gchar *lua_src; - gdouble t1, reference; + char *lua_src; + double t1, reference; lua_src = g_build_filename(argv0_dirname, lua_src_name, NULL); if (luaL_dofile(L, lua_src) != 0) { @@ -142,19 +142,19 @@ void rspamd_lua_lua_pcall_vs_resume_test_func(void) } g_free(lua_src); - gint function_call = luaL_ref(L, LUA_REGISTRYINDEX); + int function_call = luaL_ref(L, LUA_REGISTRYINDEX); msg_info("calling"); reference = t1 = test_pcall(L, function_call); - msg_notice("pcall stat: ts: %1.5f, avg:%1.5f, slow=%1.2f", t1, t1 / (gdouble) N, t1 / reference); + msg_notice("pcall stat: ts: %1.5f, avg:%1.5f, slow=%1.2f", t1, t1 / (double) N, t1 / reference); t1 = test_resume(L, function_call); - msg_notice("resume stat: ts: %1.5f, avg:%1.5f, slow=%1.2f", t1, t1 / (gdouble) N, t1 / reference); + msg_notice("resume stat: ts: %1.5f, avg:%1.5f, slow=%1.2f", t1, t1 / (double) N, t1 / reference); t1 = test_resume_get_thread(function_call); - msg_notice("resume+get thread stat: ts: %1.5f, avg:%1.5f, slow=%1.2f", t1, t1 / (gdouble) N, t1 / reference); + msg_notice("resume+get thread stat: ts: %1.5f, avg:%1.5f, slow=%1.2f", t1, t1 / (double) N, t1 / reference); t1 = test_resume_get_new_thread(function_call); - msg_notice("resume+get [new] thread stat: ts: %1.5f, avg:%1.5f, slow=%1.2f", t1, t1 / (gdouble) N, t1 / reference); + msg_notice("resume+get [new] thread stat: ts: %1.5f, avg:%1.5f, slow=%1.2f", t1, t1 / (double) N, t1 / reference); } diff --git a/test/rspamd_lua_test.c b/test/rspamd_lua_test.c index 87cc9b7cf..2e5abe37c 100644 --- a/test/rspamd_lua_test.c +++ b/test/rspamd_lua_test.c @@ -24,9 +24,9 @@ #endif static const char *lua_src_name = "lua/tests.lua"; -extern gchar *lua_test; -extern gchar *lua_test_case; -extern gchar *argv0_dirname; +extern char *lua_test; +extern char *lua_test_case; +extern char *argv0_dirname; extern struct rspamd_main *rspamd_main; static int @@ -60,10 +60,10 @@ _Noreturn void rspamd_lua_test_func(void) { lua_State *L = (lua_State *) rspamd_main->cfg->lua_state; - gchar *lua_src, *rp, rp_buf[PATH_MAX], path_buf[PATH_MAX], *tmp, *dir, *pattern; - const gchar *old_path; + char *lua_src, *rp, rp_buf[PATH_MAX], path_buf[PATH_MAX], *tmp, *dir, *pattern; + const char *old_path; glob_t globbuf; - gint i, len; + int i, len; rspamd_lua_set_env(L, NULL, NULL, NULL); rspamd_lua_set_globals(rspamd_main->cfg, L); @@ -105,14 +105,14 @@ rspamd_lua_test_func(void) pattern = g_malloc(len); rspamd_snprintf(pattern, len, "%s/unit/%s", dir, "*.lua"); - gint lua_test_len = 0; - gint inserted_file = 1; - gint path_start; + int lua_test_len = 0; + int inserted_file = 1; + int path_start; if (lua_test) { lua_test_len = strlen(lua_test); } if (glob(pattern, GLOB_DOOFFS, NULL, &globbuf) == 0) { - for (i = 0; i < (gint) globbuf.gl_pathc; i++) { + for (i = 0; i < (int) globbuf.gl_pathc; i++) { if (lua_test) { path_start = strlen(globbuf.gl_pathv[i]) - lua_test_len; if (path_start < 0 || diff --git a/test/rspamd_radix_test.c b/test/rspamd_radix_test.c index 466f355cf..3d6aca3e7 100644 --- a/test/rspamd_radix_test.c +++ b/test/rspamd_radix_test.c @@ -1,11 +1,11 @@ -/*- - * Copyright 2016 Vsevolod Stakhov +/* + * Copyright 2024 Vsevolod Stakhov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -20,8 +20,8 @@ #include "btrie.h" const gsize max_elts = 500 * 1024; -const gint lookup_cycles = 1 * 1024; -const gint lookup_divisor = 10; +const int lookup_cycles = 1 * 1024; +const int lookup_divisor = 10; const uint masks[] = { 8, @@ -39,8 +39,8 @@ struct _tv { const char *nip; const char *m; uint32_t mask; - guint8 *addr; - guint8 *naddr; + uint8_t *addr; + uint8_t *naddr; gsize len; } test_vec[] = { {"192.168.1.1", "192.168.1.2", "32", 0, 0, 0, 0}, @@ -209,14 +209,14 @@ void rspamd_radix_test_func(void) struct { uint32_t addr; uint32_t mask; - guint8 addr6[16]; + uint8_t addr6[16]; uint32_t mask6; - guint8 addr64[16]; + uint8_t addr64[16]; } *addrs; gsize nelts, i, check; - gint lc; + int lc; gboolean all_good = TRUE; - gdouble ts1, ts2; + double ts1, ts2; double diff; /* Test suite for the compressed trie */ @@ -277,7 +277,7 @@ void rspamd_radix_test_func(void) msg_notice("Checked %hz elements in %.0f ticks (%.2f ticks per lookup)", nelts * lookup_cycles / lookup_divisor, diff, - diff / ((gdouble) nelts * lookup_cycles / lookup_divisor)); + diff / ((double) nelts * lookup_cycles / lookup_divisor)); rspamd_mempool_delete(pool); /* @@ -289,7 +289,7 @@ void rspamd_radix_test_func(void) ts1 = rspamd_get_ticks(TRUE); for (i = 0; i < nelts; i++) { - btrie_add_prefix(btrie, (guchar *) &addrs[i].addr, + btrie_add_prefix(btrie, (unsigned char *) &addrs[i].addr, addrs[i].mask, GSIZE_TO_POINTER(i + 1)); } ts2 = rspamd_get_ticks(TRUE); @@ -303,12 +303,12 @@ void rspamd_radix_test_func(void) for (i = 0; i < nelts / lookup_divisor; i++) { check = rspamd_random_uint64_fast() % nelts; - if (btrie_lookup(btrie, (guchar *) &addrs[check].addr, sizeof(addrs[check].addr) * 8) == NULL) { + if (btrie_lookup(btrie, (unsigned char *) &addrs[check].addr, sizeof(addrs[check].addr) * 8) == NULL) { char ipbuf[INET6_ADDRSTRLEN + 1]; all_good = FALSE; - inet_ntop(AF_INET, (guchar *) &addrs[check].addr, ipbuf, sizeof(ipbuf)); + inet_ntop(AF_INET, (unsigned char *) &addrs[check].addr, ipbuf, sizeof(ipbuf)); msg_notice("BAD btrie: {\"%s\", NULL, \"%ud\", 0, 0, 0, 0},", ipbuf, addrs[check].mask); @@ -322,7 +322,7 @@ void rspamd_radix_test_func(void) msg_notice("Checked %hz elements in %.0f ticks (%.2f ticks per lookup)", nelts * lookup_cycles / lookup_divisor, diff, - diff / ((gdouble) nelts * lookup_cycles / lookup_divisor)); + diff / ((double) nelts * lookup_cycles / lookup_divisor)); rspamd_mempool_delete(pool); /* @@ -355,7 +355,7 @@ void rspamd_radix_test_func(void) all_good = FALSE; - inet_ntop(AF_INET, (guchar *) &addrs[check].addr, ipbuf, sizeof(ipbuf)); + inet_ntop(AF_INET, (unsigned char *) &addrs[check].addr, ipbuf, sizeof(ipbuf)); msg_notice("BAD btrie: {\"%s\", NULL, \"%ud\", 0, 0, 0, 0},", ipbuf, addrs[check].mask); @@ -369,7 +369,7 @@ void rspamd_radix_test_func(void) msg_notice("Checked %hz elements in %.0f ticks (%.2f ticks per lookup)", nelts * lookup_cycles / lookup_divisor, diff, - diff / ((gdouble) nelts * lookup_cycles / lookup_divisor)); + diff / ((double) nelts * lookup_cycles / lookup_divisor)); rspamd_mempool_delete(pool); g_free(addrs); diff --git a/test/rspamd_rrd_test.c b/test/rspamd_rrd_test.c index 2860cd8f6..60cc72097 100644 --- a/test/rspamd_rrd_test.c +++ b/test/rspamd_rrd_test.c @@ -25,15 +25,15 @@ const int pdp_per_cdp = 60; void rspamd_rrd_test_func(void) { - gchar tmpfile[PATH_MAX]; + char tmpfile[PATH_MAX]; struct rrd_rra_def rra[4]; struct rrd_ds_def ds[2]; GArray ar; GError *err = NULL; struct rspamd_rrd_file *rrd; - gdouble ticks; - gint i; - gdouble t[2], cnt = 0.0; + double ticks; + int i; + double t[2], cnt = 0.0; rspamd_snprintf(tmpfile, sizeof(tmpfile), "/tmp/rspamd_rrd.rrd"); unlink(tmpfile); diff --git a/test/rspamd_shingles_test.c b/test/rspamd_shingles_test.c index 4c1c6472f..d1a10de84 100644 --- a/test/rspamd_shingles_test.c +++ b/test/rspamd_shingles_test.c @@ -19,10 +19,10 @@ #include "ottery.h" #include <math.h> -static const gchar * +static const char * algorithm_to_string(enum rspamd_shingle_alg alg) { - const gchar *ret = "unknown"; + const char *ret = "unknown"; switch (alg) { case RSPAMD_SHINGLES_OLD: @@ -77,7 +77,7 @@ generate_fuzzy_words(gsize cnt, gsize max_len) } static void -permute_vector(GArray *in, gdouble prob) +permute_vector(GArray *in, double prob) { gsize i, total = 0; rspamd_ftok_t *w; @@ -85,7 +85,7 @@ permute_vector(GArray *in, gdouble prob) for (i = 0; i < in->len; i++) { if (ottery_rand_unsigned() <= G_MAXUINT * prob) { w = &g_array_index(in, rspamd_ftok_t, i); - generate_random_string((gchar *) w->begin, w->len); + generate_random_string((char *) w->begin, w->len); total++; } } @@ -105,14 +105,14 @@ free_fuzzy_words(GArray *ar) } static void -test_case(gsize cnt, gsize max_len, gdouble perm_factor, +test_case(gsize cnt, gsize max_len, double perm_factor, enum rspamd_shingle_alg alg) { GArray *input; struct rspamd_shingle *sgl, *sgl_permuted; - gdouble res; - guchar key[16]; - gdouble ts1, ts2; + double res; + unsigned char key[16]; + double ts1, ts2; ottery_rand_bytes(key, sizeof(key)); input = generate_fuzzy_words(cnt, max_len); @@ -280,7 +280,7 @@ void rspamd_shingles_test_func(void) { enum rspamd_shingle_alg alg = RSPAMD_SHINGLES_OLD; struct rspamd_shingle *sgl; - guchar key[16]; + unsigned char key[16]; GArray *input; rspamd_ftok_t tok; int i; @@ -289,7 +289,7 @@ void rspamd_shingles_test_func(void) input = g_array_sized_new(FALSE, FALSE, sizeof(rspamd_ftok_t), 5); for (i = 0; i < 5; i++) { - gchar *b = g_alloca(8); + char *b = g_alloca(8); memset(b, 0, 8); memcpy(b + 1, "test", 4); b[0] = 'a' + i; diff --git a/test/rspamd_test_suite.c b/test/rspamd_test_suite.c index b3d03915f..7648cddd4 100644 --- a/test/rspamd_test_suite.c +++ b/test/rspamd_test_suite.c @@ -9,10 +9,10 @@ struct rspamd_main *rspamd_main = NULL; struct ev_loop *event_loop = NULL; worker_t *workers[] = {NULL}; -gchar *lua_test = NULL; -gchar *lua_test_case = NULL; +char *lua_test = NULL; +char *lua_test_case = NULL; gboolean verbose = FALSE; -gchar *argv0_dirname = NULL; +char *argv0_dirname = NULL; static GOptionEntry entries[] = { diff --git a/test/rspamd_upstream_test.c b/test/rspamd_upstream_test.c index 1f4e27daa..998a51f26 100644 --- a/test/rspamd_upstream_test.c +++ b/test/rspamd_upstream_test.c @@ -27,7 +27,7 @@ extern struct ev_loop *event_loop; static void rspamd_upstream_test_method(struct upstream_list *ls, - enum rspamd_upstream_rotation rot, const gchar *expected) + enum rspamd_upstream_rotation rot, const char *expected) { struct upstream *up; @@ -58,9 +58,9 @@ void rspamd_upstream_test_func(void) struct upstream *up, *upn; struct rspamd_dns_resolver *resolver; struct rspamd_config *cfg; - gint i, success = 0; - const gint assumptions = 100500; - gdouble p; + int i, success = 0; + const int assumptions = 100500; + double p; static ev_timer ev; rspamd_inet_addr_t *addr, *next_addr, *paddr; @@ -149,7 +149,7 @@ void rspamd_upstream_test_func(void) } } - p = 1.0 - fabs(3.0 / 4.0 - (gdouble) success / (gdouble) assumptions); + p = 1.0 - fabs(3.0 / 4.0 - (double) success / (double) assumptions); /* * P value is calculated as following: * when we add/remove M upstreams from the list, the probability of hash |