1# Copyright 2019 The Hafnium Authors.
2#
3# Use of this source code is governed by a BSD-style
4# license that can be found in the LICENSE file or at
5# https://opensource.org/licenses/BSD-3-Clause.
6
7import("//build/image/image.gni")
8import("//build/toolchain/platform.gni")
9import("//test/hftest/args.gni")
10
11executable("test_binary") {
12  include_dirs = [
13    "//driver/linux/inc/uapi",
14    "//third_party/linux/include/uapi",
15  ]
16
17  testonly = true
18  sources = [ "linux.c" ]
19  deps = [ "//test/hftest:hftest_linux" ]
20  output_name = "test_binary"
21}
22
23vm_kernel("socket_vm1") {
24  testonly = true
25
26  deps = [
27    ":hftest_secondary_vm_socket",
28    "//vmlib/aarch64:call",
29  ]
30}
31
32linux_initrd("linux_test_initrd") {
33  testonly = true
34
35  # Always use the aarch64_linux_clang toolchain to build test_binary
36  test_binary_target = ":test_binary(//build/toolchain:aarch64_linux_clang)"
37
38  files = [
39    [
40      get_label_info(test_binary_target, "root_out_dir") + "/test_binary",
41      test_binary_target,
42    ],
43    [
44      get_label_info("//driver/linux", "target_out_dir") + "/hafnium.ko",
45      "//driver/linux",
46    ],
47  ]
48}
49
50manifest("linux_test_manifest") {
51  source = "manifest.dts"
52  output = "manifest.dtb"
53  overlay = hftest_manifest_overlay
54}
55
56initrd("linux_test") {
57  testonly = true
58
59  files = [
60    [
61      "manifest.dtb",
62      ":linux_test_manifest",
63      "manifest.dtb",
64    ],
65    [
66      "vmlinuz",
67      "//third_party/linux:linux__prebuilt",
68      "linux__prebuilt.bin",
69    ],
70    [
71      "initrd.img",
72      ":linux_test_initrd",
73      "linux_test_initrd/initrd.img",
74    ],
75    [
76      "socket0",
77      ":socket_vm1",
78      "socket_vm1.bin",
79    ],
80  ]
81}
82
83group("linux") {
84  testonly = true
85
86  deps = [ ":linux_test" ]
87}
88
89# Testing framework for a secondary VM with socket.
90source_set("hftest_secondary_vm_socket") {
91  testonly = true
92
93  configs += [ "//test/hftest:hftest_config" ]
94
95  sources = [ "hftest_socket.c" ]
96
97  deps = [
98    "//src:dlog",
99    "//src:panic",
100    "//src:std",
101    "//src/arch/${plat_arch}:entry",
102    "//src/arch/${plat_arch}/hftest:entry",
103    "//src/arch/${plat_arch}/hftest:power_mgmt",
104  ]
105}
106