[llvm] 3a226db - [BinaryFormat] Disable MachOTest.UnalignedLC on SPARC (#100086)

via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 6 00:08:45 PDT 2024


Author: Rainer Orth
Date: 2024-08-06T09:08:41+02:00
New Revision: 3a226dbe27ac7c7d935bc0968e84e31798a01207

URL: https://github.com/llvm/llvm-project/commit/3a226dbe27ac7c7d935bc0968e84e31798a01207
DIFF: https://github.com/llvm/llvm-project/commit/3a226dbe27ac7c7d935bc0968e84e31798a01207.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`.

Added: 
    

Modified: 
    llvm/unittests/BinaryFormat/MachOTest.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/unittests/BinaryFormat/MachOTest.cpp b/llvm/unittests/BinaryFormat/MachOTest.cpp
index 391298ff38d76..78b20c28a9549 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-commits mailing list