Running browser_tests on VM

Sometimes, browser_tests fails only on VM, not on your workstation, and you need to debug it on VM.

Create a Chromium OS image as usual

x86-generic is the preferable platform to be run on VM. However, an image built for x86-alex just worked fine on VM as of writing, so you could use it instead if it's more convenient for you (but not guaranteed).

(in chroot)
echo x86-generic > .default_board 
 ./setup_board && ./build_packages --nowithautotest && ./build_image --noenable_rootfs_verification --withdev

In this page, we assume x86-generic is used. Replace x86-generic with your board name as needed.

Create a Chromium OS VM test image


(in chroot)
./image_to_vm.sh --test_image

Start up the VM


(outside chroot)
sudo kvm -m 2048 -vga std -net nic,model=virtio -net user,hostfwd=tcp::9222-:22 -serial none -hda /path/to/chromiumos/src/build/images/x86-generic/latest/chromiumos_qemu_image.bin

You should adjust the path to the qemu image.

Run browser_tests


gtest_filter can be used to filter tests. For instance, if you want to run EnterpriseMetricsTest.DevicePolicyStoreSuccess, run the following:

(in chroot)
./run_remote_tests.sh --use_emerged --remote localhost --ssh_port 9222 desktopui_BrowserTest.control.custom --args 'gtest_filter=EnterpriseMetricsTest.DevicePolicyStoreSuccess'

First time, it takes several minutes as it packs dependencies (including browser_tests binary) and copies them to the VM. From the second time, you can make it faster by adding skip_deps to --args:

./run_remote_tests.sh --use_emerged --remote localhost --ssh_port 9222 desktopui_BrowserTest.control.custom --args 'skip_deps gtest_filter=EnterpriseMetricsTest.DevicePolicyStoreSuccess'

Examine the result


At the end of the output, you'll see something like:

>>> Details stored under /tmp/run_remote_tests.4FHQ

The detailed test output can be found deep under the directory:

less /tmp/run_remote_tests.4FHQ/desktopui_BrowserTest.custom/desktopui_BrowserTest/debug/desktopui_BrowserTest.DEBUG

Fix the test and rerun the test


Once you fix the test in Chrome tree, run the following to rebuild Chrome as well as the tests. Note that you should set CHROME_ORIGIN=LOCAL_SOURCE to build Chrome from your local tree.

USE=build_tests emerge-x86-generic chromeos-chrome

Then, run the following to rerun the test.

./run_remote_tests.sh --use_emerged --remote localhost --ssh_port 9222 desktopui_BrowserTest.control.custom --args 'gtest_filter=EnterpriseMetricsTest.DevicePolicyStoreSuccess'

Be sure NOT to add 'skip_deps' here. You need to reprocess the dependencies so the new browser_tests binary gets copied to the VM.

Want to see symbolized crash dump from CHECK failures?


The test binaries copied to VM have no symbol information attached. Hence you'll only see raw addresses from CHECK failures, like:

[13506:13506:1228/104116:61846195821:FATAL:dbus_thread_manager.cc(176)] Check failed: g_dbus_thread_manager. DBusThreadManager::Get() called before Initialize()
        0x74355546
        0x7439d089
        0x72b3a400
        0x719bfca3
        ....

To see symbolized crash dump, you need to take extra steps (we should make it easier though):

USE="build_tests chrome_debug_tests" emerge-x86-generic chromeos-chrome
cp /var/lib/portage/distfiles-target/chrome-src/src/out_x86-generic/Release/browser_tests .
strip --strip-debug browser_tests # this step is optional see below.
scp -P 9222 browser_tests root@localhost:/usr/local/autotest/deps/chrome_test/test_src/out/Release/browser_tests
./run_remote_tests.sh --use_emerged --remote localhost --ssh_port 9222 desktopui_BrowserTest.control.custom --args 'skip_deps gtest_filter=EnterpriseMetricsTest.DevicePolicyStoreSuccess'

With chrome_debug_tests, you'll have unstripped binaries in  /var/lib/portage/distfiles-target/chrome-src/src/out_x86-generic/Release. An unstripped browser_tests can be as big as 900MB. If you are only interested in symbol names, not detailed debug info, you can strip the debug info but keep the symbol names, which results in a binary of 100MB, to make copying the file to VM faster.

Be sure to add 'skip_deps' here. Otherwise, autotest will overwrite browser_tests again. 

Trouble Shooting


If you set USE=-build_tests in the chroot, you may encounter the following error when running run_remote_tests.

ERROR   : Cannot find match for "desktopui_BrowserTest.control.custom"

If you see the error, just run the following in the chroot.

USE="build_tests" emerge-x86-generic chromeos-chrome

This will build browser_tests and other files which are necessary to run tests on VM.

Comments