blob: bac82c6ad35332225d3737f6ba6c6dff2c4d7a4c [file] [log] [blame]
mukesh agrawal8a3188d2011-12-01 20:56:44 +00001Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
mukesh agrawal70d3ebe2011-10-13 14:45:54 -07002Use of this source code is governed by a BSD-style license that can be
3found in the LICENSE file.
4
5Intro
6-----
7We test shill using two sets of tests: unit tests, and integration
8tests. The unit tests are built using Google Test [1] and Google Mock
9[2]; the integration tests use autotest [3].
10
11Running unit tests
12------------------
13- build the shill_unittest target
14- run the resulting shill_unittest binary
15- if you're using our ebuild scripts, you can do both by running
16 (chroot)$ FEATURES="test" emerge-x86-generic shill
Paul Stewart85a1bad2011-10-21 22:36:38 -070017- run the unit tests from your host machine under gdb
18 (chroot)$ FEATURES="test noclean" emerge-x86-generic shill
19 (chroot)$ gdb_x86_local --board x86-generic \
20 /build/x86-generic/tmp/portage/chromeos-base/shill-9999/work/shill-9999/shill_unittest
21 (Of course if the unit tests segfaulted, you wouldn't need the emerge
22 step since the build directory would have been retained in the course
23 of the test failing.)
mukesh agrawal70d3ebe2011-10-13 14:45:54 -070024
Chris Masone5756a362011-10-24 10:34:10 -070025- for an incremental workflow, you can setup like this:
26 (chroot)$ cros_workon --board x86-generic shill
27- incrementally build like this:
28 (chroot)$ CXXFLAGS=-g cros_workon_make --board x86-generic --reconf --test shill
29- and then debug tests like this:
30 (chroot)$ gdb_x86_local --board x86-generic /path/to/checkout/src/platform/shill/shill_unittest
31
mukesh agrawal15908392011-11-16 18:29:25 +000032- you can specify arguments to the unit tests like this:
33 - full workflow:
34 (chroot)$ GTEST_ARGS="--v=1000 --gtest_filter=WiFiPropertyTest.*" \
35 FEATURES="test" emerge-x86-generic shill
36 - incremenetal workflow:
37 (chroot)$ GTEST_ARGS="--v=1000 --gtest_filter=WiFiPropertyTest.*" \
38 CXXFLAGS=-g cros_workon_make --board x86-generic --reconf --test shill
39
mukesh agrawal70d3ebe2011-10-13 14:45:54 -070040Running integration tests
41-------------------------
42- build a test image, suitable for a VM:
43 (chroot) src/scripts$ ./build_packages --board=x86-generic
Wade Guthrie8624e432012-04-11 11:12:00 -070044 (chroot) src/scripts$ ./build_image --board=x86-generic \
45 --noenable_rootfs_verification test
mukesh agrawal70d3ebe2011-10-13 14:45:54 -070046 (chroot) src/scripts$ ./image_to_vm.sh --board=x86-generic --test_image
47
48- start the VM
49 (host)$ sudo kvm -m 1024 -vga std -pidfile /tmp/kvm.pid \
50 -net nic,model=virtio -net user,hostfwd=tcp::9222-:22 \
51 -hda <path to chroot>/src/build/images/x86-generic/latest/chromiumos_qemu_image.bin
52
53- open a root shell on the VM console
Wade Guthrie8624e432012-04-11 11:12:00 -070054 - in VM console, log in with any legal account (but not Guest)
mukesh agrawal70d3ebe2011-10-13 14:45:54 -070055 - hit C-A-t to open a shell (use right control and alt, to avoid escaping
56 out of VM's mouse capture)
57
58 crosh> shell
59 chronos@localhost / $ sudo bash
60
Wade Guthrie8624e432012-04-11 11:12:00 -070061- if you've modified the source after building the image, load shill onto VM image:
62 (chroot) src/scripts$ ./start_devserver
mukesh agrawal70d3ebe2011-10-13 14:45:54 -070063 localhost / # FEATURES="nostrip" gmerge shill
64
65- stop flimflam, and start shill
66 localhost / # stop flimflam
Gaurav Shah85587102011-11-29 10:34:22 -080067 localhost / # shill --foreground --v=1000 \
mukesh agrawal8a3188d2011-12-01 20:56:44 +000068 --device-black-list=managed0,managed1
mukesh agrawal70d3ebe2011-10-13 14:45:54 -070069 (the black list keep shill from configuring the devices used by the hostapd
70 processes.)
71
72- run the tests
73 (chroot) src/scripts$ ./run_remote_tests.sh --board=x86-generic \
74 --remote=127.0.0.1 --ssh_port 9222 \
75 --args="config_file=wifi_vm_config" WiFiManager
76
Gaurav Shahd52caa52011-10-25 10:46:03 -070077 To run a specific test out of the test suite, use test_pat option to --args.
78
79 # Example: To just run the 035CheckWEPKeySyntax test:
80 (chroot) src/scripts$ ./run_remote_tests.sh --board=x86-generic \
81 --remote=127.0.0.1 --ssh_port 9222 \
82 --args="config_file=wifi_vm_config test_pat=035CheckWEPKeySyntax" WiFiManager
83
mukesh agrawal70d3ebe2011-10-13 14:45:54 -070084- configuration note: if you use a different port
85 (e.g. hostfwd=tcp::9223-:22), you'll need to change:
86 - the ssh_port argument to run_remote_tests
87 - the port numbers in
88 <chroot>/third_party/autotest/files/client/config/wifi_vm_config
89
90- debugging test failures
91 - "grep shill /var/log/messages" for log messages
92 - "grep wpa_supplicant /var/log/messages" for supplicant log messages
93 - "wpa_debug debug" to increase supplicant log level
94 - try resetting the test infrastructure
95 - rmmod mac80211_hwsim mac80211 cfg80211
96 - restart wpasupplicant
97 - rm /tmp/hostapd-test.control/*
mukesh agrawalc2f39fc2011-11-07 22:07:23 +000098 - examine autotest log files
99 - check how far the test got before it failed
100 $ grep -a ': step ' <test output>/<suite name>/<suite name>.<test name>/debug/<suite name>.<test name>.INFO
101 e.g.
102 (chroot) $ grep -a ': step ' /tmp/run_remote_tests.abcd/network_WiFiRoaming/network_WiFiRoaming.002Suspend/debug/network_WiFiRoaming.002Suspend.INFO
103 - read the log file
104 (chroot) $ LESSOPEN= less /tmp/run_remote_tests.abcd/network_WiFiRoaming/network_WiFiRoaming.002Suspend/debug/network_WiFiRoaming.002Suspend.INFO
105
106 (LESSOPEN= prevents less from misinterpreting the logs as binary files,
107 and piping them through hexdump.)
mukesh agrawal70d3ebe2011-10-13 14:45:54 -0700108
109- additional test suites: we have a number of other WiFi test suites
110 (in addition to WiFiManager). these are: WiFiMatFunc, WiFiPerf,
111 WiFiRoaming, WiFiSecMat. the WiFiPerf tests are probably not too
112 relevant to shill (just yet), but the rest probably are.
113
114[1] http://code.google.com/p/googletest/
115[2] http://code.google.com/p/googlemock/
116[3] http://autotest.kernel.org/,
Gaurav Shahd52caa52011-10-25 10:46:03 -0700117 http://www.chromium.org/chromium-os/testing/testing-faq