[llvm-branch-commits] [llvm] aa3bbf1 - [BinaryFormat] Disable MachOTest.UnalignedLC on SPARC (#100086)

Tobias Hieta via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Sat Aug 10 03:00:55 PDT 2024


Author: Rainer Orth
Date: 2024-08-10T12:00:43+02:00
New Revision: aa3bbf147fbbd289485e7bdf12d27c1d3c0169c6

URL: https://github.com/llvm/llvm-project/commit/aa3bbf147fbbd289485e7bdf12d27c1d3c0169c6
DIFF: https://github.com/llvm/llvm-project/commit/aa3bbf147fbbd289485e7bdf12d27c1d3c0169c6.diff

LOG: [BinaryFormat] Disable MachOTest.UnalignedLC on SPARC (#100086)

As discussed in Issue #86793, the `MachOTest.UnalignedLC` test dies with
`SIGBUS` on SPARC, a strict-alignment target. It simply cannot work
there. Besides, the test invokes undefined behaviour on big-endian
targets, so this patch disables it on all of those.

Tested on `sparcv9-sun-solaris2.11` and `amd64-pc-solaris2.11`.

(cherry picked from commit 3a226dbe27ac7c7d935bc0968e84e31798a01207)

Added: 
    

Modified: 
    llvm/unittests/BinaryFormat/MachOTest.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/unittests/BinaryFormat/MachOTest.cpp b/llvm/unittests/BinaryFormat/MachOTest.cpp
index 391298ff38d764..78b20c28a9549a 100644
--- a/llvm/unittests/BinaryFormat/MachOTest.cpp
+++ b/llvm/unittests/BinaryFormat/MachOTest.cpp
@@ -6,6 +6,7 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "llvm/ADT/bit.h"
 #include "llvm/BinaryFormat/MachO.h"
 #include "llvm/TargetParser/Triple.h"
 #include "gtest/gtest.h"
@@ -13,7 +14,15 @@
 using namespace llvm;
 using namespace llvm::MachO;
 
-TEST(MachOTest, UnalignedLC) {
+#if BYTE_ORDER == BIG_ENDIAN
+// As discussed in Issue #86793, this test cannot work on a strict-alignment
+// targets like SPARC.  Besides, it's undefined behaviour on big-endian hosts.
+#define MAYBE_UnalignedLC DISABLED_UnalignedLC
+#else
+#define MAYBE_UnalignedLC UnalignedLC
+#endif
+
+TEST(MachOTest, MAYBE_UnalignedLC) {
   unsigned char Valid32BitMachO[] = {
       0xCE, 0xFA, 0xED, 0xFE, 0x07, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
       0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00,


        


More information about the llvm-branch-commits mailing list