]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#65,!18] Unit-test added for sanity checking the environment.
authorTomek Mrugalski <tomasz@isc.org>
Mon, 10 Sep 2018 19:41:05 +0000 (21:41 +0200)
committerFrancis Dupont <fdupont@isc.org>
Wed, 12 Sep 2018 13:37:38 +0000 (15:37 +0200)
src/lib/yang/tests/translator_unittests.cc

index 49ab57d659cf1bfe3e10ac64ff0193665220b0e7..263de9be909769a86a2263fbb089c012fcb83542 100644 (file)
@@ -18,6 +18,41 @@ using namespace isc::yang;
 
 namespace {
 
+const std::string TEST_MODULE="example-module";
+
+// This test verifies if there are test models installed and accessible.
+// To run those tests properly, the following models need to be installed:
+// - example-module
+// - test-module
+TEST(TranslatorBasicTest, testEnvironmentCheck) {
+    // Get a connection.
+    S_Connection conn(new Connection("translator unittests"));
+    // Get a session.
+    S_Session sess(new Session(conn, SR_DS_CANDIDATE));
+
+    S_Yang_Schemas schemas = sess->list_schemas();
+
+    size_t schema_cnt = schemas->schema_cnt();
+    std::cout << "There are " << schema_cnt << " YANG schema(s) installed:" << endl;
+
+    bool found = false;
+    for (int i = 0; i < schema_cnt; i++) {
+        string name(schemas->schema(i)->module_name());
+        if (name == TEST_MODULE) {
+            found = true;
+        }
+        std::cout << "Schema " << i << ": " << name << endl;
+    }
+
+    EXPECT_TRUE(found) << "\nERROR: Module used in unit-tests " << TEST_MODULE
+                       << " is not installed. The environment is not suitable for\n"
+                       << "ERROR: running unit-tests. Please locate example-module.yang "
+                       << "and issue the following command:\n"
+                       << "ERROR: sysrepoctl --install --yang=example-module.yang\n"
+                       << "ERROR:\n"
+                       << "ERROR: Following tests will most likely fail.\n";
+}
+
 // Test constructor.
 TEST(TranslatorBasicTest, constructor) {
     // Get a connection.