File: 0006-Fix-endianness-issue-with-tests.patch

package info (click to toggle)
ros-vision-opencv 1.16.2%2Bds-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 632 kB
  • sloc: cpp: 2,981; python: 679; xml: 91; sh: 21; makefile: 9
file content (42 lines) | stat: -rw-r--r-- 1,295 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
From: =?utf-8?q?Timo_R=C3=B6hling?= <roehling@debian.org>
Date: Tue, 26 Oct 2021 23:40:04 +0200
Subject: Fix endianness issue with tests

---
 cv_bridge/test/utest.cpp | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/cv_bridge/test/utest.cpp b/cv_bridge/test/utest.cpp
index d74be56..8ff6292 100644
--- a/cv_bridge/test/utest.cpp
+++ b/cv_bridge/test/utest.cpp
@@ -2,6 +2,11 @@
 #include <sensor_msgs/image_encodings.h>
 #include <gtest/gtest.h>
 
+#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
+static constexpr bool native_bigendian = true;
+#else
+static constexpr bool native_bigendian = false;
+#endif
 
 // Tests conversion of non-continuous cv::Mat. #5206
 TEST(CvBridgeTest, NonContinuous)
@@ -79,7 +84,7 @@ TEST(CvBridgeTest, imageMessageStep)
   image.encoding = "mono8";
   image.height = 220;
   image.width = 200;
-  image.is_bigendian = false;
+  image.is_bigendian = native_bigendian;
   image.step = 208;
 
   image.data.resize(image.height*image.step);
@@ -111,7 +116,7 @@ TEST(CvBridgeTest, imageMessageConversion)
   cv_bridge::CvImagePtr cv_ptr;
   imgmsg.height = 220;
   imgmsg.width = 200;
-  imgmsg.is_bigendian = false;
+  imgmsg.is_bigendian = native_bigendian;
 
   // image with data type float32 and 1 channels
   imgmsg.encoding = "32FC1";