]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#65,!30] Added test that loads and verified trees from yang_configs.h
authorTomek Mrugalski <tomasz@isc.org>
Tue, 23 Oct 2018 19:03:56 +0000 (21:03 +0200)
committerFrancis Dupont <fdupont@isc.org>
Wed, 24 Oct 2018 13:50:51 +0000 (15:50 +0200)
src/lib/yang/tests/translator_utils_unittests.cc
src/lib/yang/tests/yang_configs.h

index 5fa1caecd6cfbf6f4ca83ded8845a3ef0147acb6..103f1f6b6da58a0963013c794fb731ff8f4838fe 100644 (file)
@@ -202,4 +202,37 @@ TEST(YangReprTest, setTest) {
     EXPECT_TRUE(repr.verify(testTree, sess, cerr));
 }
 
+
+/// @brief Tests specified configuration.
+///
+/// Configuration is set and then verified using YangRepr object.
+///
+/// @param model name of the model to be verified against
+/// @param tree tree to be verified
+void sanityCheckConfig(const std::string& model, const YRTree& tree) {
+    // Get a translator object to play with.
+    S_Connection conn(new Connection("utils unittests"));
+    S_Session sess(new Session(conn, SR_DS_CANDIDATE));
+
+    // Get it.
+    YangRepr repr(model);
+
+    EXPECT_NO_THROW(repr.set(tree, sess))
+        << " for model " << model;
+    bool result = false;
+    EXPECT_NO_THROW(result = repr.verify(tree, sess, cerr))
+        << " for model " << model;
+    EXPECT_TRUE(result);
+}
+
+// This is test environment sanity check. It verifies that every configuration
+// defined in yang_configs.h is sane.
+TEST(YangReprTest, verifyConfigs) {
+    for (auto x : test_configs) {
+        cout << "Testing tree for model " << x.first << endl;
+        sanityCheckConfig(x.first, x.second);
+    }
+}
+
+
 }; // end of anonymous namespace
index 540885286d03493b4e3e6d730d63752d4a822804..04573b1a1ad791f0eb0bd88ba8d215ad31411dcb 100644 (file)
@@ -442,6 +442,20 @@ const YRTree designExampleTree = {
       "disabled", SR_ENUM_T, true }
 };
 
+/// @brief Set of example configurations
+const std::map<std::string, YRTree> test_configs =
+{
+    { exampleModel, exampleTree },
+    { testModel, testTree },
+    { subnetTwoPoolsModelIetf6, subnetTwoPoolsTreeIetf6 },
+    { subnetTimersModel, subnetTimersIetf6 },
+    { validModelIetf6, validTreeIetf6 },
+    { subnetOptionsModelKeaDhcp4, subnetOptionsTreeKeaDhcp4 },
+    { subnetOptionsModelKeaDhcp6, subnetOptionsTreeKeaDhcp6 },
+    { designExampleModel, designExampleTree }
+};
+
+
 }; // end of namespace isc::yang::test
 }; // end of namespace isc::yang
 }; // end of namespace isc