authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-10-21 17:17:06-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-10-23 16:27:39-07:00
log22948616ff8da42f9ae9d7b292d80a01537f2a7e
tree0862322a5c24cdc64b70f7a817df63de3703d6d2
parent5d75d8f6fc026948aa02309bd820fc15206288e0

split a fat test case


1 files changed, 77 insertions(+), 75 deletions(-)

test/link/elf.zig+77-75
...@@ -51,6 +51,7 @@ pub fn testAll(b: *Build, build_opts: BuildOptions) *Step {...@@ -51,6 +51,7 @@ pub fn testAll(b: *Build, build_opts: BuildOptions) *Step {
51 elf_step.dependOn(testEmitRelocatable(b, .{ .target = musl_target }));51 elf_step.dependOn(testEmitRelocatable(b, .{ .target = musl_target }));
52 elf_step.dependOn(testRelocatableArchive(b, .{ .target = musl_target }));52 elf_step.dependOn(testRelocatableArchive(b, .{ .target = musl_target }));
53 elf_step.dependOn(testRelocatableEhFrame(b, .{ .target = musl_target }));53 elf_step.dependOn(testRelocatableEhFrame(b, .{ .target = musl_target }));
54 elf_step.dependOn(testRelocatableEhFrameComdatHeavy(b, .{ .target = musl_target }));
54 elf_step.dependOn(testRelocatableNoEhFrame(b, .{ .target = musl_target }));55 elf_step.dependOn(testRelocatableNoEhFrame(b, .{ .target = musl_target }));
5556
56 // Exercise linker in ar mode57 // Exercise linker in ar mode
...@@ -2723,86 +2724,87 @@ fn testRelocatableArchive(b: *Build, opts: Options) *Step {...@@ -2723,86 +2724,87 @@ fn testRelocatableArchive(b: *Build, opts: Options) *Step {
2723fn testRelocatableEhFrame(b: *Build, opts: Options) *Step {2724fn testRelocatableEhFrame(b: *Build, opts: Options) *Step {
2724 const test_step = addTestStep(b, "relocatable-eh-frame", opts);2725 const test_step = addTestStep(b, "relocatable-eh-frame", opts);
27252726
2726 {2727 const obj = addObject(b, opts, .{
2727 const obj = addObject(b, opts, .{2728 .name = "obj1",
2728 .name = "obj1",2729 .cpp_source_bytes =
2729 .cpp_source_bytes =2730 \\#include <stdexcept>
2730 \\#include <stdexcept>2731 \\int try_me() {
2731 \\int try_me() {2732 \\ throw std::runtime_error("Oh no!");
2732 \\ throw std::runtime_error("Oh no!");2733 \\}
2733 \\}2734 ,
2734 ,2735 });
2735 });2736 addCppSourceBytes(obj,
2736 addCppSourceBytes(obj,2737 \\extern int try_me();
2737 \\extern int try_me();2738 \\int try_again() {
2738 \\int try_again() {2739 \\ return try_me();
2739 \\ return try_me();2740 \\}
2740 \\}2741 , &.{});
2741 , &.{});2742 obj.linkLibCpp();
2742 obj.linkLibCpp();
27432743
2744 const exe = addExecutable(b, opts, .{ .name = "test1" });2744 const exe = addExecutable(b, opts, .{ .name = "test1" });
2745 addCppSourceBytes(exe,2745 addCppSourceBytes(exe,
2746 \\#include <iostream>2746 \\#include <iostream>
2747 \\#include <stdexcept>2747 \\#include <stdexcept>
2748 \\extern int try_again();2748 \\extern int try_again();
2749 \\int main() {2749 \\int main() {
2750 \\ try {2750 \\ try {
2751 \\ try_again();2751 \\ try_again();
2752 \\ } catch (const std::exception &e) {2752 \\ } catch (const std::exception &e) {
2753 \\ std::cout << "exception=" << e.what();2753 \\ std::cout << "exception=" << e.what();
2754 \\ }2754 \\ }
2755 \\ return 0;2755 \\ return 0;
2756 \\}2756 \\}
2757 , &.{});2757 , &.{});
2758 exe.addObject(obj);2758 exe.addObject(obj);
2759 exe.linkLibCpp();2759 exe.linkLibCpp();
27602760
2761 const run = addRunArtifact(exe);2761 const run = addRunArtifact(exe);
2762 run.expectStdOutEqual("exception=Oh no!");2762 run.expectStdOutEqual("exception=Oh no!");
2763 test_step.dependOn(&run.step);2763 test_step.dependOn(&run.step);
2764 }
27652764
2766 {2765 return test_step;
2767 // Let's make the object file COMDAT group heavy!2766}
2768 const obj = addObject(b, opts, .{
2769 .name = "obj2",
2770 .cpp_source_bytes =
2771 \\#include <stdexcept>
2772 \\int try_me() {
2773 \\ throw std::runtime_error("Oh no!");
2774 \\}
2775 ,
2776 });
2777 addCppSourceBytes(obj,
2778 \\extern int try_me();
2779 \\int try_again() {
2780 \\ return try_me();
2781 \\}
2782 , &.{});
2783 addCppSourceBytes(obj,
2784 \\#include <iostream>
2785 \\#include <stdexcept>
2786 \\extern int try_again();
2787 \\int main() {
2788 \\ try {
2789 \\ try_again();
2790 \\ } catch (const std::exception &e) {
2791 \\ std::cout << "exception=" << e.what();
2792 \\ }
2793 \\ return 0;
2794 \\}
2795 , &.{});
2796 obj.linkLibCpp();
27972767
2798 const exe = addExecutable(b, opts, .{ .name = "test2" });2768fn testRelocatableEhFrameComdatHeavy(b: *Build, opts: Options) *Step {
2799 exe.addObject(obj);2769 const test_step = addTestStep(b, "relocatable-eh-frame-comdat-heavy", opts);
2800 exe.linkLibCpp();
28012770
2802 const run = addRunArtifact(exe);2771 const obj = addObject(b, opts, .{
2803 run.expectStdOutEqual("exception=Oh no!");2772 .name = "obj2",
2804 test_step.dependOn(&run.step);2773 .cpp_source_bytes =
2805 }2774 \\#include <stdexcept>
2775 \\int try_me() {
2776 \\ throw std::runtime_error("Oh no!");
2777 \\}
2778 ,
2779 });
2780 addCppSourceBytes(obj,
2781 \\extern int try_me();
2782 \\int try_again() {
2783 \\ return try_me();
2784 \\}
2785 , &.{});
2786 addCppSourceBytes(obj,
2787 \\#include <iostream>
2788 \\#include <stdexcept>
2789 \\extern int try_again();
2790 \\int main() {
2791 \\ try {
2792 \\ try_again();
2793 \\ } catch (const std::exception &e) {
2794 \\ std::cout << "exception=" << e.what();
2795 \\ }
2796 \\ return 0;
2797 \\}
2798 , &.{});
2799 obj.linkLibCpp();
2800
2801 const exe = addExecutable(b, opts, .{ .name = "test2" });
2802 exe.addObject(obj);
2803 exe.linkLibCpp();
2804
2805 const run = addRunArtifact(exe);
2806 run.expectStdOutEqual("exception=Oh no!");
2807 test_step.dependOn(&run.step);
28062808
2807 return test_step;2809 return test_step;
2808}2810}