mirror of
https://github.com/ziglang/zig.git
synced 2024-11-16 09:03:12 +00:00
add standalone tests for the new linker bug fixes
This is just a temp addition until I figure out how to tweak the stage2 test harness to add the ability to test the linker too.
This commit is contained in:
parent
3ff05b79b9
commit
bd926e5ea0
@ -34,6 +34,10 @@ pub fn addCases(cases: *tests.StandaloneContext) void {
|
||||
cases.addBuildFile("test/standalone/link_frameworks/build.zig", .{
|
||||
.requires_macos_sdk = true,
|
||||
});
|
||||
cases.addBuildFile("test/standalone/link_common_symbols_alignment/build.zig", .{});
|
||||
if (builtin.os.tag == .macos) {
|
||||
cases.addBuildFile("test/standalone/link_import_tls_dylib/build.zig", .{});
|
||||
}
|
||||
cases.addBuildFile("test/standalone/issue_339/build.zig", .{});
|
||||
cases.addBuildFile("test/standalone/issue_8550/build.zig", .{});
|
||||
cases.addBuildFile("test/standalone/issue_794/build.zig", .{});
|
||||
|
2
test/standalone/link_common_symbols_alignment/a.c
Normal file
2
test/standalone/link_common_symbols_alignment/a.c
Normal file
@ -0,0 +1,2 @@
|
||||
int foo;
|
||||
__attribute__((aligned(4096))) int bar;
|
16
test/standalone/link_common_symbols_alignment/build.zig
Normal file
16
test/standalone/link_common_symbols_alignment/build.zig
Normal file
@ -0,0 +1,16 @@
|
||||
const Builder = @import("std").build.Builder;
|
||||
|
||||
pub fn build(b: *Builder) void {
|
||||
const mode = b.standardReleaseOptions();
|
||||
|
||||
const lib_a = b.addStaticLibrary("a", null);
|
||||
lib_a.addCSourceFiles(&.{"a.c"}, &.{"-fcommon"});
|
||||
lib_a.setBuildMode(mode);
|
||||
|
||||
const test_exe = b.addTest("main.zig");
|
||||
test_exe.setBuildMode(mode);
|
||||
test_exe.linkLibrary(lib_a);
|
||||
|
||||
const test_step = b.step("test", "Test it");
|
||||
test_step.dependOn(&test_exe.step);
|
||||
}
|
9
test/standalone/link_common_symbols_alignment/main.zig
Normal file
9
test/standalone/link_common_symbols_alignment/main.zig
Normal file
@ -0,0 +1,9 @@
|
||||
const std = @import("std");
|
||||
|
||||
extern var foo: i32;
|
||||
extern var bar: i32;
|
||||
|
||||
test {
|
||||
try std.testing.expect(@ptrToInt(&foo) % 4 == 0);
|
||||
try std.testing.expect(@ptrToInt(&bar) % 4096 == 0);
|
||||
}
|
1
test/standalone/link_import_tls_dylib/a.c
Normal file
1
test/standalone/link_import_tls_dylib/a.c
Normal file
@ -0,0 +1 @@
|
||||
_Thread_local int a;
|
16
test/standalone/link_import_tls_dylib/build.zig
Normal file
16
test/standalone/link_import_tls_dylib/build.zig
Normal file
@ -0,0 +1,16 @@
|
||||
const Builder = @import("std").build.Builder;
|
||||
|
||||
pub fn build(b: *Builder) void {
|
||||
const mode = b.standardReleaseOptions();
|
||||
|
||||
const lib = b.addSharedLibrary("a", null, b.version(1, 0, 0));
|
||||
lib.setBuildMode(mode);
|
||||
lib.addCSourceFile("a.c", &.{});
|
||||
|
||||
const test_exe = b.addTest("main.zig");
|
||||
test_exe.setBuildMode(mode);
|
||||
test_exe.linkLibrary(lib);
|
||||
|
||||
const test_step = b.step("test", "Test it");
|
||||
test_step.dependOn(&test_exe.step);
|
||||
}
|
7
test/standalone/link_import_tls_dylib/main.zig
Normal file
7
test/standalone/link_import_tls_dylib/main.zig
Normal file
@ -0,0 +1,7 @@
|
||||
const std = @import("std");
|
||||
|
||||
extern threadlocal var a: i32;
|
||||
|
||||
test {
|
||||
try std.testing.expect(a == 0);
|
||||
}
|
Loading…
Reference in New Issue
Block a user