Lorenz Brun | 547b33f | 2020-04-23 15:27:06 +0200 | [diff] [blame] | 1 | # 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 | """ |
| 18 | Ktest provides a simple macro to run tests inside the normal Smalltown kernel |
| 19 | """ |
| 20 | |
| 21 | def 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 > \"$@\" |
| 33 | dir /dev 0755 0 0 |
| 34 | nod /dev/console 0600 0 0 c 5 1 |
| 35 | nod /dev/null 0644 0 0 c 1 3 |
| 36 | file /init $(location //core/tools/ktestinit) 0755 0 0 |
| 37 | file /tester $(location """ + tester + """) 0755 0 0 |
| 38 | """ + initramfs_extra + """ |
| 39 | EOF |
| 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", |
| 60 | ], |
| 61 | ) |