Skip to content
Permalink
Browse files

tests: drivers: flash_simulator: removing CONFIG_ prefix from defines

Removed the CONFIG_ prefix from definitions, which are declared in the
test source file. They could be easily confused with Kconfig
definitions.

Signed-off-by: Kamil Piszczek <Kamil.Piszczek@nordicsemi.no>
  • Loading branch information...
kapi-no authored and galak committed Apr 26, 2019
1 parent 5fd99f5 commit 3ce677092d3636785ea1398efee93489614f05f7
Showing with 51 additions and 51 deletions.
  1. +51 −51 tests/drivers/flash_simulator/src/main.c
@@ -9,17 +9,17 @@
#include <device.h>

/* configuration derived from DT */
#define CONFIG_FLASH_SIMULATOR_BASE_OFFSET DT_FLASH_BASE_ADDRESS
#define CONFIG_FLASH_SIMULATOR_ERASE_UNIT DT_FLASH_ERASE_BLOCK_SIZE
#define CONFIG_FLASH_SIMULATOR_PROG_UNIT DT_FLASH_WRITE_BLOCK_SIZE
#define CONFIG_FLASH_SIMULATOR_FLASH_SIZE DT_FLASH_SIZE
#define FLASH_SIMULATOR_BASE_OFFSET DT_FLASH_BASE_ADDRESS
#define FLASH_SIMULATOR_ERASE_UNIT DT_FLASH_ERASE_BLOCK_SIZE
#define FLASH_SIMULATOR_PROG_UNIT DT_FLASH_WRITE_BLOCK_SIZE
#define FLASH_SIMULATOR_FLASH_SIZE DT_FLASH_SIZE

/* Offset between pages */
#define TEST_SIM_FLASH_SIZE (CONFIG_FLASH_SIMULATOR_ERASE_UNIT *\
CONFIG_FLASH_SIMULATOR_FLASH_SIZE)
#define TEST_SIM_FLASH_SIZE (FLASH_SIMULATOR_ERASE_UNIT *\
FLASH_SIMULATOR_FLASH_SIZE)

#define TEST_SIM_FLASH_END (TEST_SIM_FLASH_SIZE +\
CONFIG_FLASH_SIMULATOR_BASE_OFFSET)
FLASH_SIMULATOR_BASE_OFFSET)

static struct device *flash_dev;
static u8_t test_read_buf[TEST_SIM_FLASH_SIZE];
@@ -69,7 +69,7 @@ static void test_int(void)
zassert_true(flash_dev != NULL,
"Simulated flash driver was not found!");

rc = flash_read(flash_dev, CONFIG_FLASH_SIMULATOR_BASE_OFFSET,
rc = flash_read(flash_dev, FLASH_SIMULATOR_BASE_OFFSET,
test_read_buf, sizeof(test_read_buf));
zassert_equal(0, rc, "flash_read should succedd");

@@ -89,19 +89,19 @@ static void test_write_read(void)
for (off = 0; off < TEST_SIM_FLASH_SIZE; off += 4) {
rc = flash_write_protection_set(flash_dev, false);
zassert_equal(0, rc, NULL);
rc = flash_write(flash_dev, CONFIG_FLASH_SIMULATOR_BASE_OFFSET +
rc = flash_write(flash_dev, FLASH_SIMULATOR_BASE_OFFSET +
off,
&val32, sizeof(val32));
zassert_equal(0, rc,
"flash_write (%d) should succedd at off 0x%x", rc,
CONFIG_FLASH_SIMULATOR_BASE_OFFSET + off);
FLASH_SIMULATOR_BASE_OFFSET + off);
val32++;
}

val32 = 0;

for (off = 0; off < TEST_SIM_FLASH_SIZE; off += 4) {
rc = flash_read(flash_dev, CONFIG_FLASH_SIMULATOR_BASE_OFFSET +
rc = flash_read(flash_dev, FLASH_SIMULATOR_BASE_OFFSET +
off,
&r_val32, sizeof(r_val32));
zassert_equal(0, rc, "flash_write should succedd");
@@ -116,28 +116,28 @@ static void test_erase(void)
{
int rc;

rc = flash_erase(flash_dev, CONFIG_FLASH_SIMULATOR_BASE_OFFSET +
CONFIG_FLASH_SIMULATOR_ERASE_UNIT,
CONFIG_FLASH_SIMULATOR_ERASE_UNIT);
rc = flash_erase(flash_dev, FLASH_SIMULATOR_BASE_OFFSET +
FLASH_SIMULATOR_ERASE_UNIT,
FLASH_SIMULATOR_ERASE_UNIT);
zassert_equal(0, rc, "flash_erase should succedd");

TC_PRINT("Incremental pattern expected\n");
pattern32_ini(0);
test_check_pattern32(CONFIG_FLASH_SIMULATOR_BASE_OFFSET, pattern32_inc,
CONFIG_FLASH_SIMULATOR_ERASE_UNIT);
test_check_pattern32(FLASH_SIMULATOR_BASE_OFFSET, pattern32_inc,
FLASH_SIMULATOR_ERASE_UNIT);

TC_PRINT("Erased area expected\n");
pattern32_ini(0xffffffff);
test_check_pattern32(CONFIG_FLASH_SIMULATOR_BASE_OFFSET +
CONFIG_FLASH_SIMULATOR_ERASE_UNIT, pattern32_flat,
CONFIG_FLASH_SIMULATOR_ERASE_UNIT);
test_check_pattern32(FLASH_SIMULATOR_BASE_OFFSET +
FLASH_SIMULATOR_ERASE_UNIT, pattern32_flat,
FLASH_SIMULATOR_ERASE_UNIT);

TC_PRINT("Incremental pattern expected\n");
pattern32_ini(CONFIG_FLASH_SIMULATOR_ERASE_UNIT*2 /
CONFIG_FLASH_SIMULATOR_PROG_UNIT);
test_check_pattern32(CONFIG_FLASH_SIMULATOR_BASE_OFFSET +
CONFIG_FLASH_SIMULATOR_ERASE_UNIT*2, pattern32_inc,
CONFIG_FLASH_SIMULATOR_ERASE_UNIT*2);
pattern32_ini(FLASH_SIMULATOR_ERASE_UNIT*2 /
FLASH_SIMULATOR_PROG_UNIT);
test_check_pattern32(FLASH_SIMULATOR_BASE_OFFSET +
FLASH_SIMULATOR_ERASE_UNIT*2, pattern32_inc,
FLASH_SIMULATOR_ERASE_UNIT*2);
}

static void test_access(void)
@@ -148,12 +148,12 @@ static void test_access(void)
rc = flash_write_protection_set(flash_dev, true);
zassert_equal(0, rc, NULL);

rc = flash_write(flash_dev, CONFIG_FLASH_SIMULATOR_BASE_OFFSET,
rc = flash_write(flash_dev, FLASH_SIMULATOR_BASE_OFFSET,
data, 4);
zassert_equal(-EACCES, rc, "Unexpected error code (%d)", rc);

rc = flash_erase(flash_dev, CONFIG_FLASH_SIMULATOR_BASE_OFFSET,
CONFIG_FLASH_SIMULATOR_ERASE_UNIT);
rc = flash_erase(flash_dev, FLASH_SIMULATOR_BASE_OFFSET,
FLASH_SIMULATOR_ERASE_UNIT);
zassert_equal(-EACCES, rc, "Unexpected error code (%d)", rc);
}

@@ -164,11 +164,11 @@ static void test_out_of_bounds(void)

rc = flash_write_protection_set(flash_dev, false);

rc = flash_write(flash_dev, CONFIG_FLASH_SIMULATOR_BASE_OFFSET - 4,
rc = flash_write(flash_dev, FLASH_SIMULATOR_BASE_OFFSET - 4,
data, 4);
zassert_equal(-EINVAL, rc, "Unexpected error code (%d)", rc);

rc = flash_write(flash_dev, CONFIG_FLASH_SIMULATOR_BASE_OFFSET - 4,
rc = flash_write(flash_dev, FLASH_SIMULATOR_BASE_OFFSET - 4,
data, 8);
zassert_equal(-EINVAL, rc, "Unexpected error code (%d)", rc);

@@ -180,30 +180,30 @@ static void test_out_of_bounds(void)
data, 8);
zassert_equal(-EINVAL, rc, "Unexpected error code (%d)", rc);

rc = flash_erase(flash_dev, CONFIG_FLASH_SIMULATOR_BASE_OFFSET -
CONFIG_FLASH_SIMULATOR_ERASE_UNIT,
CONFIG_FLASH_SIMULATOR_ERASE_UNIT);
rc = flash_erase(flash_dev, FLASH_SIMULATOR_BASE_OFFSET -
FLASH_SIMULATOR_ERASE_UNIT,
FLASH_SIMULATOR_ERASE_UNIT);
zassert_equal(-EINVAL, rc, "Unexpected error code (%d)", rc);

rc = flash_erase(flash_dev, TEST_SIM_FLASH_END,
CONFIG_FLASH_SIMULATOR_ERASE_UNIT);
FLASH_SIMULATOR_ERASE_UNIT);
zassert_equal(-EINVAL, rc, "Unexpected error code (%d)", rc);

rc = flash_erase(flash_dev, CONFIG_FLASH_SIMULATOR_BASE_OFFSET -
CONFIG_FLASH_SIMULATOR_ERASE_UNIT*2,
CONFIG_FLASH_SIMULATOR_ERASE_UNIT*2);
rc = flash_erase(flash_dev, FLASH_SIMULATOR_BASE_OFFSET -
FLASH_SIMULATOR_ERASE_UNIT*2,
FLASH_SIMULATOR_ERASE_UNIT*2);
zassert_equal(-EINVAL, rc, "Unexpected error code (%d)", rc);

rc = flash_erase(flash_dev, TEST_SIM_FLASH_END -
CONFIG_FLASH_SIMULATOR_ERASE_UNIT,
CONFIG_FLASH_SIMULATOR_ERASE_UNIT*2);
FLASH_SIMULATOR_ERASE_UNIT,
FLASH_SIMULATOR_ERASE_UNIT*2);
zassert_equal(-EINVAL, rc, "Unexpected error code (%d)", rc);

rc = flash_read(flash_dev, CONFIG_FLASH_SIMULATOR_BASE_OFFSET - 4,
rc = flash_read(flash_dev, FLASH_SIMULATOR_BASE_OFFSET - 4,
data, 4);
zassert_equal(-EINVAL, rc, "Unexpected error code (%d)", rc);

rc = flash_read(flash_dev, CONFIG_FLASH_SIMULATOR_BASE_OFFSET - 4,
rc = flash_read(flash_dev, FLASH_SIMULATOR_BASE_OFFSET - 4,
data, 8);
zassert_equal(-EINVAL, rc, "Unexpected error code (%d)", rc);

@@ -220,25 +220,25 @@ static void test_align(void)
int rc;
u8_t data[4] = {0};

rc = flash_read(flash_dev, CONFIG_FLASH_SIMULATOR_BASE_OFFSET + 1,
rc = flash_read(flash_dev, FLASH_SIMULATOR_BASE_OFFSET + 1,
data, 4);
zassert_equal(-EINVAL, rc, "Unexpected error code (%d)", rc);

rc = flash_write(flash_dev, CONFIG_FLASH_SIMULATOR_BASE_OFFSET + 1,
rc = flash_write(flash_dev, FLASH_SIMULATOR_BASE_OFFSET + 1,
data, 4);
zassert_equal(-EINVAL, rc, "Unexpected error code (%d)", rc);

rc = flash_write(flash_dev, CONFIG_FLASH_SIMULATOR_BASE_OFFSET,
rc = flash_write(flash_dev, FLASH_SIMULATOR_BASE_OFFSET,
data, 3);
zassert_equal(-EINVAL, rc, "Unexpected error code (%d)", rc);

rc = flash_erase(flash_dev, CONFIG_FLASH_SIMULATOR_BASE_OFFSET + 1,
CONFIG_FLASH_SIMULATOR_ERASE_UNIT);
rc = flash_erase(flash_dev, FLASH_SIMULATOR_BASE_OFFSET + 1,
FLASH_SIMULATOR_ERASE_UNIT);

zassert_equal(-EINVAL, rc, "Unexpected error code (%d)", rc);

rc = flash_erase(flash_dev, CONFIG_FLASH_SIMULATOR_BASE_OFFSET,
CONFIG_FLASH_SIMULATOR_ERASE_UNIT + 1);
rc = flash_erase(flash_dev, FLASH_SIMULATOR_BASE_OFFSET,
FLASH_SIMULATOR_ERASE_UNIT + 1);

zassert_equal(-EINVAL, rc, "Unexpected error code (%d)", rc);
}
@@ -248,15 +248,15 @@ static void test_double_write(void)
int rc;
u8_t data[4] = {0};

rc = flash_erase(flash_dev, CONFIG_FLASH_SIMULATOR_BASE_OFFSET,
CONFIG_FLASH_SIMULATOR_ERASE_UNIT);
rc = flash_erase(flash_dev, FLASH_SIMULATOR_BASE_OFFSET,
FLASH_SIMULATOR_ERASE_UNIT);
zassert_equal(0, rc, "flash_erase should succedd");

rc = flash_write(flash_dev, CONFIG_FLASH_SIMULATOR_BASE_OFFSET,
rc = flash_write(flash_dev, FLASH_SIMULATOR_BASE_OFFSET,
data, 4);
zassert_equal(0, rc, "flash_write should succedd");

rc = flash_write(flash_dev, CONFIG_FLASH_SIMULATOR_BASE_OFFSET,
rc = flash_write(flash_dev, FLASH_SIMULATOR_BASE_OFFSET,
data, 4);
zassert_equal(-EIO, rc, "Unexpected error code (%d)", rc);
}

0 comments on commit 3ce6770

Please sign in to comment.
You can’t perform that action at this time.