mirror of https://github.com/ARMmbed/mbed-os.git
SFDP: TestEraseTypeAlgorithm: Move setup into test case
The test data `struct mbed::sfdp_smptbl_info smptbl` is only relevant to `TestEraseTypeAlgorithm` and not shared with other test cases.pull/14983/head
parent
651099225e
commit
f08c3cdfb5
|
@ -1,4 +1,4 @@
|
||||||
/* Copyright (c) 2020 ARM Limited
|
/* Copyright (c) 2020-2021 ARM Limited
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
@ -19,18 +19,23 @@
|
||||||
#include "blockdevice/internal/SFDP.h"
|
#include "blockdevice/internal/SFDP.h"
|
||||||
|
|
||||||
class TestSFDP : public testing::Test {
|
class TestSFDP : public testing::Test {
|
||||||
protected:
|
};
|
||||||
struct mbed::sfdp_smptbl_info smptbl;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct Mbed OS SFDP info.
|
* Test if sfdp_iterate_next_largest_erase_type() returns the most
|
||||||
* Normally this is parsed from the flash-chips's
|
* optimal erase type, whose erase size is as large as possible
|
||||||
* raw SFDP table bytes, but for unit test we construct
|
* while being compatible with both alignment and size requirements.
|
||||||
* SFDP info manually
|
|
||||||
*/
|
*/
|
||||||
virtual void SetUp()
|
TEST_F(TestSFDP, TestEraseTypeAlgorithm)
|
||||||
{
|
{
|
||||||
|
// Erase 104KB starting at 92KB
|
||||||
|
int address = 92 * 1024;
|
||||||
|
int size = 104 * 1024;
|
||||||
|
int region = 1;
|
||||||
|
int type;
|
||||||
|
|
||||||
// The mock flash supports 4KB, 32KB and 64KB erase types
|
// The mock flash supports 4KB, 32KB and 64KB erase types
|
||||||
|
struct mbed::sfdp_smptbl_info smptbl;
|
||||||
smptbl.erase_type_size_arr[0] = 4 * 1024;
|
smptbl.erase_type_size_arr[0] = 4 * 1024;
|
||||||
smptbl.erase_type_size_arr[1] = 32 * 1024;
|
smptbl.erase_type_size_arr[1] = 32 * 1024;
|
||||||
smptbl.erase_type_size_arr[2] = 64 * 1024;
|
smptbl.erase_type_size_arr[2] = 64 * 1024;
|
||||||
|
@ -47,21 +52,6 @@ protected:
|
||||||
smptbl.region_erase_types_bitfld[0] = 0b0001; // 4KB only
|
smptbl.region_erase_types_bitfld[0] = 0b0001; // 4KB only
|
||||||
smptbl.region_erase_types_bitfld[1] = 0b0111; // 64KB, 32KB, 4KB
|
smptbl.region_erase_types_bitfld[1] = 0b0111; // 64KB, 32KB, 4KB
|
||||||
smptbl.region_erase_types_bitfld[2] = 0b0110; // 64KB, 32KB
|
smptbl.region_erase_types_bitfld[2] = 0b0110; // 64KB, 32KB
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test if sfdp_iterate_next_largest_erase_type() returns the most
|
|
||||||
* optimal erase type, whose erase size is as large as possible
|
|
||||||
* while being compatible with both alignment and size requirements.
|
|
||||||
*/
|
|
||||||
TEST_F(TestSFDP, TestEraseTypeAlgorithm)
|
|
||||||
{
|
|
||||||
// Erase 104KB starting at 92KB
|
|
||||||
int address = 92 * 1024;
|
|
||||||
int size = 104 * 1024;
|
|
||||||
int region = 1;
|
|
||||||
int type;
|
|
||||||
|
|
||||||
// Expected outcome:
|
// Expected outcome:
|
||||||
// * The starting position 92KB is 4KB-aligned
|
// * The starting position 92KB is 4KB-aligned
|
||||||
|
|
Loading…
Reference in New Issue