osaf/services/saf/amf/amfd/tests/test_ckpt_enc_dec.cc |  73 +++++++++++++++++-
 1 files changed, 68 insertions(+), 5 deletions(-)


diff --git a/osaf/services/saf/amf/amfd/tests/test_ckpt_enc_dec.cc 
b/osaf/services/saf/amf/amfd/tests/test_ckpt_enc_dec.cc
--- a/osaf/services/saf/amf/amfd/tests/test_ckpt_enc_dec.cc
+++ b/osaf/services/saf/amf/amfd/tests/test_ckpt_enc_dec.cc
@@ -86,20 +86,83 @@ TEST_F(CkptEncDecTest, testEncDecAvdApp)
   char *tmpData = new char[size];
   char *buf = sysf_data_at_start(enc.io_uba.ub, size, tmpData);
   uint32_t offset = sizeof(SaNameT) + sizeof(uint32_t);
-  uint32_t *fld = (uint32_t*) &buf[offset];
-  delete [] tmpData;
+  uint32_t *fld = reinterpret_cast<uint32_t*>(&buf[offset]);
 
   // verify that the encoded value is in network byte order
   if (isLittleEndian()) {
-    ASSERT_EQ(*fld, (uint32_t) 0x11223344);
+    // saAmfApplicationCurrNumSGs
+    ASSERT_EQ(*fld, static_cast<uint32_t>(0x11223344));
   } else {
-    ASSERT_EQ(*fld, (uint32_t) 0x44332211);
+    // saAmfApplicationCurrNumSGs
+    ASSERT_EQ(*fld, static_cast<uint32_t>(0x44332211));
   }
 
+  delete [] tmpData;
+
   memset(&app, '\0', sizeof(AVD_APP));
   decode_app(&enc.io_uba, &app);
 
   ASSERT_EQ(Amf::to_string(&app.name), "AppName");
   ASSERT_EQ(app.saAmfApplicationAdminState, SA_AMF_ADMIN_LOCKED);
-  ASSERT_EQ(app.saAmfApplicationCurrNumSGs, (uint32_t) 0x44332211);
+  ASSERT_EQ(app.saAmfApplicationCurrNumSGs, static_cast<uint32_t>(0x44332211));
 }
+
+TEST_F(CkptEncDecTest, testEncDecAvdComp) {
+  int rc = 0;
+  std::string comp_name{"CompName"};
+  std::string comp_proxy_name{"CompProxyName"};
+  AVD_COMP comp(asSaNameT(comp_name));
+
+  comp.saAmfCompOperState = static_cast<SaAmfOperationalStateT>(0x44332211);
+  comp.saAmfCompReadinessState = static_cast<SaAmfReadinessStateT>(0x55443322);
+  comp.saAmfCompPresenceState = static_cast<SaAmfPresenceStateT>(0x66554433);
+  comp.saAmfCompRestartCount = 0x77665544;
+  comp.saAmfCompCurrProxyName = *(asSaNameT(comp_proxy_name));
+
+  rc = ncs_enc_init_space(&enc.io_uba);
+  ASSERT_TRUE(rc == NCSCC_RC_SUCCESS);
+
+  enc.io_msg_type = NCS_MBCSV_MSG_ASYNC_UPDATE;
+  enc.io_action = NCS_MBCSV_ACT_UPDATE;
+  enc.io_reo_hdl = (MBCSV_REO_HDL) & comp;
+  enc.io_reo_type = AVSV_CKPT_AVD_COMP_CONFIG;
+  enc.i_peer_version = AVD_MBCSV_SUB_PART_VERSION_3;
+
+  encode_comp(&enc.io_uba, &comp);
+  
+  // retrieve AVD_COMP encoded data from the USR buf
+  int32_t size = enc.io_uba.ttl;
+  char *tmpData = new char[size];
+  char *buf = sysf_data_at_start(enc.io_uba.ub, size, tmpData);
+  uint32_t offset = sizeof(SaNameT);
+  uint32_t *fld = reinterpret_cast<uint32_t*>(&buf[offset]);
+  
+  // verify that the encoded value is in network byte order
+  if (isLittleEndian()) {
+    // saAmfCompOperState
+    ASSERT_EQ(*fld++, static_cast<uint32_t>(0x11223344));
+    // saAmfCompReadinessState
+    ASSERT_EQ(*fld++, static_cast<uint32_t>(0x22334455));
+    // saAmfCompPresenceState
+    ASSERT_EQ(*fld, static_cast<uint32_t>(0x33445566));
+  } else {
+    // saAmfCompOperState
+    ASSERT_EQ(*fld++, static_cast<uint32_t>(0x44332211));
+    // saAmfCompReadinessState
+    ASSERT_EQ(*fld++, static_cast<uint32_t>(0x55443322));
+    // saAmfCompPresenceState
+    ASSERT_EQ(*fld, static_cast<uint32_t>(0x66554433));
+  }
+
+  delete [] tmpData;
+
+  memset(&comp, '\0', sizeof (AVD_COMP));
+  decode_comp(&enc.io_uba, &comp);
+
+  ASSERT_EQ(Amf::to_string(&comp.comp_info.name), "CompName");
+  ASSERT_EQ(comp.saAmfCompOperState, 
static_cast<SaAmfOperationalStateT>(0x44332211));
+  ASSERT_EQ(comp.saAmfCompReadinessState, 
static_cast<SaAmfReadinessStateT>(0x55443322));
+  ASSERT_EQ(comp.saAmfCompPresenceState, 
static_cast<SaAmfPresenceStateT>(0x66554433));
+  ASSERT_EQ(comp.saAmfCompRestartCount, static_cast<uint32_t>(0x77665544));
+  ASSERT_EQ(Amf::to_string(&comp.saAmfCompCurrProxyName), "CompProxyName");
+}

------------------------------------------------------------------------------
_______________________________________________
Opensaf-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensaf-devel

Reply via email to