Chong Gu | 2242dd5 | 2022-07-12 23:33:04 | [diff] [blame] | 1 | # Run Tests on Fuchsia with CFv2 Test Scripts |
| 2 | |
David Dorwin | badcdae | 2023-02-03 04:03:17 | [diff] [blame] | 3 | **If you are looking for information on _running_ tests, see |
| 4 | [Deploying and running gtests on Fuchsia](gtests.md).** |
| 5 | |
Chong Gu | 2242dd5 | 2022-07-12 23:33:04 | [diff] [blame] | 6 | [TOC] |
| 7 | |
David Dorwin | badcdae | 2023-02-03 04:03:17 | [diff] [blame] | 8 | This page documents the individual scripts that support running various Chromium |
| 9 | [test types](build_instructions.md#running-test-suites). |
| 10 | The scripts can be found [here](../../build/fuchsia/test/) The new scripts currently support: |
Chong Gu | 2242dd5 | 2022-07-12 23:33:04 | [diff] [blame] | 11 | |
| 12 | ## Run CFv2 gtest binaries on Fuchsia |
| 13 | |
David Dorwin | badcdae | 2023-02-03 04:03:17 | [diff] [blame] | 14 | To build gtest binaries for Fuchsia follow |
Chong Gu | 2242dd5 | 2022-07-12 23:33:04 | [diff] [blame] | 15 | [build instructions](build_instructions.md). |
| 16 | |
David Dorwin | badcdae | 2023-02-03 04:03:17 | [diff] [blame] | 17 | #### E2E Testing Script (recommended) |
Chong Gu | 2242dd5 | 2022-07-12 23:33:04 | [diff] [blame] | 18 | |
| 19 | Once the emulator is running, you can run tests on this emulator instance by |
| 20 | adding the command line arguments indicated above: |
| 21 | |
| 22 | ```bash |
David Dorwin | 44350d9 | 2023-02-06 16:49:00 | [diff] [blame] | 23 | $ ./build/fuchsia/test/run_test.py [TEST_BINARY] -C [OUTPUT_DIR] --target-id [EMULATOR_NAME] |
Chong Gu | 2242dd5 | 2022-07-12 23:33:04 | [diff] [blame] | 24 | ``` |
| 25 | |
David Dorwin | badcdae | 2023-02-03 04:03:17 | [diff] [blame] | 26 | For gtests, there are scripts that further abstract the command line above. |
| 27 | See [Deploying and running gtests on Fuchsia](gtests.md). |
| 28 | |
Chong Gu | 2242dd5 | 2022-07-12 23:33:04 | [diff] [blame] | 29 | #### Step by step approach |
| 30 | |
| 31 | Alternatively, testing can be done step by step. The following steps are |
| 32 | equivalent to the [E2E testing script](#e2e-testing-script). |
| 33 | |
| 34 | Before starting the steps, it is recommended to set the device that will be used |
| 35 | as 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 | |
| 41 | If the device is not set as default, all the steps other than package publishing |
| 42 | will require an extra `--target-id [EMULATOR_NAME]` flag. |
| 43 | |
| 44 | ##### Publish packages |
| 45 | |
| 46 | Before devices can run the packages built, a directory needs to be initialized |
| 47 | to serve as a package repository and the packages must be published to it: |
| 48 | |
| 49 | ```bash |
David Dorwin | 44350d9 | 2023-02-06 16:49:00 | [diff] [blame] | 50 | $ ./build/fuchsia/test/publish_package.py -C [OUTPUT_DIR] --repo [REPO_DIR] --packages [TEST_BINARY] |
Chong Gu | 2242dd5 | 2022-07-12 23:33:04 | [diff] [blame] | 51 | ``` |
| 52 | |
| 53 | ##### Package installation |
| 54 | |
| 55 | The packages need to be installed on the device: |
| 56 | |
| 57 | ```bash |
David Dorwin | 0b893e2f | 2023-02-06 03:42:01 | [diff] [blame] | 58 | $ ./build/fuchsia/test/serve_repo.py start --serve-repo [REPO_DIR] |
Chong Gu | 2242dd5 | 2022-07-12 23:33:04 | [diff] [blame] | 59 | ``` |
| 60 | |
| 61 | ##### Stream system logs |
| 62 | |
| 63 | System logs can be obtained via: |
| 64 | |
| 65 | ```bash |
David Dorwin | 44350d9 | 2023-02-06 16:49:00 | [diff] [blame] | 66 | $ ./build/fuchsia/test/log_manager.py start --packages [TEST_BINARY] -C [OUTPUT_DIR] |
Chong Gu | 2242dd5 | 2022-07-12 23:33:04 | [diff] [blame] | 67 | ``` |
| 68 | |
| 69 | Specifying the test binary and the output directory allows the logs to be |
| 70 | properly symbolized. |
| 71 | |
| 72 | ##### Run test package |
| 73 | |
| 74 | ```bash |
David Dorwin | 0b893e2f | 2023-02-06 03:42:01 | [diff] [blame] | 75 | $ ./build/fuchsia/test/run_executable_test.py --test-name [TEST_BINARY] |
Chong Gu | 2242dd5 | 2022-07-12 23:33:04 | [diff] [blame] | 76 | ``` |