windows tests: move tests, get rid of wine-binfmt
This removes all other Bazel test commands, so all tests can be again tested with `bazel test ...`. Also, fixes linux-arm64 glibc tests. Until now they've worked only in CI. Now they work everywhere I tried.
This commit is contained in:
parent
86ae317685
commit
3ac217e2cc
|
@ -5,7 +5,7 @@ packages:
|
|||
- qemu-user-static
|
||||
- binfmt-support
|
||||
- moreutils
|
||||
- wine-binfmt
|
||||
- wine64
|
||||
sources:
|
||||
- https://git.sr.ht/~motiejus/bazel-zig-cc
|
||||
environment:
|
||||
|
|
11
ci/test
11
ci/test
|
@ -1,13 +1,4 @@
|
|||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
set -xeuo pipefail
|
||||
|
||||
bazel test ...
|
||||
|
||||
# Windows tests
|
||||
# Unfortunately wine-binfmt breaks within the bazel sandbox, so we disable it
|
||||
# to run this test.
|
||||
bazel test //test/c:winver_windows_amd64 \
|
||||
--spawn_strategy=standalone
|
||||
# There is no no easy way to run windows_arm64 binaries on Linux, so we just
|
||||
# cross compile one for testing.
|
||||
bazel build //test/c:winver_windows_arm64
|
||||
|
|
|
@ -1,3 +1,10 @@
|
|||
def _vars_script(env, run_under, cmd):
|
||||
ret = ["#!/bin/sh"]
|
||||
for k, v in env.items():
|
||||
ret += ['export {}="{}"'.format(k, v)]
|
||||
ret += ['exec {} {} "$@"'.format(run_under, cmd)]
|
||||
return "\n".join(ret) + "\n" # trailing newline is easier on the eyes
|
||||
|
||||
def _platform_transition_impl(settings, attr):
|
||||
_ignore = settings
|
||||
return {
|
||||
|
@ -17,16 +24,18 @@ def _platform_binary_impl(ctx):
|
|||
|
||||
executable = None
|
||||
if source_info.files_to_run and source_info.files_to_run.executable:
|
||||
command = _vars_script(ctx.attr.env, ctx.attr.run_under, source_info.files_to_run.executable.short_path)
|
||||
executable = ctx.actions.declare_file("{}_{}".format(ctx.file.src.basename, ctx.attr.platform))
|
||||
ctx.actions.run_shell(
|
||||
command = "cp {} {}".format(source_info.files_to_run.executable.path, executable.path),
|
||||
inputs = [source_info.files_to_run.executable],
|
||||
outputs = [executable],
|
||||
ctx.actions.write(
|
||||
output = executable,
|
||||
content = command,
|
||||
is_executable = True,
|
||||
)
|
||||
|
||||
return [DefaultInfo(
|
||||
files = depset(ctx.files.src),
|
||||
executable = executable,
|
||||
files = depset([executable]),
|
||||
runfiles = ctx.runfiles(files = ctx.files.src),
|
||||
)]
|
||||
|
||||
_attrs = {
|
||||
|
@ -38,6 +47,12 @@ _attrs = {
|
|||
"platform": attr.string(
|
||||
doc = "The platform to build the target for.",
|
||||
),
|
||||
"run_under": attr.string(
|
||||
doc = "wrapper executable",
|
||||
),
|
||||
"env": attr.string_dict(
|
||||
doc = "Environment variables for the test",
|
||||
),
|
||||
"_allowlist_function_transition": attr.label(
|
||||
default = "@bazel_tools//tools/allowlists/function_transition_allowlist",
|
||||
),
|
||||
|
|
40
test/c/BUILD
40
test/c/BUILD
|
@ -1,4 +1,4 @@
|
|||
load("@bazel-zig-cc//rules:platform.bzl", "platform_binary", "platform_test")
|
||||
load("@bazel-zig-cc//rules:platform.bzl", "platform_binary")
|
||||
|
||||
cc_binary(
|
||||
name = "which_libc",
|
||||
|
@ -13,7 +13,9 @@ cc_binary(
|
|||
platform_binary(
|
||||
name = "which_libc_{}".format(name),
|
||||
src = "which_libc",
|
||||
env = {"QEMU_LD_PREFIX": "/usr/aarch64-linux-gnu"} if is_arm64 else {},
|
||||
platform = platform,
|
||||
run_under = "qemu-aarch64-static" if is_arm64 else "",
|
||||
),
|
||||
sh_test(
|
||||
name = "test_libc_{}".format(name),
|
||||
|
@ -25,34 +27,12 @@ cc_binary(
|
|||
},
|
||||
),
|
||||
)
|
||||
for name, platform, want in [
|
||||
("linux_amd64_musl", "//libc_aware/platform:linux_amd64_musl", "non-glibc"),
|
||||
("linux_amd64_gnu.2.19", "//libc_aware/platform:linux_amd64_gnu.2.19", "glibc_2.19"),
|
||||
("linux_amd64_gnu.2.28", "//libc_aware/platform:linux_amd64_gnu.2.28", "glibc_2.28"),
|
||||
("linux_amd64_gnu.2.31", "//libc_aware/platform:linux_amd64_gnu.2.31", "glibc_2.31"),
|
||||
("linux_amd64", "//platform:linux_amd64", "glibc_2.19"),
|
||||
("linux_arm64", "//platform:linux_arm64", "glibc_2.28"),
|
||||
for name, platform, want, is_arm64 in [
|
||||
("linux_amd64_musl", "//libc_aware/platform:linux_amd64_musl", "non-glibc", False),
|
||||
("linux_amd64_gnu.2.19", "//libc_aware/platform:linux_amd64_gnu.2.19", "glibc_2.19", False),
|
||||
("linux_amd64_gnu.2.28", "//libc_aware/platform:linux_amd64_gnu.2.28", "glibc_2.28", False),
|
||||
("linux_amd64_gnu.2.31", "//libc_aware/platform:linux_amd64_gnu.2.31", "glibc_2.31", False),
|
||||
("linux_amd64", "//platform:linux_amd64", "glibc_2.19", False),
|
||||
("linux_arm64", "//platform:linux_arm64", "glibc_2.28", True),
|
||||
]
|
||||
]
|
||||
|
||||
cc_binary(
|
||||
name = "winver",
|
||||
srcs = ["main_winver.c"],
|
||||
target_compatible_with = [
|
||||
"@platforms//os:windows",
|
||||
],
|
||||
)
|
||||
|
||||
platform_test(
|
||||
name = "winver_windows_amd64",
|
||||
src = "winver",
|
||||
platform = "//platform:windows_amd64",
|
||||
tags = ["manual"],
|
||||
)
|
||||
|
||||
platform_binary(
|
||||
name = "winver_windows_arm64",
|
||||
src = "winver",
|
||||
platform = "//platform:windows_arm64",
|
||||
tags = ["manual"],
|
||||
)
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
#/bin/bash
|
||||
#!/bin/bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
# shellcheck disable=SC2153
|
||||
want=$WANT
|
||||
# shellcheck disable=SC2153
|
||||
binary=$BINARY
|
||||
|
||||
got=$($binary)
|
||||
|
||||
if [[ "$got" != "$want" ]]; then
|
||||
|
|
|
@ -41,12 +41,14 @@ go_binary(
|
|||
platform_test(
|
||||
name = "cgo_test_{}".format(name),
|
||||
src = "cgo_test",
|
||||
env = {"QEMU_LD_PREFIX": "/usr/aarch64-linux-gnu"} if is_arm64 else {},
|
||||
platform = platform,
|
||||
run_under = "qemu-aarch64-static" if is_arm64 else "",
|
||||
)
|
||||
for name, platform in [
|
||||
("linux_amd64_musl", "//libc_aware/platform:linux_amd64_musl"),
|
||||
("linux_amd64_gnu.2.19", "//libc_aware/platform:linux_amd64_gnu.2.19"),
|
||||
("linux_arm64_musl", "//libc_aware/platform:linux_arm64_musl"),
|
||||
("linux_arm64_gnu.2.28", "//libc_aware/platform:linux_arm64_gnu.2.28"),
|
||||
for name, platform, is_arm64 in [
|
||||
("linux_amd64_musl", "//libc_aware/platform:linux_amd64_musl", False),
|
||||
("linux_amd64_gnu.2.19", "//libc_aware/platform:linux_amd64_gnu.2.19", False),
|
||||
("linux_arm64_musl", "//libc_aware/platform:linux_arm64_musl", True),
|
||||
("linux_arm64_gnu.2.28", "//libc_aware/platform:linux_arm64_gnu.2.28", True),
|
||||
]
|
||||
]
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
load("@bazel-zig-cc//rules:platform.bzl", "platform_binary", "platform_test")
|
||||
|
||||
cc_binary(
|
||||
name = "winver",
|
||||
srcs = ["main.c"],
|
||||
tags = ["manual"],
|
||||
)
|
||||
|
||||
platform_test(
|
||||
name = "winver_windows_amd64",
|
||||
src = "winver",
|
||||
platform = "//platform:windows_amd64",
|
||||
run_under = "wine64-stable",
|
||||
tags = ["no-sandbox"],
|
||||
)
|
||||
|
||||
platform_binary(
|
||||
name = "winver_windows_arm64",
|
||||
src = "winver",
|
||||
platform = "//platform:windows_arm64",
|
||||
)
|
Loading…
Reference in New Issue