Deprecated in favor of this doc.Writing a simple test
Decide if your test is a client or server test and choose the appropriate directory from the above. In the sections below we refer to this directory as ${TEST_ROOT} below.
Next decide which area your test falls within based on the tracker (http://code.google.com/p/chromium-os/issues/list). It should be something like "desktopui", "platform", or "network" for instance. This name is used to create the test name; e.g. "network_UnplugCable". Create a directory for your test at $(TEST_ROOT)/$(LOWERCASE_AREA)_$(TEST_NAME).
Try to find an example test that does something similar and copy it. You will create at least 2 files:
${TEST_ROOT}/${LOWERCASE_AREA}_${TEST_NAME}/control
${TEST_ROOT}/${LOWERCASE_AREA}_${TEST_NAME}/${LOWERCASE_AREA}_${TEST_NAME}.py
After this, you should modify the autotest-tests-9999.ebuild under src/third_party/chromiumos-overlay/chromeos-base/autotest-tests and add your test to IUSE_TESTS or it won't be picked up by autotest when you ask it to build specific tests. For more information on writing your test, see the frequently asked questions. Adding binaries for your tests to call as part of the test (e.g. test suites, etc.)In order to cross-compile, your test's compilation step should be implemented inside the setup() method of your python code. A couple of simple examples:
It is your responsibility to make sure the test will build for all supported platforms as it will cause a build break if it does not. The setup method of all python scripts are built as part of build_autotest.sh (which is called when you build_packages --withautotest). This script calls all the setup functions of every python test and runs them. These setup steps are compiled on the host for execution on the target. The cross-compiler flags are already set so make sure if you have your own Makefile to take in the CC, CFLAGS, etc from the environment rather than hardcode them. Note that if you have a setup() method, it should create a src directory, even if empty, to avoid running the setup method on the target device.Writing tests that require that a user is logged inIf you write a test that requires a user is logged in, have your test subclass site_ui_test.UITest. Any test that is a subclass of this class will login with the default test account as part of test initialization and logout as part of test cleanup. |
