diff --git a/0001-update-wire-read-write-tests.patch b/0001-update-wire-read-write-tests.patch new file mode 100644 index 0000000..0b8e3eb --- /dev/null +++ b/0001-update-wire-read-write-tests.patch @@ -0,0 +1,126 @@ +From d71f8493fdb43c9522924efdd970b0e799cf0f84 Mon Sep 17 00:00:00 2001 +From: Jan Vcelak +Date: Tue, 8 Oct 2013 13:54:42 +0200 +Subject: [PATCH] update wire read/write tests + +Tests were failing on big-endian machines. + +refs #178 +--- + src/tests/libknot/wire_tests.c | 93 +++++++++--------------------------------- + 1 file changed, 19 insertions(+), 74 deletions(-) + +diff --git a/src/tests/libknot/wire_tests.c b/src/tests/libknot/wire_tests.c +index 7e4d001..51969ca 100644 +--- a/src/tests/libknot/wire_tests.c ++++ b/src/tests/libknot/wire_tests.c +@@ -27,87 +27,32 @@ unit_api wire_tests_api = { + &wire_tests_run + }; + ++#define write_test(size, value, ...) { \ ++ const uint8_t expect[] = { __VA_ARGS__ }; \ ++ uint8_t wdata[sizeof(expect)] = { 0x00 }; \ ++ knot_wire_write_u ## size(wdata, value); \ ++ ok(memcmp(wdata, expect, sizeof(expect)) == 0, "%d-bit write", size); \ ++} ++ + static int wire_tests_count(int argc, char *argv[]) + { + return 8; + } + +-#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ +- #define ENDIAN_MATCH(expression, match_little, match_big) \ +- ((expression) == (match_little)) +-#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ +- #define ENDIAN_MATCH(expression, match_little, match_big) \ +- ((expression) == (match_big)) +-#else +- #error Unsupported byte order. +-#endif +- + static int wire_tests_run(int argc, char *argv[]) + { +- // 1. - 16-bit read +- { +- uint16_t data = 0xAABB; +- ok(ENDIAN_MATCH(knot_wire_read_u16((uint8_t *)&data), +- 0xBBAA, 0xAABB), "16-bit read"); +- } +- +- // 2. - 16-bit read +- { +- uint16_t data_in = 0xAABB; +- uint64_t data_out = 0xFF0000; +- knot_wire_write_u16((uint8_t *)&data_out, data_in); +- ok(ENDIAN_MATCH(data_out, +- 0xFFBBAA, 0xFFAABB), "16-bit write"); +- } +- +- // 3. - 32-bit read +- { +- uint32_t data = 0xAABBCCDD; +- ok(ENDIAN_MATCH(knot_wire_read_u32((uint8_t *)&data), +- 0xDDCCBBAA, 0xAABBCCDD), "32-bit read"); +- } +- +- // 4. - 32-bit write +- { +- uint32_t data_in = 0xAABBCCDD; +- uint64_t data_out = 0xFF00000000; +- knot_wire_write_u32((uint8_t *)&data_out, data_in); +- ok(ENDIAN_MATCH(data_out, +- 0xFFDDCCBBAA, 0xFFAABBCCDD), "32-bit write"); +- +- } +- +- // 5. - 48-bit read +- { +- uint64_t data = 0x81AABBCCDDEEFF; +- ok(ENDIAN_MATCH(knot_wire_read_u48((uint8_t *)&data), +- 0xFFEEDDCCBBAA, 0xAABBCCDDEEFF), "48-bit read"); +- } +- +- // 6. - 48-bit write +- { +- uint64_t data_in = 0x81AABBCCDDEEFF; +- uint64_t data_out = 0xDD000000000000; +- knot_wire_write_u48((uint8_t *)&data_out, data_in); +- ok(ENDIAN_MATCH(data_out, +- 0xDDFFEEDDCCBBAA, 0xDDAABBCCDDEEFF), "48-bit write"); +- } +- +- // 7. - 64-bit read +- { +- uint64_t data = 0x8899AABBCCDDEEFF; +- ok(ENDIAN_MATCH(knot_wire_read_u64((uint8_t *)&data), +- 0xFFEEDDCCBBAA9988, 0x8899AABBCCDDEEFF), "64-bit read"); +- } +- +- // 8. - 64-bit write +- { +- uint64_t data_in = 0x8899AABBCCDDEEFF; +- uint64_t data_out = 0x0; +- knot_wire_write_u64((uint8_t *)&data_out, data_in); +- ok(ENDIAN_MATCH(data_out, +- 0xFFEEDDCCBBAA9988, 0x8899AABBCCDDEEFF), "64-bit write"); +- } ++ const uint8_t rdata[] = { 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff }; ++ ++ ok(knot_wire_read_u16(rdata) == 0x8899, "16-bit read"); ++ ok(knot_wire_read_u32(rdata) == 0x8899aabb, "32-bit read"); ++ ok(knot_wire_read_u48(rdata) == 0x8899aabbccdd, "48-bit read"); ++ ok(knot_wire_read_u64(rdata) == 0x8899aabbccddeeff, "64-bit read"); ++ ++ write_test(16, 0x1122, 0x11, 0x22); ++ write_test(32, 0x66778899, 0x66, 0x77, 0x88, 0x99); ++ write_test(48, 0xbbccdd778899, 0xbb, 0xcc, 0xdd, 0x77, 0x88, 0x99); ++ write_test(64, 0xbbccddee66778899, 0xbb, 0xcc, 0xdd, 0xee, ++ 0x66, 0x77, 0x88, 0x99); + + return 0; + } +-- +1.8.3.1 + diff --git a/knot.spec b/knot.spec index 99a107f..af6f510 100644 --- a/knot.spec +++ b/knot.spec @@ -4,7 +4,7 @@ Summary: An authoritative DNS daemon Name: knot Version: 1.3.2 -Release: 1%{?dist} +Release: 2%{?dist} License: GPLv3 Group: System Environment/Daemons URL: http://www.knot-dns.cz @@ -13,6 +13,8 @@ Source1: %{name}.service Source2: %{name}.conf Source3: %{name}.tmpfiles +Patch1: 0001-update-wire-read-write-tests.patch + BuildRequires: flex bison ragel openssl-devel userspace-rcu-devel libcap-ng-devel BuildRequires: texinfo BuildRequires: systemd-units @@ -26,6 +28,7 @@ Knot DNS is a high-performance authoritative DNS server implementation. %prep %setup -q +%patch1 -p1 %build # disable debug code (causes unused warnings) @@ -93,6 +96,9 @@ fi %doc %{_infodir}/%{name}.info.gz %changelog +* Tue Oct 08 2013 Jan Vcelak 1.3.2-2 +- fix failing wire reading/writing tests on big endian (#1015976) + * Tue Oct 01 2013 Jan Vcelak 1.3.2-1 - update to 1.3.2 + possibility to set max UDP payload in EDNS0