blob: 9c8f1805107d70bb0399b051260ad5b311603435 [file] [log] [blame] [view]
Chong Gu2242dd52022-07-12 23:33:041# Run Tests on Fuchsia with CFv2 Test Scripts
2
David Dorwinbadcdae2023-02-03 04:03:173**If you are looking for information on _running_ tests, see
4[Deploying and running gtests on Fuchsia](gtests.md).**
5
Chong Gu2242dd52022-07-12 23:33:046[TOC]
7
David Dorwinbadcdae2023-02-03 04:03:178This page documents the individual scripts that support running various Chromium
9[test types](build_instructions.md#running-test-suites).
10The scripts can be found [here](../../build/fuchsia/test/) The new scripts currently support:
Chong Gu2242dd52022-07-12 23:33:0411
12## Run CFv2 gtest binaries on Fuchsia
13
David Dorwinbadcdae2023-02-03 04:03:1714To build gtest binaries for Fuchsia follow
Chong Gu2242dd52022-07-12 23:33:0415[build instructions](build_instructions.md).
16
David Dorwinbadcdae2023-02-03 04:03:1717#### E2E Testing Script (recommended)
Chong Gu2242dd52022-07-12 23:33:0418
19Once the emulator is running, you can run tests on this emulator instance by
20adding the command line arguments indicated above:
21
22```bash
David Dorwin44350d92023-02-06 16:49:0023$ ./build/fuchsia/test/run_test.py [TEST_BINARY] -C [OUTPUT_DIR] --target-id [EMULATOR_NAME]
Chong Gu2242dd52022-07-12 23:33:0424```
25
David Dorwinbadcdae2023-02-03 04:03:1726For gtests, there are scripts that further abstract the command line above.
27See [Deploying and running gtests on Fuchsia](gtests.md).
28
Chong Gu2242dd52022-07-12 23:33:0429#### Step by step approach
30
31Alternatively, testing can be done step by step. The following steps are
32equivalent to the [E2E testing script](#e2e-testing-script).
33
34Before starting the steps, it is recommended to set the device that will be used
35as the default device that `ffx` uses:
36
37```bash
38$ ./third_party/fuchsia_sdk/sdk/tools/x64/ffx target default set [EMULATOR_NAME]
39```
40
41If the device is not set as default, all the steps other than package publishing
42will require an extra `--target-id [EMULATOR_NAME]` flag.
43
44##### Publish packages
45
46Before devices can run the packages built, a directory needs to be initialized
47to serve as a package repository and the packages must be published to it:
48
49```bash
David Dorwin44350d92023-02-06 16:49:0050$ ./build/fuchsia/test/publish_package.py -C [OUTPUT_DIR] --repo [REPO_DIR] --packages [TEST_BINARY]
Chong Gu2242dd52022-07-12 23:33:0451```
52
53##### Package installation
54
55The packages need to be installed on the device:
56
57```bash
David Dorwin0b893e2f2023-02-06 03:42:0158$ ./build/fuchsia/test/serve_repo.py start --serve-repo [REPO_DIR]
Chong Gu2242dd52022-07-12 23:33:0459```
60
61##### Stream system logs
62
63System logs can be obtained via:
64
65```bash
David Dorwin44350d92023-02-06 16:49:0066$ ./build/fuchsia/test/log_manager.py start --packages [TEST_BINARY] -C [OUTPUT_DIR]
Chong Gu2242dd52022-07-12 23:33:0467```
68
69Specifying the test binary and the output directory allows the logs to be
70properly symbolized.
71
72##### Run test package
73
74```bash
David Dorwin0b893e2f2023-02-06 03:42:0175$ ./build/fuchsia/test/run_executable_test.py --test-name [TEST_BINARY]
Chong Gu2242dd52022-07-12 23:33:0476```