5 #ifndef OPENTITAN_SW_DEVICE_SILICON_CREATOR_LIB_ERROR_UNITTEST_UTIL_H_
6 #define OPENTITAN_SW_DEVICE_SILICON_CREATOR_LIB_ERROR_UNITTEST_UTIL_H_
14 #include "sw/device/silicon_creator/lib/error.h"
16 const inline std::map<std::string, uint32_t> &GetErrorMap() {
17 #define STRINGIFY(x) #x
18 #define ERROR_MAP_INIT(name, value) \
19 { STRINGIFY(name), value }
20 static std::map<std::string, uint32_t> errors = {
21 DEFINE_ERRORS(ERROR_MAP_INIT)};
27 const inline std::map<uint32_t, std::string> &GetErrorToStringMap() {
28 #define STRINGIFY(x) #x
29 #define ERROR_MAP_INIT(name, value) \
30 { value, STRINGIFY(name) }
31 static std::map<uint32_t, std::string> errors = {
32 DEFINE_ERRORS(ERROR_MAP_INIT)};
41 void inline PrintTo(
const rom_error_t &err, std::ostream *os) {
42 const std::map<uint32_t, std::string> &error_to_string_map =
43 GetErrorToStringMap();
45 if (error_to_string_map.count(err)) {
46 *os << error_to_string_map.at(err);
48 *os <<
"Unrecognized rom_error_t value";
50 *os <<
" (0x" << std::hex << err <<
")";