std, compiler-rt: remove test names where applicable

Tests with no names are executed when using `zig test` regardless of the
`--test-filter` used. Non-named tests should be used when simply
importing unit tests from another file. This allows `zig test` to find
all the appropriate tests, even when using `--test-filter`.
This commit is contained in:
Andrew Kelley
2021-08-30 14:43:46 -07:00
parent ca21cad2bf
commit a2ff3a13fe
57 changed files with 81 additions and 72 deletions

View File

@@ -1,4 +1,5 @@
const std = @import("../../std.zig");
const maxInt = std.math.maxInt;
const linux = std.os.linux;
const iovec = std.os.iovec;
const iovec_const = std.os.iovec_const;
@@ -8,6 +9,7 @@ const sigset_t = linux.sigset_t;
const uid_t = linux.uid_t;
const gid_t = linux.gid_t;
const pid_t = linux.pid_t;
const sockaddr = linux.sockaddr;
pub fn syscall0(number: SYS) usize {
return asm volatile ("svc #0"

View File

@@ -1,4 +1,5 @@
const std = @import("../../std.zig");
const maxInt = std.math.maxInt;
const linux = std.os.linux;
const socklen_t = linux.socklen_t;
const sockaddr = linux.sockaddr;

View File

@@ -5,6 +5,11 @@ const expectEqual = std.testing.expectEqual;
const expectError = std.testing.expectError;
const expect = std.testing.expect;
const linux = std.os.linux;
const fd_t = linux.fd_t;
const pid_t = linux.pid_t;
const getErrno = linux.getErrno;
pub const btf = @import("bpf/btf.zig");
pub const kern = @import("bpf/kern.zig");
@@ -1501,7 +1506,7 @@ pub fn map_create(map_type: MapType, key_size: u32, value_size: u32, max_entries
attr.map_create.value_size = value_size;
attr.map_create.max_entries = max_entries;
const rc = bpf(.map_create, &attr, @sizeOf(MapCreateAttr));
const rc = linux.bpf(.map_create, &attr, @sizeOf(MapCreateAttr));
switch (errno(rc)) {
.SUCCESS => return @intCast(fd_t, rc),
.INVAL => return error.MapTypeOrAttrInvalid,
@@ -1525,7 +1530,7 @@ pub fn map_lookup_elem(fd: fd_t, key: []const u8, value: []u8) !void {
attr.map_elem.key = @ptrToInt(key.ptr);
attr.map_elem.result.value = @ptrToInt(value.ptr);
const rc = bpf(.map_lookup_elem, &attr, @sizeOf(MapElemAttr));
const rc = linux.bpf(.map_lookup_elem, &attr, @sizeOf(MapElemAttr));
switch (errno(rc)) {
.SUCCESS => return,
.BADF => return error.BadFd,
@@ -1547,7 +1552,7 @@ pub fn map_update_elem(fd: fd_t, key: []const u8, value: []const u8, flags: u64)
attr.map_elem.result = .{ .value = @ptrToInt(value.ptr) };
attr.map_elem.flags = flags;
const rc = bpf(.map_update_elem, &attr, @sizeOf(MapElemAttr));
const rc = linux.bpf(.map_update_elem, &attr, @sizeOf(MapElemAttr));
switch (errno(rc)) {
.SUCCESS => return,
.@"2BIG" => return error.ReachedMaxEntries,
@@ -1568,7 +1573,7 @@ pub fn map_delete_elem(fd: fd_t, key: []const u8) !void {
attr.map_elem.map_fd = fd;
attr.map_elem.key = @ptrToInt(key.ptr);
const rc = bpf(.map_delete_elem, &attr, @sizeOf(MapElemAttr));
const rc = linux.bpf(.map_delete_elem, &attr, @sizeOf(MapElemAttr));
switch (errno(rc)) {
.SUCCESS => return,
.BADF => return error.BadFd,
@@ -1631,7 +1636,7 @@ pub fn prog_load(
attr.prog_load.log_level = l.level;
}
const rc = bpf(.prog_load, &attr, @sizeOf(ProgLoadAttr));
const rc = linux.bpf(.prog_load, &attr, @sizeOf(ProgLoadAttr));
return switch (errno(rc)) {
.SUCCESS => @intCast(fd_t, rc),
.ACCES => error.UnsafeProgram,

View File

@@ -1,3 +1,5 @@
const std = @import("../../../std.zig");
const magic = 0xeb9f;
const version = 1;

View File

@@ -1,5 +1,10 @@
const std = @import("../../../std.zig");
const kern = @import("kern.zig");
const PtRegs = @compileError("TODO missing os bits: PtRegs");
const TcpHdr = @compileError("TODO missing os bits: TcpHdr");
const SkFullSock = @compileError("TODO missing os bits: SkFullSock");
// in BPF, all the helper calls
// TODO: when https://github.com/ziglang/zig/issues/1717 is here, make a nice
// function that uses the Helper enum

View File

@@ -1,4 +1,5 @@
const std = @import("../../std.zig");
const maxInt = std.math.maxInt;
const linux = std.os.linux;
const socklen_t = linux.socklen_t;
const iovec = linux.iovec;
@@ -8,6 +9,7 @@ const gid_t = linux.gid_t;
const pid_t = linux.pid_t;
const stack_t = linux.stack_t;
const sigset_t = linux.sigset_t;
const sockaddr = linux.sockaddr;
pub fn syscall0(number: SYS) usize {
return asm volatile ("int $0x80"
@@ -628,40 +630,28 @@ pub const LOCK = struct {
pub const MAP = struct {
/// Share changes
pub const SHARED = 0x01;
/// Changes are private
pub const PRIVATE = 0x02;
/// share + validate extension flags
pub const SHARED_VALIDATE = 0x03;
/// Mask for type of mapping
pub const TYPE = 0x0f;
/// Interpret addr exactly
pub const FIXED = 0x10;
/// don't use a file
pub const ANONYMOUS = if (is_mips) 0x800 else 0x20;
pub const ANONYMOUS = 0x20;
/// populate (prefault) pagetables
pub const POPULATE = if (is_mips) 0x10000 else 0x8000;
pub const POPULATE = 0x8000;
/// do not block on IO
pub const NONBLOCK = if (is_mips) 0x20000 else 0x10000;
pub const NONBLOCK = 0x10000;
/// give out an address that is best suited for process/thread stacks
pub const STACK = if (is_mips) 0x40000 else 0x20000;
pub const STACK = 0x20000;
/// create a huge page mapping
pub const HUGETLB = if (is_mips) 0x80000 else 0x40000;
pub const HUGETLB = 0x40000;
/// perform synchronous page faults for the mapping
pub const SYNC = 0x80000;
/// FIXED which doesn't unmap underlying mapping
pub const FIXED_NOREPLACE = 0x100000;
/// For anonymous mmap, memory could be uninitialized
pub const UNINITIALIZED = 0x4000000;

View File

@@ -1,4 +1,5 @@
const std = @import("../../std.zig");
const maxInt = std.math.maxInt;
const linux = std.os.linux;
const socklen_t = linux.socklen_t;
const iovec = linux.iovec;

View File

@@ -1,4 +1,5 @@
const std = @import("../../std.zig");
const maxInt = std.math.maxInt;
const linux = std.os.linux;
const socklen_t = linux.socklen_t;
const iovec = linux.iovec;
@@ -8,6 +9,7 @@ const gid_t = linux.gid_t;
const pid_t = linux.pid_t;
const stack_t = linux.stack_t;
const sigset_t = linux.sigset_t;
const sockaddr = linux.sockaddr;
pub fn syscall0(number: SYS) usize {
return asm volatile (

View File

@@ -1,4 +1,5 @@
const std = @import("../../std.zig");
const maxInt = std.math.maxInt;
const linux = std.os.linux;
const socklen_t = linux.socklen_t;
const iovec = linux.iovec;
@@ -8,6 +9,7 @@ const gid_t = linux.gid_t;
const pid_t = linux.pid_t;
const stack_t = linux.stack_t;
const sigset_t = linux.sigset_t;
const sockaddr = linux.sockaddr;
pub fn syscall0(number: SYS) usize {
return asm volatile (

View File

@@ -1,4 +1,5 @@
const std = @import("../../std.zig");
const maxInt = std.math.maxInt;
const pid_t = linux.pid_t;
const uid_t = linux.uid_t;
const clock_t = linux.clock_t;