summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Jeffery <andrew@aj.id.au>2018-02-22 15:34:17 +1030
committerAndrew Jeffery <andrew@aj.id.au>2018-03-24 13:59:32 +1030
commit32476cb46ba69a6b5890a5372fa050de6c0a43c1 (patch)
treecb28f622f6929263518e5619f5eeeaac089ac1ce
parente4cf6ac8d9ae6a1398b9f3510ac4939de0148001 (diff)
downloadphosphor-mboxd-32476cb46ba69a6b5890a5372fa050de6c0a43c1.tar.gz
phosphor-mboxd-32476cb46ba69a6b5890a5372fa050de6c0a43c1.zip
test: tmpd: Populate path members under struct mbox_context
Change-Id: I9d18bd108d1c0972a5fefa384152757a2483c103 Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
-rw-r--r--test/vpnor/create_pnor_partition_table.cpp4
-rw-r--r--test/vpnor/create_read_window_vpnor.cpp19
-rw-r--r--test/vpnor/tmpd.hpp13
-rw-r--r--test/vpnor/write_flash_vpnor.cpp7
4 files changed, 22 insertions, 21 deletions
diff --git a/test/vpnor/create_pnor_partition_table.cpp b/test/vpnor/create_pnor_partition_table.cpp
index 98d474b..09f481d 100644
--- a/test/vpnor/create_pnor_partition_table.cpp
+++ b/test/vpnor/create_pnor_partition_table.cpp
@@ -20,7 +20,9 @@ namespace test = openpower::virtual_pnor::test;
int main()
{
- test::VpnorRoot root(toc, BLOCK_SIZE);
+ struct mbox_context _ctx, *ctx = &_ctx;
+
+ test::VpnorRoot root(ctx, toc, BLOCK_SIZE);
const openpower::virtual_pnor::partition::Table table(root.ro(), BLOCK_SIZE,
PNOR_SIZE);
diff --git a/test/vpnor/create_read_window_vpnor.cpp b/test/vpnor/create_read_window_vpnor.cpp
index 5adb044..87deb9c 100644
--- a/test/vpnor/create_read_window_vpnor.cpp
+++ b/test/vpnor/create_read_window_vpnor.cpp
@@ -65,24 +65,17 @@ namespace test = openpower::virtual_pnor::test;
int main()
{
- fs::path path;
- const char *cpath;
-
- test::VpnorRoot root(toc, BLOCK_SIZE);
- root.write("HBB", data, sizeof(data));
-
- path = root.ro();
- cpath = path.c_str();
+ struct mbox_context *ctx;
system_set_reserved_size(MEM_SIZE);
system_set_mtd_sizes(MEM_SIZE, ERASE_SIZE);
- struct mbox_context *ctx = mbox_create_test_context(N_WINDOWS, WINDOW_SIZE);
- strcpy(ctx->paths.ro_loc, cpath);
- strcpy(ctx->paths.rw_loc, cpath);
- strcpy(ctx->paths.prsv_loc, cpath);
+ ctx = mbox_create_test_context(N_WINDOWS, WINDOW_SIZE);
+
+ test::VpnorRoot root(ctx, toc, BLOCK_SIZE);
+ root.write("HBB", data, sizeof(data));
- vpnor_create_partition_table_from_path(ctx, cpath);
+ vpnor_create_partition_table_from_path(ctx, root.ro().c_str());
int rc = mbox_command_dispatch(ctx, get_info, sizeof(get_info));
assert(rc == 1);
diff --git a/test/vpnor/tmpd.hpp b/test/vpnor/tmpd.hpp
index 28d27c9..8ff40ad 100644
--- a/test/vpnor/tmpd.hpp
+++ b/test/vpnor/tmpd.hpp
@@ -8,6 +8,7 @@
#include <experimental/filesystem>
#include "config.h"
+#include "mbox.h"
#include "pnor_partition_table.hpp"
namespace openpower
@@ -23,7 +24,8 @@ class VpnorRoot
{
public:
template <std::size_t N>
- VpnorRoot(const std::string (&toc)[N], size_t blockSize)
+ VpnorRoot(struct mbox_context* ctx, const std::string (&toc)[N],
+ size_t blockSize)
{
char tmplt[] = "/tmp/vpnor_root.XXXXXX";
char* tmpdir = mkdtemp(tmplt);
@@ -51,6 +53,15 @@ class VpnorRoot
/* Update the ToC if the partition file was created */
std::ofstream(tocFilePath, std::ofstream::app) << line << "\n";
}
+
+ strncpy(ctx->paths.ro_loc, ro().c_str(), PATH_MAX - 1);
+ ctx->paths.ro_loc[PATH_MAX - 1] = '\0';
+ strncpy(ctx->paths.rw_loc, rw().c_str(), PATH_MAX - 1);
+ ctx->paths.rw_loc[PATH_MAX - 1] = '\0';
+ strncpy(ctx->paths.prsv_loc, prsv().c_str(), PATH_MAX - 1);
+ ctx->paths.prsv_loc[PATH_MAX - 1] = '\0';
+ strncpy(ctx->paths.patch_loc, patch().c_str(), PATH_MAX - 1);
+ ctx->paths.patch_loc[PATH_MAX - 1] = '\0';
}
VpnorRoot(const VpnorRoot&) = delete;
diff --git a/test/vpnor/write_flash_vpnor.cpp b/test/vpnor/write_flash_vpnor.cpp
index 384c13a..c53e8da 100644
--- a/test/vpnor/write_flash_vpnor.cpp
+++ b/test/vpnor/write_flash_vpnor.cpp
@@ -80,11 +80,6 @@ void init(struct mbox_context* ctx, test::VpnorRoot& root)
ctx->block_size_shift = BLOCK_SIZE_SHIFT;
ctx->flash_bmap = reinterpret_cast<uint8_t*>(
calloc(MEM_SIZE >> ctx->erase_size_shift, sizeof(*ctx->flash_bmap)));
-
- strcpy(ctx->paths.ro_loc, root.ro().c_str());
- strcpy(ctx->paths.rw_loc, root.rw().c_str());
- strcpy(ctx->paths.prsv_loc, root.prsv().c_str());
- strcpy(ctx->paths.patch_loc, root.patch().c_str());
}
int main(void)
@@ -97,7 +92,7 @@ int main(void)
struct mbox_context* ctx = &context;
memset(ctx, 0, sizeof(mbox_context));
- test::VpnorRoot root(toc, BLOCK_SIZE);
+ test::VpnorRoot root(ctx, toc, BLOCK_SIZE);
// Initialize the context before running the test case.
init(ctx, root);
OpenPOWER on IntegriCloud