blob: aef749b23790ae6b76dfa01a04304da4a0891def [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"""
18Ktest provides a simple macro to run tests inside the normal Smalltown kernel
19"""
20
21def ktest(deps, tester, initramfs_extra, cmdline):
22 native.genrule(
23 name = "test_initramfs",
24 srcs = [
25 "//core/tools/ktestinit",
26 ] + deps + [tester],
27 outs = [
28 "initramfs.cpio.lz4",
29 ],
30 testonly = True,
31 cmd = """
32 $(location @linux//:gen_init_cpio) - <<- 'EOF' | lz4 -l > \"$@\"
33dir /dev 0755 0 0
34nod /dev/console 0600 0 0 c 5 1
35nod /dev/null 0644 0 0 c 1 3
36file /init $(location //core/tools/ktestinit) 0755 0 0
37file /tester $(location """ + tester + """) 0755 0 0
38""" + initramfs_extra + """
39EOF
40 """,
41 tools = [
42 "@linux//:gen_init_cpio",
43 ],
44 )
45
46 native.sh_test(
47 name = "ktest",
48 args = [
49 "$(location //core/tools/ktest)",
50 "$(location :test_initramfs)",
51 "$(location //core/tools/ktest:linux-testing)",
52 cmdline,
53 ],
54 size = "small",
55 srcs = ["//core/tools/ktest:test-script"],
56 data = [
57 "//core/tools/ktest",
58 ":test_initramfs",
59 "//core/tools/ktest:linux-testing",
Lorenz Brun3ff5af32020-06-24 16:34:11 +020060 "@com_github_bonzini_qboot//:qboot-bin",
Lorenz Brun547b33f2020-04-23 15:27:06 +020061 ],
Lorenz Brun3ff5af32020-06-24 16:34:11 +020062 )