mirror of
https://gitlab.nic.cz/labs/bird.git
synced 2025-01-06 09:01:53 +00:00
Birdtest: Compability bug fixes
Tested on Ubuntu & FreeBSD & NetBSD & OpenBSD
This commit is contained in:
parent
2bb3d343e9
commit
5419d2a3c5
@ -19,7 +19,8 @@ t_mkmask(void)
|
||||
int i;
|
||||
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);
|
||||
expect = (u32) (0xffffffff << (32-i));
|
||||
|
@ -8,6 +8,7 @@
|
||||
#define _BIRD_BUFFER_H_
|
||||
|
||||
#include "lib/resource.h"
|
||||
#include "sysdep/config.h"
|
||||
|
||||
#define BUFFER(type) struct { type *data; uint used, size; }
|
||||
|
||||
|
@ -8,6 +8,7 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "test/birdtest.h"
|
||||
#include "sysdep/config.h"
|
||||
#include "lib/resource.h"
|
||||
#include "lib/buffer.h"
|
||||
|
||||
@ -24,8 +25,8 @@ show_buf(buffer_int *b)
|
||||
int i;
|
||||
bt_debug(".used = %d, .size = %d\n", b->used, b->size);
|
||||
|
||||
for (i = 0; i < b->size; i++)
|
||||
bt_debug(" .data[%3i] = %-16d expected %-16d %s\n", i, b->data[i], expected[i], (b->data[i] == expected[i] ? "OK" : "FAIL!"));
|
||||
for (i = 0; i < b->used; i++)
|
||||
bt_debug(" .data[%3d] = %-16d expected %-16d %s\n", i, b->data[i], expected[i], (b->data[i] == expected[i] ? "OK" : "FAIL!"));
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -80,7 +80,7 @@ t_verify(void)
|
||||
|
||||
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;
|
||||
}
|
||||
|
@ -7,6 +7,7 @@
|
||||
*/
|
||||
|
||||
#include "test/birdtest.h"
|
||||
#include "sysdep/config.h"
|
||||
#include "lib/heap.h"
|
||||
|
||||
#define MAX_NUM 1000
|
||||
|
@ -11,7 +11,10 @@
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#ifdef HAVE_EXECINFO
|
||||
#include <execinfo.h>
|
||||
#endif
|
||||
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/resource.h>
|
||||
@ -106,11 +109,13 @@ bt_init(int argc, char *argv[])
|
||||
static void
|
||||
dump_stack(void)
|
||||
{
|
||||
#ifdef HAVE_EXECINFO
|
||||
static void *backbuf[50];
|
||||
int levels;
|
||||
|
||||
levels = backtrace(backbuf, 50);
|
||||
backtrace_symbols_fd(backbuf, levels, STDERR_FILENO);
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -117,11 +117,11 @@ void bt_strncat_(char *buf, size_t buf_size, const char *str, ...);
|
||||
#define bt_dump_struct(buf, data) \
|
||||
do \
|
||||
{ \
|
||||
unsigned int i; \
|
||||
unsigned int k; \
|
||||
u32 *pc = (u32*) data; \
|
||||
bt_strncat(buf, "{"); \
|
||||
for (i = 0; i < (sizeof(*data) / sizeof(typeof(*pc))); i++) \
|
||||
bt_strncat(buf, "%s0x%08X", (i ? ", " : ""), pc[i]); \
|
||||
for (k = 0; k < (sizeof(*data) / sizeof(typeof(*pc))); k++) \
|
||||
bt_strncat(buf, "%s0x%08X", (k ? ", " : ""), pc[k]); \
|
||||
bt_strncat(buf, "}"); \
|
||||
} while (0)
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
#include "sysdep/config.h"
|
||||
#include "lib/event.c" /* REMOVE ME */
|
||||
#include "lib/ip.c" /* REMOVE ME */
|
||||
#include "lib/resource.c" /* REMOVE ME */
|
||||
|
@ -3,6 +3,24 @@
|
||||
objdir=$1
|
||||
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')
|
||||
|
||||
num_all_tests=0
|
||||
@ -17,12 +35,13 @@ for test in $all_tests ; do
|
||||
cols=$(tput cols)
|
||||
offset=$((cols-17))
|
||||
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
|
||||
printf "[\e[1;32m OK \e[0m]"
|
||||
printf "[${green}${bold} OK ${normal}]"
|
||||
num_succ_tests=$((num_succ_tests+1))
|
||||
else
|
||||
printf "[\e[1;31mFAIL\e[0m]"
|
||||
printf "[${red}${bold}FAIL${normal}]"
|
||||
num_fail_tests=$((num_fail_tests+1))
|
||||
fi
|
||||
printf "\n"
|
||||
|
Loading…
Reference in New Issue
Block a user