Skip to content

Commit af23396

Browse files
author
Vincent Dupont
committed
fixup! unittests: add spiffs unittests
1 parent 681654b commit af23396

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

tests/unittests/tests-spiffs/tests-spiffs.c

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
/* Define MTD_0 in board.h to use the board mtd if any */
2727
#ifdef MTD_0
28-
#define _dev MTD_0
28+
#define _dev (MTD_0)
2929
#else
3030
/* Test mock object implementing a simple RAM-based mtd */
3131
#ifndef SECTOR_COUNT
@@ -108,19 +108,18 @@ static const mtd_desc_t driver = {
108108
.power = _power,
109109
};
110110

111-
static mtd_dev_t _dev = {
111+
static mtd_dev_t dev = {
112112
.driver = &driver,
113113
.sector_count = SECTOR_COUNT,
114114
.pages_per_sector = PAGE_PER_SECTOR,
115115
.page_size = PAGE_SIZE,
116116
};
117+
118+
static mtd_dev_t *_dev = (mtd_dev_t*) &dev;
117119
#endif /* MTD_0 */
118120

119121
static struct spiffs_desc spiffs_desc = {
120122
.lock = MUTEX_INIT,
121-
#if SPIFFS_HAL_CALLBACK_EXTRA == 1
122-
.dev = (mtd_dev_t*) &_dev,
123-
#endif
124123
};
125124

126125
static vfs_mount_t _test_spiffs_mount = {
@@ -129,6 +128,13 @@ static vfs_mount_t _test_spiffs_mount = {
129128
.private_data = &spiffs_desc,
130129
};
131130

131+
static void test_spiffs_setup(void)
132+
{
133+
#if SPIFFS_HAL_CALLBACK_EXTRA == 1
134+
spiffs_desc.dev = _dev;
135+
#endif
136+
}
137+
132138
static void test_spiffs_teardown(void)
133139
{
134140
vfs_mount(&_test_spiffs_mount);
@@ -395,7 +401,7 @@ Test *tests_spiffs_tests(void)
395401
new_TestFixture(tests_spiffs_write2),
396402
};
397403

398-
EMB_UNIT_TESTCALLER(spiffs_tests, NULL, test_spiffs_teardown, fixtures);
404+
EMB_UNIT_TESTCALLER(spiffs_tests, test_spiffs_setup, test_spiffs_teardown, fixtures);
399405

400406
return (Test *)&spiffs_tests;
401407
}

0 commit comments

Comments
 (0)