1 // SPDX-License-Identifier: Apache-2.0 2 // Copyright (C) 2018 IBM Corp. 3 4 #include "config.h" 5 6 #include "vpnor/pnor_partition_table.hpp" 7 8 #include <cassert> 9 10 #include "common.h" 11 #include "vpnor/pnor_partition_defs.h" 12 13 static constexpr auto BLOCK_SIZE = 4 * 1024; 14 static constexpr auto DATA_MASK = ((1 << 24) - 1); 15 16 int main() 17 { 18 namespace vpnor = openpower::virtual_pnor; 19 20 struct pnor_partition part; 21 std::string line; 22 23 mbox_vlog = mbox_log_console; 24 verbosity = MBOX_LOG_DEBUG; 25 26 line = "partition01=FOO,00001000,00002000,80,ECC"; 27 vpnor::parseTocLine(line, BLOCK_SIZE, part); 28 assert((part.data.user.data[0]) == PARTITION_ECC_PROTECTED); 29 assert(!(part.data.user.data[1] & DATA_MASK)); 30 31 line = "partition01=FOO,00001000,00002000,80,PRESERVED"; 32 vpnor::parseTocLine(line, BLOCK_SIZE, part); 33 assert(!(part.data.user.data[0])); 34 assert((part.data.user.data[1] & DATA_MASK) == PARTITION_PRESERVED); 35 36 line = "partition01=FOO,00001000,00002000,80,READONLY"; 37 vpnor::parseTocLine(line, BLOCK_SIZE, part); 38 assert(!(part.data.user.data[0])); 39 assert((part.data.user.data[1] & DATA_MASK) == PARTITION_READONLY); 40 41 /* BACKUP is unimplemented */ 42 line = "partition01=FOO,00001000,00002000,80,BACKUP"; 43 vpnor::parseTocLine(line, BLOCK_SIZE, part); 44 assert(!(part.data.user.data[0])); 45 assert(!(part.data.user.data[1] & DATA_MASK)); 46 47 line = "partition01=FOO,00001000,00002000,80,REPROVISION"; 48 vpnor::parseTocLine(line, BLOCK_SIZE, part); 49 assert(!(part.data.user.data[0])); 50 assert((part.data.user.data[1] & DATA_MASK) == PARTITION_REPROVISION); 51 52 line = "partition01=FOO,00001000,00002000,80,VOLATILE"; 53 vpnor::parseTocLine(line, BLOCK_SIZE, part); 54 assert(!(part.data.user.data[0])); 55 assert((part.data.user.data[1] & DATA_MASK) == PARTITION_VOLATILE); 56 57 line = "partition01=FOO,00001000,00002000,80,CLEARECC"; 58 vpnor::parseTocLine(line, BLOCK_SIZE, part); 59 assert(!(part.data.user.data[0])); 60 assert((part.data.user.data[1] & DATA_MASK) == PARTITION_CLEARECC); 61 62 line = "partition01=FOO,00001000,00002000,80,READWRITE"; 63 vpnor::parseTocLine(line, BLOCK_SIZE, part); 64 assert(!(part.data.user.data[0])); 65 assert(((part.data.user.data[1] & DATA_MASK) ^ PARTITION_READONLY) == 66 PARTITION_READONLY); 67 68 line = "partition01=FOO,00001000,00002000,80,"; 69 vpnor::parseTocLine(line, BLOCK_SIZE, part); 70 assert(!(part.data.user.data[0])); 71 assert(!(part.data.user.data[1] & DATA_MASK)); 72 73 line = "partition01=FOO,00001000,00002000,80,junk"; 74 vpnor::parseTocLine(line, BLOCK_SIZE, part); 75 assert(!(part.data.user.data[0])); 76 assert(!(part.data.user.data[1] & DATA_MASK)); 77 78 return 0; 79 } 80