Migrate to libyang2
Explanation of some of the changes:
1) New libyang produces different schema paths, that don't include
choice/case nodes. This can be seen in Firewall.cpp.
2) New sysrepo does not use <map>, so it has to be included at multiple
places.
3) getUniqueSubtree is now just one line of code. Another commit can get
rid of it.
4) dataFromSysrepo sometimes gives less and sometimes more data. This is
because it now uses libyang instead of sr_val_t
- When it gives more data it's usually just lists or empty containers,
sr_val_t didn't give those.
- When it gives less data it's also just empty containers. This can
be seen with "sensor-data" in hardware_ietf-hardware.cpp.
Depends-on: https://gerrit.cesnet.cz/c/CzechLight/dependencies/+/5171
Change-Id: I388536269e790b8b74ea7791c79b180adc5d80a6
Co-authored-by: Jan Kundrát <jan.kundrat@cesnet.cz>
diff --git a/tests/sysrepo_system-ietfsystem.cpp b/tests/sysrepo_system-ietfsystem.cpp
index 3ecb96e..0118877 100644
--- a/tests/sysrepo_system-ietfsystem.cpp
+++ b/tests/sysrepo_system-ietfsystem.cpp
@@ -66,7 +66,7 @@
}
auto sysrepo = std::make_shared<velia::system::IETFSystem>(srSess, file, *dbusConnClient, dbusConnServer->getUniqueName());
- REQUIRE(dataFromSysrepo(client, modulePrefix + "/platform", SR_DS_OPERATIONAL) == expected);
+ REQUIRE(dataFromSysrepo(client, modulePrefix + "/platform", sysrepo::Datastore::Operational) == expected);
}
SECTION("Invalid data (missing VERSION and NAME keys)")
@@ -88,20 +88,20 @@
xpath = "/ietf-system:system/contact";
}
- client->session_switch_ds(SR_DS_OPERATIONAL);
- REQUIRE_THROWS_WITH(client->get_item(xpath), "Item not found");
+ client.switchDatastore(sysrepo::Datastore::Operational);
+ REQUIRE(!client.getData(xpath));
- client->session_switch_ds(SR_DS_RUNNING);
- client->set_item_str(xpath, "lamparna");
+ client.switchDatastore(sysrepo::Datastore::Running);
+ client.setItem(xpath, "lamparna");
- REQUIRE(!!client->get_item(xpath));
+ REQUIRE(client.getData(xpath));
}
SECTION("clock")
{
auto sys = std::make_shared<velia::system::IETFSystem>(srSess, CMAKE_CURRENT_SOURCE_DIR "/tests/system/os-release", *dbusConnClient, dbusConnServer->getUniqueName());
- client->session_switch_ds(SR_DS_OPERATIONAL);
- REQUIRE(!!client->get_item("/ietf-system:system-state/clock/current-datetime"));
+ client.switchDatastore(sysrepo::Datastore::Operational);
+ REQUIRE(client.getData("/ietf-system:system-state/clock/current-datetime"));
}
SECTION("DNS resolvers")
@@ -154,7 +154,7 @@
};
}
- REQUIRE(dataFromSysrepo(client, "/ietf-system:system/dns-resolver", SR_DS_OPERATIONAL) == expected);
+ REQUIRE(dataFromSysrepo(client, "/ietf-system:system/dns-resolver", sysrepo::Datastore::Operational) == expected);
}
#ifdef TEST_RPC_SYSTEM_REBOOT