如果您或您的團隊有非基因測試或測試 需要自訂執行器,您必須建立測試領域才能執行這些測試。
您可以在下方看到測試領域範例
// Copyright 2023 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// This realm installs various testing collections.
{
include: [
// Required: Include various test collections/realms.
"//sdk/ctf/test_realm/meta/test-collection.shard.cml",
"//src/devices/testing/devices_test_realm.shard.cml",
"//src/lib/vulkan/vulkan_test_realm.shard.cml",
"//src/media/testing/drm_test_realm.shard.cml",
"//src/sys/component_manager/tests/capability_provider_vfs_compliance/vfs_compliance_test_realm.shard.cml",
"//src/sys/testing/meta/chromium_test_realm.shard.cml",
// Optional: Include optional runners.
"//src/sys/testing/meta/runners/fuzz-test-runner.shard.cml",
"//src/sys/testing/meta/runners/inspect-test-runner.shard.cml",
"//src/sys/testing/meta/runners/netemul-test-runner.shard.cml",
"//src/sys/testing/meta/runners/standard-test-runners.shard.cml",
"//src/sys/testing/meta/runners/starnix-test-runner.shard.cml",
"//src/sys/testing/meta/runners/stress-test-runner.shard.cml",
// Required: Include various test collections/realms.
"//src/sys/testing/meta/starnix-tests.shard.cml",
"//src/sys/testing/meta/system-tests.shard.cml",
"//src/sys/testing/meta/test-arch-tests.shard.cml",
"//src/testing/system-validation/meta/system_validation_test_realm.shard.cml",
// Required: Include other required shards.
"sys/component/realm_builder.shard.cml",
"syslog/client.shard.cml",
],
expose: [
// Required: Expose Realm protocol so that test manager can launch tests
// in the realm.
{
protocol: "fuchsia.component.Realm",
from: "framework",
},
],
// TODO(https://fxbug.dev/42063673): Move to corresponding runner and collection
// files.
environments: [
{
name: "test-env",
extends: "realm",
runners: [
{
runner: "elf_test_runner",
from: "#elf_test_runner",
},
{
runner: "elf_test_ambient_exec_runner",
from: "#elf_test_ambient_exec_runner",
},
{
runner: "elf_test_create_raw_processes_runner",
from: "#elf_test_create_raw_processes_runner",
},
{
runner: "elf_test_create_raw_processes_ambient_exec_runner",
from: "#elf_test_create_raw_processes_ambient_exec_runner",
},
{
runner: "gtest_runner",
from: "#gtest_runner",
},
{
runner: "gunit_runner",
from: "#gunit_runner",
},
{
runner: "netemul_test_runner",
from: "#netemul_test_runner",
},
{
runner: "rust_test_runner",
from: "#rust_test_runner",
},
{
runner: "rust_test_create_raw_processes_runner",
from: "#rust_test_create_raw_processes_runner",
},
{
runner: "rust_test_next_vdso_runner",
from: "#rust_test_next_vdso_runner",
},
{
runner: "starnix_test_runner",
from: "#starnix_test_runners",
},
{
runner: "starnix_unit_test_runner",
from: "#starnix_test_runners",
},
{
runner: "inspect_test_runner",
from: "#inspect_test_runner",
},
{
runner: "go_test_runner",
from: "#go_test_runner",
},
{
runner: "stress_test_runner",
from: "#stress_test_runner",
},
{
runner: "realm_builder",
from: "#realm_builder_server",
},
],
resolvers: [
{
resolver: "realm_builder_resolver",
from: "#realm_builder_server",
scheme: "realm-builder",
},
],
__stop_timeout_ms: 30000,
},
],
}
檔案連結。
必要部分
測試領域資訊清單必須包含特定部分, 測試元件的執行。
測試用系列作品
每個測試領域都必須含有一或多個測試集合,讓 Test
Manager
可執行測試。在提供的範例測試領域中,我們會使用
透過資料分割來自訂集合如需相關資訊,請參閱「系統測試」一文
「集合」做為範例,可執行多種非密封的程式碼
測試。
公開區段
每個測試領域都必須公開通訊協定 fuchsia.component.Realm
。這個通訊協定
可讓測試管理員在領域內啟動元件。
運作範圍建構工具
每個測試領域都必須包含運作範圍建構工具資料分割 協助測試管理工具在集合中動態執行測試。
選用專區
測試執行器
雖然非必要,但建議在大部分測試領域納入標準測試範圍 執行器,在領域中執行基本測試。適用情形 可將自訂測試執行工具納入 測試收集環境
整合樹狀結構內建構規則
在我們的建構規則中註冊您的路徑名稱:
_type_moniker_map = {
system = "/core/testing:system-tests"
test_arch = "/core/testing:test-arch-tests"
...
<new_type> = "/path/to/test/realm/moniker"
}
將新的 test_type
指派給測試:
// BUILD.gn
fuchsia_test_component("my_test") {
component_name = "my_test"
manifest = "meta/my_test.cml"
deps = [ ":my_test_bin" ]
test_type = "<new_type>"
}
您現在可以使用 fx test
執行測試。
樹狀結構測試外
整合測試指令碼,使用領域路徑名稱呼叫 ffx test
:
ffx test run --realm "/path/to/test/realm/moniker" <test_url>