tools: specify common ipmi errors for humans

Add a check for common ipmi failure codes to the IPMI exception object
to make the messages more human readable.

Change-Id: If143a3a63748c258b2fdc4fd074cf5070c0b88d9
Signed-off-by: Patrick Venture <venture@google.com>
diff --git a/test/Makefile.am b/test/Makefile.am
index 0b01997..9be5ae4 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -30,7 +30,8 @@
 	tools_blob_unittest \
 	tools_bt_unittest \
 	tools_updater_unittest \
-	tools_ipmi_unittest
+	tools_ipmi_unittest \
+	tools_ipmi_error_unittest
 
 TESTS = $(check_PROGRAMS)
 
@@ -81,3 +82,6 @@
 
 tools_ipmi_unittest_SOURCES = tools_ipmi_unittest.cpp
 tools_ipmi_unittest_LDADD = $(top_builddir)/tools/ipmi_handler.o
+
+tools_ipmi_error_unittest_SOURCES = tools_ipmi_error_unittest.cpp
+tools_ipmi_error_unittest_LDADD =
diff --git a/test/tools_ipmi_error_unittest.cpp b/test/tools_ipmi_error_unittest.cpp
new file mode 100644
index 0000000..86264a1
--- /dev/null
+++ b/test/tools_ipmi_error_unittest.cpp
@@ -0,0 +1,28 @@
+#include "ipmi_errors.hpp"
+
+#include <gtest/gtest.h>
+
+namespace host_tool
+{
+
+TEST(IpmiExceptionTest, VerifyTimedOutIsString)
+{
+    /* Verify that throwing the exception with the cc code for timed out gets
+     * converted to the human readable string.
+     */
+    bool verified = false;
+
+    try
+    {
+        throw IpmiException(0xc3);
+    }
+    catch (const IpmiException& i)
+    {
+        EXPECT_STREQ("Received IPMI_CC: timeout", i.what());
+        verified = true;
+    }
+
+    EXPECT_TRUE(verified);
+}
+
+} // namespace host_tool