blob: aa23cd4237d0e4b27ddb9b9fb8bacb1a3c007159 [file] [log] [blame] [view]
Christopher Wiley191e10c2016-02-01 14:56:56 -08001## Introduction
2
3`test_that` is the supported mechanism to run autotests against Chrome OS
4devices at your desk. `test_that` replaces an older script, `run_remote_tests`.
5
Aviv Keshet5cfcf3d2016-06-14 19:03:08 -07006Features for testing a local device:
Christopher Wiley191e10c2016-02-01 14:56:56 -08007 - CTRL+C kills `test_that` and all its autoserv children. Orphaned processes
8 are no longer left behind.
9 - Tests that require binary autotest dependencies will just work, because
10 test_that always runs from the sysroot location.
11 - Running emerge after python-only test changes is no longer necessary.
12 test_that uses autotest_quickmerge to copy your python changes to the
13 sysroot.
14 - Tests are generally specified to `test_that` by the NAME field of their
15 control file. Matching tests by filename is supported using f:[file
16 pattern]
17
Aviv Keshet5cfcf3d2016-06-14 19:03:08 -070018In addition to running tests against local device, `test_that` can be used to
19launch jobs in the ChromeOS Hardware Lab (or against a local Autotest instance
20or a Moblab). This feature is only supported for infrastructure-produced builds
21that were uploaded to google storage.
22
Christopher Wiley191e10c2016-02-01 14:56:56 -080023### Example uses (inside the chroot)
24
25Run the test(s) named dummy\_Pass:
26
27```
28$ test_that -b ${board} ${host} dummy_Pass
29```
30
31Run the test(s) named dummy\_Pass.suspend:
32
33```
34$ test_that -b ${board} ${host} dummy_Pass.suspend
35```
36
37Run the smoke suite against dut:
38
39```
40$ test_that -b ${board} ${host} suite:smoke
41```
42
43Run all tests whose names match the regular expression `^login_.*$`. Note that
44even though these tests have binary dependencies, there is no longer a need to
45specify extra flags.
46
47```
48$ test_that -b ${board} ${host} e:login_.*
49```
50
51Run all tests whose control file filename matches the regular expression
52`^.*control.dummy$`:
53
54```
55$ test_that -b ${board} ${host} f:.*control.dummy
56```
57
58### Running jobs in the lab
59
60`test_that` now allows you to run jobs in the test lab. The usage is similar to
61running tests against a specified host. The keyword :lab: is used as
62test\_that's REMOTE argument, and the -i/--build argument is required, and takes
63a trybot, paladin, or canary build number. To learn how to build a trybot image
64with a new test that you're iterating on, see "dynamic suite" codelab.
65
66For instance:
67
68```
69$ test_that -b lumpy -i lumpy-paladin/R38-6009.0.0-rc4 :lab: dummy_Pass
70```
71
72This will kick off a suite in the lab that consists of just 1 job, dummy\_Pass,
73to run in this case on board lumpy using the image
74lumpy-paladin/R38-6009.0.0-rc4. The lab's scheduler will take responsibility
75for finding a suitable set of hosts, provisioning them to the correct image,
76and running the tests. `test_that` will return after the suite finishes running,
77with a suite run report.
78
79You can specify multiple tests or test-matching expressions in the same way as
80before:
81
82```
83$ test_that -b lumpy -i ${latest_image} :lab: dummy_Pass dummy_Fail
84$ test_that -b lumpy -i ${latest_image} :lab: e:login_.*
85```
86
87Kicking off a run in the lab should be useful whenever you need to run a
88particular test on a board or image that you do not have readily available
89locally.For occasional runs of ad-hoc suites in the lab, this will also avoid
90the need to create a suite control file and wait for it to end up in an image.
91
92You can also kick off a suite, for example with:
93
94```
95test_that -b peach_pit :lab: suite:pyauto_perf -i 'peach_pit-release/R32-4763.0.0'
96```
97
98That told me that my job ID was 5196037. I could follow along by going to
99http://cautotest/afe/#tab_id=view_job&object_id=5195962.
100
Aviv Keshet5cfcf3d2016-06-14 19:03:08 -0700101Things to note about running in the lab:
Christopher Wiley191e10c2016-02-01 14:56:56 -0800102
Aviv Keshet5cfcf3d2016-06-14 19:03:08 -0700103 - This feature will only work on builds that produced autotest test artifacts.
104 If your build doesn't have such artifacts, you will see a
105 [confusing error](crbug.com/354556). The easiest way today to guarantee
106 that hwtest artifacts are produced is to make sure that your tryjob
107 is launched with the --hwtest flag. Once [this bug](crbug.com/299838) is
108 fixed that will no longer be the case.
109 - By default, jobs will be scheduled in the `suites` machine pool. That can be
110 overridden with the `-p` flag.
111 - This will only work with images newer than Sept 20, 2013 (specifically, builds
112 that contain Ifa73d7de7aac9c6efebd5f559708623804ad3691).
113
114
115### Running jobs against a local Autotest setup or MobLab
116
117`test_that` allows you to run jobs against a local Autotest setup or a
118MobLab instance. This usage is similar to running tests in the lab. The argument
119--web allows you to specify the web address of the Autotest instance you want to
120run tests within.
121
122For instance:
123```
124$ test_that -b lumpy -i lumpy-paladin/R38-6009.0.0-rc4 --web 100.96.51.136 :lab:
125dummy_Pass
126```
127
128This will kick off the dummy_Pass test on a lumpy device on the Autotest
129instance located at 100.96.51.136