summaryrefslogtreecommitdiffstats
path: root/test/vpnor/create_pnor_partition_table.cpp
diff options
context:
space:
mode:
authorAndrew Jeffery <andrew@aj.id.au>2018-03-02 09:26:03 +1030
committerAndrew Jeffery <andrew@aj.id.au>2018-04-04 00:31:48 +0930
commit742a1f6ac66eac80cd1f814430972256b62f9ac5 (patch)
tree2cea69bba919f973bcf45a62da6cfb6461ebd7c8 /test/vpnor/create_pnor_partition_table.cpp
parente9493adc142eaafabe30c8a0dd22b60a0c08f4f0 (diff)
downloadphosphor-mboxd-742a1f6ac66eac80cd1f814430972256b62f9ac5.tar.gz
phosphor-mboxd-742a1f6ac66eac80cd1f814430972256b62f9ac5.zip
pnor_partition_table: Refactor to allow tests to specify patch location
The Table class was unhelpful for testing in a couple of ways: 1. It attempted to access files on the filesystem whilst parsing ToC entries 2. It incorrectly assumed the location of the files it was accessing Both of these issues come down to handling of patch files and the configuration of the 'actual' member of the partition struct. Hoist the handling of the partition entry's data size out of the ToC parser, and rework the Table constructor to only require a struct mbox_context pointer. We can then use the paths member of mbox_context to find the patch location rather than hard-code the value generated by the configure script. This prompts a rework and rename of the wrapper functions in mboxd_pnor_partition_table.{cpp,h} to better align with the new behaviour of the Table constructor. Reworking the wrappers has knock-on effects in the tests, but the changes are straight-forward. Change-Id: I87e63daf0d28b93566f7e5cb565cbf0790428479 Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
Diffstat (limited to 'test/vpnor/create_pnor_partition_table.cpp')
-rw-r--r--test/vpnor/create_pnor_partition_table.cpp32
1 files changed, 21 insertions, 11 deletions
diff --git a/test/vpnor/create_pnor_partition_table.cpp b/test/vpnor/create_pnor_partition_table.cpp
index 09f481d..761b5cd 100644
--- a/test/vpnor/create_pnor_partition_table.cpp
+++ b/test/vpnor/create_pnor_partition_table.cpp
@@ -6,13 +6,22 @@
#include "config.h"
#include "pnor_partition_table.hpp"
+extern "C" {
+#include "test/mbox.h"
+#include "test/system.h"
+}
+
#include "test/vpnor/tmpd.hpp"
static const auto BLOCK_SIZE = 4 * 1024;
+static const auto ERASE_SIZE = BLOCK_SIZE;
static const auto PNOR_SIZE = 64 * 1024 * 1024;
+static const auto MEM_SIZE = PNOR_SIZE;
+static const auto N_WINDOWS = 1;
+static const auto WINDOW_SIZE = BLOCK_SIZE;
const std::string toc[] = {
- "partition01=HBB,00000000,00000400,80,ECC,PRESERVED",
+ "partition01=HBB,00000000,00001000,80,ECC,PRESERVED",
};
constexpr auto partitionName = "HBB";
@@ -20,19 +29,20 @@ namespace test = openpower::virtual_pnor::test;
int main()
{
- struct mbox_context _ctx, *ctx = &_ctx;
+ struct mbox_context* ctx;
+ system_set_reserved_size(MEM_SIZE);
+ system_set_mtd_sizes(PNOR_SIZE, ERASE_SIZE);
+ ctx = mbox_create_test_context(N_WINDOWS, WINDOW_SIZE);
test::VpnorRoot root(ctx, toc, BLOCK_SIZE);
-
- const openpower::virtual_pnor::partition::Table table(root.ro(), BLOCK_SIZE,
- PNOR_SIZE);
+ const openpower::virtual_pnor::partition::Table table(ctx);
pnor_partition_table expectedTable{};
expectedTable.data.magic = PARTITION_HEADER_MAGIC;
expectedTable.data.version = PARTITION_VERSION_1;
- expectedTable.data.size = 1; // 1 block
+ expectedTable.data.size = 1;
expectedTable.data.entry_size = sizeof(pnor_partition);
- expectedTable.data.entry_count = 1; // 1 partition
+ expectedTable.data.entry_count = 1;
expectedTable.data.block_size = BLOCK_SIZE;
expectedTable.data.block_count =
(PNOR_SIZE) / expectedTable.data.block_size;
@@ -41,9 +51,9 @@ int main()
pnor_partition expectedPartition{};
strcpy(expectedPartition.data.name, partitionName);
- expectedPartition.data.base = 0; // starts at offset 0
- expectedPartition.data.size = 1; // 1 block
- expectedPartition.data.actual = 0x400; // 1024 bytes
+ expectedPartition.data.base = 0;
+ expectedPartition.data.size = 1;
+ expectedPartition.data.actual = 0x1000;
expectedPartition.data.id = 1;
expectedPartition.data.pid = PARENT_PATITION_ID;
expectedPartition.data.type = PARTITION_TYPE_DATA;
@@ -63,7 +73,7 @@ int main()
sizeof(pnor_partition));
assert(rc == 0);
- const pnor_partition& first = table.partition(0); // Partition at offset 0
+ const pnor_partition& first = table.partition(0);
rc = memcmp(&first, &result.partitions[0], sizeof(pnor_partition));
assert(rc == 0);
OpenPOWER on IntegriCloud