mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-02-21 11:54:15 +01:00
OP-954 Fixes for UT
+review OPReview-470
This commit is contained in:
parent
6ba15ebc53
commit
a7460bfd3c
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
/* Enable/Disable PiOS modules */
|
/* Enable/Disable PiOS modules */
|
||||||
#define PIOS_INCLUDE_FLASH
|
#define PIOS_INCLUDE_FLASH
|
||||||
//#define PIOS_INCLUDE_FREERTOS
|
//#define PIOS_FLASHFS_LOGFS_MAX_DEVS 5
|
||||||
|
#define PIOS_INCLUDE_FREERTOS
|
||||||
|
|
||||||
#endif /* PIOS_CONFIG_H */
|
#endif /* PIOS_CONFIG_H */
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
#include <stdio.h> /* fopen/fread/fwrite/fseek */
|
#include <stdio.h> /* fopen/fread/fwrite/fseek */
|
||||||
#include <assert.h> /* assert */
|
#include <assert.h> /* assert */
|
||||||
#include <string.h> /* memset */
|
#include <string.h> /* memset */
|
||||||
|
#include <unistd.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include "pios_flash_ut_priv.h"
|
#include "pios_flash_ut_priv.h"
|
||||||
|
|
||||||
@ -55,6 +55,25 @@ int32_t PIOS_Flash_UT_Init(uintptr_t * flash_id, const struct pios_flash_ut_cfg
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t PIOS_Flash_UT_Destroy(uintptr_t flash_id) {
|
||||||
|
/* Check inputs */
|
||||||
|
assert(flash_id);
|
||||||
|
struct flash_ut_dev * flash_dev = (void*)flash_id;
|
||||||
|
|
||||||
|
if (flash_dev->flash_file == NULL) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
fclose(flash_dev->flash_file);
|
||||||
|
|
||||||
|
free(flash_dev);
|
||||||
|
|
||||||
|
unlink (FLASH_IMAGE_FILE);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**********************************
|
/**********************************
|
||||||
*
|
*
|
||||||
* Provide a PIOS flash driver API
|
* Provide a PIOS flash driver API
|
||||||
|
@ -7,6 +7,7 @@ struct pios_flash_ut_cfg {
|
|||||||
|
|
||||||
int32_t PIOS_Flash_UT_Init(uintptr_t * flash_id, const struct pios_flash_ut_cfg * cfg);
|
int32_t PIOS_Flash_UT_Init(uintptr_t * flash_id, const struct pios_flash_ut_cfg * cfg);
|
||||||
|
|
||||||
|
int32_t PIOS_Flash_UT_Destroy(uintptr_t flash_id);
|
||||||
extern const struct pios_flash_driver pios_ut_flash_driver;
|
extern const struct pios_flash_driver pios_ut_flash_driver;
|
||||||
|
|
||||||
#if !defined(FLASH_IMAGE_FILE)
|
#if !defined(FLASH_IMAGE_FILE)
|
||||||
|
@ -87,7 +87,6 @@ protected:
|
|||||||
TEST_F(LogfsTestRaw, FlashInit) {
|
TEST_F(LogfsTestRaw, FlashInit) {
|
||||||
uintptr_t flash_id;
|
uintptr_t flash_id;
|
||||||
EXPECT_EQ(0, PIOS_Flash_UT_Init(&flash_id, &flash_config));
|
EXPECT_EQ(0, PIOS_Flash_UT_Init(&flash_id, &flash_config));
|
||||||
|
|
||||||
PIOS_Flash_UT_Destroy(flash_id);
|
PIOS_Flash_UT_Destroy(flash_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -97,11 +96,12 @@ TEST_F(LogfsTestRaw, LogfsInit) {
|
|||||||
|
|
||||||
uintptr_t fs_id;
|
uintptr_t fs_id;
|
||||||
EXPECT_EQ(0, PIOS_FLASHFS_Logfs_Init(&fs_id, &flashfs_config_partition_a, &pios_ut_flash_driver, flash_id));
|
EXPECT_EQ(0, PIOS_FLASHFS_Logfs_Init(&fs_id, &flashfs_config_partition_a, &pios_ut_flash_driver, flash_id));
|
||||||
|
|
||||||
PIOS_FLASHFS_Logfs_Destroy(fs_id);
|
PIOS_FLASHFS_Logfs_Destroy(fs_id);
|
||||||
PIOS_Flash_UT_Destroy(flash_id);
|
PIOS_Flash_UT_Destroy(flash_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class LogfsTestCooked : public LogfsTestRaw {
|
class LogfsTestCooked : public LogfsTestRaw {
|
||||||
protected:
|
protected:
|
||||||
virtual void SetUp() {
|
virtual void SetUp() {
|
||||||
@ -109,7 +109,6 @@ protected:
|
|||||||
LogfsTestRaw::SetUp();
|
LogfsTestRaw::SetUp();
|
||||||
|
|
||||||
/* Init the flash and the flashfs so we don't need to repeat this in every test */
|
/* Init the flash and the flashfs so we don't need to repeat this in every test */
|
||||||
uintptr_t flash_id;
|
|
||||||
EXPECT_EQ(0, PIOS_Flash_UT_Init(&flash_id, &flash_config));
|
EXPECT_EQ(0, PIOS_Flash_UT_Init(&flash_id, &flash_config));
|
||||||
EXPECT_EQ(0, PIOS_FLASHFS_Logfs_Init(&fs_id, &flashfs_config_partition_a, &pios_ut_flash_driver, flash_id));
|
EXPECT_EQ(0, PIOS_FLASHFS_Logfs_Init(&fs_id, &flashfs_config_partition_a, &pios_ut_flash_driver, flash_id));
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user