diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/vpnor/Makefile.am.include | 8 | ||||
-rw-r--r-- | test/vpnor/create_pnor_partition_table.cpp | 32 | ||||
-rw-r--r-- | test/vpnor/create_read_window_oob.cpp | 2 | ||||
-rw-r--r-- | test/vpnor/create_read_window_partition_exists.cpp | 2 | ||||
-rw-r--r-- | test/vpnor/create_read_window_partition_invalid.cpp | 2 | ||||
-rw-r--r-- | test/vpnor/create_read_window_straddle_partitions.cpp | 2 | ||||
-rw-r--r-- | test/vpnor/create_read_window_toc.cpp | 4 | ||||
-rw-r--r-- | test/vpnor/read_patch.cpp | 2 | ||||
-rw-r--r-- | test/vpnor/toc_lookup_failed.cpp | 2 | ||||
-rw-r--r-- | test/vpnor/toc_lookup_found.cpp | 2 | ||||
-rw-r--r-- | test/vpnor/toc_missing_file.cpp | 2 | ||||
-rw-r--r-- | test/vpnor/toc_overlap.cpp | 2 | ||||
-rw-r--r-- | test/vpnor/write_patch.cpp | 2 | ||||
-rw-r--r-- | test/vpnor/write_patch_resize.cpp | 2 | ||||
-rw-r--r-- | test/vpnor/write_prsv.cpp | 2 | ||||
-rw-r--r-- | test/vpnor/write_ro.cpp | 2 | ||||
-rw-r--r-- | test/vpnor/write_rw.cpp | 2 |
17 files changed, 45 insertions, 27 deletions
diff --git a/test/vpnor/Makefile.am.include b/test/vpnor/Makefile.am.include index 22bcd41..8d0dd65 100644 --- a/test/vpnor/Makefile.am.include +++ b/test/vpnor/Makefile.am.include @@ -8,6 +8,14 @@ VPNOR_LDADD = -lstdc++fs \ test_vpnor_create_pnor_partition_table_SOURCES = \ $(TEST_MBOX_VPNOR_SRCS) \ + $(TEST_MOCK_SRCS) \ + mboxd_msg.c \ + mboxd_windows.c \ + mboxd_lpc.c \ + mboxd_lpc_virtual.cpp \ + mboxd_pnor_partition_table.cpp \ + mboxd_flash_virtual.cpp \ + pnor_partition.cpp \ %reldir%/create_pnor_partition_table.cpp test_vpnor_create_pnor_partition_table_LDFLAGS = $(OESDK_TESTCASE_FLAGS) test_vpnor_create_pnor_partition_table_LDADD = $(VPNOR_LDADD) 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); diff --git a/test/vpnor/create_read_window_oob.cpp b/test/vpnor/create_read_window_oob.cpp index ce85617..8b2b0f4 100644 --- a/test/vpnor/create_read_window_oob.cpp +++ b/test/vpnor/create_read_window_oob.cpp @@ -49,7 +49,7 @@ int main() ctx = mbox_create_test_context(N_WINDOWS, WINDOW_SIZE); test::VpnorRoot root(ctx, toc, BLOCK_SIZE); - vpnor_create_partition_table_from_path(ctx, root.ro().c_str()); + init_vpnor_from_paths(ctx); rc = mbox_command_dispatch(ctx, get_info, sizeof(get_info)); assert(rc == 1); diff --git a/test/vpnor/create_read_window_partition_exists.cpp b/test/vpnor/create_read_window_partition_exists.cpp index d72f6d1..f0466c9 100644 --- a/test/vpnor/create_read_window_partition_exists.cpp +++ b/test/vpnor/create_read_window_partition_exists.cpp @@ -57,7 +57,7 @@ int main() test::VpnorRoot root(ctx, toc, BLOCK_SIZE); root.write("HBB", data, sizeof(data)); - vpnor_create_partition_table_from_path(ctx, root.ro().c_str()); + init_vpnor_from_paths(ctx); int rc = mbox_command_dispatch(ctx, get_info, sizeof(get_info)); assert(rc == 1); diff --git a/test/vpnor/create_read_window_partition_invalid.cpp b/test/vpnor/create_read_window_partition_invalid.cpp index 52dd159..cdd895b 100644 --- a/test/vpnor/create_read_window_partition_invalid.cpp +++ b/test/vpnor/create_read_window_partition_invalid.cpp @@ -45,7 +45,7 @@ int main() ctx = mbox_create_test_context(N_WINDOWS, WINDOW_SIZE); test::VpnorRoot root(ctx, toc, BLOCK_SIZE); - vpnor_create_partition_table_from_path(ctx, root.ro().c_str()); + init_vpnor_from_paths(ctx); rc = mbox_command_dispatch(ctx, get_info, sizeof(get_info)); assert(rc == 1); diff --git a/test/vpnor/create_read_window_straddle_partitions.cpp b/test/vpnor/create_read_window_straddle_partitions.cpp index ca0ac0b..67149fa 100644 --- a/test/vpnor/create_read_window_straddle_partitions.cpp +++ b/test/vpnor/create_read_window_straddle_partitions.cpp @@ -54,7 +54,7 @@ int main() ctx = mbox_create_test_context(N_WINDOWS, WINDOW_SIZE); test::VpnorRoot root(ctx, toc, BLOCK_SIZE); - vpnor_create_partition_table_from_path(ctx, root.ro().c_str()); + init_vpnor_from_paths(ctx); int rc = mbox_command_dispatch(ctx, get_info, sizeof(get_info)); assert(rc == 1); diff --git a/test/vpnor/create_read_window_toc.cpp b/test/vpnor/create_read_window_toc.cpp index 00b9dfe..1f68371 100644 --- a/test/vpnor/create_read_window_toc.cpp +++ b/test/vpnor/create_read_window_toc.cpp @@ -55,12 +55,12 @@ int main() ctx = mbox_create_test_context(N_WINDOWS, WINDOW_SIZE); test::VpnorRoot root(ctx, toc, BLOCK_SIZE); - vpnor::partition::Table table(root.ro(), BLOCK_SIZE, PNOR_SIZE); + vpnor::partition::Table table(ctx); /* Make sure the ToC exactly fits in the space allocated for it */ assert(table.capacity() == TOC_PART_SIZE); - vpnor_create_partition_table_from_path(ctx, root.ro().c_str()); + init_vpnor_from_paths(ctx); rc = mbox_command_dispatch(ctx, get_info, sizeof(get_info)); assert(rc == 1); diff --git a/test/vpnor/read_patch.cpp b/test/vpnor/read_patch.cpp index b06907c..2a91b66 100644 --- a/test/vpnor/read_patch.cpp +++ b/test/vpnor/read_patch.cpp @@ -56,7 +56,7 @@ int main() std::vector<uint8_t> patch(PATCH_SIZE, 0xff); root.patch("ONE", patch.data(), patch.size()); - vpnor_create_partition_table_from_path(ctx, root.ro().c_str()); + init_vpnor_from_paths(ctx); int rc = mbox_command_dispatch(ctx, get_info, sizeof(get_info)); assert(rc == 1); diff --git a/test/vpnor/toc_lookup_failed.cpp b/test/vpnor/toc_lookup_failed.cpp index a35975a..5230ab1 100644 --- a/test/vpnor/toc_lookup_failed.cpp +++ b/test/vpnor/toc_lookup_failed.cpp @@ -39,7 +39,7 @@ int main() ctx = mbox_create_test_context(N_WINDOWS, WINDOW_SIZE); test::VpnorRoot root(ctx, toc, BLOCK_SIZE); - vpnor::partition::Table table(root.ro(), BLOCK_SIZE, PNOR_SIZE); + vpnor::partition::Table table(ctx); try { diff --git a/test/vpnor/toc_lookup_found.cpp b/test/vpnor/toc_lookup_found.cpp index c98b718..fdc5a10 100644 --- a/test/vpnor/toc_lookup_found.cpp +++ b/test/vpnor/toc_lookup_found.cpp @@ -39,7 +39,7 @@ int main() ctx = mbox_create_test_context(N_WINDOWS, WINDOW_SIZE); test::VpnorRoot root(ctx, toc, BLOCK_SIZE); - vpnor::partition::Table table(root.ro(), BLOCK_SIZE, PNOR_SIZE); + vpnor::partition::Table table(ctx); const struct pnor_partition& part = table.partition("TWO"); assert(part.data.id == 2); diff --git a/test/vpnor/toc_missing_file.cpp b/test/vpnor/toc_missing_file.cpp index aad80b4..dd602bb 100644 --- a/test/vpnor/toc_missing_file.cpp +++ b/test/vpnor/toc_missing_file.cpp @@ -44,7 +44,7 @@ int main() try { - vpnor::partition::Table table(root.ro(), BLOCK_SIZE, PNOR_SIZE); + vpnor::partition::Table table(ctx); } catch (vpnor::InvalidTocEntry& e) { diff --git a/test/vpnor/toc_overlap.cpp b/test/vpnor/toc_overlap.cpp index 3f1ca3f..97748e2 100644 --- a/test/vpnor/toc_overlap.cpp +++ b/test/vpnor/toc_overlap.cpp @@ -41,7 +41,7 @@ int main() try { - vpnor::partition::Table table(root.ro(), BLOCK_SIZE, PNOR_SIZE); + vpnor::partition::Table table(ctx); } catch (vpnor::InvalidTocEntry& e) { diff --git a/test/vpnor/write_patch.cpp b/test/vpnor/write_patch.cpp index b0d5fa7..f45ab26 100644 --- a/test/vpnor/write_patch.cpp +++ b/test/vpnor/write_patch.cpp @@ -50,7 +50,7 @@ int main(void) fs::path patch = root.patch() / "TEST1"; assert(fs::copy_file(root.ro() / "TEST1", patch)); - vpnor_create_partition_table_from_path(ctx, root.ro().c_str()); + init_vpnor_from_paths(ctx); /* Test */ memset(src, 0x33, sizeof(src)); diff --git a/test/vpnor/write_patch_resize.cpp b/test/vpnor/write_patch_resize.cpp index 24c71b0..350b210 100644 --- a/test/vpnor/write_patch_resize.cpp +++ b/test/vpnor/write_patch_resize.cpp @@ -49,7 +49,7 @@ int main(void) std::vector<uint8_t> patchContent(PATCH_SIZE, 0xaa); root.patch("TEST1", patchContent.data(), patchContent.size()); - vpnor_create_partition_table_from_path(ctx, root.ro().c_str()); + init_vpnor_from_paths(ctx); /* Test */ std::vector<uint8_t> update(UPDATE_SIZE, 0x55); diff --git a/test/vpnor/write_prsv.cpp b/test/vpnor/write_prsv.cpp index 03624e4..faa05db 100644 --- a/test/vpnor/write_prsv.cpp +++ b/test/vpnor/write_prsv.cpp @@ -39,7 +39,7 @@ int main(void) verbosity = (verbose)2; test::VpnorRoot root(ctx, toc, BLOCK_SIZE); - vpnor_create_partition_table_from_path(ctx, root.ro().c_str()); + init_vpnor_from_paths(ctx); /* Test */ memset(src, 0xaa, sizeof(src)); diff --git a/test/vpnor/write_ro.cpp b/test/vpnor/write_ro.cpp index fe934dd..504822a 100644 --- a/test/vpnor/write_ro.cpp +++ b/test/vpnor/write_ro.cpp @@ -36,7 +36,7 @@ int main(void) verbosity = (verbose)2; test::VpnorRoot root(ctx, toc, BLOCK_SIZE); - vpnor_create_partition_table_from_path(ctx, root.ro().c_str()); + init_vpnor_from_paths(ctx); /* Test */ rc = write_flash(ctx, 0x1000, src, sizeof(src)); diff --git a/test/vpnor/write_rw.cpp b/test/vpnor/write_rw.cpp index eff959b..aba12bb 100644 --- a/test/vpnor/write_rw.cpp +++ b/test/vpnor/write_rw.cpp @@ -40,7 +40,7 @@ int main(void) test::VpnorRoot root(ctx, toc, BLOCK_SIZE); /* write_flash() doesn't copy the file for us */ assert(fs::copy_file(root.ro() / "TEST1", root.rw() / "TEST1")); - vpnor_create_partition_table_from_path(ctx, root.ro().c_str()); + init_vpnor_from_paths(ctx); /* Test */ memset(src, 0xbb, sizeof(src)); |