While I don't see -Werror being used on tests anytime soon, there's no reason to keep the warnings in tests unfixed.
Signed-off-by: David Lamparter <[email protected]> --- tests/Makefile.am | 4 ++-- tests/bgp_mp_attr_test.c | 2 +- tests/bgp_mpath_test.c | 2 +- tests/ecommunity_test.c | 2 +- tests/heavy-thread.c | 2 ++ tests/heavy-wq.c | 2 ++ tests/heavy.c | 2 ++ tests/main.c | 2 +- tests/test-checksum.c | 35 ----------------------------------- tests/test-segv.c | 2 +- tests/test-sig.c | 6 +++--- tests/test-timer-correctness.c | 9 ++++++--- tests/tests.h | 31 +++++++++++++++++++++++++++++++ 13 files changed, 53 insertions(+), 48 deletions(-) create mode 100644 tests/tests.h diff --git a/tests/Makefile.am b/tests/Makefile.am index 1fe28c7..b542071 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -36,14 +36,14 @@ check_PROGRAMS = testsig testsegv testbuffer testmemory heavy heavywq heavythrea test-commands-defun.c: ../vtysh/vtysh_cmd.c sed \ - -e '/"vtysh.h"/d' \ + -e 's/"vtysh\.h"/"tests.h"/' \ -e 's/vtysh_init_cmd/test_init_cmd/' \ -e 's/VTYSH_[A-Z][A-Z_0-9]*/0/g' \ < ../vtysh/vtysh_cmd.c \ > test-commands-defun.c BUILT_SOURCES = test-commands-defun.c -noinst_HEADERS = prng.h +noinst_HEADERS = prng.h tests.h testsig_SOURCES = test-sig.c testsegv_SOURCES = test-segv.c diff --git a/tests/bgp_mp_attr_test.c b/tests/bgp_mp_attr_test.c index 5f0e733..d649e14 100644 --- a/tests/bgp_mp_attr_test.c +++ b/tests/bgp_mp_attr_test.c @@ -545,7 +545,7 @@ main (void) return -1; peer = peer_create_accept (bgp); - peer->host = "foo"; + peer->host = (char *)"foo"; for (i = AFI_IP; i < AFI_MAX; i++) for (j = SAFI_UNICAST; j < SAFI_MAX; j++) diff --git a/tests/bgp_mpath_test.c b/tests/bgp_mpath_test.c index 3d0ecb7..3594753 100644 --- a/tests/bgp_mpath_test.c +++ b/tests/bgp_mpath_test.c @@ -252,7 +252,7 @@ run_bgp_mp_list (testcase_t *t) bgp_mp_list_add (&mp_list, &test_mp_list_info[3]); bgp_mp_list_add (&mp_list, &test_mp_list_info[0]); - for (i = 0, mp_node = listhead(&mp_list); i < test_mp_list_info_count; + for (i = 0, mp_node = mp_list.head; i < test_mp_list_info_count; i++, mp_node = listnextnode(mp_node)) { info = listgetdata(mp_node); diff --git a/tests/ecommunity_test.c b/tests/ecommunity_test.c index cd1681d..f12aa71 100644 --- a/tests/ecommunity_test.c +++ b/tests/ecommunity_test.c @@ -132,7 +132,7 @@ parse_test (struct test_segment *t) printf ("%s: %s\n", t->name, t->desc); - ecom = ecommunity_parse (t->data, t->len); + ecom = ecommunity_parse ((u_int8_t *)t->data, t->len); printf ("ecom: %s\nvalidating...:\n", ecommunity_str (ecom)); diff --git a/tests/heavy-thread.c b/tests/heavy-thread.c index cd3a3b9..c2e71c1 100644 --- a/tests/heavy-thread.c +++ b/tests/heavy-thread.c @@ -37,6 +37,8 @@ #include "memory.h" #include "log.h" +#include "tests.h" + extern struct thread_master *master; enum diff --git a/tests/heavy-wq.c b/tests/heavy-wq.c index e5f688c..2f133cc 100644 --- a/tests/heavy-wq.c +++ b/tests/heavy-wq.c @@ -36,6 +36,8 @@ #include "workqueue.h" #include <math.h> +#include "tests.h" + extern struct thread_master *master; static struct work_queue *heavy_wq; diff --git a/tests/heavy.c b/tests/heavy.c index 577a481..9af46c8 100644 --- a/tests/heavy.c +++ b/tests/heavy.c @@ -36,6 +36,8 @@ #include "memory.h" #include <math.h> +#include "tests.h" + enum { ITERS_FIRST = 0, diff --git a/tests/main.c b/tests/main.c index 5e7bdcb..5396c7d 100644 --- a/tests/main.c +++ b/tests/main.c @@ -52,7 +52,7 @@ DEFUN (daemon_exit, } static int timer_count; -int +static int test_timer (struct thread *thread) { int *count = THREAD_ARG(thread); diff --git a/tests/test-checksum.c b/tests/test-checksum.c index 9672e95..b6741f3 100644 --- a/tests/test-checksum.c +++ b/tests/test-checksum.c @@ -46,41 +46,6 @@ typedef uint16_t testoff_t; /* Fletcher Checksum -- Refer to RFC1008. */ #define MODX 4102 -/* Accumulator phase of checksum */ -static -struct acc_vals -accumulate (u_char *buffer, testsz_t len, testoff_t off) -{ - u_int8_t *p; - u_int16_t *csum; - int i, partial_len; - struct acc_vals ret; - - csum = (u_int16_t *) (buffer + off); - *(csum) = 0; - - p = buffer; - ret.c0 = 0; - ret.c1 = 0; - - while (len != 0) - { - partial_len = MIN(len, MODX); - - for (i = 0; i < partial_len; i++) - { - ret.c0 = ret.c0 + *(p++); - ret.c1 += ret.c0; - } - - ret.c0 = ret.c0 % 255; - ret.c1 = ret.c1 % 255; - - len -= partial_len; - } - return ret; -} - /* The final reduction phase. * This one should be the original ospfd version */ diff --git a/tests/test-segv.c b/tests/test-segv.c index 55bd25a..1b851fc 100644 --- a/tests/test-segv.c +++ b/tests/test-segv.c @@ -35,7 +35,7 @@ struct quagga_signal_t sigs[] = struct thread_master *master; -int +static int threadfunc (struct thread *thread) { int *null = NULL; diff --git a/tests/test-sig.c b/tests/test-sig.c index 7415d7a..f24da96 100644 --- a/tests/test-sig.c +++ b/tests/test-sig.c @@ -22,19 +22,19 @@ #include "lib/log.h" #include "lib/memory.h" -void +static void sighup (void) { printf ("processed hup\n"); } -void +static void sigusr1 (void) { printf ("processed usr1\n"); } -void +static void sigusr2 (void) { printf ("processed usr2\n"); diff --git a/tests/test-timer-correctness.c b/tests/test-timer-correctness.c index 94c8f1d..47c0b73 100644 --- a/tests/test-timer-correctness.c +++ b/tests/test-timer-correctness.c @@ -140,8 +140,9 @@ int main(int argc, char **argv) interval_msec = prng_rand(prng) % 5000; arg = XMALLOC(MTYPE_TMP, TIMESTR_LEN + 1); timers[i] = thread_add_timer_msec(master, timer_func, arg, interval_msec); - ret = snprintf(arg, TIMESTR_LEN + 1, "%ld.%06ld", - timers[i]->u.sands.tv_sec, timers[i]->u.sands.tv_usec); + ret = snprintf(arg, TIMESTR_LEN + 1, "%lld.%06lld", + (long long)timers[i]->u.sands.tv_sec, + (long long)timers[i]->u.sands.tv_usec); assert(ret > 0); assert((size_t)ret < TIMESTR_LEN + 1); timers_pending++; @@ -180,7 +181,9 @@ int main(int argc, char **argv) ret = snprintf(expected_buf + expected_buf_pos, expected_buf_len - expected_buf_pos, - "%ld.%06ld\n", alarms[i]->tv_sec, alarms[i]->tv_usec); + "%lld.%06lld\n", + (long long)alarms[i]->tv_sec, + (long long)alarms[i]->tv_usec); assert(ret > 0); expected_buf_pos += ret; assert(expected_buf_pos < expected_buf_len); diff --git a/tests/tests.h b/tests/tests.h new file mode 100644 index 0000000..a528e55 --- /dev/null +++ b/tests/tests.h @@ -0,0 +1,31 @@ +/* + * Test wrappers common header file + * + * Copyright (C) 2015 by David Lamparter, + * for Open Source Routing./ NetDEF, Inc. + * + * This file is part of Quagga + * + * Quagga is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2, or (at your option) any + * later version. + * + * Quagga is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Quagga; see the file COPYING. If not, write to the Free + * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ + +#ifndef _QUAGGA_TESTS_H +#define _QUAGGA_TESTS_H + +extern void test_init (void); +extern void test_init_cmd (void); + +#endif /* _QUAGGA_TESTS_H */ -- 2.0.4 _______________________________________________ Quagga-dev mailing list [email protected] https://lists.quagga.net/mailman/listinfo/quagga-dev
