From 30bcf84c932a579532e5f8417af549494e11b6e9 Mon Sep 17 00:00:00 2001 From: Andrew Jeffery Date: Mon, 26 Mar 2018 12:13:20 +1030 Subject: test: Move vpnor tests to vpnor directory In the spirit of things that are together should be kept together. The repository layout now better corresponds to upstream with the exception of the vpnor directory and some modifications to Makefile.am Change-Id: I16d59a3c9ee846065f6a8c83eb4459715d525f3f Signed-off-by: Andrew Jeffery --- vpnor/test/write_ro.cpp | 50 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 vpnor/test/write_ro.cpp (limited to 'vpnor/test/write_ro.cpp') diff --git a/vpnor/test/write_ro.cpp b/vpnor/test/write_ro.cpp new file mode 100644 index 0000000..53eeb18 --- /dev/null +++ b/vpnor/test/write_ro.cpp @@ -0,0 +1,50 @@ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (C) 2018 IBM Corp. + +#include +#include +#include +#include +#include +#include + +#include "common.h" +#include "mbox.h" +#include "mboxd_flash.h" + +#include "vpnor/test/tmpd.hpp" + +static constexpr auto BLOCK_SIZE = 0x1000; + +const std::string toc[] = { + "partition01=TEST1,00001000,00002000,80,ECC,READONLY", +}; + +int main(void) +{ + namespace fs = std::experimental::filesystem; + namespace test = openpower::virtual_pnor::test; + + struct mbox_context _ctx, *ctx = &_ctx; + uint8_t src[8] = {0}; + int rc; + + /* Setup */ + memset(ctx, 0, sizeof(mbox_context)); + + mbox_vlog = &mbox_log_console; + verbosity = (verbose)2; + + test::VpnorRoot root(ctx, toc, BLOCK_SIZE); + init_vpnor_from_paths(ctx); + + /* Test */ + rc = write_flash(ctx, 0x1000, src, sizeof(src)); + + /* Verify we can't write to RO partitions */ + assert(rc != 0); + + destroy_vpnor(ctx); + + return 0; +} -- cgit v1.2.1