[PATCH] D112898: [lld] Add test suite mode for running LLD main twice

Shoaib Meenai via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Oct 31 17:04:34 PDT 2021


smeenai updated this revision to Diff 383696.
smeenai added a comment.

Use XFAIL instead of unsupported, so that we get notified if the behavior changes


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D112898/new/

https://reviews.llvm.org/D112898

Files:
  lld/test/MachO/error-limit.test
  lld/test/MachO/invalid/bad-archive.s
  lld/test/MachO/invalid/cstring-dedup.s
  lld/test/MachO/invalid/lto-bitcode-nodatalayout.ll
  lld/test/MachO/invalid/reserved-section-name.s
  lld/test/MachO/time-trace.s
  lld/test/lit.cfg.py


Index: lld/test/lit.cfg.py
===================================================================
--- lld/test/lit.cfg.py
+++ lld/test/lit.cfg.py
@@ -81,7 +81,22 @@
 
 # Set a fake constant version so that we get consistent output.
 config.environment['LLD_VERSION'] = 'LLD 1.0'
-config.environment['LLD_IN_TEST'] = '1'
+
+# LLD_IN_TEST determines how many times `main` is run inside each process, which
+# lets us test that it's cleaning up after itself and resetting global state
+# correctly (which is important for usage as a library).
+run_lld_main_twice = lit_config.params.get('RUN_LLD_MAIN_TWICE', False)
+if not run_lld_main_twice:
+    config.environment['LLD_IN_TEST'] = '1'
+else:
+    config.environment['LLD_IN_TEST'] = '2'
+    # Many ELF tests fail in this mode.
+    config.excludes.append('ELF')
+    # Some old Mach-O backend tests fail, and it's due for removal anyway.
+    config.excludes.append('mach-o')
+    # Some new Mach-O backend tests fail; give them a way to mark themselves
+    # unsupported in this mode.
+    config.available_features.add('main-run-twice')
 
 # Indirectly check if the mt.exe Microsoft utility exists by searching for
 # cvtres, which always accompanies it.  Alternatively, check if we can use
Index: lld/test/MachO/time-trace.s
===================================================================
--- lld/test/MachO/time-trace.s
+++ lld/test/MachO/time-trace.s
@@ -1,3 +1,7 @@
+## When running main twice, we'll also output the time trace JSON twice, which
+## breaks JSON parsing.
+# XFAIL: main-run-twice
+
 # REQUIRES: x86
 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %s -o %t.o
 
Index: lld/test/MachO/invalid/reserved-section-name.s
===================================================================
--- lld/test/MachO/invalid/reserved-section-name.s
+++ lld/test/MachO/invalid/reserved-section-name.s
@@ -1,3 +1,7 @@
+## We're intentionally testing fatal errors (for malformed input files), and
+## fatal errors aren't supported for testing when main is run twice.
+# XFAIL: main-run-twice
+
 # REQUIRES: x86
 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %s -o %t.o
 # RUN: not %lld -o %t %t.o 2>&1 | FileCheck %s -DFILE=%t.o
Index: lld/test/MachO/invalid/lto-bitcode-nodatalayout.ll
===================================================================
--- lld/test/MachO/invalid/lto-bitcode-nodatalayout.ll
+++ lld/test/MachO/invalid/lto-bitcode-nodatalayout.ll
@@ -1,3 +1,7 @@
+;; We're intentionally testing fatal errors (for malformed input files), and
+;; fatal errors aren't supported for testing when main is run twice.
+; XFAIL: main-run-twice
+
 ; REQUIRES: x86
 ; RUN: llvm-as %s -o %t.o
 ; RUN: not %lld %t.o -o /dev/null 2>&1 | FileCheck %s
Index: lld/test/MachO/invalid/cstring-dedup.s
===================================================================
--- lld/test/MachO/invalid/cstring-dedup.s
+++ lld/test/MachO/invalid/cstring-dedup.s
@@ -1,3 +1,7 @@
+## We're intentionally testing fatal errors (for malformed input files), and
+## fatal errors aren't supported for testing when main is run twice.
+# XFAIL: main-run-twice
+
 # REQUIRES: x86
 # RUN: rm -rf %t; split-file %s %t
 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/not-terminated.s -o %t/not-terminated.o
Index: lld/test/MachO/invalid/bad-archive.s
===================================================================
--- lld/test/MachO/invalid/bad-archive.s
+++ lld/test/MachO/invalid/bad-archive.s
@@ -1,3 +1,7 @@
+## We're intentionally testing fatal errors (for malformed input files), and
+## fatal errors aren't supported for testing when main is run twice.
+# XFAIL: main-run-twice
+
 # REQUIRES: x86
 # RUN: echo "!<arch>" > %t.a
 # RUN: echo "foo" >> %t.a
Index: lld/test/MachO/error-limit.test
===================================================================
--- lld/test/MachO/error-limit.test
+++ lld/test/MachO/error-limit.test
@@ -1,3 +1,7 @@
+## We're intentionally testing fatal errors, which isn't supported for testing
+## when main is run twice.
+XFAIL: main-run-twice
+
 ## Check that we only see 20 (the default error-limit) "cannot open" errors
 RUN: not %lld A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 2>&1 | \
 RUN:     FileCheck -check-prefix=DEFAULT %s


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D112898.383696.patch
Type: text/x-patch
Size: 4263 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211101/af9299e4/attachment.bin>


More information about the llvm-commits mailing list