]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Birdtest: Compability bug fixes
authorPavel Tvrdík <pawel.tvrdik@gmail.cz>
Wed, 15 Apr 2015 13:42:43 +0000 (15:42 +0200)
committerPavel Tvrdík <pawel.tvrdik@gmail.cz>
Wed, 15 Apr 2015 13:42:43 +0000 (15:42 +0200)
Tested on Ubuntu & FreeBSD & NetBSD & OpenBSD

lib/bitops_test.c
lib/buffer.h
lib/buffer_test.c
lib/checksum_test.c
lib/heap_test.c
test/birdtest.c
test/birdtest.h
test/birdtest_support.h
tools/run_tests.sh

index 4ab978e19bfaf968f2ec5e14f8ea4582d9e9a3c2..59c0cd56f6b3afe0ed52498292c49ee98e3d64ad 100644 (file)
@@ -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));
index f01eaeeb27ae6fc09c20c2149291dcf8fe7d5222..6fa6a789cbef9df9d45d2604f4c0e8d0d8b14f4a 100644 (file)
@@ -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; }
 
index 77e161a528d95e3b1616699111e60e68719078f3..1298233e2736e4914cfff1c94d21118d4fcaac1c 100644 (file)
@@ -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
index 690cd2e24415f1a997ea4d50cae2a260832b4585..8306d26298566fdc7084b3dc8f7275bb4850b783 100644 (file)
@@ -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;
 }
index 8fde031ec4429d834f466c7afd23ad55b5ebb7b8..2e324ec9f9ece88a5b885502fb1172a1d4ef8cd5 100644 (file)
@@ -7,6 +7,7 @@
  */
 
 #include "test/birdtest.h"
+#include "sysdep/config.h"
 #include "lib/heap.h"
 
 #define MAX_NUM 1000
index 134992690584387cced0a3b7b83523aeb02a9f73..722be0fb6195d855229e3022f20fd446c8112622 100644 (file)
 #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
index 7edfa52a22ccfd1d2c9d26889538c1f2fd570e3e..ff3010faa3c0bb516d712967a7cd672ccd1d69ab 100644 (file)
@@ -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)
 
index 4554cf0296a9c3376f9d9f99b83ee8e43f1b2787..1f5985c0c404b54d83818f07c6b0e1ffbd45991f 100644 (file)
@@ -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 */
index 9d06061fdf030298312ec42d77e0497dc86456a8..03c3e78c411de9f69d3bc48140f0bfb01f580cf4 100755 (executable)
@@ -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"