authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-09-25 15:57:13-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-09-25 16:21:04-04:00
logd1705baa749a696132e272974858fef8273614ff
treec5ef1538c0bfa2bb37382c979ee90a3a881a584e
parent40e77dad836abf130bf49af1838d108f0fc2e94e
signaturelock-open Commit is signed but in an unrecognized format.

enable test coverage for armv8-linux-musleabihf

* 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).

16 files changed, 115 insertions(+), 19 deletions(-)

std/c.zig+3-3
......@@ -70,13 +70,13 @@ pub extern "c" fn raise(sig: c_int) c_int;
7070pub extern "c" fn read(fd: fd_t, buf: [*]u8, nbyte: usize) isize;
7171pub extern "c" fn readv(fd: c_int, iov: [*]const iovec, iovcnt: c_uint) isize;
7272pub extern "c" fn pread(fd: fd_t, buf: [*]u8, nbyte: usize, offset: u64) isize;
73pub extern "c" fn preadv(fd: c_int, iov: [*]const iovec, iovcnt: c_uint, offset: usize) isize;
73pub extern "c" fn preadv(fd: c_int, iov: [*]const iovec, iovcnt: c_uint, offset: u64) isize;
7474pub extern "c" fn writev(fd: c_int, iov: [*]const iovec_const, iovcnt: c_uint) isize;
75pub extern "c" fn pwritev(fd: c_int, iov: [*]const iovec_const, iovcnt: c_uint, offset: usize) isize;
75pub extern "c" fn pwritev(fd: c_int, iov: [*]const iovec_const, iovcnt: c_uint, offset: u64) isize;
7676pub extern "c" fn stat(noalias path: [*]const u8, noalias buf: *Stat) c_int;
7777pub extern "c" fn write(fd: fd_t, buf: [*]const u8, nbyte: usize) isize;
7878pub extern "c" fn pwrite(fd: fd_t, buf: [*]const u8, nbyte: usize, offset: u64) isize;
79pub 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;
79pub 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;
8080pub extern "c" fn munmap(addr: *align(page_size) c_void, len: usize) c_int;
8181pub extern "c" fn mprotect(addr: *align(page_size) c_void, len: usize, prot: c_uint) c_int;
8282pub extern "c" fn unlink(path: [*]const u8) c_int;
std/fmt.zig+24
......@@ -1233,6 +1233,10 @@ test "cstr" {
12331233}
12341234
12351235test "filesize" {
1236 if (builtin.os == .linux and builtin.arch == .arm and builtin.abi == .musleabihf) {
1237 // TODO https://github.com/ziglang/zig/issues/3289
1238 return error.SkipZigTest;
1239 }
12361240 try testFmt("file size: 63MiB\n", "file size: {Bi}\n", usize(63 * 1024 * 1024));
12371241 try testFmt("file size: 66.06MB\n", "file size: {B:.2}\n", usize(63 * 1024 * 1024));
12381242}
......@@ -1267,6 +1271,10 @@ test "enum" {
12671271}
12681272
12691273test "float.scientific" {
1274 if (builtin.os == .linux and builtin.arch == .arm and builtin.abi == .musleabihf) {
1275 // TODO https://github.com/ziglang/zig/issues/3289
1276 return error.SkipZigTest;
1277 }
12701278 try testFmt("f32: 1.34000003e+00", "f32: {e}", f32(1.34));
12711279 try testFmt("f32: 1.23400001e+01", "f32: {e}", f32(12.34));
12721280 try testFmt("f64: -1.234e+11", "f64: {e}", f64(-12.34e10));
......@@ -1274,6 +1282,10 @@ test "float.scientific" {
12741282}
12751283
12761284test "float.scientific.precision" {
1285 if (builtin.os == .linux and builtin.arch == .arm and builtin.abi == .musleabihf) {
1286 // TODO https://github.com/ziglang/zig/issues/3289
1287 return error.SkipZigTest;
1288 }
12771289 try testFmt("f64: 1.40971e-42", "f64: {e:.5}", f64(1.409706e-42));
12781290 try testFmt("f64: 1.00000e-09", "f64: {e:.5}", f64(@bitCast(f32, u32(814313563))));
12791291 try testFmt("f64: 7.81250e-03", "f64: {e:.5}", f64(@bitCast(f32, u32(1006632960))));
......@@ -1283,6 +1295,10 @@ test "float.scientific.precision" {
12831295}
12841296
12851297test "float.special" {
1298 if (builtin.os == .linux and builtin.arch == .arm and builtin.abi == .musleabihf) {
1299 // TODO https://github.com/ziglang/zig/issues/3289
1300 return error.SkipZigTest;
1301 }
12861302 try testFmt("f64: nan", "f64: {}", math.nan_f64);
12871303 // negative nan is not defined by IEE 754,
12881304 // and ARM thus normalizes it to positive nan
......@@ -1294,6 +1310,10 @@ test "float.special" {
12941310}
12951311
12961312test "float.decimal" {
1313 if (builtin.os == .linux and builtin.arch == .arm and builtin.abi == .musleabihf) {
1314 // TODO https://github.com/ziglang/zig/issues/3289
1315 return error.SkipZigTest;
1316 }
12971317 try testFmt("f64: 152314000000000000000000000000", "f64: {d}", f64(1.52314e+29));
12981318 try testFmt("f32: 1.1", "f32: {d:.1}", f32(1.1234));
12991319 try testFmt("f32: 1234.57", "f32: {d:.2}", f32(1234.567));
......@@ -1312,6 +1332,10 @@ test "float.decimal" {
13121332}
13131333
13141334test "float.libc.sanity" {
1335 if (builtin.os == .linux and builtin.arch == .arm and builtin.abi == .musleabihf) {
1336 // TODO https://github.com/ziglang/zig/issues/3289
1337 return error.SkipZigTest;
1338 }
13151339 try testFmt("f64: 0.00001", "f64: {d:.5}", f64(@bitCast(f32, u32(916964781))));
13161340 try testFmt("f64: 0.00001", "f64: {d:.5}", f64(@bitCast(f32, u32(925353389))));
13171341 try testFmt("f64: 0.10000", "f64: {d:.5}", f64(@bitCast(f32, u32(1036831278))));
std/heap.zig+1-1
......@@ -780,7 +780,7 @@ test "FixedBufferAllocator" {
780780}
781781
782782test "FixedBufferAllocator.reset" {
783 var buf: [8]u8 align(@alignOf(usize)) = undefined;
783 var buf: [8]u8 align(@alignOf(u64)) = undefined;
784784 var fba = FixedBufferAllocator.init(buf[0..]);
785785
786786 const X = 0xeeeeeeeeeeeeeeee;
std/math/big/rational.zig+8
......@@ -742,6 +742,10 @@ test "big.rational setFloatString" {
742742}
743743
744744test "big.rational toFloat" {
745 if (builtin.os == .linux and builtin.arch == .arm and builtin.abi == .musleabihf) {
746 // TODO https://github.com/ziglang/zig/issues/3289
747 return error.SkipZigTest;
748 }
745749 var a = try Rational.init(al);
746750
747751 // = 3.14159297943115234375
......@@ -754,6 +758,10 @@ test "big.rational toFloat" {
754758}
755759
756760test "big.rational set/to Float round-trip" {
761 if (builtin.os == .linux and builtin.arch == .arm and builtin.abi == .musleabihf) {
762 // TODO https://github.com/ziglang/zig/issues/3289
763 return error.SkipZigTest;
764 }
757765 var a = try Rational.init(al);
758766 var prng = std.rand.DefaultPrng.init(0x5EED);
759767 var i: usize = 0;
std/math/complex/atan.zig+5
......@@ -5,6 +5,7 @@
55// https://git.musl-libc.org/cgit/musl/tree/src/complex/catan.c
66
77const std = @import("../../std.zig");
8const builtin = @import("builtin");
89const testing = std.testing;
910const math = std.math;
1011const cmath = math.complex;
......@@ -129,6 +130,10 @@ test "complex.catan32" {
129130}
130131
131132test "complex.catan64" {
133 if (builtin.os == .linux and builtin.arch == .arm and builtin.abi == .musleabihf) {
134 // TODO https://github.com/ziglang/zig/issues/3289
135 return error.SkipZigTest;
136 }
132137 const a = Complex(f64).new(5, 3);
133138 const c = atan(a);
134139
std/math/complex/cosh.zig+5
......@@ -4,6 +4,7 @@
44// https://git.musl-libc.org/cgit/musl/tree/src/complex/ccoshf.c
55// https://git.musl-libc.org/cgit/musl/tree/src/complex/ccosh.c
66
7const builtin = @import("builtin");
78const std = @import("../../std.zig");
89const testing = std.testing;
910const math = std.math;
......@@ -164,6 +165,10 @@ test "complex.ccosh32" {
164165}
165166
166167test "complex.ccosh64" {
168 if (builtin.os == .linux and builtin.arch == .arm and builtin.abi == .musleabihf) {
169 // TODO https://github.com/ziglang/zig/issues/3289
170 return error.SkipZigTest;
171 }
167172 const a = Complex(f64).new(5, 3);
168173 const c = cosh(a);
169174
std/math/complex/exp.zig+5
......@@ -4,6 +4,7 @@
44// https://git.musl-libc.org/cgit/musl/tree/src/complex/cexpf.c
55// https://git.musl-libc.org/cgit/musl/tree/src/complex/cexp.c
66
7const builtin = @import("builtin");
78const std = @import("../../std.zig");
89const testing = std.testing;
910const math = std.math;
......@@ -130,6 +131,10 @@ test "complex.cexp32" {
130131}
131132
132133test "complex.cexp64" {
134 if (builtin.os == .linux and builtin.arch == .arm and builtin.abi == .musleabihf) {
135 // TODO https://github.com/ziglang/zig/issues/3289
136 return error.SkipZigTest;
137 }
133138 const a = Complex(f64).new(5, 3);
134139 const c = exp(a);
135140
std/math/complex/sinh.zig+5
......@@ -4,6 +4,7 @@
44// https://git.musl-libc.org/cgit/musl/tree/src/complex/csinhf.c
55// https://git.musl-libc.org/cgit/musl/tree/src/complex/csinh.c
66
7const builtin = @import("builtin");
78const std = @import("../../std.zig");
89const testing = std.testing;
910const math = std.math;
......@@ -163,6 +164,10 @@ test "complex.csinh32" {
163164}
164165
165166test "complex.csinh64" {
167 if (builtin.os == .linux and builtin.arch == .arm and builtin.abi == .musleabihf) {
168 // TODO https://github.com/ziglang/zig/issues/3289
169 return error.SkipZigTest;
170 }
166171 const a = Complex(f64).new(5, 3);
167172 const c = sinh(a);
168173
std/math/complex/tanh.zig+5
......@@ -4,6 +4,7 @@
44// https://git.musl-libc.org/cgit/musl/tree/src/complex/ctanhf.c
55// https://git.musl-libc.org/cgit/musl/tree/src/complex/ctanh.c
66
7const builtin = @import("builtin");
78const std = @import("../../std.zig");
89const testing = std.testing;
910const math = std.math;
......@@ -112,6 +113,10 @@ test "complex.ctanh32" {
112113}
113114
114115test "complex.ctanh64" {
116 if (builtin.os == .linux and builtin.arch == .arm and builtin.abi == .musleabihf) {
117 // TODO https://github.com/ziglang/zig/issues/3289
118 return error.SkipZigTest;
119 }
115120 const a = Complex(f64).new(5, 3);
116121 const c = tanh(a);
117122
std/math/cos.zig+4
......@@ -100,6 +100,10 @@ test "math.cos32" {
100100}
101101
102102test "math.cos64" {
103 if (builtin.os == .linux and builtin.arch == .arm and builtin.abi == .musleabihf) {
104 // TODO https://github.com/ziglang/zig/issues/3289
105 return error.SkipZigTest;
106 }
103107 const epsilon = 0.000001;
104108
105109 expect(math.approxEq(f64, cos_(f64, 0.0), 1.0, epsilon));
std/math/pow.zig+12
......@@ -184,6 +184,10 @@ fn isOddInteger(x: f64) bool {
184184}
185185
186186test "math.pow" {
187 if (builtin.os == .linux and builtin.arch == .arm and builtin.abi == .musleabihf) {
188 // TODO https://github.com/ziglang/zig/issues/3289
189 return error.SkipZigTest;
190 }
187191 const epsilon = 0.000001;
188192
189193 expect(math.approxEq(f32, pow(f32, 0.0, 3.3), 0.0, epsilon));
......@@ -202,6 +206,10 @@ test "math.pow" {
202206}
203207
204208test "math.pow.special" {
209 if (builtin.os == .linux and builtin.arch == .arm and builtin.abi == .musleabihf) {
210 // TODO https://github.com/ziglang/zig/issues/3289
211 return error.SkipZigTest;
212 }
205213 const epsilon = 0.000001;
206214
207215 expect(pow(f32, 4, 0.0) == 1.0);
......@@ -244,6 +252,10 @@ test "math.pow.special" {
244252}
245253
246254test "math.pow.overflow" {
255 if (builtin.os == .linux and builtin.arch == .arm and builtin.abi == .musleabihf) {
256 // TODO https://github.com/ziglang/zig/issues/3289
257 return error.SkipZigTest;
258 }
247259 expect(math.isPositiveInf(pow(f64, 2, 1 << 32)));
248260 expect(pow(f64, 2, -(1 << 32)) == 0);
249261 expect(math.isNegativeInf(pow(f64, -2, (1 << 32) + 1)));
std/math/sin.zig+20
......@@ -84,12 +84,20 @@ fn sin_(comptime T: type, x_: T) T {
8484}
8585
8686test "math.sin" {
87 if (builtin.os == .linux and builtin.arch == .arm and builtin.abi == .musleabihf) {
88 // TODO https://github.com/ziglang/zig/issues/3289
89 return error.SkipZigTest;
90 }
8791 expect(sin(f32(0.0)) == sin_(f32, 0.0));
8892 expect(sin(f64(0.0)) == sin_(f64, 0.0));
8993 expect(comptime (math.sin(f64(2))) == math.sin(f64(2)));
9094}
9195
9296test "math.sin32" {
97 if (builtin.os == .linux and builtin.arch == .arm and builtin.abi == .musleabihf) {
98 // TODO https://github.com/ziglang/zig/issues/3289
99 return error.SkipZigTest;
100 }
93101 const epsilon = 0.000001;
94102
95103 expect(math.approxEq(f32, sin_(f32, 0.0), 0.0, epsilon));
......@@ -102,6 +110,10 @@ test "math.sin32" {
102110}
103111
104112test "math.sin64" {
113 if (builtin.os == .linux and builtin.arch == .arm and builtin.abi == .musleabihf) {
114 // TODO https://github.com/ziglang/zig/issues/3289
115 return error.SkipZigTest;
116 }
105117 const epsilon = 0.000001;
106118
107119 expect(math.approxEq(f64, sin_(f64, 0.0), 0.0, epsilon));
......@@ -114,6 +126,10 @@ test "math.sin64" {
114126}
115127
116128test "math.sin32.special" {
129 if (builtin.os == .linux and builtin.arch == .arm and builtin.abi == .musleabihf) {
130 // TODO https://github.com/ziglang/zig/issues/3289
131 return error.SkipZigTest;
132 }
117133 expect(sin_(f32, 0.0) == 0.0);
118134 expect(sin_(f32, -0.0) == -0.0);
119135 expect(math.isNan(sin_(f32, math.inf(f32))));
......@@ -122,6 +138,10 @@ test "math.sin32.special" {
122138}
123139
124140test "math.sin64.special" {
141 if (builtin.os == .linux and builtin.arch == .arm and builtin.abi == .musleabihf) {
142 // TODO https://github.com/ziglang/zig/issues/3289
143 return error.SkipZigTest;
144 }
125145 expect(sin_(f64, 0.0) == 0.0);
126146 expect(sin_(f64, -0.0) == -0.0);
127147 expect(math.isNan(sin_(f64, math.inf(f64))));
std/math/tan.zig+4
......@@ -91,6 +91,10 @@ test "math.tan32" {
9191}
9292
9393test "math.tan64" {
94 if (builtin.os == .linux and builtin.arch == .arm and builtin.abi == .musleabihf) {
95 // TODO https://github.com/ziglang/zig/issues/3289
96 return error.SkipZigTest;
97 }
9498 const epsilon = 0.000001;
9599
96100 expect(math.approxEq(f64, tan_(f64, 0.0), 0.0, epsilon));
std/os.zig+1-1
......@@ -2048,7 +2048,7 @@ pub fn mmap(
20482048 prot: u32,
20492049 flags: u32,
20502050 fd: fd_t,
2051 offset: isize,
2051 offset: u64,
20522052) MMapError![]align(mem.page_size) u8 {
20532053 const err = if (builtin.link_libc) blk: {
20542054 const rc = std.c.mmap(ptr, length, prot, flags, fd, offset);
std/os/linux.zig+3-3
......@@ -190,11 +190,11 @@ pub fn umount2(special: [*]const u8, flags: u32) usize {
190190 return syscall2(SYS_umount2, @ptrToInt(special), flags);
191191}
192192
193pub fn mmap(address: ?[*]u8, length: usize, prot: usize, flags: u32, fd: i32, offset: isize) usize {
193pub fn mmap(address: ?[*]u8, length: usize, prot: usize, flags: u32, fd: i32, offset: u64) usize {
194194 if (@hasDecl(@This(), "SYS_mmap2")) {
195 return syscall6(SYS_mmap2, @ptrToInt(address), length, prot, flags, @bitCast(usize, isize(fd)), @bitCast(usize, @divTrunc(offset, MMAP2_UNIT)));
195 return syscall6(SYS_mmap2, @ptrToInt(address), length, prot, flags, @bitCast(usize, isize(fd)), @truncate(usize, offset / MMAP2_UNIT));
196196 } else {
197 return syscall6(SYS_mmap, @ptrToInt(address), length, prot, flags, @bitCast(usize, isize(fd)), @bitCast(usize, offset));
197 return syscall6(SYS_mmap, @ptrToInt(address), length, prot, flags, @bitCast(usize, isize(fd)), offset);
198198 }
199199}
200200
test/tests.zig+10-11
......@@ -109,17 +109,16 @@ const test_targets = [_]TestTarget{
109109 },
110110 },
111111 },
112 // TODO https://github.com/ziglang/zig/issues/3286
113 //TestTarget{
114 // .target = Target{
115 // .Cross = CrossTarget{
116 // .os = .linux,
117 // .arch = builtin.Arch{ .arm = builtin.Arch.Arm32.v8_5a },
118 // .abi = .musleabihf,
119 // },
120 // },
121 // .link_libc = true,
122 //},
112 TestTarget{
113 .target = Target{
114 .Cross = CrossTarget{
115 .os = .linux,
116 .arch = builtin.Arch{ .arm = builtin.Arch.Arm32.v8_5a },
117 .abi = .musleabihf,
118 },
119 },
120 .link_libc = true,
121 },
123122 // TODO https://github.com/ziglang/zig/issues/3287
124123 //TestTarget{
125124 // .target = Target{