split a fat test case

This commit is contained in:
Andrew Kelley 2024-10-21 17:17:06 -07:00
parent 5d75d8f6fc
commit 22948616ff

View file

@ -51,6 +51,7 @@ pub fn testAll(b: *Build, build_opts: BuildOptions) *Step {
elf_step.dependOn(testEmitRelocatable(b, .{ .target = musl_target })); elf_step.dependOn(testEmitRelocatable(b, .{ .target = musl_target }));
elf_step.dependOn(testRelocatableArchive(b, .{ .target = musl_target })); elf_step.dependOn(testRelocatableArchive(b, .{ .target = musl_target }));
elf_step.dependOn(testRelocatableEhFrame(b, .{ .target = musl_target })); elf_step.dependOn(testRelocatableEhFrame(b, .{ .target = musl_target }));
elf_step.dependOn(testRelocatableEhFrameComdatHeavy(b, .{ .target = musl_target }));
elf_step.dependOn(testRelocatableNoEhFrame(b, .{ .target = musl_target })); elf_step.dependOn(testRelocatableNoEhFrame(b, .{ .target = musl_target }));
// Exercise linker in ar mode // Exercise linker in ar mode
@ -2723,86 +2724,87 @@ fn testRelocatableArchive(b: *Build, opts: Options) *Step {
fn testRelocatableEhFrame(b: *Build, opts: Options) *Step { fn testRelocatableEhFrame(b: *Build, opts: Options) *Step {
const test_step = addTestStep(b, "relocatable-eh-frame", opts); const test_step = addTestStep(b, "relocatable-eh-frame", opts);
{ const obj = addObject(b, opts, .{
const obj = addObject(b, opts, .{ .name = "obj1",
.name = "obj1", .cpp_source_bytes =
.cpp_source_bytes = \\#include <stdexcept>
\\#include <stdexcept> \\int try_me() {
\\int try_me() { \\ throw std::runtime_error("Oh no!");
\\ throw std::runtime_error("Oh no!"); \\}
\\} ,
, });
}); addCppSourceBytes(obj,
addCppSourceBytes(obj, \\extern int try_me();
\\extern int try_me(); \\int try_again() {
\\int try_again() { \\ return try_me();
\\ return try_me(); \\}
\\} , &.{});
, &.{}); obj.linkLibCpp();
obj.linkLibCpp();
const exe = addExecutable(b, opts, .{ .name = "test1" }); const exe = addExecutable(b, opts, .{ .name = "test1" });
addCppSourceBytes(exe, addCppSourceBytes(exe,
\\#include <iostream> \\#include <iostream>
\\#include <stdexcept> \\#include <stdexcept>
\\extern int try_again(); \\extern int try_again();
\\int main() { \\int main() {
\\ try { \\ try {
\\ try_again(); \\ try_again();
\\ } catch (const std::exception &e) { \\ } catch (const std::exception &e) {
\\ std::cout << "exception=" << e.what(); \\ std::cout << "exception=" << e.what();
\\ } \\ }
\\ return 0; \\ return 0;
\\} \\}
, &.{}); , &.{});
exe.addObject(obj); exe.addObject(obj);
exe.linkLibCpp(); exe.linkLibCpp();
const run = addRunArtifact(exe); const run = addRunArtifact(exe);
run.expectStdOutEqual("exception=Oh no!"); run.expectStdOutEqual("exception=Oh no!");
test_step.dependOn(&run.step); test_step.dependOn(&run.step);
}
{ return test_step;
// Let's make the object file COMDAT group heavy! }
const obj = addObject(b, opts, .{
.name = "obj2",
.cpp_source_bytes =
\\#include <stdexcept>
\\int try_me() {
\\ throw std::runtime_error("Oh no!");
\\}
,
});
addCppSourceBytes(obj,
\\extern int try_me();
\\int try_again() {
\\ return try_me();
\\}
, &.{});
addCppSourceBytes(obj,
\\#include <iostream>
\\#include <stdexcept>
\\extern int try_again();
\\int main() {
\\ try {
\\ try_again();
\\ } catch (const std::exception &e) {
\\ std::cout << "exception=" << e.what();
\\ }
\\ return 0;
\\}
, &.{});
obj.linkLibCpp();
const exe = addExecutable(b, opts, .{ .name = "test2" }); fn testRelocatableEhFrameComdatHeavy(b: *Build, opts: Options) *Step {
exe.addObject(obj); const test_step = addTestStep(b, "relocatable-eh-frame-comdat-heavy", opts);
exe.linkLibCpp();
const run = addRunArtifact(exe); const obj = addObject(b, opts, .{
run.expectStdOutEqual("exception=Oh no!"); .name = "obj2",
test_step.dependOn(&run.step); .cpp_source_bytes =
} \\#include <stdexcept>
\\int try_me() {
\\ throw std::runtime_error("Oh no!");
\\}
,
});
addCppSourceBytes(obj,
\\extern int try_me();
\\int try_again() {
\\ return try_me();
\\}
, &.{});
addCppSourceBytes(obj,
\\#include <iostream>
\\#include <stdexcept>
\\extern int try_again();
\\int main() {
\\ try {
\\ try_again();
\\ } catch (const std::exception &e) {
\\ std::cout << "exception=" << e.what();
\\ }
\\ return 0;
\\}
, &.{});
obj.linkLibCpp();
const exe = addExecutable(b, opts, .{ .name = "test2" });
exe.addObject(obj);
exe.linkLibCpp();
const run = addRunArtifact(exe);
run.expectStdOutEqual("exception=Oh no!");
test_step.dependOn(&run.step);
return test_step; return test_step;
} }