0
0
mirror of https://gitlab.nic.cz/labs/bird.git synced 2025-01-07 17:41:58 +00:00

Birdtest: Compability bug fixes

Tested on Ubuntu & FreeBSD & NetBSD & OpenBSD
This commit is contained in:
Pavel Tvrdík 2015-04-15 15:42:43 +02:00
parent 2bb3d343e9
commit 5419d2a3c5
9 changed files with 39 additions and 10 deletions

View File

@ -19,7 +19,8 @@ t_mkmask(void)
int i; int i;
u32 compute, expect; u32 compute, expect;
for (i = 0; i <= 32; i++) bt_assert(u32_mkmask(0) == 0x00000000);
for (i = 1; i <= 32; i++)
{ {
compute = u32_mkmask(i); compute = u32_mkmask(i);
expect = (u32) (0xffffffff << (32-i)); expect = (u32) (0xffffffff << (32-i));

View File

@ -8,6 +8,7 @@
#define _BIRD_BUFFER_H_ #define _BIRD_BUFFER_H_
#include "lib/resource.h" #include "lib/resource.h"
#include "sysdep/config.h"
#define BUFFER(type) struct { type *data; uint used, size; } #define BUFFER(type) struct { type *data; uint used, size; }

View File

@ -8,6 +8,7 @@
#include <stdlib.h> #include <stdlib.h>
#include "test/birdtest.h" #include "test/birdtest.h"
#include "sysdep/config.h"
#include "lib/resource.h" #include "lib/resource.h"
#include "lib/buffer.h" #include "lib/buffer.h"
@ -24,8 +25,8 @@ show_buf(buffer_int *b)
int i; int i;
bt_debug(".used = %d, .size = %d\n", b->used, b->size); bt_debug(".used = %d, .size = %d\n", b->used, b->size);
for (i = 0; i < b->size; i++) for (i = 0; i < b->used; i++)
bt_debug(" .data[%3i] = %-16d expected %-16d %s\n", i, b->data[i], expected[i], (b->data[i] == expected[i] ? "OK" : "FAIL!")); bt_debug(" .data[%3d] = %-16d expected %-16d %s\n", i, b->data[i], expected[i], (b->data[i] == expected[i] ? "OK" : "FAIL!"));
} }
static void static void

View File

@ -80,7 +80,7 @@ t_verify(void)
a[MAX_NUM] = sum; a[MAX_NUM] = sum;
bt_assert(ipsum_verify(a, sizeof(a) + sizeof(u32), NULL)); bt_assert(ipsum_verify(a, sizeof(a), NULL));
return BT_SUCCESS; return BT_SUCCESS;
} }

View File

@ -7,6 +7,7 @@
*/ */
#include "test/birdtest.h" #include "test/birdtest.h"
#include "sysdep/config.h"
#include "lib/heap.h" #include "lib/heap.h"
#define MAX_NUM 1000 #define MAX_NUM 1000

View File

@ -11,7 +11,10 @@
#include <string.h> #include <string.h>
#include <signal.h> #include <signal.h>
#include <unistd.h> #include <unistd.h>
#ifdef HAVE_EXECINFO
#include <execinfo.h> #include <execinfo.h>
#endif
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include <sys/resource.h> #include <sys/resource.h>
@ -106,11 +109,13 @@ bt_init(int argc, char *argv[])
static void static void
dump_stack(void) dump_stack(void)
{ {
#ifdef HAVE_EXECINFO
static void *backbuf[50]; static void *backbuf[50];
int levels; int levels;
levels = backtrace(backbuf, 50); levels = backtrace(backbuf, 50);
backtrace_symbols_fd(backbuf, levels, STDERR_FILENO); backtrace_symbols_fd(backbuf, levels, STDERR_FILENO);
#endif
} }
void void

View File

@ -117,11 +117,11 @@ void bt_strncat_(char *buf, size_t buf_size, const char *str, ...);
#define bt_dump_struct(buf, data) \ #define bt_dump_struct(buf, data) \
do \ do \
{ \ { \
unsigned int i; \ unsigned int k; \
u32 *pc = (u32*) data; \ u32 *pc = (u32*) data; \
bt_strncat(buf, "{"); \ bt_strncat(buf, "{"); \
for (i = 0; i < (sizeof(*data) / sizeof(typeof(*pc))); i++) \ for (k = 0; k < (sizeof(*data) / sizeof(typeof(*pc))); k++) \
bt_strncat(buf, "%s0x%08X", (i ? ", " : ""), pc[i]); \ bt_strncat(buf, "%s0x%08X", (k ? ", " : ""), pc[k]); \
bt_strncat(buf, "}"); \ bt_strncat(buf, "}"); \
} while (0) } while (0)

View File

@ -1,3 +1,4 @@
#include "sysdep/config.h"
#include "lib/event.c" /* REMOVE ME */ #include "lib/event.c" /* REMOVE ME */
#include "lib/ip.c" /* REMOVE ME */ #include "lib/ip.c" /* REMOVE ME */
#include "lib/resource.c" /* REMOVE ME */ #include "lib/resource.c" /* REMOVE ME */

View File

@ -3,6 +3,24 @@
objdir=$1 objdir=$1
srcdir=$2 srcdir=$2
# see if it supports colors...
ncolors=$(tput colors)
if test -n "$ncolors" && test $ncolors -ge 8; then
bold="$(tput bold)"
underline="$(tput smul)"
standout="$(tput smso)"
normal="$(tput sgr0)"
black="$(tput setaf 0)"
red="$(tput setaf 1)"
green="$(tput setaf 2)"
yellow="$(tput setaf 3)"
blue="$(tput setaf 4)"
magenta="$(tput setaf 5)"
cyan="$(tput setaf 6)"
white="$(tput setaf 7)"
fi
all_tests=$(find "$objdir" -name '*_test') all_tests=$(find "$objdir" -name '*_test')
num_all_tests=0 num_all_tests=0
@ -17,12 +35,13 @@ for test in $all_tests ; do
cols=$(tput cols) cols=$(tput cols)
offset=$((cols-17)) offset=$((cols-17))
fmt=" [%2d/%-2d] %-${offset}s" fmt=" [%2d/%-2d] %-${offset}s"
printf "$fmt" $((num_test++)) $num_all_tests "$test" printf "$fmt" $num_test $num_all_tests "$test"
num_test=$((num_test+1))
if [ $exit_code -eq 0 ]; then if [ $exit_code -eq 0 ]; then
printf "[\e[1;32m OK \e[0m]" printf "[${green}${bold} OK ${normal}]"
num_succ_tests=$((num_succ_tests+1)) num_succ_tests=$((num_succ_tests+1))
else else
printf "[\e[1;31mFAIL\e[0m]" printf "[${red}${bold}FAIL${normal}]"
num_fail_tests=$((num_fail_tests+1)) num_fail_tests=$((num_fail_tests+1))
fi fi
printf "\n" printf "\n"