Andrew Jeffery | 3376dac | 2018-02-27 17:03:08 +1030 | [diff] [blame] | 1 | // 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" |
| 7 | #include "pnor_partition_table.hpp" |
| 8 | #include "xyz/openbmc_project/Common/error.hpp" |
| 9 | |
| 10 | extern "C" { |
| 11 | #include "test/mbox.h" |
| 12 | #include "test/system.h" |
| 13 | } |
| 14 | |
| 15 | #include "test/vpnor/tmpd.hpp" |
| 16 | |
| 17 | static constexpr auto BLOCK_SIZE = 0x1000; |
| 18 | static constexpr auto ERASE_SIZE = BLOCK_SIZE; |
| 19 | static constexpr auto PNOR_SIZE = 64 * 1024 * 1024; |
| 20 | static constexpr auto MEM_SIZE = 32 * 1024 * 1024; |
| 21 | static constexpr auto N_WINDOWS = 1; |
| 22 | static constexpr auto WINDOW_SIZE = BLOCK_SIZE * 2; |
| 23 | |
| 24 | const std::string toc[] = { |
| 25 | "partition01=ONE,00001000,00002000,80,", |
| 26 | }; |
| 27 | |
| 28 | int main() |
| 29 | { |
| 30 | namespace err = sdbusplus::xyz::openbmc_project::Common::Error; |
| 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 Jeffery | 742a1f6 | 2018-03-02 09:26:03 +1030 | [diff] [blame] | 42 | vpnor::partition::Table table(ctx); |
Andrew Jeffery | 3376dac | 2018-02-27 17:03:08 +1030 | [diff] [blame] | 43 | |
| 44 | try |
| 45 | { |
| 46 | table.partition("TWO"); |
| 47 | } |
Andrew Jeffery | ae1edb9 | 2018-02-28 23:16:48 +1030 | [diff] [blame] | 48 | catch (vpnor::UnknownPartition& e) |
Andrew Jeffery | 3376dac | 2018-02-27 17:03:08 +1030 | [diff] [blame] | 49 | { |
| 50 | return 0; |
| 51 | } |
| 52 | |
| 53 | assert(false); |
| 54 | } |