From 60070e0c1352a1cc6b02a0d1a30c657368a033c3 Mon Sep 17 00:00:00 2001
From: Rui Ueyama <ruiu@bluewhale.systems>
Date: Fri, 19 Aug 2022 20:05:26 +0800
Subject: [PATCH] Simplify

---
 test/elf/CMakeLists.txt   | 265 +-------------------------------------
 test/macho/CMakeLists.txt | 100 +-------------
 2 files changed, 6 insertions(+), 359 deletions(-)

diff --git a/test/elf/CMakeLists.txt b/test/elf/CMakeLists.txt
index 5d15d6cb..138e8205 100644
--- a/test/elf/CMakeLists.txt
+++ b/test/elf/CMakeLists.txt
@@ -1,269 +1,12 @@
-set(MOLD_ELF_TESTS
-  absolute-symbols
-  allow-multiple-definition
-  ar-alignment
-  arm32-thumb-interwork
-  as-needed
-  as-needed-weak
-  as-needed2
-  auxiliary
-  basic
-  bno-symbolic
-  bsymbolic
-  bsymbolic-functions
-  bug178
-  build-id
-  canonical-plt
-  cmdline
-  color-diagnostics
-  comment
-  common
-  common-archive
-  common-ref
-  compress-debug-sections
-  compressed-debug-info
-  compressed-debug-info-gnu
-  copyrel
-  copyrel-protected
-  copyrel-relro
-  dead-debug-sections
-  debug-macro-section
-  default-symver
-  defsym
-  defsym2
-  demangle
-  demangle-rust
-  dependency-file
-  disable-new-dtags
-  discard
-  dso-undef
-  dt-init
-  dt-needed
-  duplicate-error
-  dynamic
-  dynamic-dt-debug
-  dynamic-linker
-  dynamic-list
-  dynamic-list2
-  dynamic-list3
-  emit-relocs
-  empty-file
-  empty-input
-  empty-version
-  emulation-deduction
-  entry
-  exception
-  exception-mcmodel-large
-  exclude-libs
-  exclude-libs2
-  exclude-libs3
-  execstack
-  execstack-if-needed
-  export-dynamic
-  export-from-exe
-  fatal-warnings
-  filler
-  filter
-  func-addr
-  gc-sections
-  gdb-index-compress-output
-  gdb-index-dwarf2
-  gdb-index-dwarf3
-  gdb-index-dwarf4
-  gdb-index-dwarf5
-  gdb-index-empty
-  glibc-2.22-bug
-  gnu-hash
-  gnu-linkonce
-  gnu-retain
-  gnu-unique
-  gnu-warning
-  hello-dynamic
-  hello-static
-  help
-  hidden-undef
-  icf
-  icf-small
-  ifunc-dso
-  ifunc-dynamic
-  ifunc-export
-  ifunc-static
-  ifunc-static-pie
-  image-base
-  incompatible-libs
-  incompatible-libs2
-  incompatible-obj
-  init
-  init-array
-  init-array-priorities
-  init-array-readonly
-  init-in-dso
-  initfirst
-  interpose
-  invalid-version-script
-  large-alignment
-  large-alignment-dso
-  link-order
-  linker-script
-  linker-script-defsym
-  linker-script2
-  linker-script3
-  linker-script4
-  lto-archive
-  lto-dso
-  lto-gcc
-  lto-llvm
-  lto-version-script
-  many-sections
-  mergeable-records
-  mergeable-strings
-  missing-but-ok
-  missing-error
-  mold-wrapper
-  mold-wrapper2
-  no-quick-exit
-  nocopyreloc
-  noinhibit-exec
-  non-canonical-plt
-  nostdlib
-  note
-  note-property
-  note2
-  now
-  oformat-binary
-  omagic
-  pack-dyn-relocs-relr
-  package-metadata
-  pie
-  plt
-  plt-dso
-  pltgot
-  preinit-array
-  print-dependencies
-  protected
-  protected-dynsym
-  push-pop-state
-  relax
-  reloc
-  reloc-overflow
-  reloc-rodata
-  reloc-zero
-  relocatable
-  relocatable-archive
-  relro
-  repro
-  require-defined
-  response-file
-  retain-symbols-file
-  reverse-sections
-  rodata-name
-  rosegment
-  rpath
-  run
-  run-clang
-  section-alignment
-  section-name
-  section-start
-  shared
-  shuffle-sections
-  shuffle-sections-seed
-  soname
-  start-lib
-  start-stop-symbol
-  static-archive
-  static-pie
-  stdout
-  strip
-  symbol-rank
-  symbol-version
-  symbol-version2
-  symbol-version3
-  symtab
-  symtab-dso
-  symtab-section-symbols
-  synthetic-symbols
-  sysroot
-  sysroot-linker-script
-  sysroot2
-  thin-archive
-  thread-count
-  tls-common
-  tls-dso
-  tls-gd
-  tls-gd-mcmodel-large
-  tls-gd-noplt
-  tls-gd2
-  tls-ie
-  tls-large-tbss
-  tls-ld
-  tls-ld-mcmodel-large
-  tls-ld-noplt
-  tls-le
-  tls-module-base
-  tls-nopic
-  tls-pic
-  tlsdesc
-  tlsdesc-import
-  tlsdesc-static
-  trace
-  trace-symbol
-  undefined
-  unique
-  unresolved-symbols
-  verbose
-  version
-  version-script
-  version-script10
-  version-script11
-  version-script12
-  version-script13
-  version-script14
-  version-script15
-  version-script16
-  version-script17
-  version-script2
-  version-script3
-  version-script4
-  version-script5
-  version-script6
-  version-script7
-  version-script8
-  version-script9
-  versioned-undef
-  visibility
-  warn-common
-  warn-execstack
-  warn-once
-  warn-shared-textrel
-  warn-textrel
-  warn-unresolved-symbols
-  weak-export-dso
-  weak-export-exe
-  weak-undef
-  whole-archive
-  wrap
-  z-cet-report
-  z-defs
-  z-ibt
-  z-ibtplt
-  z-max-page-size
-  z-nodefaultlib
-  z-nodump
-  z-now
-  z-origin
-  z-separate-code
-  z-shstk
-  z-text
-  z-unknown
-  )
-
 option(MOLD_ENABLE_QEMU_TESTS "Enable tests for other targets" OFF)
 
+file(GLOB MOLD_ELF_TESTS RELATIVE ${CMAKE_CURRENT_LIST_DIR} "*.sh")
+
 function(mold_add_arch_test NAME TRIPLE MACHINE)
   if(NOT ${CMAKE_HOST_SYSTEM_PROCESSOR} STREQUAL ${MACHINE})
     set(TEST_NAME "${MACHINE}-${NAME}")
     add_test(NAME ${TEST_NAME}
-      COMMAND bash -x ${CMAKE_CURRENT_LIST_DIR}/${NAME}.sh
+      COMMAND bash -x ${CMAKE_CURRENT_LIST_DIR}/${NAME}
       WORKING_DIRECTORY ${mold_BINARY_DIR})
 
     set(TEST_ENV
@@ -280,7 +23,7 @@ endfunction()
 
 foreach(TEST IN LISTS MOLD_ELF_TESTS)
   add_test(NAME "${CMAKE_HOST_SYSTEM_PROCESSOR}-${TEST}"
-    COMMAND bash -x ${CMAKE_CURRENT_LIST_DIR}/${TEST}.sh
+    COMMAND bash -x ${CMAKE_CURRENT_LIST_DIR}/${TEST}
     WORKING_DIRECTORY ${mold_BINARY_DIR})
 
   if(MOLD_ENABLE_QEMU_TESTS)
