Source: libcbor
Version: 0.10.2-1.2
Tags: ftbfs
X-Debbugs-Cc: del...@debian.org

libcbor fails to build from source on the hppa and mips architectures.
Reason is, that a testcases which checks the binary representation
of NaN fails on those architectures, because they use a different binary
encoding of the bytes.
See the "encoding" section at https://en.wikipedia.org/wiki/NaN for details.

Failure except:
20: [ RUN      ] test_float
20: [  ERROR   ] --- difference at offset 2 0xffffffbf 0xffffffc0
20: difference at offset 3 0xffffffff 0x00
20: difference at offset 4 0xffffffff 0x00
20: 3 bytes of 0x1739c and 0xfa001b57 differ
20: [   LINE   ] --- ./test/float_ctrl_encoders_test.c:150: error: Failure!
20: [  FAILED  ] test_float
20: [ RUN      ] test_double
20: [  ERROR   ] --- difference at offset 2 0xfffffff7 0xfffffff8
20: difference at offset 3 0xffffffff 0x00
20: difference at offset 4 0xffffffff 0x00
20: difference at offset 5 0xffffffff 0x00
20: difference at offset 6 0xffffffff 0x00
20: difference at offset 7 0xffffffff 0x00
20: difference at offset 8 0xffffffff 0x00
20: 7 bytes of 0x1739c and 0xfa001b63 differ
20: [   LINE   ] --- ./test/float_ctrl_encoders_test.c:177: error: Failure!

The attached patch avoids this test on hppa and thus building libcbor succeeds.
I did not test the patch on mips yet.

Helge
--- test/float_ctrl_encoders_test.c.org	2024-04-27 14:49:38.175261711 +0000
+++ test/float_ctrl_encoders_test.c	2024-04-27 14:59:12.825184338 +0000
@@ -9,6 +9,16 @@
 #include "assertions.h"
 #include "cbor.h"
 
+/* In NaNs generated by the PA-RISC and old MIPS processors, the
+ * signaling/quiet bit is zero if the NaN is quiet, and non-zero if the NaN is
+ * signaling. Thus the binary representation is different to other
+ * architectures. See encoding section at https://en.wikipedia.org/wiki/NaN */
+#if defined(__hppa__) || defined(__mips__)
+#define ARCH_WITH_STD_IEEE_754_NAN	0
+#else
+#define ARCH_WITH_STD_IEEE_754_NAN	1
+#endif
+
 unsigned char buffer[512];
 
 static void test_bools(void **_CBOR_UNUSED(_state)) {
@@ -147,13 +157,15 @@
                       5);
 
   assert_size_equal(5, cbor_encode_single(NAN, buffer, 512));
-  assert_memory_equal(buffer, ((unsigned char[]){0xFA, 0x7F, 0xC0, 0x00, 0x00}),
+  if (ARCH_WITH_STD_IEEE_754_NAN)
+	  assert_memory_equal(buffer, ((unsigned char[]){0xFA, 0x7F, 0xC0, 0x00, 0x00}),
                       5);
 
 #ifndef _WIN32
   // TODO: https://github.com/PJK/libcbor/issues/271
   assert_size_equal(5, cbor_encode_single(nanf("3"), buffer, 512));
-  assert_memory_equal(buffer, ((unsigned char[]){0xFA, 0x7F, 0xC0, 0x00, 0x03}),
+  if (ARCH_WITH_STD_IEEE_754_NAN)
+  	assert_memory_equal(buffer, ((unsigned char[]){0xFA, 0x7F, 0xC0, 0x00, 0x03}),
                       5);
 #endif
 
@@ -174,7 +186,8 @@
       9);
 
   assert_size_equal(9, cbor_encode_double(nan(""), buffer, 512));
-  assert_memory_equal(
+  if (ARCH_WITH_STD_IEEE_754_NAN)
+    assert_memory_equal(
       buffer,
       ((unsigned char[]){0xFB, 0x7F, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}),
       9);
@@ -182,7 +195,8 @@
 #ifndef _WIN32
   // TODO: https://github.com/PJK/libcbor/issues/271
   assert_size_equal(9, cbor_encode_double(nan("3"), buffer, 512));
-  assert_memory_equal(
+  if (ARCH_WITH_STD_IEEE_754_NAN)
+    assert_memory_equal(
       buffer,
       ((unsigned char[]){0xFB, 0x7F, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03}),
       9);

Reply via email to