summaryrefslogtreecommitdiffstats
path: root/tests/init_shutdown.c
Commit message (Collapse)AuthorAgeFilesLines
* tests: Rename init_shutdown.c into lifecycle.cAnastasia Klimchuk2022-03-101-352/+0
| | | | | | | | | | | | | | | | Lifecycle tests are getting an upgrade later in this chain, which means lifecycle becomes more than just init and shutdown. Rename into lifecycle.c to reflect the upgrade. BUG=b:181803212 TEST=ninja test Change-Id: I8d734c43cc15c7ec1055d3fb5bdcdca8c90d0987 Signed-off-by: Anastasia Klimchuk <aklm@chromium.org> Reviewed-on: https://review.coreboot.org/c/flashrom/+/59739 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Thomas Heijligen <src@posteo.de> Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
* tests: Add init-shutdown test for raiden_debug_spiAnastasia Klimchuk2021-11-291-0/+95
| | | | | | | | | | | | | | | | | This patch adds a test for raiden_debug_spi and lots of libusb wraps. libusb.h becomes required for tests to build and run, since new tests are using libusb structs in depth and opaque symbols not sufficient anymore. BUG=b:181803212 TEST=builds and ninja test Change-Id: I880a8637ab02de179df9169c1898230bce4dc1c7 Signed-off-by: Anastasia Klimchuk <aklm@chromium.org> Reviewed-on: https://review.coreboot.org/c/flashrom/+/57918 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
* tests: Add wrap for libusb_init and use it in dediprog testAnastasia Klimchuk2021-10-181-0/+8
| | | | | | | | | | | | | | | | | | | | Missing wrap for libusb_init has been discovered while working on the test for raiden_debug_spi. Both dediprog (existing test) and raiden_debug_spi (new test, see later in this chain) are using libusb_init, so it definitely needs to be wrapped and added to io_mock. Why tests worked before, without the wrap: my understanding is that real libusb_init was called for dediprog test? Given that tests definitely should not call any real libusb functions, wrap is needed. BUG=b:181803212 TEST=builds and ninja test Change-Id: I51c9cb96db1afb3298f4d098df96509d3cb3c046 Signed-off-by: Anastasia Klimchuk <aklm@chromium.org> Reviewed-on: https://review.coreboot.org/c/flashrom/+/57917 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Nico Huber <nico.h@gmx.de>
* tests: Add NON_ZERO macro and not_null function instead of MOCK_HANDLEAnastasia Klimchuk2021-10-181-3/+1
| | | | | | | | | | | | | | | | | | | | | | | | This patch adds NON_ZERO macro and not_null function into io_mock.h, so that they can be used anywhere in tests. Common usage for not_null is to indicate a valid pointer, where it doesn't matter what the pointer is, only matters it is not null. Common usage of NON_ZERO is to indicate a valid file descriptor, where it only matters the descriptor is non-zero integer. New features replace all usages of previous MOCK_HANDLE. This patch corrects return value from __wrap_ioctl to be successful by default. It used to be MOCK_HANDLE, but should be 0. Included in this patch because this is also a replacement of MOCK_HANDLE. BUG=b:181803212 TEST=builds and ninja test Change-Id: I5ad6ee4aa9091447c6c9108c92bf7f6e755fca48 Signed-off-by: Anastasia Klimchuk <aklm@chromium.org> Reviewed-on: https://review.coreboot.org/c/flashrom/+/57269 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Nico Huber <nico.h@gmx.de>
* mec1308: remove MEC1308 EC programmerVictor Ding2021-09-221-44/+0
| | | | | | | | | | | | | | | | | Best efforts were made to upstream older Chromebook support for good intentions for folks interested. However, we no longer have the hardware available to test and maintain the code as the hardware is now end of life. Therefore the code state has sadly fallen into a unknown state. BUG=none BRANCH=none TEST=builds and ninja test passes Signed-off-by: Victor Ding <victording@google.com> Change-Id: I535b6380846734c999474519e9e60a73eb6a2ec4 Reviewed-on: https://review.coreboot.org/c/flashrom/+/56476 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Nico Huber <nico.h@gmx.de>
* ene_lpc: remove ENE LPC programmerVictor Ding2021-09-221-63/+0
| | | | | | | | | | | | | | | | | Best efforts were made to upstream older Chromebook support for good intentions for folks interested. However, we no longer have the hardware available to test and maintain the code as the hardware is now end of life. Therefore the code state has sadly fallen into a unknown state. BUG=none BRANCH=none TEST=builds and ninja test passes Signed-off-by: Victor Ding <victording@google.com> Change-Id: I3f40db22c42c04ce029c4defd837e05ebb550c9b Reviewed-on: https://review.coreboot.org/c/flashrom/+/56475 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Nico Huber <nico.h@gmx.de>
* tests: Mock file i/o for linux_mtd and linux_spi testsAnastasia Klimchuk2021-08-301-3/+96
| | | | | | | | | | | | | | | | | | | | | | | | This patch adds an init-shutdown test for linux_mtd. Since linux_mtd is using file i/o operations, those are added to the framework and mocked. Another driver linux_spi which is also using file i/o, got an upgrade in this patch, and it is now reading max buffer size from sysfs (using mocked file i/o). A good side-effect is that linux_mtd is the first test for opaque masters, which is great to have in preparation for a change like CB:56103 but for opaque masters. BUG=b:181803212 TEST=builds and ninja test Change-Id: I73f0d6ff2ad5074add7a721ed3416230d3647e3f Signed-off-by: Anastasia Klimchuk <aklm@chromium.org> Reviewed-on: https://review.coreboot.org/c/flashrom/+/56413 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Nico Huber <nico.h@gmx.de> Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
* tests: add init_shutdown test for realtek_mst_i2c_spiPeter Marheine2021-08-191-0/+54
| | | | | | | | | | | | | | | | This can catch regressions like the earlier one in this programmer that caused initialization to always fail. Requires support for mocking POSIX file I/O functions because the programmer does ioctls on the opened file. TEST=ninja test Signed-off-by: Peter Marheine <pmarheine@chromium.org> Change-Id: I5a5c617d1ec35d2a3bbe622e5add82a65eb396f0 Reviewed-on: https://review.coreboot.org/c/flashrom/+/56911 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Anastasia Klimchuk <aklm@chromium.org> Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
* tests: Add init-shutdown test for nicrealtekAnastasia Klimchuk2021-08-091-0/+9
| | | | | | | | | | | | | | | | | | This patch adds a test and mocks for two pci functions that nicreltek is using. Main reason for this is to have at least one test for par master (currently there are none), in preparation for a change like CB:56103 but for par masters. BUG=b:181803212 TEST=ninja test Change-Id: Iaed14fe1d83c8eb45ec185ebd3f1c97cb81941f4 Signed-off-by: Anastasia Klimchuk <aklm@chromium.org> Reviewed-on: https://review.coreboot.org/c/flashrom/+/56470 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
* tests: Wrap strdup to help cmocka recognise memory allocationAnastasia Klimchuk2021-07-191-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | This is a known issue in cmocka (see https://github.com/clibs/cmocka/issues/17) where cmocka does not recognise memory allocation happening inside strdup, and then later throws an error when the memory is freed. If the issue is fixed at some point, this workaround can be removed. Given that cmocka already overrides malloc, calloc, realloc, free, adding strdup there seems fine. Existing tests now can (and have to) free the memory they allocated by strdup, and this is in the same patch. BUG=b:193584590 TEST=ninja test Change-Id: I56aef6b342752d80995c36ab075b12198fc101d9 Signed-off-by: Anastasia Klimchuk <aklm@chromium.org> Reviewed-on: https://review.coreboot.org/c/flashrom/+/56323 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Edward O'Callaghan <quasisec@chromium.org> Reviewed-by: Angel Pons <th3fanbus@gmail.com>
* dediprog: Init-shutdown test for dediprogAnastasia Klimchuk2021-07-191-0/+34
| | | | | | | | | | | | | | | | | This patch adds mocks for libusb functions. To avoid dependency on libusb.h, libusb symbols for context and device handle are redefined. Real libusb functions are never called in tests anyway, cmocka wraps work with this without complaints. BUG=b:181803212 TEST=builds and ninja test Change-Id: I38508dfb6d7c24d42522f22fcae0c5e410c5f7ea Signed-off-by: Anastasia Klimchuk <aklm@chromium.org> Reviewed-on: https://review.coreboot.org/c/flashrom/+/55934 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Nico Huber <nico.h@gmx.de> Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
* tests: Do not run a test if its driver is not builtAnastasia Klimchuk2021-06-251-0/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For all tests that exist as of today, drivers are built by default, however config options can be disabled and in that case test should not be run. Technically, this is done by skipping the test. BUG=b:181803212 TEST=1) Tested by adding into tests/meson.build -DCONFIG_xxx=0 4 times (for every driver with test), and then running ninja test Result: corresponding test is skipped, all other tests are passed 2) Running ninja test with default config settings (everything is enabled, no overriding in test meson). Result: all tests are passed. 3) Replacing one of config options in the patch with CONFIG_JLINK_SPI which is disabled by default. Result: corresponding test is skipped. Change-Id: Ic1c48e41f658045a608f46636071f478ba646f77 Signed-off-by: Anastasia Klimchuk <aklm@chromium.org> Reviewed-on: https://review.coreboot.org/c/flashrom/+/55295 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Angel Pons <th3fanbus@gmail.com> Reviewed-by: Nico Huber <nico.h@gmx.de> Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
* programmer_init: use struct programmer_entry*Thomas Heijligen2021-06-101-9/+9
| | | | | | | | Change-Id: Iacf0f25abc94a84c5d52c8d69a3e8640817b060a Signed-off-by: Thomas Heijligen <thomas.heijligen@secunet.de> Reviewed-on: https://review.coreboot.org/c/flashrom/+/55121 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Nico Huber <nico.h@gmx.de>
* tests: Add unit test to run init/shutdown for mec1308.c, ene_lpc.cAnastasia Klimchuk2021-06-051-0/+100
| | | | | | | | | | | | | | | | This patch includes mocks for io operations in hwaccess_x86_io.h because those are needed to test lifecycle of mec1308.c and ene_lpc.c BUG=b:181803212 TEST=builds and ninja test Change-Id: I3af612defe1af3850dfc1626a208d873e3a3eddc Signed-off-by: Anastasia Klimchuk <aklm@chromium.org> Reviewed-on: https://review.coreboot.org/c/flashrom/+/51487 Reviewed-by: Edward O'Callaghan <quasisec@chromium.org> Reviewed-by: Nico Huber <nico.h@gmx.de> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
* tests: Add unit test to run init/shutdown for linux_spi.cAnastasia Klimchuk2021-04-271-0/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The current implementation tests a particular path of the init procedure. There are two ways for it to succeed: reading the buffer size from sysfs and the fallback to getpagesize(). This test does the latter (fallback to getpagesize). Extract from meson-logs/testlog.txt for new test: [ RUN ] linux_spi_init_and_shutdown_test_success Testing programmer_init for programmer=25 ... __wrap_open64 is called __wrap_ioctl is called __wrap_ioctl is called __wrap_ioctl is called __wrap_fopen64 is called ... programmer_init for programmer=25 successful Testing programmer_shutdown for programmer=25 ... ... programmer_shutdown for programmer=25 successful [ OK ] linux_spi_init_and_shutdown_test_success BUG=b:181803212 TEST=builds and ninja test Change-Id: I4911fbb6f04371283f0e62d2196bdd691a227584 Signed-off-by: Anastasia Klimchuk <aklm@chromium.org> Reviewed-on: https://review.coreboot.org/c/flashrom/+/52498 Reviewed-by: Nico Huber <nico.h@gmx.de> Reviewed-by: Angel Pons <th3fanbus@gmail.com> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
* tests: Add unit test to run init/shutdown for dummyflasher.cAnastasia Klimchuk2021-04-271-0/+37
Introduce test to exercise that init and shutdown of drivers correctly manage the drivers life-time state. We constrain ourselves to dummyflasher in particular here as it does not need any mocking. BUG=b:181803212 TEST=builds and ninja test Change-Id: I3c0ef73397f00c1db7aabb5f9f00cb43525af29c Signed-off-by: Anastasia Klimchuk <aklm@chromium.org> Reviewed-on: https://review.coreboot.org/c/flashrom/+/52497 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Nico Huber <nico.h@gmx.de>