summaryrefslogtreecommitdiff
path: root/include/test_util.h
Commit message (Collapse)AuthorAgeFilesLines
* Optimize memsetDaisuke Nojiri2014-03-011-0/+13
| | | | | | | | | | | | | | | | | | | | | | | | | This speeds up memset by copying a word at a time. Ran the unit test on Peppy: > runtest ... Running test_memset... (speed gain: 141532 -> 32136 us) OK ... Ran make buildall: ... Running test_memset... (speed gain: 1338 -> 280 us) OK ... TEST=Described above. BUG=chrome-os-partner:23720 BRANCH=none Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Change-Id: If34b06ad70f448d950535a4bea4f6556627a9b6f Tested-by: Daisuke Nojiri <dnojiri@google.com> Reviewed-on: https://chromium-review.googlesource.com/185936 Reviewed-by: Randall Spangler <rspangler@chromium.org> Commit-Queue: Daisuke Nojiri <dnojiri@google.com>
* emulator: Move trace dump to a separate moduleVic (Chun-Ju) Yang2014-01-221-11/+1
| | | | | | | | | | | | | | | The implementation of trace dump has little to do with task scheduling, so we should move it to a separate module for cleaner code. This requires exposing some emulator-specific task info, as defined in host_task.h. BUG=chrome-os-partner:19235 TEST=Pass all tests BRANCH=None Change-Id: Iba9bc0794a4e1dd4ddb92b98345162b398fa6a8d Signed-off-by: Vic (Chun-Ju) Yang <victoryang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/183238
* Dump stack trace on emulator test failureVic (Chun-Ju) Yang2014-01-081-0/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Emulator test failures are sometimes hard to debug, especially when the test is stuck somewhere and times out. Let's have the emulator dump stack trace when an assertion fails or a test times out. The produced stack trace is in this format: #0 build/host/kb_8042/kb_8042.exe() [0x412421] /home/victoryang/trunk/src/platform/ec/test/kb_8042.c:104 #1 build/host/kb_8042/kb_8042.exe() [0x4124a9] /home/victoryang/trunk/src/platform/ec/test/kb_8042.c:129 #2 build/host/kb_8042/kb_8042.exe(run_test+0x3a) [0x412e2c] /home/victoryang/trunk/src/platform/ec/test/kb_8042.c:262 #3 build/host/kb_8042/kb_8042.exe(_run_test+0x11) [0x4061de] /home/victoryang/trunk/src/platform/ec/core/host/task.c:90 #4 build/host/kb_8042/kb_8042.exe(_task_start_impl+0x79) [0x406b72] /home/victoryang/trunk/src/platform/ec/core/host/task.c:408 #5 /lib64/libpthread.so.0(+0x70b1) [0x7f6dc2fa10b1] ??:0 #6 /lib64/libc.so.6(clone+0x6d) [0x7f6dc2cd8efd] ??:0 The file name and line number in the trace is generated by addr2line. BUG=chrome-os-partner:19235 chromium:331548 TEST=Put in a infinite loop in a test, and see stack trace when it times out. TEST=Add a failing assertion, and see stack trace when it fails. BRANCH=None Change-Id: I4494ffd1ebc98081ce40e860a146202084aa2a1e Signed-off-by: Vic (Chun-Ju) Yang <victoryang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/181730
* Add interrupt support for emulatorVic Yang2014-01-061-0/+22
| | | | | | | | | | | | | | | | | | This provides us a way to inject interrupts during a test. If a test has interrupt_generator() defined, it will run in a separate thread. The generator can then trigger interrupts when it decides to. The current running task is suspended while emulator is executing ISR. Also fixes a bug that tasks run without scheduler notifying them during emulator start-up. BUG=chrome-os-partner:19235 TEST=Repeatedly run all tests. BRANCH=None Change-Id: I0f921c47c0f848a9626da6272d9040e2b7c5ac86 Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/55671
* Move pseudo random number generator to commonVic (Chun-Ju) Yang2013-12-271-0/+4
| | | | | | | | | | | | | | We have three copies of the same pseudo random number generator in our test codes. Let's consolidate them into a single copy in test_util. BUG=chrome-os-partner:19235 TEST=Pass all tests BRANCH=None Change-Id: I7ea0b3476f3cfe6944855f19861e3c86af35807e Signed-off-by: Vic (Chun-Ju) Yang <victoryang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/181085 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* Test interface for detaching fake I2C devicesVic Yang2013-09-271-0/+21
| | | | | | | | | | | | | | This provides an interface to detach and re-attach fake I2C devices, which can be used to test I2C connection failure. BUG=chrome-os-partner:19235 TEST=Pass sbs_charging test along with the next CL BRANCH=None Change-Id: Ibfee79b13d45e62377d894aa28547e77bef2189e Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/170752 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* Fake I2C device support for emulatorVic Yang2013-09-171-0/+53
| | | | | | | | | | | | | | | | | To test drivers, we need a way to fake I2C periphrals. With this CL, a fake peripheral can be done by declaring its own I2C read/write functions. The fake I2C peripherals may return EC_ERROR_INVAL to indicate it's not responding. The emulator I2C read/write call scans through all registered I2C peripherals and uses the first response. BUG=chrome-os-partner:19235 TEST=Pass sbs_charging test with the next CL. BRANCH=None Change-Id: I9380dc40e147781b42e09eb6979c864bbd9f2ac4 Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/169511 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* Add boot key testVic Yang2013-09-051-0/+6
| | | | | | | | | | | | | This checks boot key combination like Power-F3-ESC and Power-F3-Down can be properly detected. BUG=chrome-os-partner:19236 TEST=Pass kb_scan test BRANCH=None Change-Id: I180918977299219a8421798dac2ab9fed84ef9a2 Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/167802
* Add multi-step test supportVic Yang2013-09-051-0/+46
| | | | | | | | | | | | | We already have a multi-step test. Let's move it to test_util.c so that upcoming tests can also use it. BUG=chrome-os-partner:19235 TEST=Pass all tests BRANCH=None Change-Id: I6b7a036297f3b4b2778687488d1dc5b5bb4fe255 Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/167950
* Flush test coverage information before rebooting emulatorVic Yang2013-09-041-0/+6
| | | | | | | | | | | | | | | If we reboots the emulator without flushing test coverage information, the test coverage report will be incorrect. Let's fix this by flushing it before every reboot. BUG=chrome-os-partner:19235 TEST=Generate test coverage report and check correctness. BRANCH=None Change-Id: I1eb060e419b767f382325bed841366c491ba56b7 Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/167770 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* Add test for console command historyVic Yang2013-08-181-0/+6
| | | | | | | | | | | | | This tests that command history is as expected. Also fix a bug that some checks in console_edit test are skipped. BUG=chrome-os-partner:19236 TEST=Pass console_edit test. BRANCH=None Change-Id: Ifbd3d1690f25b35bf5efe523e656b013aa534d26 Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/64837
* Add system_common unit testVic Yang2013-07-221-0/+16
| | | | | | | | | | | | | | This tests reboot-on-ap-shutdown. BUG=chrome-os-partner:19236 TEST=Pass the test BRANCH=None Change-Id: Ic1a07670f82646e85d014d52a2aba0835319c212 Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/62855 Reviewed-by: Randall Spangler <rspangler@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* Add thermal host and console command testVic Yang2013-07-111-5/+5
| | | | | | | | | | | | | | This checks the functionality of thermal engine related host and console commands. BUG=chrome-os-partner:19236 TEST=Pass all tests. BRANCH=None Change-Id: I604ed3bfed3549b2573fac65da83450acd3f2797 Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/60964 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* Add function to inject console input from testVic Yang2013-07-111-0/+4
| | | | | | | | | | | | | This can be used to test console command. BUG=chrome-os-partner:19236 TEST=Build success BRANCH=None Change-Id: I7ce002f9e66fd7786492bacb453f126b9766d741 Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/60978 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* A method to mock host commandVic Yang2013-06-171-0/+3
| | | | | | | | | | | | This will be used often, so let's move it to test_util.c. BUG=chrome-os-partner:19235 TEST=Pass flash test. BRANCH=None Change-Id: I2f685f657f8742c2b29e3b9c88ba01daacf982f8 Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/58793
* Make target for test coverage report generationVic Yang2013-06-161-0/+6
| | | | | | | | | | | | | By 'make coverage', lcov is used to generate test coverage report in HTML format stored in coverage_rpt folder. BUG=chrome-os-partner:19235 TEST=Generate a report. BRANCH=None Change-Id: I44142eaaeb897cf09179764781120370920144cd Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/58203
* Unit test for queue implementationVic Yang2013-06-101-0/+12
| | | | | | | | | | | BUG=chrome-os-partner:19236 TEST=Pass the test. BRANCH=None Change-Id: I575e4a9abfd9431e3b74c36da8c3d69285e5c0fb Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/58032 Reviewed-by: Yung-Chieh Lo <yjlou@chromium.org>
* Enable flash unit test on emulatorVic Yang2013-06-031-0/+2
| | | | | | | | | | | BUG=chrome-os-partner:19236 TEST=Pass all tests BRANCH=None Change-Id: I09276292499b94b2d4810830de51e4c63a9b7342 Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/56704 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* Add hook testVic Yang2013-05-141-1/+12
| | | | | | | | | | | | | Test of hook functionality. BUG=chrome-os-partner:19236 TEST=Pass the test BRANCH=None Change-Id: I4700f3061edd0707932e935a719fc73c3976892e Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/50957 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* Put test utility macros in headerVic Yang2013-05-081-0/+50
Several test utility macros have been duplicated across tests. Let's put them in a single place. BUG=chrome-os-partner:19236 TEST='make runtests', 'BOARD=spring make tests' BRANCH=None Change-Id: Ib0c9f829715425cc23e33b8ef456b17dfadab13c Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/50513 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>