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>
diff --git a/mboxd_pnor_partition_table.cpp b/mboxd_pnor_partition_table.cpp
index e58b019..db53dc8 100644
--- a/mboxd_pnor_partition_table.cpp
+++ b/mboxd_pnor_partition_table.cpp
@@ -26,17 +26,17 @@
         strncpy(context->paths.patch_loc, PARTITION_FILES_PATCH_LOC, PATH_MAX);
         context->paths.prsv_loc[PATH_MAX - 1] = '\0';
 
-        rc = vpnor_create_partition_table_from_path(context,
-                                                    PARTITION_FILES_RO_LOC);
+        rc = init_vpnor_from_paths(context);
         if (rc < 0)
+        {
             return rc;
+        }
     }
 
     return 0;
 }
 
-int vpnor_create_partition_table_from_path(struct mbox_context *context,
-                                           const char *path)
+int init_vpnor_from_paths(struct mbox_context *context)
 {
     namespace err = sdbusplus::xyz::openbmc_project::Common::Error;
     namespace fs = std::experimental::filesystem;
@@ -44,14 +44,11 @@
 
     if (context && !context->vpnor)
     {
-        fs::path dir(path);
         try
         {
             context->vpnor = new vpnor_partition_table;
             context->vpnor->table =
-                new openpower::virtual_pnor::partition::Table(
-                    std::move(dir), 1 << context->erase_size_shift,
-                    context->flash_size);
+                new openpower::virtual_pnor::partition::Table(context);
         }
         catch (vpnor::TocEntryError &e)
         {
@@ -87,17 +84,14 @@
 
     try
     {
-        openpower::virtual_pnor::partition::Table blTable(
-            fs::path{PARTITION_FILES_RO_LOC}, eraseSize, pnorSize);
-
         vpnor_partition_table vtbl{};
-        vtbl.table = &blTable;
-        struct mbox_context local
-        {
-        };
+        struct mbox_context local = *context;
         local.vpnor = &vtbl;
         local.block_size_shift = log_2(eraseSize);
-        memcpy(&local.paths, &context->paths, sizeof(local.paths));
+
+        openpower::virtual_pnor::partition::Table blTable(&local);
+
+        vtbl.table = &blTable;
 
         size_t tocOffset = 0;