blob: 411e3f846419b283bd576b19623544c7943de761 [file] [log] [blame]
Andrew Jefferya138f562018-02-27 16:58:02 +10301// SPDX-License-Identifier: Apache-2.0
2// Copyright (C) 2018 IBM Corp.
3#include <assert.h>
4#include <string.h>
5
6#include "config.h"
Andrew Jeffery53c21aa2018-03-26 11:56:16 +10307#include "vpnor/pnor_partition_table.hpp"
Andrew Jefferya138f562018-02-27 16:58:02 +10308
9extern "C" {
10#include "test/mbox.h"
11#include "test/system.h"
12}
13
Andrew Jeffery30bcf842018-03-26 12:13:20 +103014#include "vpnor/test/tmpd.hpp"
Andrew Jefferya138f562018-02-27 16:58:02 +103015
16static constexpr auto BLOCK_SIZE = 0x1000;
17static constexpr auto ERASE_SIZE = BLOCK_SIZE;
18static constexpr auto PNOR_SIZE = 64 * 1024 * 1024;
19static constexpr auto MEM_SIZE = 32 * 1024 * 1024;
20static constexpr auto N_WINDOWS = 1;
21static constexpr auto WINDOW_SIZE = BLOCK_SIZE * 2;
22
23const std::string toc[] = {
24 "partition01=ONE,00001000,00002000,80,",
25 "partition02=TWO,00002000,00004000,80,",
26 "partition03=THREE,00004000,00008000,80,",
27};
28
29int main()
30{
31 namespace test = openpower::virtual_pnor::test;
32 namespace vpnor = openpower::virtual_pnor;
33
34 struct mbox_context* ctx;
35
36 system_set_reserved_size(MEM_SIZE);
37 system_set_mtd_sizes(MEM_SIZE, ERASE_SIZE);
38
39 ctx = mbox_create_test_context(N_WINDOWS, WINDOW_SIZE);
40
41 test::VpnorRoot root(ctx, toc, BLOCK_SIZE);
Andrew Jeffery742a1f62018-03-02 09:26:03 +103042 vpnor::partition::Table table(ctx);
Andrew Jefferya138f562018-02-27 16:58:02 +103043
44 const struct pnor_partition& part = table.partition("TWO");
45 assert(part.data.id == 2);
46 assert(part.data.base == 2);
47 assert(part.data.size == 2);
48
49 return 0;
50}