Skip to content

Commit

Permalink
enable test coverage for armv8-linux-musleabihf
Browse files Browse the repository at this point in the history
 * fix libc prototypes of offsets to have correct integer sizes and
   signedness. This gets all behavior tests to pass for
   armv8-linux-musleabihf
 * fix linux mmap syscall to have correct integer size and signedness
   for offset
 * disable failing armv8-linux-musleabihf std lib tests. See 3289. I
   suspect compiler-rt issue. Note these tests fail with this target
   triple regardless of whether musl is actually linked (-lc).
  • Loading branch information
andrewrk committed Sep 25, 2019
1 parent 40e77da commit d1705ba
Show file tree
Hide file tree
Showing 16 changed files with 115 additions and 19 deletions.
6 changes: 3 additions & 3 deletions std/c.zig
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,13 @@ pub extern "c" fn raise(sig: c_int) c_int;
pub extern "c" fn read(fd: fd_t, buf: [*]u8, nbyte: usize) isize;
pub extern "c" fn readv(fd: c_int, iov: [*]const iovec, iovcnt: c_uint) isize;
pub extern "c" fn pread(fd: fd_t, buf: [*]u8, nbyte: usize, offset: u64) isize;
pub extern "c" fn preadv(fd: c_int, iov: [*]const iovec, iovcnt: c_uint, offset: usize) isize;
pub extern "c" fn preadv(fd: c_int, iov: [*]const iovec, iovcnt: c_uint, offset: u64) isize;
pub extern "c" fn writev(fd: c_int, iov: [*]const iovec_const, iovcnt: c_uint) isize;
pub extern "c" fn pwritev(fd: c_int, iov: [*]const iovec_const, iovcnt: c_uint, offset: usize) isize;
pub extern "c" fn pwritev(fd: c_int, iov: [*]const iovec_const, iovcnt: c_uint, offset: u64) isize;
pub extern "c" fn stat(noalias path: [*]const u8, noalias buf: *Stat) c_int;
pub extern "c" fn write(fd: fd_t, buf: [*]const u8, nbyte: usize) isize;
pub extern "c" fn pwrite(fd: fd_t, buf: [*]const u8, nbyte: usize, offset: u64) isize;
pub extern "c" fn mmap(addr: ?*align(page_size) c_void, len: usize, prot: c_uint, flags: c_uint, fd: fd_t, offset: isize) *c_void;
pub extern "c" fn mmap(addr: ?*align(page_size) c_void, len: usize, prot: c_uint, flags: c_uint, fd: fd_t, offset: u64) *c_void;
pub extern "c" fn munmap(addr: *align(page_size) c_void, len: usize) c_int;
pub extern "c" fn mprotect(addr: *align(page_size) c_void, len: usize, prot: c_uint) c_int;
pub extern "c" fn unlink(path: [*]const u8) c_int;
Expand Down
24 changes: 24 additions & 0 deletions std/fmt.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1233,6 +1233,10 @@ test "cstr" {
}

test "filesize" {
if (builtin.os == .linux and builtin.arch == .arm and builtin.abi == .musleabihf) {
// TODO https://github.com/ziglang/zig/issues/3289
return error.SkipZigTest;
}
try testFmt("file size: 63MiB\n", "file size: {Bi}\n", usize(63 * 1024 * 1024));
try testFmt("file size: 66.06MB\n", "file size: {B:.2}\n", usize(63 * 1024 * 1024));
}
Expand Down Expand Up @@ -1267,13 +1271,21 @@ test "enum" {
}

test "float.scientific" {
if (builtin.os == .linux and builtin.arch == .arm and builtin.abi == .musleabihf) {
// TODO https://github.com/ziglang/zig/issues/3289
return error.SkipZigTest;
}
try testFmt("f32: 1.34000003e+00", "f32: {e}", f32(1.34));
try testFmt("f32: 1.23400001e+01", "f32: {e}", f32(12.34));
try testFmt("f64: -1.234e+11", "f64: {e}", f64(-12.34e10));
try testFmt("f64: 9.99996e-40", "f64: {e}", f64(9.999960e-40));
}

test "float.scientific.precision" {
if (builtin.os == .linux and builtin.arch == .arm and builtin.abi == .musleabihf) {
// TODO https://github.com/ziglang/zig/issues/3289
return error.SkipZigTest;
}
try testFmt("f64: 1.40971e-42", "f64: {e:.5}", f64(1.409706e-42));
try testFmt("f64: 1.00000e-09", "f64: {e:.5}", f64(@bitCast(f32, u32(814313563))));
try testFmt("f64: 7.81250e-03", "f64: {e:.5}", f64(@bitCast(f32, u32(1006632960))));
Expand All @@ -1283,6 +1295,10 @@ test "float.scientific.precision" {
}

test "float.special" {
if (builtin.os == .linux and builtin.arch == .arm and builtin.abi == .musleabihf) {
// TODO https://github.com/ziglang/zig/issues/3289
return error.SkipZigTest;
}
try testFmt("f64: nan", "f64: {}", math.nan_f64);
// negative nan is not defined by IEE 754,
// and ARM thus normalizes it to positive nan
Expand All @@ -1294,6 +1310,10 @@ test "float.special" {
}

test "float.decimal" {
if (builtin.os == .linux and builtin.arch == .arm and builtin.abi == .musleabihf) {
// TODO https://github.com/ziglang/zig/issues/3289
return error.SkipZigTest;
}
try testFmt("f64: 152314000000000000000000000000", "f64: {d}", f64(1.52314e+29));
try testFmt("f32: 1.1", "f32: {d:.1}", f32(1.1234));
try testFmt("f32: 1234.57", "f32: {d:.2}", f32(1234.567));
Expand All @@ -1312,6 +1332,10 @@ test "float.decimal" {
}

test "float.libc.sanity" {
if (builtin.os == .linux and builtin.arch == .arm and builtin.abi == .musleabihf) {
// TODO https://github.com/ziglang/zig/issues/3289
return error.SkipZigTest;
}
try testFmt("f64: 0.00001", "f64: {d:.5}", f64(@bitCast(f32, u32(916964781))));
try testFmt("f64: 0.00001", "f64: {d:.5}", f64(@bitCast(f32, u32(925353389))));
try testFmt("f64: 0.10000", "f64: {d:.5}", f64(@bitCast(f32, u32(1036831278))));
Expand Down
2 changes: 1 addition & 1 deletion std/heap.zig
Original file line number Diff line number Diff line change
Expand Up @@ -780,7 +780,7 @@ test "FixedBufferAllocator" {
}

test "FixedBufferAllocator.reset" {
var buf: [8]u8 align(@alignOf(usize)) = undefined;
var buf: [8]u8 align(@alignOf(u64)) = undefined;
var fba = FixedBufferAllocator.init(buf[0..]);

const X = 0xeeeeeeeeeeeeeeee;
Expand Down
8 changes: 8 additions & 0 deletions std/math/big/rational.zig
Original file line number Diff line number Diff line change
Expand Up @@ -742,6 +742,10 @@ test "big.rational setFloatString" {
}

test "big.rational toFloat" {
if (builtin.os == .linux and builtin.arch == .arm and builtin.abi == .musleabihf) {
// TODO https://github.com/ziglang/zig/issues/3289
return error.SkipZigTest;
}
var a = try Rational.init(al);

// = 3.14159297943115234375
Expand All @@ -754,6 +758,10 @@ test "big.rational toFloat" {
}

test "big.rational set/to Float round-trip" {
if (builtin.os == .linux and builtin.arch == .arm and builtin.abi == .musleabihf) {
// TODO https://github.com/ziglang/zig/issues/3289
return error.SkipZigTest;
}
var a = try Rational.init(al);
var prng = std.rand.DefaultPrng.init(0x5EED);
var i: usize = 0;
Expand Down
5 changes: 5 additions & 0 deletions std/math/complex/atan.zig
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
// https://git.musl-libc.org/cgit/musl/tree/src/complex/catan.c

const std = @import("../../std.zig");
const builtin = @import("builtin");
const testing = std.testing;
const math = std.math;
const cmath = math.complex;
Expand Down Expand Up @@ -129,6 +130,10 @@ test "complex.catan32" {
}

test "complex.catan64" {
if (builtin.os == .linux and builtin.arch == .arm and builtin.abi == .musleabihf) {
// TODO https://github.com/ziglang/zig/issues/3289
return error.SkipZigTest;
}
const a = Complex(f64).new(5, 3);
const c = atan(a);

Expand Down
5 changes: 5 additions & 0 deletions std/math/complex/cosh.zig
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
// https://git.musl-libc.org/cgit/musl/tree/src/complex/ccoshf.c
// https://git.musl-libc.org/cgit/musl/tree/src/complex/ccosh.c

const builtin = @import("builtin");
const std = @import("../../std.zig");
const testing = std.testing;
const math = std.math;
Expand Down Expand Up @@ -164,6 +165,10 @@ test "complex.ccosh32" {
}

test "complex.ccosh64" {
if (builtin.os == .linux and builtin.arch == .arm and builtin.abi == .musleabihf) {
// TODO https://github.com/ziglang/zig/issues/3289
return error.SkipZigTest;
}
const a = Complex(f64).new(5, 3);
const c = cosh(a);

Expand Down
5 changes: 5 additions & 0 deletions std/math/complex/exp.zig
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
// https://git.musl-libc.org/cgit/musl/tree/src/complex/cexpf.c
// https://git.musl-libc.org/cgit/musl/tree/src/complex/cexp.c

const builtin = @import("builtin");
const std = @import("../../std.zig");
const testing = std.testing;
const math = std.math;
Expand Down Expand Up @@ -130,6 +131,10 @@ test "complex.cexp32" {
}

test "complex.cexp64" {
if (builtin.os == .linux and builtin.arch == .arm and builtin.abi == .musleabihf) {
// TODO https://github.com/ziglang/zig/issues/3289
return error.SkipZigTest;
}
const a = Complex(f64).new(5, 3);
const c = exp(a);

Expand Down
5 changes: 5 additions & 0 deletions std/math/complex/sinh.zig
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
// https://git.musl-libc.org/cgit/musl/tree/src/complex/csinhf.c
// https://git.musl-libc.org/cgit/musl/tree/src/complex/csinh.c

const builtin = @import("builtin");
const std = @import("../../std.zig");
const testing = std.testing;
const math = std.math;
Expand Down Expand Up @@ -163,6 +164,10 @@ test "complex.csinh32" {
}

test "complex.csinh64" {
if (builtin.os == .linux and builtin.arch == .arm and builtin.abi == .musleabihf) {
// TODO https://github.com/ziglang/zig/issues/3289
return error.SkipZigTest;
}
const a = Complex(f64).new(5, 3);
const c = sinh(a);

Expand Down
5 changes: 5 additions & 0 deletions std/math/complex/tanh.zig
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
// https://git.musl-libc.org/cgit/musl/tree/src/complex/ctanhf.c
// https://git.musl-libc.org/cgit/musl/tree/src/complex/ctanh.c

const builtin = @import("builtin");
const std = @import("../../std.zig");
const testing = std.testing;
const math = std.math;
Expand Down Expand Up @@ -112,6 +113,10 @@ test "complex.ctanh32" {
}

test "complex.ctanh64" {
if (builtin.os == .linux and builtin.arch == .arm and builtin.abi == .musleabihf) {
// TODO https://github.com/ziglang/zig/issues/3289
return error.SkipZigTest;
}
const a = Complex(f64).new(5, 3);
const c = tanh(a);

Expand Down
4 changes: 4 additions & 0 deletions std/math/cos.zig
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ test "math.cos32" {
}

test "math.cos64" {
if (builtin.os == .linux and builtin.arch == .arm and builtin.abi == .musleabihf) {
// TODO https://github.com/ziglang/zig/issues/3289
return error.SkipZigTest;
}
const epsilon = 0.000001;

expect(math.approxEq(f64, cos_(f64, 0.0), 1.0, epsilon));
Expand Down
12 changes: 12 additions & 0 deletions std/math/pow.zig
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,10 @@ fn isOddInteger(x: f64) bool {
}

test "math.pow" {
if (builtin.os == .linux and builtin.arch == .arm and builtin.abi == .musleabihf) {
// TODO https://github.com/ziglang/zig/issues/3289
return error.SkipZigTest;
}
const epsilon = 0.000001;

expect(math.approxEq(f32, pow(f32, 0.0, 3.3), 0.0, epsilon));
Expand All @@ -202,6 +206,10 @@ test "math.pow" {
}

test "math.pow.special" {
if (builtin.os == .linux and builtin.arch == .arm and builtin.abi == .musleabihf) {
// TODO https://github.com/ziglang/zig/issues/3289
return error.SkipZigTest;
}
const epsilon = 0.000001;

expect(pow(f32, 4, 0.0) == 1.0);
Expand Down Expand Up @@ -244,6 +252,10 @@ test "math.pow.special" {
}

test "math.pow.overflow" {
if (builtin.os == .linux and builtin.arch == .arm and builtin.abi == .musleabihf) {
// TODO https://github.com/ziglang/zig/issues/3289
return error.SkipZigTest;
}
expect(math.isPositiveInf(pow(f64, 2, 1 << 32)));
expect(pow(f64, 2, -(1 << 32)) == 0);
expect(math.isNegativeInf(pow(f64, -2, (1 << 32) + 1)));
Expand Down
20 changes: 20 additions & 0 deletions std/math/sin.zig
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,20 @@ fn sin_(comptime T: type, x_: T) T {
}

test "math.sin" {
if (builtin.os == .linux and builtin.arch == .arm and builtin.abi == .musleabihf) {
// TODO https://github.com/ziglang/zig/issues/3289
return error.SkipZigTest;
}
expect(sin(f32(0.0)) == sin_(f32, 0.0));
expect(sin(f64(0.0)) == sin_(f64, 0.0));
expect(comptime (math.sin(f64(2))) == math.sin(f64(2)));
}

test "math.sin32" {
if (builtin.os == .linux and builtin.arch == .arm and builtin.abi == .musleabihf) {
// TODO https://github.com/ziglang/zig/issues/3289
return error.SkipZigTest;
}
const epsilon = 0.000001;

expect(math.approxEq(f32, sin_(f32, 0.0), 0.0, epsilon));
Expand All @@ -102,6 +110,10 @@ test "math.sin32" {
}

test "math.sin64" {
if (builtin.os == .linux and builtin.arch == .arm and builtin.abi == .musleabihf) {
// TODO https://github.com/ziglang/zig/issues/3289
return error.SkipZigTest;
}
const epsilon = 0.000001;

expect(math.approxEq(f64, sin_(f64, 0.0), 0.0, epsilon));
Expand All @@ -114,6 +126,10 @@ test "math.sin64" {
}

test "math.sin32.special" {
if (builtin.os == .linux and builtin.arch == .arm and builtin.abi == .musleabihf) {
// TODO https://github.com/ziglang/zig/issues/3289
return error.SkipZigTest;
}
expect(sin_(f32, 0.0) == 0.0);
expect(sin_(f32, -0.0) == -0.0);
expect(math.isNan(sin_(f32, math.inf(f32))));
Expand All @@ -122,6 +138,10 @@ test "math.sin32.special" {
}

test "math.sin64.special" {
if (builtin.os == .linux and builtin.arch == .arm and builtin.abi == .musleabihf) {
// TODO https://github.com/ziglang/zig/issues/3289
return error.SkipZigTest;
}
expect(sin_(f64, 0.0) == 0.0);
expect(sin_(f64, -0.0) == -0.0);
expect(math.isNan(sin_(f64, math.inf(f64))));
Expand Down
4 changes: 4 additions & 0 deletions std/math/tan.zig
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ test "math.tan32" {
}

test "math.tan64" {
if (builtin.os == .linux and builtin.arch == .arm and builtin.abi == .musleabihf) {
// TODO https://github.com/ziglang/zig/issues/3289
return error.SkipZigTest;
}
const epsilon = 0.000001;

expect(math.approxEq(f64, tan_(f64, 0.0), 0.0, epsilon));
Expand Down
2 changes: 1 addition & 1 deletion std/os.zig
Original file line number Diff line number Diff line change
Expand Up @@ -2048,7 +2048,7 @@ pub fn mmap(
prot: u32,
flags: u32,
fd: fd_t,
offset: isize,
offset: u64,
) MMapError![]align(mem.page_size) u8 {
const err = if (builtin.link_libc) blk: {
const rc = std.c.mmap(ptr, length, prot, flags, fd, offset);
Expand Down
6 changes: 3 additions & 3 deletions std/os/linux.zig
Original file line number Diff line number Diff line change
Expand Up @@ -190,11 +190,11 @@ pub fn umount2(special: [*]const u8, flags: u32) usize {
return syscall2(SYS_umount2, @ptrToInt(special), flags);
}

pub fn mmap(address: ?[*]u8, length: usize, prot: usize, flags: u32, fd: i32, offset: isize) usize {
pub fn mmap(address: ?[*]u8, length: usize, prot: usize, flags: u32, fd: i32, offset: u64) usize {
if (@hasDecl(@This(), "SYS_mmap2")) {
return syscall6(SYS_mmap2, @ptrToInt(address), length, prot, flags, @bitCast(usize, isize(fd)), @bitCast(usize, @divTrunc(offset, MMAP2_UNIT)));
return syscall6(SYS_mmap2, @ptrToInt(address), length, prot, flags, @bitCast(usize, isize(fd)), @truncate(usize, offset / MMAP2_UNIT));
} else {
return syscall6(SYS_mmap, @ptrToInt(address), length, prot, flags, @bitCast(usize, isize(fd)), @bitCast(usize, offset));
return syscall6(SYS_mmap, @ptrToInt(address), length, prot, flags, @bitCast(usize, isize(fd)), offset);
}
}

Expand Down
21 changes: 10 additions & 11 deletions test/tests.zig
Original file line number Diff line number Diff line change
Expand Up @@ -109,17 +109,16 @@ const test_targets = [_]TestTarget{
},
},
},
// TODO https://github.com/ziglang/zig/issues/3286
//TestTarget{
// .target = Target{
// .Cross = CrossTarget{
// .os = .linux,
// .arch = builtin.Arch{ .arm = builtin.Arch.Arm32.v8_5a },
// .abi = .musleabihf,
// },
// },
// .link_libc = true,
//},
TestTarget{
.target = Target{
.Cross = CrossTarget{
.os = .linux,
.arch = builtin.Arch{ .arm = builtin.Arch.Arm32.v8_5a },
.abi = .musleabihf,
},
},
.link_libc = true,
},
// TODO https://github.com/ziglang/zig/issues/3287
//TestTarget{
// .target = Target{
Expand Down

0 comments on commit d1705ba

Please sign in to comment.