Skip to content

Commit

Permalink
tests: benchmarks: power_consumption: flash: extend test with writes
Browse files Browse the repository at this point in the history
Add erase and write operation.
Validate read values.

Signed-off-by: Piotr Kosycarz <[email protected]>
  • Loading branch information
nordic-piks committed Jan 10, 2025
1 parent 118ee39 commit 5648126
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions tests/benchmarks/power_consumption/flash/src/driver_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,29 @@

#define TEST_AREA_OFFSET 0xff000
#define EXPECTED_SIZE 512
#define FLASH_PAGE_SIZE 4096

uint8_t buf[EXPECTED_SIZE];
uint8_t fill_value = 0x00;

Check failure on line 25 in tests/benchmarks/power_consumption/flash/src/driver_test.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

GLOBAL_INITIALISERS

tests/benchmarks/power_consumption/flash/src/driver_test.c:25 do not initialise globals to 0x00

static const struct device *flash_dev = DEVICE_DT_GET(FLASH_NODE);


void thread_definition(void)
{
int ret;
int rc;

while (1) {
ret = flash_read(flash_dev, TEST_AREA_OFFSET, buf, EXPECTED_SIZE);
if (ret < 0) {
printk("Failure in reading byte %d", ret);
return;
rc = flash_erase(flash_dev, TEST_AREA_OFFSET, FLASH_PAGE_SIZE);
__ASSERT(rc == 0, "flash_erase %d\n", rc);
rc = flash_fill(flash_dev, fill_value, TEST_AREA_OFFSET, EXPECTED_SIZE);
__ASSERT(rc == 0, "flash_fill %d\n", rc);
rc = flash_read(flash_dev, TEST_AREA_OFFSET, buf, EXPECTED_SIZE);
__ASSERT(rc == 0, "flash_read %d\n", rc);
for (size_t i = 0; i < EXPECTED_SIZE; i++) {
__ASSERT(buf[i] == fill_value, "flash value %d but expected %d\n", buf[i], fill_value);

Check warning on line 42 in tests/benchmarks/power_consumption/flash/src/driver_test.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

LONG_LINE

tests/benchmarks/power_consumption/flash/src/driver_test.c:42 line length of 111 exceeds 100 columns
buf[i] = (uint8_t)i;
}
fill_value++;
};
};

0 comments on commit 5648126

Please sign in to comment.