FIX: vsm_lookup_zone_by_id, vsm_zone_get_netdevs; test added 28/37528/4
authorMateusz Malicki <m.malicki2@samsung.com>
Mon, 30 Mar 2015 13:37:40 +0000 (15:37 +0200)
committerDariusz Michaluk <d.michaluk@samsung.com>
Mon, 30 Mar 2015 15:41:25 +0000 (08:41 -0700)
[BUG]           Can't get return parameters from vsm_lookup_zone_by_id.
                Segfault when calling zone_get_netdevs.
[Cause]         Return type should by (siss) not ((siss)); parameters aren't set properly.
                Wrong return type in vsm_zone_get_netdevs (NetDevList instead GetNetDevAttrs).
[Solution]      Return type changed.
                Added ClientSuite/LookupZoneById, ClientSuite/ZoneGetNetdevs tests.
[Verification]  Run ClientSuite test

Change-Id: I56365571aef20ecf445b5a89b6edf94abd567a35

client/vasum-client-impl.cpp
server/host-connection.cpp
server/host-dbus-definitions.hpp
server/zones-manager.cpp
tests/unit_tests/client/ut-client.cpp

index f4d8580..4f3a05c 100644 (file)
@@ -491,15 +491,12 @@ VsmStatus Client::vsm_lookup_zone_by_id(const char* id, VsmZone* zone) noexcept
     VsmStatus ret = callMethod(HOST_INTERFACE,
                                api::host::METHOD_GET_ZONE_INFO,
                                args_in,
-                               "((siss))",
+                               "(siss)",
                                &out);
     if (ret != VSMCLIENT_SUCCESS) {
         return ret;
     }
-    GVariant* unpacked;
-    g_variant_get(out, "(*)", &unpacked);
-    toBasic(unpacked, zone);
-    g_variant_unref(unpacked);
+    toBasic(out, zone);
     g_variant_unref(out);
     return ret;
 }
index f3cbfa0..1bdd790 100644 (file)
@@ -355,7 +355,7 @@ void HostConnection::onMessageCall(const std::string& objectPath,
         config::loadFromGVariant(parameters, data);
 
         if (mGetNetdevListCallback) {
-            auto rb = std::make_shared<api::DbusMethodResultBuilder<api::GetNetDevAttrs>>(result);
+            auto rb = std::make_shared<api::DbusMethodResultBuilder<api::NetDevList>>(result);
             mGetNetdevListCallback(data, rb);
         }
         return;
index 1e6fecc..7476bb5 100644 (file)
@@ -91,7 +91,10 @@ const std::string DEFINITION =
     "    </method>"
     "    <method name='" + METHOD_GET_ZONE_INFO + "'>"
     "      <arg type='s' name='id' direction='in'/>"
-    "      <arg type='(siss)' name='result' direction='out'/>"
+    "      <arg type='s' name='id' direction='out'/>"
+    "      <arg type='i' name='vt' direction='out'/>"
+    "      <arg type='s' name='state' direction='out'/>"
+    "      <arg type='s' name='rootPath' direction='out'/>"
     "    </method>"
     "    <method name='" + METHOD_SET_NETDEV_ATTRS + "'>"
     "      <arg type='s' name='zone' direction='in'/>"
index 4f34a76..d3e802b 100644 (file)
@@ -810,6 +810,9 @@ void ZonesManager::handleGetZoneInfoCall(const api::ZoneId& zoneId,
         return;
     }
 
+    zoneInfo->id = zone.getId();
+    zoneInfo->vt = zone.getVT();
+    zoneInfo->rootPath = zone.getRootPath();
     result->set(zoneInfo);
 }
 
index 197da5e..40372f4 100644 (file)
@@ -221,6 +221,26 @@ BOOST_AUTO_TEST_CASE(GetActiveZoneId)
     vsm_client_free(client);
 }
 
+BOOST_AUTO_TEST_CASE(LookupZoneById)
+{
+    const std::string activeZoneId = "zone1";
+
+    VsmClient client = vsm_client_create();
+    VsmStatus status = vsm_connect(client);
+    BOOST_REQUIRE_EQUAL(VSMCLIENT_SUCCESS, status);
+    VsmZone info;
+    status = vsm_lookup_zone_by_id(client, activeZoneId.c_str(), &info);
+    BOOST_REQUIRE_EQUAL(VSMCLIENT_SUCCESS, status);
+
+    BOOST_CHECK_EQUAL(info->id, activeZoneId);
+    BOOST_CHECK_EQUAL(info->state, RUNNING);
+    BOOST_CHECK_EQUAL(info->terminal, -1);
+    BOOST_CHECK_EQUAL(info->rootfs_path, "/tmp/ut-zones/" + activeZoneId + "/rootfs");
+
+    vsm_zone_free(info);
+    vsm_client_free(client);
+}
+
 BOOST_AUTO_TEST_CASE(SetActiveZone)
 {
     const std::string newActiveZoneId = "zone2";
@@ -425,4 +445,27 @@ BOOST_AUTO_TEST_CASE(Provision)
     vsm_client_free(client);
 }
 
+BOOST_AUTO_TEST_CASE(ZoneGetNetdevs)
+{
+    const std::string activeZoneId = "zone1";
+
+    VsmClient client = vsm_client_create();
+    VsmStatus status = vsm_connect(client);
+    BOOST_REQUIRE_EQUAL(VSMCLIENT_SUCCESS, status);
+    VsmArrayString netdevs;
+    status = vsm_zone_get_netdevs(client, activeZoneId.c_str(), &netdevs);
+    BOOST_REQUIRE_EQUAL(VSMCLIENT_SUCCESS, status);
+    BOOST_REQUIRE(netdevs != NULL);
+    vsm_array_string_free(netdevs);
+    vsm_client_free(client);
+}
+
+//TODO: We need createBridge from vasum::netdev
+//BOOST_AUTO_TEST_CASE(CreateDestroyNetdev)
+//BOOST_AUTO_TEST_CASE(LookupNetdev)
+//BOOST_AUTO_TEST_CASE(GetSetDeleteIpAddr)
+//BOOST_AUTO_TEST_CASE(NetdevUpDown)
+
+
+
 BOOST_AUTO_TEST_SUITE_END()