Skip to content

Commit

Permalink
Restored functionality of make test builds
Browse files Browse the repository at this point in the history
(Fixes #926)
  • Loading branch information
Nightwalker-87 committed Apr 17, 2020
1 parent c2c4808 commit aa38587
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 27 deletions.
3 changes: 1 addition & 2 deletions include/stlink/tools/flash.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ enum flash_area {FLASH_MAIN_MEMORY = 0, FLASH_SYSTEM_MEMORY = 1,FLASH_OTP = 2, F
struct flash_opts
{
enum flash_cmd cmd;
const char* devname;
uint8_t serial[STLINK_SERIAL_MAX_SIZE];
const char* filename;
stm32_addr_t addr;
Expand All @@ -28,7 +27,7 @@ struct flash_opts
int opt;
};

#define FLASH_OPTS_INITIALIZER {0, NULL, { 0 }, NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0}
#define FLASH_OPTS_INITIALIZER {0, { 0 }, NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0}

int flash_get_opts(struct flash_opts* o, int ac, char** av);

Expand Down
30 changes: 5 additions & 25 deletions tests/flash.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ static bool execute_test(const struct Test * test) {

if (ret && (res == 0)) {
ret &= (opts.cmd == test->opts.cmd);
ret &= cmp_strings(opts.devname, test->opts.devname);
ret &= cmp_mem(opts.serial, test->opts.serial, sizeof(opts.serial));
ret &= cmp_strings(opts.filename, test->opts.filename);
ret &= (opts.addr == test->opts.addr);
Expand All @@ -76,9 +75,8 @@ static bool execute_test(const struct Test * test) {

static struct Test tests[] = {
{ "", -1, FLASH_OPTS_INITIALIZER },
{ "--debug --reset read /dev/sg0 test.bin 0x80000000 0x1000", 0,
{ "--debug --reset read test.bin 0x80000000 0x1000", 0,
{ .cmd = FLASH_CMD_READ,
.devname = "/dev/sg0",
.serial = { 0 },
.filename = "test.bin",
.addr = 0x80000000,
Expand All @@ -87,9 +85,8 @@ static struct Test tests[] = {
.log_level = DEBUG_LOG_LEVEL,
.format = FLASH_FORMAT_BINARY }
},
{ "--debug --reset write /dev/sg0 test.bin 0x80000000", 0,
{ "--debug --reset write test.bin 0x80000000", 0,
{ .cmd = FLASH_CMD_WRITE,
.devname = "/dev/sg0",
.serial = { 0 },
.filename = "test.bin",
.addr = 0x80000000,
Expand All @@ -98,21 +95,8 @@ static struct Test tests[] = {
.log_level = DEBUG_LOG_LEVEL,
.format = FLASH_FORMAT_BINARY }
},
{ "--serial A1020304 /dev/sg0 erase", -1, FLASH_OPTS_INITIALIZER },
{ "/dev/sg0 erase", 0,
{ .cmd = FLASH_CMD_ERASE,
.devname = "/dev/sg0",
.serial = { 0 },
.filename = NULL,
.addr = 0,
.size = 0,
.reset = 0,
.log_level = STND_LOG_LEVEL,
.format = FLASH_FORMAT_BINARY }
},
{ "--debug --reset read test.bin 0x80000000 0x1000", 0,
{ .cmd = FLASH_CMD_READ,
.devname = NULL,
.serial = { 0 },
.filename = "test.bin",
.addr = 0x80000000,
Expand All @@ -123,7 +107,6 @@ static struct Test tests[] = {
},
{ "--debug --reset write test.bin 0x80000000", 0,
{ .cmd = FLASH_CMD_WRITE,
.devname = NULL,
.serial = { 0 },
.filename = "test.bin",
.addr = 0x80000000,
Expand All @@ -134,7 +117,6 @@ static struct Test tests[] = {
},
{ "erase", 0,
{ .cmd = FLASH_CMD_ERASE,
.devname = NULL,
.serial = { 0 },
.filename = NULL,
.addr = 0,
Expand All @@ -145,7 +127,6 @@ static struct Test tests[] = {
},
{ "--debug --reset --format=ihex write test.hex", 0,
{ .cmd = FLASH_CMD_WRITE,
.devname = NULL,
.serial = { 0 },
.filename = "test.hex",
.addr = 0,
Expand All @@ -157,10 +138,10 @@ static struct Test tests[] = {
{ "--debug --reset --format=binary write test.hex", -1, FLASH_OPTS_INITIALIZER },
{ "--debug --reset --format=ihex write test.hex 0x80000000", -1, FLASH_OPTS_INITIALIZER },
{ "--debug --reset write test.hex sometext", -1, FLASH_OPTS_INITIALIZER },
{ "--serial A1020304 erase sometext", -1, FLASH_OPTS_INITIALIZER },
{ "--serial A1020304 erase", 0,
{ .cmd = FLASH_CMD_ERASE,
.devname = NULL,
.serial = "\0\0\0\0\0\0\0\0\xA1\x02\x03\x04",
.serial = "\xA1\x02\x03\x04",
.filename = NULL,
.addr = 0,
.size = 0,
Expand All @@ -170,8 +151,7 @@ static struct Test tests[] = {
},
{ "--serial=A1020304 erase", 0,
{ .cmd = FLASH_CMD_ERASE,
.devname = NULL,
.serial = "\0\0\0\0\0\0\0\0\xA1\x02\x03\x04",
.serial = "\xA1\x02\x03\x04",
.filename = NULL,
.addr = 0,
.size = 0,
Expand Down

0 comments on commit aa38587

Please sign in to comment.