aboutsummaryrefslogtreecommitdiffstats
path: root/tests/chip.c
Commit message (Collapse)AuthorAgeFilesLines
* tests: Add and include headers with function prototypesAnastasia Klimchuk2022-04-291-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | Part 2 of fixing -Wmissing-prototypes warnings. This patch adds headers with function prototypes and includes the headers into source files. This fixes the warnings like this: warning: no previous prototype for ‘function_name’ [-Wmissing-prototypes] This patch is needed to sync compiler warning options between meson and makefile. TEST=running the following produces no warnings: meson setup --wipe (to clean build directory) ninja test Change-Id: Ia1ff22deb2354569f277649c6575ef2d5ffbb6e0 Signed-off-by: Anastasia Klimchuk <aklm@chromium.org> Reviewed-on: https://review.coreboot.org/c/flashrom/+/63489 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Thomas Heijligen <src@posteo.de> Reviewed-by: Felix Singer <felixsinger@posteo.net> Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
* tests: Mark all static functions as staticAnastasia Klimchuk2022-04-291-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | Part 1 of fixing -Wmissing-prototypes warnings. This patch is adding static to all functions which are actually static. This fixes the warnings like this: warning: no previous prototype for ‘function_name’ [-Wmissing-prototypes] This patch is needed to sync compiler warning options between meson and makefile. TEST=running the following produces no warnings: meson setup --wipe (to clean build directory) ninja test Change-Id: Ic54da5ac1b2a46f55e3e3bee4ed952bdf59e8444 Signed-off-by: Anastasia Klimchuk <aklm@chromium.org> Reviewed-on: https://review.coreboot.org/c/flashrom/+/63571 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Thomas Heijligen <src@posteo.de> Reviewed-by: Felix Singer <felixsinger@posteo.net> Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
* tests/: Add file path and flags validation to open() callsEdward O'Callaghan2022-04-181-17/+71
| | | | | | | | | | | | | | | | | With this change we add path and flag validation to many tests that do not call open. Expected path is set to NULL, if the code indead calls open then the assertion for non-NULL will make the test fail. BUG=b:217629892,b:215255210 TEST=`ninja test`. Change-Id: I892fa1ecee26ebce9640893edbb228fa9aa7b0b6 Signed-off-by: Edward O'Callaghan <quasisec@google.com> Co-Author: Daniel Campello <campello@chromium.org> Signed-off-by: Daniel Campello <campello@chromium.org> Reviewed-on: https://review.coreboot.org/c/flashrom/+/62320 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
* tests: Add tests for verify operationAnastasia Klimchuk2022-02-181-0/+96
| | | | | | | | | | | | | | | This patch adds two tests which cover verify operation, and adds io_mock for fread. BUG=b:181803212 TEST=ninja test Change-Id: I1cc6f73f9b1e385eb963adccf20759c13a40ed3b Signed-off-by: Anastasia Klimchuk <aklm@chromium.org> Reviewed-on: https://review.coreboot.org/c/flashrom/+/59239 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Edward O'Callaghan <quasisec@chromium.org> Reviewed-by: Felix Singer <felixsinger@posteo.net>
* tests: Add comprehensive comment for chip.cAnastasia Klimchuk2022-02-141-0/+12
| | | | | | | | | | | | | | | The following describes the two mechanisms of testing done for flash chip operations. BUG=b:181803212 TEST=ninja test Change-Id: Ie498ec55cce8460fc0b2e1fe27254d3a9f763fac Signed-off-by: Anastasia Klimchuk <aklm@chromium.org> Reviewed-on: https://review.coreboot.org/c/flashrom/+/59238 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Felix Singer <felixsinger@posteo.net> Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
* tests: Set up mock chip memory in consistent and predictable wayAnastasia Klimchuk2022-02-141-0/+2
| | | | | | | | | | | | | | | | | | | | | This patch adds a macro MOCK_CHIP_CONTENT which represents a memory state of a mock chip. The macro is used to initialise mock chip memory at the beginning of a test (in setup_chip function). Previously mock chip memory was not reset between tests. For existing tests that did not matter, however new test for verify operation (added later in this chain) needs mock chip memory to be setup in a predictable way. BUG=b:181803212 TEST=ninja test Change-Id: I0d7623a601c207bfc62d54ab89d94cda56d85871 Signed-off-by: Anastasia Klimchuk <aklm@chromium.org> Reviewed-on: https://review.coreboot.org/c/flashrom/+/59237 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Felix Singer <felixsinger@posteo.net> Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
* tests: Convert write chip tests to libflashrom APIAnastasia Klimchuk2022-01-191-2/+11
| | | | | | | | | | | | | As a part of effort to convert command line (and everything else) to be libflashrom users, chip tests need to be converted as well. TEST=ninja test Change-Id: I965598cfa74e3fb7d0780ad34491f4057617691e Signed-off-by: Anastasia Klimchuk <aklm@chromium.org> Reviewed-on: https://review.coreboot.org/c/flashrom/+/61139 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
* tests: Convert read chip tests to libflashrom APIAnastasia Klimchuk2022-01-191-2/+11
| | | | | | | | | | | | | As a part of effort to convert command line (and everything else) to be libflashrom users, chip tests need to be converted as well. TEST=ninja test Change-Id: I4493d4f269595783830c39a720b0a8963eab9daa Signed-off-by: Anastasia Klimchuk <aklm@chromium.org> Reviewed-on: https://review.coreboot.org/c/flashrom/+/61138 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
* tests: Convert erase chip tests to libflashrom APIAnastasia Klimchuk2022-01-191-2/+3
| | | | | | | | | | | | | As a part of effort to convert command line (and everything else) to be libflashrom users, chip tests need to be converted as well. TEST=ninja test Change-Id: I38529a6b4d79882f50068b3628089b178dbe0a50 Signed-off-by: Anastasia Klimchuk <aklm@chromium.org> Reviewed-on: https://review.coreboot.org/c/flashrom/+/61137 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
* tests: Rename flash context in chip tests to flashctxAnastasia Klimchuk2021-11-081-22/+22
| | | | | | | | | | | | | | | Flash context used to be named `flash` which was missing the context part of it. Now it is renamed into flashctx for clarity. BUG=b:181803212 TEST=ninja test Change-Id: I3f4d9c4fe85752e16bab71ad22b0135a96cac28a Signed-off-by: Anastasia Klimchuk <aklm@chromium.org> Reviewed-on: https://review.coreboot.org/c/flashrom/+/58596 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Angel Pons <th3fanbus@gmail.com> Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
* tests: Add tests to write on chipAnastasia Klimchuk2021-11-081-0/+61
| | | | | | | | | | | | | | | | This patch adds two tests and initialises page_size in mock chip chip_W25Q128_V. page_size was not needed for previous tests (erase and read). page_size only needed to execute writing on chip with dummyflasher, so it is added here. BUG=b:181803212 TEST=ninja test Change-Id: I6f0336613ab16a7e59857006496e3590ddb14d00 Signed-off-by: Anastasia Klimchuk <aklm@chromium.org> Reviewed-on: https://review.coreboot.org/c/flashrom/+/58357 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
* tests: Revise mock chip definition and usageAnastasia Klimchuk2021-10-011-117/+60
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch is doing few things: 1) Makes chip definitions static global so that they can be reused between test functions. 2) Promotes existing mock chip from 8KiB to 8MiB and eraseblocks are expanded accordingly. Old value of 8KiB was very small and it was confusing. Mock chip looks more realistic now. 3) Uses KiB and MiB macros from flash.h for mock chip definition 4) Renames CHIP_TOTAL_SIZE to MOCK_CHIP_SIZE to avoid confusion (there is also a W25Q128.V chip in the tests) 5) Makes chip definitions const so that every test can work on a fresh copy on the stack. BUG=b:181803212 TEST=builds and ninja test Change-Id: Ia9b5fc71e30610684e68e9aca9fb1970da8f840a Signed-off-by: Anastasia Klimchuk <aklm@chromium.org> Reviewed-on: https://review.coreboot.org/c/flashrom/+/57437 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Nico Huber <nico.h@gmx.de>
* tests: Add tests to read from chipAnastasia Klimchuk2021-10-011-0/+97
| | | | | | | | | | | | | | | | | | | | Two tests cover the code which performs do_read operation. First one works with fake chip and dummy programmer. Fake chip has all operations defined, and a buffer to emulate chip memory. Second one uses the chip which is closer to the real one, because read/write/unlock/erase operations are real. The tests takes the advantage of dummyflasher's capability of emulating a W25Q128.V chip. BUG=b:181803212 TEST=builds and ninja test Change-Id: Ia57781ebc670c7bd6197e56fe8a20651a425c756 Signed-off-by: Anastasia Klimchuk <aklm@chromium.org> Reviewed-on: https://review.coreboot.org/c/flashrom/+/57326 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Nico Huber <nico.h@gmx.de>
* tests: Extract setup and teardown for chip testsAnastasia Klimchuk2021-10-011-55/+47
| | | | | | | | | | | | | | | Steps to setup and teardown for a chip test are repeated for every test, so they can be extracted into their own functions. BUG=b:181803212 TEST=builds and ninja test Change-Id: If59315646f06344664df08b145866d9ce846d751 Signed-off-by: Anastasia Klimchuk <aklm@chromium.org> Reviewed-on: https://review.coreboot.org/c/flashrom/+/57436 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 tests to erase a chipAnastasia Klimchuk2021-08-191-0/+226
Two tests cover the code which performs do_erase operation. First one works with fake chip and dummy programmer. Fake chip has all operations defined, and a buffer to emulate chip memory. Second one uses the chip which is closer to the real one, because read/write/unlock/erase operations are real. The tests takes the advantage of dummyflasher's capability of emulating a W25Q128.V chip. BUG=b:181803212 TEST=builds and ninja test Change-Id: I6f74bfe4e02244d24d6c837cc3d551251e7b4898 Signed-off-by: Anastasia Klimchuk <aklm@chromium.org> Reviewed-on: https://review.coreboot.org/c/flashrom/+/56501 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>