blob: ab647e16933600a9ce11a578a159b7a7c88bb882 [file] [log] [blame]
mukesh agrawal70d3ebe2011-10-13 14:45:54 -07001Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
2Use 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 agrawal70d3ebe2011-10-13 14:45:54 -070032Running integration tests
33-------------------------
34- build a test image, suitable for a VM:
35 (chroot) src/scripts$ ./build_packages --board=x86-generic
36 (chroot) src/scripts$ ./build_image --board=x86-generic --withdev \
37 --test --noenable_rootfs_verification
38 (chroot) src/scripts$ ./image_to_vm.sh --board=x86-generic --test_image
39
40- start the VM
41 (host)$ sudo kvm -m 1024 -vga std -pidfile /tmp/kvm.pid \
42 -net nic,model=virtio -net user,hostfwd=tcp::9222-:22 \
43 -hda <path to chroot>/src/build/images/x86-generic/latest/chromiumos_qemu_image.bin
44
45- open a root shell on the VM console
46 - in VM console, log in as guest
47 - hit C-A-t to open a shell (use right control and alt, to avoid escaping
48 out of VM's mouse capture)
49
50 crosh> shell
51 chronos@localhost / $ sudo bash
52
53- load shill onto VM image
54 localhost / # FEATURES="nostrip" gmerge shill
55
56- stop flimflam, and start shill
57 localhost / # stop flimflam
58 localhost / # shill --v=1000 \
59 --device-black-list=managed0,managed1,mon.managed0,mon.managed1
60 (the black list keep shill from configuring the devices used by the hostapd
61 processes.)
62
63- run the tests
64 (chroot) src/scripts$ ./run_remote_tests.sh --board=x86-generic \
65 --remote=127.0.0.1 --ssh_port 9222 \
66 --args="config_file=wifi_vm_config" WiFiManager
67
Gaurav Shahd52caa52011-10-25 10:46:03 -070068 To run a specific test out of the test suite, use test_pat option to --args.
69
70 # Example: To just run the 035CheckWEPKeySyntax test:
71 (chroot) src/scripts$ ./run_remote_tests.sh --board=x86-generic \
72 --remote=127.0.0.1 --ssh_port 9222 \
73 --args="config_file=wifi_vm_config test_pat=035CheckWEPKeySyntax" WiFiManager
74
mukesh agrawal70d3ebe2011-10-13 14:45:54 -070075- configuration note: if you use a different port
76 (e.g. hostfwd=tcp::9223-:22), you'll need to change:
77 - the ssh_port argument to run_remote_tests
78 - the port numbers in
79 <chroot>/third_party/autotest/files/client/config/wifi_vm_config
80
81- debugging test failures
82 - "grep shill /var/log/messages" for log messages
83 - "grep wpa_supplicant /var/log/messages" for supplicant log messages
84 - "wpa_debug debug" to increase supplicant log level
85 - try resetting the test infrastructure
86 - rmmod mac80211_hwsim mac80211 cfg80211
87 - restart wpasupplicant
88 - rm /tmp/hostapd-test.control/*
mukesh agrawalc2f39fc2011-11-07 22:07:23 +000089 - examine autotest log files
90 - check how far the test got before it failed
91 $ grep -a ': step ' <test output>/<suite name>/<suite name>.<test name>/debug/<suite name>.<test name>.INFO
92 e.g.
93 (chroot) $ grep -a ': step ' /tmp/run_remote_tests.abcd/network_WiFiRoaming/network_WiFiRoaming.002Suspend/debug/network_WiFiRoaming.002Suspend.INFO
94 - read the log file
95 (chroot) $ LESSOPEN= less /tmp/run_remote_tests.abcd/network_WiFiRoaming/network_WiFiRoaming.002Suspend/debug/network_WiFiRoaming.002Suspend.INFO
96
97 (LESSOPEN= prevents less from misinterpreting the logs as binary files,
98 and piping them through hexdump.)
mukesh agrawal70d3ebe2011-10-13 14:45:54 -070099
100- additional test suites: we have a number of other WiFi test suites
101 (in addition to WiFiManager). these are: WiFiMatFunc, WiFiPerf,
102 WiFiRoaming, WiFiSecMat. the WiFiPerf tests are probably not too
103 relevant to shill (just yet), but the rest probably are.
104
105[1] http://code.google.com/p/googletest/
106[2] http://code.google.com/p/googlemock/
107[3] http://autotest.kernel.org/,
Gaurav Shahd52caa52011-10-25 10:46:03 -0700108 http://www.chromium.org/chromium-os/testing/testing-faq