就本文件而言,「目標」是指執行正在測試的 Fuuchsia 版本的機器,而「主機」則是指執行一些穩定 OS 的機器。主機目標互動測試會在主機上執行,並與目標互動。
GN 中的聲明
如何在 GN 中宣告主機目標互動測試:
例如:
# Doesn't have to be go_test. This is just an example.
go_test("an_hti_test") {
...
# Declares that Fuchsia should be running in an emulator before this test
# starts on the host.
environments = [emu_env]
...
}
# This should be included in the transitive deps of some tests bundle.
group("tests") {
testonly = true
# Anything that depends on ":tests" will build the test as a host test.
public_deps = [":an_hti_test($host_toolchain)"]
}
主機測試 API
持續整合基礎架構 (AKA「infra」) 和 fx test
會啟動目標,然後在主機上叫用測試。
SL4F 是主機與目標互動的一種方式。SL4F 主機程式庫會負責與目標建立連線。
不想使用 SL4F 的測試可以剖析這些環境變數,並處理本身與主機的通訊:
FUCHSIA_IPV4_ADDR
:IPv4 位址。FUCHSIA_IPV6_ADDR
:IPv6 位址。FUCHSIA_SSH_KEY
:安全殼層金鑰檔案路徑。