blob: cb56e518474b019f4eac8a6b9f8492c498b13c1e [file] [log] [blame]
Andrew Jeffery3376dac2018-02-27 17:03:08 +10301// SPDX-License-Identifier: Apache-2.0
2// Copyright (C) 2018 IBM Corp.
Andrew Jeffery3376dac2018-02-27 17:03:08 +10303#include "config.h"
William A. Kennington IIId5f1d402018-10-11 13:55:04 -07004
Andrew Jeffery53c21aa2018-03-26 11:56:16 +10305#include "vpnor/pnor_partition_table.hpp"
Andrew Jeffery3376dac2018-02-27 17:03:08 +10306#include "xyz/openbmc_project/Common/error.hpp"
7
Andrew Jeffery261f61a2019-03-14 09:57:28 +10308#include <cassert>
9#include <cstring>
William A. Kennington IIId5f1d402018-10-11 13:55:04 -070010
Andrew Jeffery3376dac2018-02-27 17:03:08 +103011extern "C" {
12#include "test/mbox.h"
13#include "test/system.h"
14}
15
Andrew Jeffery30bcf842018-03-26 12:13:20 +103016#include "vpnor/test/tmpd.hpp"
Andrew Jeffery3376dac2018-02-27 17:03:08 +103017
18static constexpr auto BLOCK_SIZE = 0x1000;
19static constexpr auto ERASE_SIZE = BLOCK_SIZE;
20static constexpr auto PNOR_SIZE = 64 * 1024 * 1024;
21static constexpr auto MEM_SIZE = 32 * 1024 * 1024;
22static constexpr auto N_WINDOWS = 1;
23static constexpr auto WINDOW_SIZE = BLOCK_SIZE * 2;
24
25const std::string toc[] = {
26 "partition01=ONE,00001000,00002000,80,",
27};
28
29int main()
30{
31 namespace err = sdbusplus::xyz::openbmc_project::Common::Error;
32 namespace test = openpower::virtual_pnor::test;
33 namespace vpnor = openpower::virtual_pnor;
34
35 struct mbox_context* ctx;
36
37 system_set_reserved_size(MEM_SIZE);
38 system_set_mtd_sizes(MEM_SIZE, ERASE_SIZE);
39
Evan Lojewskif1e547c2019-03-14 14:34:33 +103040 ctx = mbox_create_frontend_context(N_WINDOWS, WINDOW_SIZE);
Andrew Jeffery3376dac2018-02-27 17:03:08 +103041
Evan Lojewskif1e547c2019-03-14 14:34:33 +103042 test::VpnorRoot root(&ctx->backend, toc, BLOCK_SIZE);
43 vpnor::partition::Table table(&ctx->backend);
Andrew Jeffery3376dac2018-02-27 17:03:08 +103044
45 try
46 {
47 table.partition("TWO");
48 }
Andrew Jefferyae1edb92018-02-28 23:16:48 +103049 catch (vpnor::UnknownPartition& e)
Andrew Jeffery3376dac2018-02-27 17:03:08 +103050 {
51 return 0;
52 }
53
54 assert(false);
55}