blob: 62cbd3a9a3e5f1931dbbb81ba3786ac92ae864a7 [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",
Serge Bazanskia3938142022-04-04 17:04:47 +020032 fsspecs = [
33 "//metropolis/node/build:earlydev.fsspec",
34 ],
Lorenz Brunddd6caf2021-03-04 17:16:04 +010035 files = _dict_union({
36 "//metropolis/test/ktest/init": "/init",
37 tester: "/tester",
38 }, files),
39 files_cc = files_cc,
Lorenz Brun547b33f2020-04-23 15:27:06 +020040 testonly = True,
Lorenz Brun547b33f2020-04-23 15:27:06 +020041 )
42
43 native.sh_test(
44 name = "ktest",
45 args = [
Serge Bazanski77cb6c52020-12-19 00:09:22 +010046 "$(location //metropolis/test/ktest)",
Lorenz Brun547b33f2020-04-23 15:27:06 +020047 "$(location :test_initramfs)",
Serge Bazanski77cb6c52020-12-19 00:09:22 +010048 "$(location //metropolis/test/ktest:linux-testing)",
Lorenz Brun547b33f2020-04-23 15:27:06 +020049 cmdline,
50 ],
51 size = "small",
Serge Bazanski77cb6c52020-12-19 00:09:22 +010052 srcs = ["//metropolis/test/ktest:test-script"],
Lorenz Brun547b33f2020-04-23 15:27:06 +020053 data = [
Serge Bazanski77cb6c52020-12-19 00:09:22 +010054 "//metropolis/test/ktest",
Lorenz Brun547b33f2020-04-23 15:27:06 +020055 ":test_initramfs",
Serge Bazanski77cb6c52020-12-19 00:09:22 +010056 "//metropolis/test/ktest:linux-testing",
Lorenz Brun3ff5af32020-06-24 16:34:11 +020057 "@com_github_bonzini_qboot//:qboot-bin",
Lorenz Brun547b33f2020-04-23 15:27:06 +020058 ],
Lorenz Brun3ff5af32020-06-24 16:34:11 +020059 )