summaryrefslogtreecommitdiffhomepage
path: root/test/syscalls/build_defs.bzl
diff options
context:
space:
mode:
authorBrian Geffon <bgeffon@google.com>2018-12-10 14:41:40 -0800
committerShentubot <shentubot@google.com>2018-12-10 14:42:34 -0800
commitd3bc79bc8438206ac6a14fde4eaa288fc07eee82 (patch)
treee820398591bfd1503456e877fa0c2bdd0f994959 /test/syscalls/build_defs.bzl
parent833edbd10b49db1f934dcb2495dcb41c1310eea4 (diff)
Open source system call tests.
PiperOrigin-RevId: 224886231 Change-Id: I0fccb4d994601739d8b16b1d4e6b31f40297fb22
Diffstat (limited to 'test/syscalls/build_defs.bzl')
-rw-r--r--test/syscalls/build_defs.bzl54
1 files changed, 54 insertions, 0 deletions
diff --git a/test/syscalls/build_defs.bzl b/test/syscalls/build_defs.bzl
new file mode 100644
index 000000000..31b311f63
--- /dev/null
+++ b/test/syscalls/build_defs.bzl
@@ -0,0 +1,54 @@
+"""Defines a rule for syscall test targets."""
+
+# syscall_test is a macro that will create targets to run the given test target
+# on the host (native) and runsc.
+def syscall_test(test, size = "small"):
+ _syscall_test(test, size, "native")
+ _syscall_test(test, size, "kvm")
+ _syscall_test(test, size, "ptrace")
+
+def _syscall_test(test, size, platform):
+ test_name = test.split(":")[1]
+
+ # Prepend "runsc" to non-native platform names.
+ full_platform = platform if platform == "native" else "runsc_" + platform
+
+ # Add the full_platform in a tag to make it easier to run all the tests on
+ # a specific platform.
+ tags = [full_platform]
+
+ # Add tag to prevent the tests from running in a Bazel sandbox.
+ # TODO: Make the tests run without this tag.
+ tags.append("no-sandbox")
+
+ # TODO: KVM tests are tagged "manual" to until the platform is
+ # more stable.
+ if platform == "kvm":
+ tags += ["manual"]
+
+ sh_test(
+ srcs = ["syscall_test_runner.sh"],
+ name = test_name + "_" + full_platform,
+ data = [
+ ":syscall_test",
+ test,
+ ],
+ args = [
+ # First argument is location to syscall_test binary.
+ "$(location :syscall_test)",
+ # Rest of arguments are passed directly to syscall_test binary.
+ "--test-name=" + test_name,
+ "--platform=" + platform,
+ "--debug=false",
+ "--strace=false",
+ "--parallel=true",
+ ],
+ size = size,
+ tags = tags,
+ )
+
+def sh_test(**kwargs):
+ """Wraps the standard sh_test."""
+ native.sh_test(
+ **kwargs
+ )