summaryrefslogtreecommitdiff
path: root/include/test_util.h
Commit message (Collapse)AuthorAgeFilesLines
* Update license boilerplate text in source code filesstabilize-quickfix-15278.72.B-ishstabilize-quickfix-15183.78.B-ishstabilize-15446.B-ishstabilize-15439.B-ishstabilize-15432.B-ishstabilize-15429.B-ishstabilize-15415.B-ishstabilize-15395.B-ishstabilize-15393.48.B-ishstabilize-15381.B-ishstabilize-15364.B-ishstabilize-15361.B-ishstabilize-15359.B-ishstabilize-15359.58.B-ishstabilize-15359.50.B-ishstabilize-15359.45.B-ishstabilize-15335.B-ishstabilize-15329.59.B-ishstabilize-15329.44.B-ishstabilize-15317.B-ishstabilize-15301.B-ishstabilize-15300.B-ishstabilize-15278.64.B-ishstabilize-15251.B-ishstabilize-15245.B-ishstabilize-15236.66.B-ishstabilize-15208.B-ishstabilize-15207.B-ishstabilize-15185.B-ishstabilize-15185.7.B-ishstabilize-15183.82.B-ishstabilize-15183.69.B-ishstabilize-15183.14.B-ishstabilize-15174.B-ishstabilize-15167.B-ishstabilize-15129.B-ishstabilize-15122.B-ishstabilize-15120.B-ishstabilize-15117.86.B-ishstabilize-15117.48.B-ishstabilize-15117.111.B-ishrelease-R114-15437.B-ishrelease-R113-15393.B-ishrelease-R112-15359.B-ishrelease-R111-15329.B-ishrelease-R110-15278.B-ishrelease-R109-15237.B-ishrelease-R109-15236.B-ishrelease-R108-15183.B-ishrelease-R107-15117.B-ishishfirmware-ti50-prepvt-15315.B-ishfirmware-skyrim-15390.B-ishfirmware-skyrim-15369.B-ishfirmware-nissa-15217.B-ishfirmware-nissa-15217.45.B-ishfirmware-nissa-15217.126.B-ishfirmware-duplo-15151.B-ishfirmware-corsola-15194.B-ishfactory-trogdor-15210.B-ishfactory-skyrim-15384.B-ishfactory-nissa-15199.B-ishfactory-corsola-15197.B-ishfactory-corsola-15196.B-ishfactory-brya-15231.B-ishMike Frysinger2022-09-141-1/+1
| | | | | | | | | | | | | | Normally we don't do this, but enough changes have accumulated that we're doing a tree-wide one-off update of the name & style. BRANCH=none BUG=chromium:1098010 TEST=`repo upload` works Change-Id: I5b357b85ae9473a192b80983871bef4ae0d4b16f Signed-off-by: Mike Frysinger <vapier@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3893394 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* test: update default setup/teardown functionsYuval Peress2021-08-311-12/+1
| | | | | | | | | | | | | | | When using ztest_unit_test the default setup/teardown functions should be before_test() and after_test(). BRANCH=none BUG=none TEST=make buildall -j Signed-off-by: Yuval Peress <peress@chromium.org> Change-Id: Ia1a65923a39d3f193a9cedecdc9d716dcf136eb6 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3132306 Commit-Queue: Paul Fagerburg <pfagerburg@chromium.org> Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org>
* zephyr: test_util: Add TEST_SUITE macroTomasz Michalec2021-04-161-0/+6
| | | | | | | | | | | | | | | TEST_SUITE macro allows to define Zephyr test as test suite instead of test_main(). Test suite can be used as part of bigger test. BUG=b:185205123 BRANCH=none TEST=zmake testall TEST=make runhosttests Signed-off-by: Tomasz Michalec <tm@semihalf.com> Change-Id: I834ccf38e256c918623e96bb39597a0b22a874c0 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2825910 Reviewed-by: Jeremy Bettis <jbettis@chromium.org>
* zephyr: test_util: improve EC compatibilityPaul Fagerburg2021-01-221-1/+3
| | | | | | | | | | | | | | | | | | | | | | When building a unit test that compiles for either EC or Ztest, the TEST_MAIN macro should call test_reset and test_print_results as part of running the tests. This allows the test code to omit the functions (which are not defined when building for Ztest). Also add the format parameter so that when testing for floating-point values being near (zassert_within or TEST_NEAR) we can specify the format for the EC assertion to print the result. BUG=b:172240633 BRANCH=None TEST=`make runhosttests` and `zmake testall` Signed-off-by: Paul Fagerburg <pfagerburg@google.com> Change-Id: I23dc933ed4ba0f386fcae68d257161ffffe226eb Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2645197 Tested-by: Paul Fagerburg <pfagerburg@chromium.org> Reviewed-by: Jack Rosenthal <jrosenth@chromium.org> Commit-Queue: Paul Fagerburg <pfagerburg@chromium.org>
* common:test: refactor test_util.h to accommodate ZephyrYuval Peress2021-01-211-3/+150
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This change refactors test functionality in test_util.h to better accomomdate zTests. This is done by: * Removing the shim version of test_util.h. This was causing a conflict that made it harder to tell what's being used. This involved migrating some needed code over: - Defining different TASK_PARAMS. - Defining test_pass for Zephyr tests. * Creating a macro (DECLARE_EC_TEST) that will automatically handle creating the individual test functions for both platform and Zephyr tests. * Creating a macro (TEST_MAIN) that will automatically handle creating the main test entry function. This use to be test_main(void) for Zephyr and run_test(int, char**) for platform/ec. To do this we'll be removing the int, char** arguments from platform/ec. This may result in some tests having to be refactored, but overall should improve the test codebase as tests should remain deterministic (i.e. not depend on any outside arguments/parameters). * Creating some common ztest_ function/macros that will allow writing platform/ec tests in a zephyr like style. see test/base32.c for an example. * Update the type of __shared_mem_buf to match Zephyr. This was causing an issue now with the full test_util.h in zephyr/test/system/. BRANCH=none BUG=b:168032590 TEST=make runhosttests TEST=zmake configure --test -B build/host/base32 zephyr/test/base32 Signed-off-by: Yuval Peress <peress@chromium.org> Change-Id: I72173a3e94c7df09a2966e7ffeb9f5668d030f29 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2634401 Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org>
* TCPMv2: Unit Test - add filename to TEST_ failing outputDenis Brockus2021-01-061-7/+10
| | | | | | | | | | | | | | BUG=none BRANCH=none TEST=make buildall Signed-off-by: Denis Brockus <dbrockus@google.com> Change-Id: I2cc35425de4b29c7f5b958428a00efdf1e31e004 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2613246 Tested-by: Denis Brockus <dbrockus@chromium.org> Auto-Submit: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Edward Hill <ecgh@chromium.org> Commit-Queue: Edward Hill <ecgh@chromium.org>
* zephyr: improve shimming for unit testsPaul Fagerburg2020-12-311-20/+3
| | | | | | | | | | | | | | | | | | | | | | | * Move the Ztest-related definitions out of test_util and into a shim version of that header. * Add definitions for EC unit tests declaring additional tasks so the task shim will pick them up correctly. * Copy the prng functions into the shimmed test_util. BUG=None BRANCH=None TEST=`make clobber ; make buildall -j ; make runhosttests` Then build the unit tests that have been ported to Ztest, e.g. `zmake configure --test -B build/base32 zephyr/test/base32` for `base32`, `crc`, `hooks`, `i2c`,and `tasks` Signed-off-by: Paul Fagerburg <pfagerburg@google.com> Change-Id: Ia2873a4c2028fcb6960e80f683189def2f3a228d Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2605231 Tested-by: Paul Fagerburg <pfagerburg@chromium.org> Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org> Commit-Queue: Paul Fagerburg <pfagerburg@chromium.org> Auto-Submit: Paul Fagerburg <pfagerburg@chromium.org>
* COIL: Clean up controller/peripheral language in headersDossym Nurmukhanov2020-12-121-6/+6
| | | | | | | | | | | BUG=none TEST=verify builds are still working BRANCH=none Signed-off-by: dossym@chromium.org Change-Id: I8925a7ffd3ab4e47dfed213438f601d673188259 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2588008 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* test_util: use ztest only if CONFIG_ZTEST is defined, not CONFIG_ZEPHYRJack Rosenthal2020-11-071-3/+3
| | | | | | | | | | | | | | | This header can be included from shimmed modules for an actual build (not just tests). In that case, CONFIG_ZEPHYR would be defined, but not CONFIG_ZTEST, and headers like ztest.h are not available. BUG=b:172678200 BRANCH=none TEST=compile both host_command.c and hooks test Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Change-Id: I24c704f6288eac9a8ca53580ec00e43073a6fef0 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2522968 Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org>
* tests: fix include for Zephyr ztestPaul Fagerburg2020-10-281-1/+1
| | | | | | | | | | | | | | | | | A test written for the Zephyr Ztest API needs to include ztest.h, not just ztest_assert.h BUG=b:168032590 BRANCH=None TEST=build base32 unit test for Zephyr Ztest target Signed-off-by: Paul Fagerburg <pfagerburg@google.com> Change-Id: Ib4558e724614d9684294e6f2b670942d1f0c82d4 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2504471 Tested-by: Paul Fagerburg <pfagerburg@chromium.org> Commit-Queue: Jack Rosenthal <jrosenth@chromium.org> Reviewed-by: Jack Rosenthal <jrosenth@chromium.org> Auto-Submit: Paul Fagerburg <pfagerburg@chromium.org>
* test: Allow EC unit test to use Ztest APIPaul Fagerburg2020-10-231-0/+54
| | | | | | | | | | | | | | | | | | | | | | | | Provide a translation layer in test_utils.h for the Zephyr zassert macros to map onto EC's TEST_ASSERT macros. With a little bit of duplicated-but-not-quite-duplicated code (test_main vs. run_test) and some extra macros for the return type of the test cases, the tests can build for either the EC framework (by default) or the Zephyr Ztest framework (#ifdef CONFIG_ZEPHYR). Update the unit test documentation to explain why (and a brief "how") developers should use the Ztest API for new unit tests. BUG=b:168032590 BRANCH=none TEST=`TEST_LIST_HOST=base32 make runhosttests` Signed-off-by: Paul Fagerburg <pfagerburg@google.com> Change-Id: I26e60788c1468e44fed565dd31162759c7587ea6 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2492527 Tested-by: Paul Fagerburg <pfagerburg@chromium.org> Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Commit-Queue: Paul Fagerburg <pfagerburg@chromium.org>
* test: Pass commandline arguments to run_testTom Hughes2020-05-301-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | run_test is called by the "runtest" console command. Console commands can take arguments, so pass along the arguments to run_test to allow parameters to be passed to run_test. The following command was used for automatic replacement: git grep --name-only 'void run_test(void)' |\ xargs sed -i 's#void run_test(void)#void run_test(int argc, char **argv)##' BRANCH=none BUG=b:155897971 TEST=make buildall -j TEST=Build and flash flash_write_protect test > runtest 1 Signed-off-by: Tom Hughes <tomhughes@chromium.org> Change-Id: Ib20b955d5ec6b98f525c94c24aadefd7a6a320a5 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2209418 Reviewed-by: Yicheng Li <yichengli@chromium.org> Commit-Queue: Yicheng Li <yichengli@chromium.org> Tested-by: Yicheng Li <yichengli@chromium.org>
* test_util: Fix typoTom Hughes2020-05-201-1/+1
| | | | | | | | | | | | BRANCH=none BUG=none TEST=make buildall -j Signed-off-by: Tom Hughes <tomhughes@chromium.org> Change-Id: I259c18e09c568e2e7c38c18c93cf666fb17de44b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2209368 Commit-Queue: Diana Z <dzigterman@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org>
* test: add better test printsJett Rink2020-04-011-8/+10
| | | | | | | | | | | | | | | | Update test runner and mux mock to print information with tags Also print out when a test passes for easier debugging BRANCH=none] BUG=none TEST=used in child CL Change-Id: I29a1193831239c160cf75be20380e677936ba9d8 Signed-off-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2131048 Reviewed-by: Diana Z <dzigterman@chromium.org>
* common: Add sensor stillness detectorYuval Peress2019-12-181-5/+11
| | | | | | | | | | | | | | This change adds a stillness detector for 3d sensors. This will be needed to filter sensor readings when calibrating later. BUG=b:138303429,chromium:1023858 BRANCH=None TEST=buildall with new unit tests Change-Id: I919ae7533fd42b0394de66aa0585e58343a662cc Signed-off-by: Yuval Peress <peress@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1833157 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
* common: Refactor motion_sense_fifoYuval Peress2019-11-111-0/+2
| | | | | | | | | | | | | | | | | This change refactors the motion_sense_fifo to uniformly prefix all the functions to avoid collisions. It also adds several unit tests and fixes a few bugs with the fifo logic. BUG=b:137758297 BRANCH=kukui TEST=buildall TEST=run CTS on arcada, kohaku, and kukui TEST=boot kohaku (verify tablet mode works as expected) Change-Id: I6e8492ae5fa474d0aa870088ab56f76b220a73e3 Signed-off-by: Yuval Peress <peress@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1835221 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
* common:test: Add comparators to test_util.hstabilize-12593.BYuval Peress2019-10-121-0/+4
| | | | | | | | | | | | | Add <, <=, >, >= tests to test_util.h BUG=None BRANCH=None TEST=buildall Change-Id: I5d8ddfc3eda59f0193707c77d52d97962ef1a325 Signed-off-by: Yuval Peress <peress@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1853694 Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
* printf: Fix formatting errorsEvan Green2019-10-051-2/+2
| | | | | | | | | | | | | | | | | | | This change fixes the printf formatting errors found by the compile-time prinf format checker. The errors fall into a few categories: 1. Incorrect size specifier (missing or extra l). 2. Missing or extra arguments. 3. Bad line splitting. BUG=chromium:984041 TEST=make -j buildall BRANCH=none Change-Id: I5618097a581210b9fcbfc81560dec050ae30b61c Signed-off-by: Evan Green <evgreen@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1819653 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
* test: Update TEST_EQ to using string format specifierYuval Peress2019-08-151-6/+6
| | | | | | | | | | | BRANCH=None BUG=None TEST=builds and all tests pass Change-Id: Idbb288d8f422b4c01fe27c989bdf1188df509a27 Signed-off-by: Yuval Peress <peress@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1752204 Reviewed-by: Jett Rink <jettrink@chromium.org>
* test: make TEST_EQ and TEST_NE use %d as formatJett Rink2019-08-091-2/+2
| | | | | | | | | | | | | | | When using TEST_EQ, the checkpatch.pl script complains about space around a ...., %d). When we are testing for equality, we are most likely be using a integer BRANCH=none BUG=none TEST=Uses of TEST_EQ work as expected when displaying errors Change-Id: Iedc69ee8b3e98fdcb2243f9dde445425f2714818 Signed-off-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1739584 Reviewed-by: Denis Brockus <dbrockus@chromium.org>
* test: Add new test framework toolsYuval Peress2019-07-241-6/+23
| | | | | | | | | | | | | | | | | | | | | | | | | Add new before/after test functions to be used for clean-up and tear-down of tests. Add new asserting functions: - TEST_EQ ensures that two values are equal - TEST_NE ensures that two values are not equal - TEST_BITS_SET ensures that a value contains all bits in mask - TEST_BITS_CLEARED ensures that a value doesn't contain any bits in mask The benefit of these is that unlike TEST_ASSERT they will also print the values when the assersion is wrong. BRANCH=None BUG=b:137758297 TEST=None yet Change-Id: I2f305ef34e541c289f22c6596f53ee5cd977c7a8 Signed-off-by: Yuval Peress <peress@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1704165 Reviewed-by: Enrico Granata <egranata@chromium.org> Reviewed-by: Jack Rosenthal <jrosenth@chromium.org> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* Remove __7b, __8b and __7bfDenis Brockus2019-07-201-5/+5
| | | | | | | | | | | | | | | | | | | The extentions were added to make the compiler perform most of the verification that the conversion was being done correctly to remove 8bit addressing as the standard I2C/SPI address type. Now that the compiler has verified the code, the extra extentions are being removed BUG=chromium:971296 BRANCH=none TEST=make buildall -j TEST=verify sensor functionality on arcada_ish Change-Id: I36894f8bb9daefb5b31b5e91577708f6f9af2a4f Signed-off-by: Denis Brockus <dbrockus@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1704792 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
* Use 7bit I2C/SPI slave addresses in ECDenis Brockus2019-07-191-6/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Opt for 7bit slave addresses in EC code. If 8bit is expected by a driver, make it local and show this in the naming. Use __7b, __7bf and __8b as name extensions for i2c/spi addresses used in the EC codebase. __7b indicates a 7bit address by itself. __7bf indicates a 7bit address with optional flags attached. __8b indicates a 8bit address by itself. Allow space for 10bit addresses, even though this is not currently being used by any of our attached devices. These extensions are for verification purposes only and will be removed in the last pass of this ticket. I want to make sure the variable names reflect the type to help eliminate future 7/8/7-flags confusion. BUG=chromium:971296 BRANCH=none TEST=make buildall -j Change-Id: I2fc3d1b52ce76184492b2aaff3060f486ca45f45 Signed-off-by: Denis Brockus <dbrockus@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1699893 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
* LICENSE: remove unnecessary (c) after CopyrightTom Hughes2019-06-191-1/+1
| | | | | | | | | | | | | | | | Ran the following command: git grep -l 'Copyright (c)' | \ xargs sed -i 's/Copyright (c)/Copyright/g' BRANCH=none BUG=none TEST=make buildall -j Change-Id: I6cc4a0f7e8b30d5b5f97d53c031c299f3e164ca7 Signed-off-by: Tom Hughes <tomhughes@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1663262 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* tests: make lighbar test easier to debugJett Rink2019-04-241-0/+3
| | | | | | | | | | | | | | | | | This test was failing and it is easier to comment out tests that are passing to debug. I needed to add a precondition so each test would pass on its own. I also needed to remove the static modifier to allow each test to be comment out. BRANCH=none BUG=none TEST=builds and passes Change-Id: Ib2a7c0948aee363e1552835222a9700225993e46 Signed-off-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1570605 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* test: host_command_fuzz: fuzzing testNicolas Boichat2018-08-161-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | Writing fuzzing tests is a little tricky, as clang takes over the main function. Instead, we start the test main function in a thread, and have LLVMFuzzerTestOneInput prepare the host command buffer, and wake the TEST_RUNNER task. To make fuzzing faster, we only send somehow correctly formed requests, with a valid checksum and length (this can be disabled with an option). We also make sure that the emulator does not hibernate, reboot or jump to a different image when fuzzing is enabled. BRANCH=none BUG=chromium:854975 TEST=make buildfuzztests -j ASAN_OPTIONS="log_path=stderr" \ build/host/host_command_fuzz/host_command_fuzz.exe -timeout=5 Change-Id: I27b25e44c405f118dfc1296247479245e15e54b4 Signed-off-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1107523 Reviewed-by: Manoj Gupta <manojgupta@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org> Reviewed-by: Jonathan Metzman <metzman@chromium.org>
* ec: Make it possible to run tests with AddressSanitizer enabledNicolas Boichat2018-06-281-1/+2
| | | | | | | | | | | | | | | | | | | Automatically use CC=clang if TEST_ASAN is specified. Also, add a __no_sanitize_address attribute macro to prevent ASan from adding guards around host_command, mkbp_event, and hook "arrays" that are generated at link-time. Also, set ASAN_OPTIONS env variable in run_host_test. BRANCH=none BUG=chromium:854924 TEST=make TEST_ASAN=y runtests -j Change-Id: Iaf0ec405022760d757a8a9d62a5022460d1b16e1 Signed-off-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1109661 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* host: mock i2c_xferGwendal Grignou2015-09-161-42/+9
| | | | | | | | | | | | | | | Instead of mocking i2c_read8/16/32, mock i2c_xfer. We can now test code that call i2c_xfer directly and test common/i2c.c BRANCH=samus, ryu BUG=chrome-os-partner:45223 TEST=Unit tests pass. Change-Id: Iaa772515c40cf55d2050d0019e2062d63278adc0 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/299768 Reviewed-by: Alec Berg <alecaberg@chromium.org>
* common: Add i2c 32bit read/writeGwendal Grignou2015-06-171-0/+12
| | | | | | | | | | | | | Add functions and associated test to read/write a 32 bit register BRANCH=smaug TEST=Test on smaug with bm160 driver BUG=chromium:39900 Change-Id: Ieff24b65f1eb8610874fe13c4a8fadf583a218cb Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/277535 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* 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>