Flatten the test directory and run scripts directly

Move shell cases and the runner directly under tests/, and remove the
standalone symbol output chunk test files and their references.

Make shell scripts executable and invoke them directly, honoring their
shebangs and execute permissions.
This commit is contained in:
Rui Ueyama committed 2026-09-14 22:54:34 +09:00
1 parent da0de56368
commit 972347aae9
567 files changed
+7 -79

No files matched your search

+2 -4
View File
@@ -4,10 +4,8 @@ version = "2.42.1"
edition = "2021"
description = "A high-performance ELF linker, rewritten in Rust"
license = "MIT"
[[test]]
name = "symbol_output_chunk"
path = "test/symbol-output-chunk.rs"
# tests/lib.rs belongs to the mold-tests workspace crate.
autotests = false
# The linker is generic over the target. Instantiating it for all twenty
# targets in one crate keeps the compiler on a single core for minutes, so
+1 -1
View File
@@ -5,6 +5,6 @@ fn main() -> ExitCode {
let root = Path::new(env!("CARGO_MANIFEST_DIR"))
.parent()
.unwrap();
let cases = [root.join("tests/cases"), root.join("test")];
let cases = [root.join("tests")];
mold_tests::run(&cases, Path::new(env!("CARGO_BIN_EXE_mold")))
}
-1
View File
@@ -833,7 +833,6 @@ impl Symbol {
}
/// Resolves the output chunk through its owning context.
#[doc = include_str!("../test/symbol-output-chunk.md")]
pub fn output_chunk<'a, E: Arch>(&self, ctx: &'a Context<E>) -> Option<&'a ChunkHeader<E>> {
match self.origin.get() {
OriginValue::OutputChunk(chunk) => Some(ctx.symbol_chunk_header(chunk)),
-2
View File
@@ -1,2 +0,0 @@
# Share the toolchain setup and assertions with the upstream shell tests.
. "$(dirname "$0")/../tests/cases/common.inc"
-24
View File
@@ -1,24 +0,0 @@
The reference cannot outlive its owning context:
```compile_fail,E0505
use mold::{arch::X86_64, chunks::ChunkId, cmdline::Args, context::Context};
let mut ctx = Context::<X86_64>::new(Args::default(), Vec::new());
let id = ctx.symbols.intern(b"synthetic");
ctx.set_symbol_output_chunk(id, ChunkId::Symtab);
let chunk = ctx.symbols[id].output_chunk(&ctx).unwrap();
drop(ctx);
println!("{}", chunk.shndx);
```
The context determines the chunk's architecture:
```compile_fail,E0308
use mold::{arch::{I386, X86_64}, chunks::ChunkId, cmdline::Args, context::Context};
let mut ctx = Context::<X86_64>::new(Args::default(), Vec::new());
let id = ctx.symbols.intern(b"synthetic");
ctx.set_symbol_output_chunk(id, ChunkId::Symtab);
let chunk = ctx.symbols[id].output_chunk::<I386>(&ctx);
```
-45
View File
@@ -1,45 +0,0 @@
use mold::arch::{I386, X86_64};
use mold::chunks::ChunkId;
use mold::cmdline::Args;
use mold::context::Context;
#[test]
fn output_chunk_survives_context_moves_and_chunk_reordering() {
let mut ctx = Box::new(Context::<X86_64>::new(Args::default(), Vec::new()));
let a = ctx.symbols.intern(b"first");
let b = ctx.symbols.intern(b"second");
ctx.set_symbol_output_chunk(a, ChunkId::Symtab);
ctx.set_symbol_output_chunk(b, ChunkId::Got);
ctx.symtab.hdr.shndx = 7;
ctx.got.hdr.shndx = 11;
ctx.chunks = vec![ChunkId::Symtab, ChunkId::Got];
// Move the inline chunk headers to a different allocation.
let mut moved = Box::new(*ctx);
moved.chunks.reverse();
assert_eq!(moved.symbols[a].output_chunk(&moved).unwrap().shndx, 7);
assert_eq!(moved.symbols[b].output_chunk(&moved).unwrap().shndx, 11);
moved.symtab.hdr.shndx = 13;
assert_eq!(moved.symbols[a].output_chunk(&moved).unwrap().shndx, 13);
moved.set_symbol_output_chunk(a, ChunkId::Got);
assert_eq!(moved.symbols[a].output_chunk(&moved).unwrap().shndx, 11);
}
#[test]
fn output_chunk_uses_the_contexts_target_layout() {
let mut ctx = Context::<I386>::new(Args::default(), Vec::new());
let id = ctx.symbols.intern(b"synthetic");
assert!(ctx.symbols[id].output_chunk(&ctx).is_none());
ctx.set_symbol_output_chunk(id, ChunkId::Symtab);
ctx.symtab.hdr.shdr.sh_addr.set(0x1234);
assert_eq!(
ctx.symbols[id]
.output_chunk(&ctx)
.unwrap()
.shdr
.sh_addr
.get(),
0x1234
);
}
+3
View File
@@ -6,5 +6,8 @@ description = "Test support for mold's shell test suite"
license = "MIT"
publish = false
[lib]
path = "lib.rs"
[dependencies]
libc = "0.2"
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loaded 100 of 567 files, more files were not shown because too many files have changed in this diff. Show more