mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 05:44:20 +00:00
move behavior tests from test/stage1/ to test/
And fix test cases to make them pass. This is in preparation for starting to pass behavior tests with self-hosted.
This commit is contained in:
parent
5a02c938da
commit
4307436b99
161 changed files with 49 additions and 1841 deletions
|
|
@ -265,7 +265,7 @@ pub fn build(b: *Builder) !void {
|
|||
fmt_step.dependOn(&fmt_build_zig.step);
|
||||
|
||||
// TODO for the moment, skip wasm32-wasi until bugs are sorted out.
|
||||
test_step.dependOn(tests.addPkgTests(b, test_filter, "test/stage1/behavior.zig", "behavior", "Run the behavior tests", modes, false, skip_non_native, skip_libc, is_wine_enabled, is_qemu_enabled, is_wasmtime_enabled, glibc_multi_dir));
|
||||
test_step.dependOn(tests.addPkgTests(b, test_filter, "test/behavior.zig", "behavior", "Run the behavior tests", modes, false, skip_non_native, skip_libc, is_wine_enabled, is_qemu_enabled, is_wasmtime_enabled, glibc_multi_dir));
|
||||
|
||||
test_step.dependOn(tests.addPkgTests(b, test_filter, "lib/std/std.zig", "std", "Run the standard library tests", modes, false, skip_non_native, skip_libc, is_wine_enabled, is_qemu_enabled, is_wasmtime_enabled, glibc_multi_dir));
|
||||
|
||||
|
|
|
|||
|
|
@ -262,7 +262,7 @@ pub const AtomicEvent = struct {
|
|||
while (true) {
|
||||
if (waiting == WAKE) {
|
||||
rc = windows.ntdll.NtWaitForKeyedEvent(handle, key, windows.FALSE, null);
|
||||
assert(rc == .WAIT_0);
|
||||
assert(rc == windows.NTSTATUS.WAIT_0);
|
||||
break;
|
||||
} else {
|
||||
waiting = @cmpxchgWeak(u32, waiters, waiting, waiting - WAIT, .Acquire, .Monotonic) orelse break;
|
||||
|
|
@ -271,7 +271,7 @@ pub const AtomicEvent = struct {
|
|||
}
|
||||
return error.TimedOut;
|
||||
},
|
||||
.WAIT_0 => {},
|
||||
windows.NTSTATUS.WAIT_0 => {},
|
||||
else => unreachable,
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ const std = @import("../std.zig");
|
|||
const assert = std.debug.assert;
|
||||
const builtin = @import("builtin");
|
||||
const macho = std.macho;
|
||||
const native_arch = builtin.target.cpu.arch;
|
||||
|
||||
usingnamespace @import("../os/bits.zig");
|
||||
|
||||
|
|
@ -34,13 +35,13 @@ extern "c" fn fstat(fd: fd_t, buf: *libc_stat) c_int;
|
|||
/// On x86_64 Darwin, fstat has to be manully linked with $INODE64 suffix to force 64bit version.
|
||||
/// Note that this is fixed on aarch64 and no longer necessary.
|
||||
extern "c" fn @"fstat$INODE64"(fd: fd_t, buf: *libc_stat) c_int;
|
||||
pub const _fstat = if (builtin.arch == .aarch64) fstat else @"fstat$INODE64";
|
||||
pub const _fstat = if (native_arch == .aarch64) fstat else @"fstat$INODE64";
|
||||
|
||||
extern "c" fn fstatat(dirfd: fd_t, path: [*:0]const u8, stat_buf: *libc_stat, flags: u32) c_int;
|
||||
/// On x86_64 Darwin, fstatat has to be manully linked with $INODE64 suffix to force 64bit version.
|
||||
/// Note that this is fixed on aarch64 and no longer necessary.
|
||||
extern "c" fn @"fstatat$INODE64"(dirfd: fd_t, path_name: [*:0]const u8, buf: *libc_stat, flags: u32) c_int;
|
||||
pub const _fstatat = if (builtin.arch == .aarch64) fstatat else @"fstatat$INODE64";
|
||||
pub const _fstatat = if (native_arch == .aarch64) fstatat else @"fstatat$INODE64";
|
||||
|
||||
pub extern "c" fn mach_absolute_time() u64;
|
||||
pub extern "c" fn mach_timebase_info(tinfo: ?*mach_timebase_info_data) void;
|
||||
|
|
|
|||
|
|
@ -242,7 +242,6 @@ pub const SYS = enum(usize) {
|
|||
tgkill = 268,
|
||||
utimes = 269,
|
||||
fadvise64_64 = 270,
|
||||
arm_fadvise64_64 = 270,
|
||||
pciconfig_iobase = 271,
|
||||
pciconfig_read = 272,
|
||||
pciconfig_write = 273,
|
||||
|
|
@ -313,8 +312,7 @@ pub const SYS = enum(usize) {
|
|||
set_robust_list = 338,
|
||||
get_robust_list = 339,
|
||||
splice = 340,
|
||||
sync_file_range2 = 341,
|
||||
arm_sync_file_range = 341,
|
||||
sync_file_range = 341,
|
||||
tee = 342,
|
||||
vmsplice = 343,
|
||||
move_pages = 344,
|
||||
|
|
|
|||
|
|
@ -101,7 +101,6 @@ pub const SYS = enum(usize) {
|
|||
sync = 81,
|
||||
fsync = 82,
|
||||
fdatasync = 83,
|
||||
sync_file_range2 = 84,
|
||||
sync_file_range = 84,
|
||||
timerfd_create = 85,
|
||||
timerfd_settime = 86,
|
||||
|
|
|
|||
|
|
@ -321,7 +321,7 @@ pub const SYS = enum(usize) {
|
|||
signalfd = 305,
|
||||
timerfd_create = 306,
|
||||
eventfd = 307,
|
||||
sync_file_range2 = 308,
|
||||
sync_file_range = 308,
|
||||
fallocate = 309,
|
||||
subpage_prot = 310,
|
||||
timerfd_settime = 311,
|
||||
|
|
|
|||
|
|
@ -312,7 +312,7 @@ pub const SYS = enum(usize) {
|
|||
signalfd = 305,
|
||||
timerfd_create = 306,
|
||||
eventfd = 307,
|
||||
sync_file_range2 = 308,
|
||||
sync_file_range = 308,
|
||||
fallocate = 309,
|
||||
subpage_prot = 310,
|
||||
timerfd_settime = 311,
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
// * When null-terminated or UTF16LE byte buffers are required, provide APIs which accept
|
||||
// slices as well as APIs which accept null-terminated UTF16LE byte buffers.
|
||||
|
||||
const builtin = std.builtin;
|
||||
const builtin = @import("builtin");
|
||||
const std = @import("../std.zig");
|
||||
const mem = std.mem;
|
||||
const assert = std.debug.assert;
|
||||
|
|
@ -985,7 +985,7 @@ pub fn QueryObjectName(
|
|||
}
|
||||
}
|
||||
test "QueryObjectName" {
|
||||
if (comptime builtin.os.tag != .windows)
|
||||
if (comptime builtin.target.os.tag != .windows)
|
||||
return;
|
||||
|
||||
//any file will do; canonicalization works on NTFS junctions and symlinks, hardlinks remain separate paths.
|
||||
|
|
@ -1140,7 +1140,7 @@ pub fn GetFinalPathNameByHandle(
|
|||
}
|
||||
|
||||
test "GetFinalPathNameByHandle" {
|
||||
if (comptime builtin.os.tag != .windows)
|
||||
if (comptime builtin.target.os.tag != .windows)
|
||||
return;
|
||||
|
||||
//any file will do
|
||||
|
|
@ -1554,7 +1554,7 @@ pub fn SetFileTime(
|
|||
}
|
||||
|
||||
pub fn teb() *TEB {
|
||||
return switch (builtin.arch) {
|
||||
return switch (builtin.target.cpu.arch) {
|
||||
.i386 => asm volatile (
|
||||
\\ movl %%fs:0x18, %[ptr]
|
||||
: [ptr] "=r" (-> *TEB)
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -4,11 +4,13 @@
|
|||
// The MIT license requires this copyright notice to be included in all copies
|
||||
// and substantial portions of the software.
|
||||
const std = @import("std");
|
||||
const builtin = std.builtin;
|
||||
const builtin = @import("builtin");
|
||||
const debug = std.debug;
|
||||
const testing = std.testing;
|
||||
const native_endian = builtin.target.cpu.arch.endian();
|
||||
const Endian = std.builtin.Endian;
|
||||
|
||||
pub fn PackedIntIo(comptime Int: type, comptime endian: builtin.Endian) type {
|
||||
pub fn PackedIntIo(comptime Int: type, comptime endian: Endian) type {
|
||||
//The general technique employed here is to cast bytes in the array to a container
|
||||
// integer (having bits % 8 == 0) large enough to contain the number of bits we want,
|
||||
// then we can retrieve or store the new value with a relative minimum of masking
|
||||
|
|
@ -71,7 +73,7 @@ pub fn PackedIntIo(comptime Int: type, comptime endian: builtin.Endian) type {
|
|||
const value_ptr = @ptrCast(*align(1) const Container, &bytes[start_byte]);
|
||||
var value = value_ptr.*;
|
||||
|
||||
if (endian != builtin.endian) value = @byteSwap(Container, value);
|
||||
if (endian != native_endian) value = @byteSwap(Container, value);
|
||||
|
||||
switch (endian) {
|
||||
.Big => {
|
||||
|
|
@ -119,7 +121,7 @@ pub fn PackedIntIo(comptime Int: type, comptime endian: builtin.Endian) type {
|
|||
const target_ptr = @ptrCast(*align(1) Container, &bytes[start_byte]);
|
||||
var target = target_ptr.*;
|
||||
|
||||
if (endian != builtin.endian) target = @byteSwap(Container, target);
|
||||
if (endian != native_endian) target = @byteSwap(Container, target);
|
||||
|
||||
//zero the bits we want to replace in the existing bytes
|
||||
const inv_mask = @intCast(Container, std.math.maxInt(UnInt)) << keep_shift;
|
||||
|
|
@ -129,7 +131,7 @@ pub fn PackedIntIo(comptime Int: type, comptime endian: builtin.Endian) type {
|
|||
//merge the new value
|
||||
target |= value;
|
||||
|
||||
if (endian != builtin.endian) target = @byteSwap(Container, target);
|
||||
if (endian != native_endian) target = @byteSwap(Container, target);
|
||||
|
||||
//save it back
|
||||
target_ptr.* = target;
|
||||
|
|
@ -151,7 +153,7 @@ pub fn PackedIntIo(comptime Int: type, comptime endian: builtin.Endian) type {
|
|||
return new_slice;
|
||||
}
|
||||
|
||||
fn sliceCast(bytes: []u8, comptime NewInt: type, comptime new_endian: builtin.Endian, bit_offset: u3, old_len: usize) PackedIntSliceEndian(NewInt, new_endian) {
|
||||
fn sliceCast(bytes: []u8, comptime NewInt: type, comptime new_endian: Endian, bit_offset: u3, old_len: usize) PackedIntSliceEndian(NewInt, new_endian) {
|
||||
const new_int_bits = comptime std.meta.bitCount(NewInt);
|
||||
const New = PackedIntSliceEndian(NewInt, new_endian);
|
||||
|
||||
|
|
@ -172,13 +174,13 @@ pub fn PackedIntIo(comptime Int: type, comptime endian: builtin.Endian) type {
|
|||
/// are packed using native endianess and without storing any meta
|
||||
/// data. PackedIntArray(i3, 8) will occupy exactly 3 bytes of memory.
|
||||
pub fn PackedIntArray(comptime Int: type, comptime int_count: usize) type {
|
||||
return PackedIntArrayEndian(Int, builtin.endian, int_count);
|
||||
return PackedIntArrayEndian(Int, native_endian, int_count);
|
||||
}
|
||||
|
||||
///Creates a bit-packed array of integers of type Int. Bits
|
||||
/// are packed using specified endianess and without storing any meta
|
||||
/// data.
|
||||
pub fn PackedIntArrayEndian(comptime Int: type, comptime endian: builtin.Endian, comptime int_count: usize) type {
|
||||
pub fn PackedIntArrayEndian(comptime Int: type, comptime endian: Endian, comptime int_count: usize) type {
|
||||
const int_bits = comptime std.meta.bitCount(Int);
|
||||
const total_bits = int_bits * int_count;
|
||||
const total_bytes = (total_bits + 7) / 8;
|
||||
|
|
@ -247,7 +249,7 @@ pub fn PackedIntArrayEndian(comptime Int: type, comptime endian: builtin.Endian,
|
|||
///Create a PackedIntSlice of the array using NewInt as the bit width integer
|
||||
/// and new_endian as the new endianess. NewInt's bit width must fit evenly within
|
||||
/// the array's Int's total bits.
|
||||
pub fn sliceCastEndian(self: *Self, comptime NewInt: type, comptime new_endian: builtin.Endian) PackedIntSliceEndian(NewInt, new_endian) {
|
||||
pub fn sliceCastEndian(self: *Self, comptime NewInt: type, comptime new_endian: Endian) PackedIntSliceEndian(NewInt, new_endian) {
|
||||
return Io.sliceCast(&self.bytes, NewInt, new_endian, 0, int_count);
|
||||
}
|
||||
};
|
||||
|
|
@ -257,13 +259,13 @@ pub fn PackedIntArrayEndian(comptime Int: type, comptime endian: builtin.Endian,
|
|||
/// Bits are packed using native endianess and without storing any meta
|
||||
/// data.
|
||||
pub fn PackedIntSlice(comptime Int: type) type {
|
||||
return PackedIntSliceEndian(Int, builtin.endian);
|
||||
return PackedIntSliceEndian(Int, native_endian);
|
||||
}
|
||||
|
||||
///Uses a slice as a bit-packed block of int_count integers of type Int.
|
||||
/// Bits are packed using specified endianess and without storing any meta
|
||||
/// data.
|
||||
pub fn PackedIntSliceEndian(comptime Int: type, comptime endian: builtin.Endian) type {
|
||||
pub fn PackedIntSliceEndian(comptime Int: type, comptime endian: Endian) type {
|
||||
const int_bits = comptime std.meta.bitCount(Int);
|
||||
const Io = PackedIntIo(Int, endian);
|
||||
|
||||
|
|
@ -328,7 +330,7 @@ pub fn PackedIntSliceEndian(comptime Int: type, comptime endian: builtin.Endian)
|
|||
///Create a PackedIntSlice of this slice using NewInt as the bit width integer
|
||||
/// and new_endian as the new endianess. NewInt's bit width must fit evenly within
|
||||
/// this slice's Int's total bits.
|
||||
pub fn sliceCastEndian(self: Self, comptime NewInt: type, comptime new_endian: builtin.Endian) PackedIntSliceEndian(NewInt, new_endian) {
|
||||
pub fn sliceCastEndian(self: Self, comptime NewInt: type, comptime new_endian: Endian) PackedIntSliceEndian(NewInt, new_endian) {
|
||||
return Io.sliceCast(self.bytes, NewInt, new_endian, self.bit_offset, self.int_count);
|
||||
}
|
||||
};
|
||||
|
|
@ -338,7 +340,7 @@ const we_are_testing_this_with_stage1_which_leaks_comptime_memory = true;
|
|||
|
||||
test "PackedIntArray" {
|
||||
// TODO @setEvalBranchQuota generates panics in wasm32. Investigate.
|
||||
if (builtin.arch == .wasm32) return error.SkipZigTest;
|
||||
if (builtin.target.cpu.arch == .wasm32) return error.SkipZigTest;
|
||||
if (we_are_testing_this_with_stage1_which_leaks_comptime_memory) return error.SkipZigTest;
|
||||
|
||||
@setEvalBranchQuota(10000);
|
||||
|
|
@ -348,7 +350,7 @@ test "PackedIntArray" {
|
|||
comptime var bits = 0;
|
||||
inline while (bits <= max_bits) : (bits += 1) {
|
||||
//alternate unsigned and signed
|
||||
const sign: builtin.Signedness = if (bits % 2 == 0) .signed else .unsigned;
|
||||
const sign: std.builtin.Signedness = if (bits % 2 == 0) .signed else .unsigned;
|
||||
const I = std.meta.Int(sign, bits);
|
||||
|
||||
const PackedArray = PackedIntArray(I, int_count);
|
||||
|
|
@ -394,7 +396,7 @@ test "PackedIntArray initAllTo" {
|
|||
|
||||
test "PackedIntSlice" {
|
||||
// TODO @setEvalBranchQuota generates panics in wasm32. Investigate.
|
||||
if (builtin.arch == .wasm32) return error.SkipZigTest;
|
||||
if (builtin.target.cpu.arch == .wasm32) return error.SkipZigTest;
|
||||
if (we_are_testing_this_with_stage1_which_leaks_comptime_memory) return error.SkipZigTest;
|
||||
|
||||
@setEvalBranchQuota(10000);
|
||||
|
|
@ -408,7 +410,7 @@ test "PackedIntSlice" {
|
|||
comptime var bits = 0;
|
||||
inline while (bits <= max_bits) : (bits += 1) {
|
||||
//alternate unsigned and signed
|
||||
const sign: builtin.Signedness = if (bits % 2 == 0) .signed else .unsigned;
|
||||
const sign: std.builtin.Signedness = if (bits % 2 == 0) .signed else .unsigned;
|
||||
const I = std.meta.Int(sign, bits);
|
||||
const P = PackedIntSlice(I);
|
||||
|
||||
|
|
@ -539,7 +541,7 @@ test "PackedInt(Array/Slice) sliceCast" {
|
|||
|
||||
var i = @as(usize, 0);
|
||||
while (i < packed_slice_cast_2.len()) : (i += 1) {
|
||||
const val = switch (builtin.endian) {
|
||||
const val = switch (native_endian) {
|
||||
.Big => 0b01,
|
||||
.Little => 0b10,
|
||||
};
|
||||
|
|
@ -547,7 +549,7 @@ test "PackedInt(Array/Slice) sliceCast" {
|
|||
}
|
||||
i = 0;
|
||||
while (i < packed_slice_cast_4.len()) : (i += 1) {
|
||||
const val = switch (builtin.endian) {
|
||||
const val = switch (native_endian) {
|
||||
.Big => 0b0101,
|
||||
.Little => 0b1010,
|
||||
};
|
||||
|
|
@ -561,7 +563,7 @@ test "PackedInt(Array/Slice) sliceCast" {
|
|||
}
|
||||
i = 0;
|
||||
while (i < packed_slice_cast_3.len()) : (i += 1) {
|
||||
const val = switch (builtin.endian) {
|
||||
const val = switch (native_endian) {
|
||||
.Big => if (i % 2 == 0) @as(u3, 0b111) else @as(u3, 0b000),
|
||||
.Little => if (i % 2 == 0) @as(u3, 0b111) else @as(u3, 0b000),
|
||||
};
|
||||
|
|
@ -641,7 +643,7 @@ test "PackedInt(Array/Slice)Endian" {
|
|||
test "PackedIntArray at end of available memory" {
|
||||
if (we_are_testing_this_with_stage1_which_leaks_comptime_memory) return error.SkipZigTest;
|
||||
|
||||
switch (builtin.os.tag) {
|
||||
switch (builtin.target.os.tag) {
|
||||
.linux, .macos, .ios, .freebsd, .netbsd, .openbsd, .windows => {},
|
||||
else => return,
|
||||
}
|
||||
|
|
@ -662,7 +664,7 @@ test "PackedIntArray at end of available memory" {
|
|||
test "PackedIntSlice at end of available memory" {
|
||||
if (we_are_testing_this_with_stage1_which_leaks_comptime_memory) return error.SkipZigTest;
|
||||
|
||||
switch (builtin.os.tag) {
|
||||
switch (builtin.target.os.tag) {
|
||||
.linux, .macos, .ios, .freebsd, .netbsd, .openbsd, .windows => {},
|
||||
else => return,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
// The MIT license requires this copyright notice to be included in all copies
|
||||
// and substantial portions of the software.
|
||||
const std = @import("std");
|
||||
const builtin = std.builtin;
|
||||
const builtin = @import("builtin");
|
||||
|
||||
export var _tls_index: u32 = std.os.windows.TLS_OUT_OF_INDEXES;
|
||||
export var _tls_start: u8 linksection(".tls") = 0;
|
||||
|
|
@ -13,7 +13,7 @@ export var __xl_a: std.os.windows.PIMAGE_TLS_CALLBACK linksection(".CRT$XLA") =
|
|||
export var __xl_z: std.os.windows.PIMAGE_TLS_CALLBACK linksection(".CRT$XLZ") = null;
|
||||
|
||||
comptime {
|
||||
if (builtin.arch == .i386) {
|
||||
if (builtin.target.cpu.arch == .i386) {
|
||||
// The __tls_array is the offset of the ThreadLocalStoragePointer field
|
||||
// in the TEB block whose base address held in the %fs segment.
|
||||
asm (
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue