summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDeepak Kodihalli <dkodihal@in.ibm.com>2016-12-02 07:10:14 -0600
committerDeepak Kodihalli <dkodihal@in.ibm.com>2016-12-08 12:40:08 -0600
commit79f9eee0da046577955a68d647b011c1850bec9b (patch)
treed76f3b9bf63936049fba9c443b985562042ed00c
parent901c5d92d10cc23c52d9ff306b3ecea276ce67a4 (diff)
downloadopenpower-vpd-parser-79f9eee0da046577955a68d647b011c1850bec9b.tar.gz
openpower-vpd-parser-79f9eee0da046577955a68d647b011c1850bec9b.zip
tests: unit-test for parse() API
Change-Id: I9912102d442f2c00ce70514a4a65f25e1552fc19 Signed-off-by: Deepak Kodihalli <dkodihal@in.ibm.com>
-rw-r--r--.gitignore5
-rw-r--r--test/Makefile.am7
-rw-r--r--test/parser/parser.cpp30
-rw-r--r--test/test.vpdbin0 -> 165 bytes
4 files changed, 42 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
index 5422c9f..71665e0 100644
--- a/.gitignore
+++ b/.gitignore
@@ -19,3 +19,8 @@ openpower-read-vpd
*.lo
*.la
test-driver
+*.dirstamp
+parser_test
+store_test
+*.log
+*.trs
diff --git a/test/Makefile.am b/test/Makefile.am
index 71591f0..428cd0b 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -6,3 +6,10 @@ TESTS = $(check_PROGRAMS)
check_PROGRAMS += store_test
store_test_SOURCES = store/store.cpp
+
+check_PROGRAMS += parser_test
+parser_test_SOURCES = \
+ parser/parser.cpp \
+ ../impl.cpp \
+ ../parser.cpp \
+ ../write.cpp
diff --git a/test/parser/parser.cpp b/test/parser/parser.cpp
new file mode 100644
index 0000000..eda30af
--- /dev/null
+++ b/test/parser/parser.cpp
@@ -0,0 +1,30 @@
+#include <defines.hpp>
+#include <store.hpp>
+#include <parser.hpp>
+#include <cassert>
+#include <fstream>
+#include <iterator>
+
+void runTests()
+{
+ using namespace openpower::vpd;
+
+ // Test parse() API
+ {
+ std::ifstream vpdFile("test.vpd", std::ios::binary);
+ Binary vpd((std::istreambuf_iterator<char>(vpdFile)),
+ std::istreambuf_iterator<char>());
+
+ auto vpdStore = parse(std::move(vpd));
+
+ assert(("P012" ==
+ vpdStore.get<Record::VINI, record::Keyword::CC>()));
+ }
+}
+
+int main()
+{
+ runTests();
+
+ return 0;
+}
diff --git a/test/test.vpd b/test/test.vpd
new file mode 100644
index 0000000..bc4fc0e
--- /dev/null
+++ b/test/test.vpd
Binary files differ
OpenPOWER on IntegriCloud