blob: 2462603edc0aeca7ed16b8337462cf19407bc891 [file] [log] [blame]
Lorenz Brun547b33f2020-04-23 15:27:06 +02001# Copyright 2020 The Monogon Project Authors.
2#
3# SPDX-License-Identifier: Apache-2.0
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16
17"""
Serge Bazanski662b5b32020-12-21 13:49:00 +010018Ktest provides a macro to run tests under a normal Metropolis node kernel
Lorenz Brun547b33f2020-04-23 15:27:06 +020019"""
20
Lorenz Brunddd6caf2021-03-04 17:16:04 +010021load("//metropolis/node/build:def.bzl", "node_initramfs")
22
23def _dict_union(x, y):
24 z = {}
25 z.update(x)
26 z.update(y)
27 return z
28
29def ktest(tester, cmdline = "", files = {}, files_cc = {}):
30 node_initramfs(
Lorenz Brun547b33f2020-04-23 15:27:06 +020031 name = "test_initramfs",
Lorenz Brunddd6caf2021-03-04 17:16:04 +010032 files = _dict_union({
33 "//metropolis/test/ktest/init": "/init",
34 tester: "/tester",
35 }, files),
36 files_cc = files_cc,
Lorenz Brun547b33f2020-04-23 15:27:06 +020037 testonly = True,
Lorenz Brun547b33f2020-04-23 15:27:06 +020038 )
39
40 native.sh_test(
41 name = "ktest",
42 args = [
Serge Bazanski77cb6c52020-12-19 00:09:22 +010043 "$(location //metropolis/test/ktest)",
Lorenz Brun547b33f2020-04-23 15:27:06 +020044 "$(location :test_initramfs)",
Serge Bazanski77cb6c52020-12-19 00:09:22 +010045 "$(location //metropolis/test/ktest:linux-testing)",
Lorenz Brun547b33f2020-04-23 15:27:06 +020046 cmdline,
47 ],
48 size = "small",
Serge Bazanski77cb6c52020-12-19 00:09:22 +010049 srcs = ["//metropolis/test/ktest:test-script"],
Lorenz Brun547b33f2020-04-23 15:27:06 +020050 data = [
Serge Bazanski77cb6c52020-12-19 00:09:22 +010051 "//metropolis/test/ktest",
Lorenz Brun547b33f2020-04-23 15:27:06 +020052 ":test_initramfs",
Serge Bazanski77cb6c52020-12-19 00:09:22 +010053 "//metropolis/test/ktest:linux-testing",
Lorenz Brun3ff5af32020-06-24 16:34:11 +020054 "@com_github_bonzini_qboot//:qboot-bin",
Lorenz Brun547b33f2020-04-23 15:27:06 +020055 ],
Lorenz Brun3ff5af32020-06-24 16:34:11 +020056 )