[openib-general] [PATCH] Opensm - osmt_service.c fixes - take #2

Yael Kalka yael at mellanox.co.il
Wed Feb 15 02:35:42 PST 2006


Hi Hal,

The following patch add the following to osmt_service.c:
1. Currently, the flow sometimes exits with "TEST PATH" although the test
actually fails.
2. Added cleanup of all the services created at the end of the test.
3. Cosmetic cleanups of the code.

Thanks,
Yael

Signed-off-by:  Yael Kalka <yael at mellanox.co.il>

Index: osmtest/osmt_service.c
===================================================================
--- osmtest/osmt_service.c	(revision 5403)
+++ osmtest/osmt_service.c	(working copy)
@@ -80,7 +80,7 @@ osmt_register_service( IN osmtest_t * co
 
   osm_log( &p_osmt->log, OSM_LOG_INFO,
            "osmt_register_service: "
-           "Registering Service: name:%s id:0x%" PRIx64 ".\n",
+           "Registering service: name:%s id:0x%" PRIx64 "\n",
            service_name, cl_ntoh64(service_id));
 
   cl_memclr( &req, sizeof( req ) );
@@ -140,8 +140,8 @@ osmt_register_service( IN osmtest_t * co
   if( status != IB_SUCCESS )
   {
     osm_log( &p_osmt->log, OSM_LOG_ERROR,
-             "osmt_register_service: ERR 0303: "
-             "ib_query failed (%s).\n", ib_get_err_str( status ) );
+             "osmt_register_service: ERR 4A01: "
+             "ib_query failed (%s)\n", ib_get_err_str( status ) );
     goto Exit;
   }
 
@@ -150,14 +150,14 @@ osmt_register_service( IN osmtest_t * co
   if( status != IB_SUCCESS )
   {
     osm_log( &p_osmt->log, OSM_LOG_ERROR,
-             "osmt_register_service: ERR 0364: "
-             "ib_query failed (%s).\n", ib_get_err_str( status ) );
+             "osmt_register_service: ERR 4A02: "
+             "ib_query failed (%s)\n", ib_get_err_str( status ) );
 
     if( status == IB_REMOTE_ERROR )
     {
       osm_log( &p_osmt->log, OSM_LOG_ERROR,
                "osmt_register_service: "
-               "Remote error = %s.\n",
+               "Remote error = %s\n",
                ib_get_mad_status_str( osm_madw_get_mad_ptr
                                       ( context.result.
                                         p_result_madw ) ) );
@@ -195,7 +195,7 @@ osmt_register_service_with_full_key ( IN
 
   osm_log( &p_osmt->log, OSM_LOG_INFO,
            "osmt_register_service_with_full_key: "
-           "Registering Service: name:%s id:0x%" PRIx64 ".\n",
+           "Registering service: name:%s id:0x%" PRIx64 "\n",
            service_name, cl_ntoh64(service_id));
 
   cl_memclr( &req, sizeof( req ) );
@@ -256,8 +256,8 @@ osmt_register_service_with_full_key ( IN
   if( status != IB_SUCCESS )
   {
     osm_log( &p_osmt->log, OSM_LOG_ERROR,
-             "osmt_register_service_with_full_key: ERR 0303: "
-             "ib_query failed (%s).\n", ib_get_err_str( status ) );
+             "osmt_register_service_with_full_key: ERR 4A03: "
+             "ib_query failed (%s)\n", ib_get_err_str( status ) );
     goto Exit;
   }
 
@@ -280,7 +280,7 @@ osmt_register_service_with_full_key ( IN
     status = IB_REMOTE_ERROR;
     osm_log( &p_osmt->log, OSM_LOG_ERROR,
              "osmt_register_service_with_full_key:"
-             "Data mismatch in service_key.\n"
+             "Data mismatch in service_key\n"
              );
     goto Exit;
   }
@@ -288,14 +288,14 @@ osmt_register_service_with_full_key ( IN
   if( status != IB_SUCCESS )
   {
     osm_log( &p_osmt->log, OSM_LOG_ERROR,
-             "osmt_register_service_with_full_key: ERR 0364: "
-             "ib_query failed (%s).\n", ib_get_err_str( status ) );
+             "osmt_register_service_with_full_key: ERR 4A04: "
+             "ib_query failed (%s)\n", ib_get_err_str( status ) );
 
     if( status == IB_REMOTE_ERROR )
     {
       osm_log( &p_osmt->log, OSM_LOG_ERROR,
                "osmt_register_service_with_full_key: "
-               "Remote error = %s.\n",
+               "Remote error = %s\n",
                ib_get_mad_status_str( osm_madw_get_mad_ptr
                                       ( context.result.
                                         p_result_madw ) ) );
@@ -337,7 +337,7 @@ osmt_register_service_with_data( IN osmt
 
   osm_log( &p_osmt->log, OSM_LOG_INFO,
            "osmt_register_service_with_data: "
-           "Registering Service: name:%s id:0x%" PRIx64 ".\n",
+           "Registering service: name:%s id:0x%" PRIx64 "\n",
            service_name, cl_ntoh64(service_id));
 
   cl_memclr( &req, sizeof( req ) );
@@ -426,8 +426,8 @@ osmt_register_service_with_data( IN osmt
   if( status != IB_SUCCESS )
   {
     osm_log( &p_osmt->log, OSM_LOG_ERROR,
-             "osmt_register_service_with_data: ERR 0303: "
-             "ib_query failed (%s).\n", ib_get_err_str( status ) );
+             "osmt_register_service_with_data: ERR 4A05: "
+             "ib_query failed (%s)\n", ib_get_err_str( status ) );
     goto Exit;
   }
 
@@ -436,14 +436,14 @@ osmt_register_service_with_data( IN osmt
   if( status != IB_SUCCESS )
   {
     osm_log( &p_osmt->log, OSM_LOG_ERROR,
-             "osmt_register_service_with_data: ERR 0364: "
-             "ib_query failed (%s).\n", ib_get_err_str( status ) );
+             "osmt_register_service_with_data: ERR 4A06: "
+             "ib_query failed (%s)\n", ib_get_err_str( status ) );
 
     if( status == IB_REMOTE_ERROR )
     {
       osm_log( &p_osmt->log, OSM_LOG_ERROR,
                "osmt_register_service_with_data: "
-               "Remote error = %s.\n",
+               "Remote error = %s\n",
                ib_get_mad_status_str( osm_madw_get_mad_ptr
                                       ( context.result.
                                         p_result_madw ) ) );
@@ -464,7 +464,7 @@ osmt_register_service_with_data( IN osmt
     status = IB_REMOTE_ERROR;
     osm_log( &p_osmt->log, OSM_LOG_ERROR,
              "osmt_register_service_with_data: "
-             "Data mismatch in service_data8.\n"
+             "Data mismatch in service_data8\n"
              );
     goto Exit;
   }
@@ -499,7 +499,7 @@ osmt_get_service_by_id_and_name ( IN osm
   if( osm_log_is_active( &p_osmt->log, OSM_LOG_VERBOSE ) )
     osm_log( &p_osmt->log, OSM_LOG_VERBOSE,
              "osmt_get_service_by_id_and_name: "
-             "Getting Service Record by id  0x%016" PRIx64 " and name : %s\n",
+             "Getting service record: id:0x%016" PRIx64 " and name:%s\n",
              cl_ntoh64(sid),sr_name);
 
   /*
@@ -509,26 +509,29 @@ osmt_get_service_by_id_and_name ( IN osm
    *
    * The query structures are locals.
    */
-  cl_memclr( &svc_rec, sizeof( svc_rec ) );
   cl_memclr( &req, sizeof( req ) );
   cl_memclr( &context, sizeof( context ) );
-  cl_memclr( &user, sizeof( user ) );
-  /* set the new service record fields */
-  cl_memclr(svc_rec.service_name, sizeof(svc_rec.service_name));
-  cl_memcpy(svc_rec.service_name, sr_name,
-            (strlen(sr_name)+1)*sizeof(char));
-  svc_rec.service_id = sid;
-  /* prepare the data used for this query */
+
   context.p_osmt = p_osmt;
+
+  /* prepare the data used for this query */
   req.query_type = OSMV_QUERY_USER_DEFINED;
   req.timeout_ms = p_osmt->opt.transaction_timeout;
   req.retry_cnt = p_osmt->opt.retry_count;
   req.flags = OSM_SA_FLAGS_SYNC;
   req.query_context = &context;
   req.pfn_query_cb = osmtest_query_res_cb;
-  req.p_query_input = &user;
   req.sm_key = 0;
 
+  cl_memclr( &svc_rec, sizeof( svc_rec ) );
+  cl_memclr( &user, sizeof( user ) );
+  /* set the new service record fields */
+  cl_memclr(svc_rec.service_name, sizeof(svc_rec.service_name));
+  cl_memcpy(svc_rec.service_name, sr_name,
+            (strlen(sr_name)+1)*sizeof(char));
+  svc_rec.service_id = sid;
+  req.p_query_input = &user;
+
   user.method = IB_MAD_METHOD_GET;
   user.attr_id = IB_MAD_ATTR_SERVICE_RECORD;
   user.comp_mask = IB_SR_COMPMASK_SID | IB_SR_COMPMASK_SNAME;
@@ -539,62 +542,73 @@ osmt_get_service_by_id_and_name ( IN osm
   if( status != IB_SUCCESS )
   {
     osm_log( &p_osmt->log, OSM_LOG_ERROR,
-             "osmt_get_service_by_id_and_name: ERR 0365: "
-             "ib_query failed (%s).\n", ib_get_err_str( status ) );
+             "osmt_get_service_by_id_and_name: ERR 4A07: "
+             "ib_query failed (%s)\n", ib_get_err_str( status ) );
     goto Exit;
   }
 
   status = context.result.status;
+  num_recs =  context.result.result_cnt;
 
   if( status != IB_SUCCESS )
   {
-    num_recs = 0;
-    if (status != IB_INVALID_PARAMETER)
-    {
-      osm_log( &p_osmt->log, OSM_LOG_ERROR,
-               "osmt_get_service_by_id_and_name: ERR 0370: "
-               "ib_query failed (%s).\n", ib_get_err_str( status ) );
-    }
+    char mad_stat_err[256];
+    /* If the failure is due to IB_SA_MAD_STATUS_NO_RECORDS and rec_num is 0,
+        then this is fine. */
     if( status == IB_REMOTE_ERROR )
+      strcpy(mad_stat_err, ib_get_mad_status_str( 
+        osm_madw_get_mad_ptr(context.result.p_result_madw) ) );
+    else
+      strcpy(mad_stat_err, ib_get_err_str(status) );
+    if( status == IB_REMOTE_ERROR && 
+        !strcmp(mad_stat_err, "IB_SA_MAD_STATUS_NO_RECORDS") &&
+        rec_num == 0 )
     {
       osm_log( &p_osmt->log, OSM_LOG_ERROR,
                "osmt_get_service_by_id_and_name: "
-               "Remote error = %s.\n",
-               ib_get_mad_status_str( osm_madw_get_mad_ptr
-                                      ( context.result.
-                                        p_result_madw ) ) );
-    }
-    goto Exit;
+               "IS EXPECTED ERROR ^^^^\n");
+      status = IB_SUCCESS;
   }
   else
   {
-    num_recs =  context.result.result_cnt;
+      osm_log( &p_osmt->log, OSM_LOG_ERROR,
+               "osmt_get_service_by_id_and_name: ERR 4A08: "
+               "Query failed:%s (%s)\n",
+               ib_get_err_str(status),
+               mad_stat_err );
+      goto Exit;
+    }
   }
 
-  if ( num_recs != rec_num )
+  if ( rec_num && num_recs != rec_num )
   {
     osm_log( &p_osmt->log, OSM_LOG_ERROR,
              "osmt_get_service_by_id_and_name: "
-             "Unmatched record number, Expeceted : %d, Got : %d.\n",
+             "Unmatched number of records: expeceted:%d, received:%d\n",
              rec_num, num_recs);
     status = IB_REMOTE_ERROR;
     goto Exit;
   }
 
   p_rec = osmv_get_query_svc_rec( context.result.p_result_madw, 0 );
+  *p_out_rec = *p_rec;
+
+  if (num_recs)
+  {
   osm_log( &p_osmt->log, OSM_LOG_VERBOSE,
            "osmt_get_service_by_id_and_name: "
-           "Found Service Record by Name:%s ID:0x%016" PRIx64 ".\n",
+             "Found service record: name:%s id:0x%016" PRIx64 "\n",
            p_rec->service_name, cl_ntoh64(p_rec->service_id));
 
   osm_dump_service_record(&p_osmt->log, p_rec, OSM_LOG_DEBUG);
-  *p_out_rec = *p_rec;
+  }
 
  Exit:
   osm_log( &p_osmt->log, OSM_LOG_VERBOSE,
            "osmt_get_service_by_id_and_name: "
-           "Expected num of records is : %d, Found number of records : %d\n",
-           rec_num,num_recs);
+           "Expected and found $d records\n",
+           rec_num );
+
   if( context.result.p_result_madw != NULL )
   {
     osm_mad_pool_put( &p_osmt->mad_pool, context.result.p_result_madw );
@@ -623,7 +637,7 @@ osmt_get_service_by_id ( IN osmtest_t * 
   if( osm_log_is_active( &p_osmt->log, OSM_LOG_VERBOSE ) )
     osm_log( &p_osmt->log, OSM_LOG_VERBOSE,
              "osmt_get_service_by_id: "
-             "Getting Service Record by id  0x%016" PRIx64 "\n",
+             "Getting service record: id:0x%016" PRIx64 "\n",
              cl_ntoh64(sid));
 
   /*
@@ -633,23 +647,26 @@ osmt_get_service_by_id ( IN osmtest_t * 
    *
    * The query structures are locals.
    */
-  cl_memclr( &svc_rec, sizeof( svc_rec ) );
   cl_memclr( &req, sizeof( req ) );
   cl_memclr( &context, sizeof( context ) );
-  cl_memclr( &user, sizeof( user ) );
-  /* set the new service record fields */
-  svc_rec.service_id = sid;
-  /* prepare the data used for this query */
+
   context.p_osmt = p_osmt;
+
+  /* prepare the data used for this query */
   req.query_type = OSMV_QUERY_USER_DEFINED;
   req.timeout_ms = p_osmt->opt.transaction_timeout;
   req.retry_cnt = p_osmt->opt.retry_count;
   req.flags = OSM_SA_FLAGS_SYNC;
   req.query_context = &context;
   req.pfn_query_cb = osmtest_query_res_cb;
-  req.p_query_input = &user;
   req.sm_key = 0;
 
+  cl_memclr( &svc_rec, sizeof( svc_rec ) );
+  cl_memclr( &user, sizeof( user ) );
+  /* set the new service record fields */
+  svc_rec.service_id = sid;
+  req.p_query_input = &user;
+
   user.method = IB_MAD_METHOD_GET;
   user.attr_id = IB_MAD_ATTR_SERVICE_RECORD;
   user.comp_mask = IB_SR_COMPMASK_SID;
@@ -660,62 +677,74 @@ osmt_get_service_by_id ( IN osmtest_t * 
   if( status != IB_SUCCESS )
   {
     osm_log( &p_osmt->log, OSM_LOG_ERROR,
-             "osmt_get_service_by_id: ERR 0365: "
-             "ib_query failed (%s).\n", ib_get_err_str( status ) );
+             "osmt_get_service_by_id: ERR 4A09: "
+             "ib_query failed (%s)\n", ib_get_err_str( status ) );
     goto Exit;
   }
 
   status = context.result.status;
+  num_recs =  context.result.result_cnt;
 
   if( status != IB_SUCCESS )
   {
-    num_recs = 0;
-    if (status != IB_INVALID_PARAMETER)
-    {
-      osm_log( &p_osmt->log, OSM_LOG_ERROR,
-               "osmt_get_service_by_id: ERR 0370: "
-               "ib_query failed (%s).\n", ib_get_err_str( status ) );
-    }
+    char mad_stat_err[256];
+    /* If the failure is due to IB_SA_MAD_STATUS_NO_RECORDS and rec_num is 0,
+        then this is fine. */
     if( status == IB_REMOTE_ERROR )
+      strcpy(mad_stat_err, ib_get_mad_status_str( 
+        osm_madw_get_mad_ptr(context.result.p_result_madw) ) );
+    else
+      strcpy(mad_stat_err, ib_get_err_str(status) );
+
+    if( status == IB_REMOTE_ERROR && 
+        !strcmp(mad_stat_err, "IB_SA_MAD_STATUS_NO_RECORDS") &&
+        rec_num == 0 )
     {
       osm_log( &p_osmt->log, OSM_LOG_ERROR,
                "osmt_get_service_by_id: "
-               "Remote error = %s.\n",
-               ib_get_mad_status_str( osm_madw_get_mad_ptr
-                                      ( context.result.
-                                        p_result_madw ) ) );
-    }
-    goto Exit;
+               "IS EXPECTED ERROR ^^^^\n");
+      status = IB_SUCCESS;
   }
   else
   {
-    num_recs =  context.result.result_cnt;
+      osm_log( &p_osmt->log, OSM_LOG_ERROR,
+               "osmt_get_service_by_id: ERR 4A0A: "
+               "Query failed:%s (%s)\n",
+               ib_get_err_str(status),
+               mad_stat_err );
+      goto Exit;
+    }
   }
 
-  if ( num_recs != rec_num )
+  if ( rec_num && num_recs != rec_num )
   {
     osm_log( &p_osmt->log, OSM_LOG_ERROR,
-             "osmt_get_service_by_id: "
-             "Unmatched record number; Expected : %d, Got : %d.\n",
+             "osmt_get_service_by_id: ERR 4A0B: "
+             "Unmatched number of records: expected:%d received:%d\n",
              rec_num, num_recs);
     status = IB_REMOTE_ERROR;
     goto Exit;
   }
 
   p_rec = osmv_get_query_svc_rec( context.result.p_result_madw, 0 );
+  *p_out_rec = *p_rec;
+
+  if (num_recs)
+  {
   osm_log( &p_osmt->log, OSM_LOG_VERBOSE,
            "osmt_get_service_by_id: "
-           "Found Service Record by Name:%s ID:0x%016" PRIx64 ".\n",
+             "Found service record: name:%s id:0x%016" PRIx64 "\n",
            p_rec->service_name, cl_ntoh64(p_rec->service_id));
 
   osm_dump_service_record(&p_osmt->log, p_rec, OSM_LOG_DEBUG);
-  *p_out_rec = *p_rec;
+  }
 
  Exit:
   osm_log( &p_osmt->log, OSM_LOG_VERBOSE,
            "osmt_get_service_by_id: "
-           "Expected num of records is : %d, Found number of records : %d\n",
-           rec_num,num_recs);
+           "Expected and found %d records\n",
+           rec_num );
+
   if( context.result.p_result_madw != NULL )
   {
     osm_mad_pool_put( &p_osmt->mad_pool, context.result.p_result_madw );
@@ -737,22 +766,25 @@ osmt_get_service_by_name_and_key ( IN os
   osmtest_req_context_t context;
   osmv_query_req_t req;
   ib_service_record_t svc_rec,*p_rec;
-  uint32_t num_recs = 0;
+  uint32_t num_recs = 0, i;
   osmv_user_query_t user;
 
   OSM_LOG_ENTER( &p_osmt->log, osmt_get_service_by_name_and_key );
 
   if( osm_log_is_active( &p_osmt->log, OSM_LOG_VERBOSE ) )
   {
-    uint8_t i;
+    char buf_service_key[33];
+    
+    sprintf(buf_service_key,
+            "0x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",
+            skey[0], skey[1], skey[2], skey[3], skey[4], skey[5], skey[6], skey[7],
+            skey[8], skey[9], skey[10], skey[11], skey[12], skey[13], skey[14],
+            skey[15]);
+    
     osm_log( &p_osmt->log, OSM_LOG_VERBOSE,
              "osmt_get_service_by_name_and_key: "
-             "Getting Service Record by Name and Key :%s.\n",
-             sr_name);
-    for (i=0 ; i<=15 ; i++)
-      osm_log( &p_osmt->log, OSM_LOG_VERBOSE,
-               "Service Key[%u] = %u\n",
-               i,skey[i]);
+             "Getting service record: name:%s and key:%s\n",
+             sr_name, buf_service_key );
   }
 
   /*
@@ -762,92 +794,108 @@ osmt_get_service_by_name_and_key ( IN os
    *
    * The query structures are locals.
    */
-  cl_memclr( &svc_rec, sizeof( svc_rec ) );
   cl_memclr( &req, sizeof( req ) );
   cl_memclr( &context, sizeof( context ) );
-  cl_memclr( &user, sizeof( user ) );
-  /* set the new service record fields */
-  cl_memclr(svc_rec.service_name, sizeof(svc_rec.service_name));
-  cl_memcpy(svc_rec.service_name, sr_name,
-            (strlen(sr_name)+1)*sizeof(char));
 
-  /* prepare the data used for this query */
   context.p_osmt = p_osmt;
+
+  /* prepare the data used for this query */
   req.query_type = OSMV_QUERY_USER_DEFINED;
   req.timeout_ms = p_osmt->opt.transaction_timeout;
   req.retry_cnt = p_osmt->opt.retry_count;
   req.flags = OSM_SA_FLAGS_SYNC;
   req.query_context = &context;
   req.pfn_query_cb = osmtest_query_res_cb;
-  req.p_query_input = &user;
   req.sm_key = 0;
 
+  cl_memclr( &svc_rec, sizeof( svc_rec ) );
+  cl_memclr( &user, sizeof( user ) );
+  /* set the new service record fields */
+  cl_memclr(svc_rec.service_name, sizeof(svc_rec.service_name));
+  cl_memcpy(svc_rec.service_name, sr_name,
+            (strlen(sr_name)+1)*sizeof(char));
+  for (i=0 ; i<=15 ; i++)
+    svc_rec.service_key[i] = skey[i];
+
+  req.p_query_input = &user;
+
   user.method = IB_MAD_METHOD_GET;
   user.attr_id = IB_MAD_ATTR_SERVICE_RECORD;
   user.comp_mask = IB_SR_COMPMASK_SNAME | IB_SR_COMPMASK_SKEY;
   user.attr_offset = ib_get_attr_offset( sizeof( ib_service_record_t ) );
   user.p_attr = &svc_rec;
-
   status = osmv_query_sa( p_osmt->h_bind, &req );
   if( status != IB_SUCCESS )
   {
     osm_log( &p_osmt->log, OSM_LOG_ERROR,
-             "osmt_get_service_by_name_and_key: ERR 0365: "
-             "ib_query failed (%s).\n", ib_get_err_str( status ) );
+             "osmt_get_service_by_name_and_key: ERR 4A0C: "
+             "ib_query failed (%s)\n", ib_get_err_str( status ) );
     goto Exit;
   }
 
   status = context.result.status;
+  num_recs =  context.result.result_cnt;
 
   if( status != IB_SUCCESS )
   {
-    num_recs = 0;
-    if (status != IB_INVALID_PARAMETER)
-    {
-      osm_log( &p_osmt->log, OSM_LOG_ERROR,
-               "osmt_get_service_by_name_and_key: ERR 0370: "
-               "ib_query failed (%s).\n", ib_get_err_str( status ) );
-    }
+    char mad_stat_err[256];
+    /* If the failure is due to IB_SA_MAD_STATUS_NO_RECORDS and rec_num is 0,
+        then this is fine. */
     if( status == IB_REMOTE_ERROR )
+      strcpy(mad_stat_err, ib_get_mad_status_str( 
+        osm_madw_get_mad_ptr(context.result.p_result_madw) ) );
+    else
+      strcpy(mad_stat_err, ib_get_err_str(status) );
+
+    if( status == IB_REMOTE_ERROR && 
+        !strcmp(mad_stat_err, "IB_SA_MAD_STATUS_NO_RECORDS") &&
+        rec_num == 0 )
     {
       osm_log( &p_osmt->log, OSM_LOG_ERROR,
                "osmt_get_service_by_name_and_key: "
-               "Remote error = %s.\n",
-               ib_get_mad_status_str( osm_madw_get_mad_ptr
-                                      ( context.result.
-                                        p_result_madw ) ) );
-    }
-    goto Exit;
+               "IS EXPECTED ERROR ^^^^\n");
+      status = IB_SUCCESS;
   }
   else
   {
-    num_recs =  context.result.result_cnt;
+      osm_log( &p_osmt->log, OSM_LOG_ERROR,
+               "osmt_get_service_by_name_and_key: ERR 4A0D: "
+               "Query failed:%s (%s)\n",
+               ib_get_err_str(status),
+               mad_stat_err );
+      goto Exit;
+    }
   }
 
-  if ( num_recs != rec_num )
+  if ( rec_num && num_recs != rec_num )
   {
     osm_log( &p_osmt->log, OSM_LOG_ERROR,
              "osmt_get_service_by_name_and_key: "
-             "Unmatched record number, Expected : %d, Got : %d.\n",
+             "Unmatched number of records: expected:%d, received:%d\n",
              rec_num, num_recs);
     status = IB_REMOTE_ERROR;
     goto Exit;
   }
 
   p_rec = osmv_get_query_svc_rec( context.result.p_result_madw, 0 );
+  *p_out_rec = *p_rec;
+
+  if ( num_recs )
+  {
   osm_log( &p_osmt->log, OSM_LOG_VERBOSE,
            "osmt_get_service_by_name_and_key: "
-           "Found Service Record by Name:%s ID:0x%016" PRIx64 ".\n",
+             "Found service record: name:%s id:0x%016" PRIx64 "\n",
            sr_name, cl_ntoh64(p_rec->service_id));
 
   osm_dump_service_record(&p_osmt->log, p_rec, OSM_LOG_DEBUG);
-  *p_out_rec = *p_rec;
+  }
 
  Exit:
   osm_log( &p_osmt->log, OSM_LOG_VERBOSE,
            "osmt_get_service_by_name_and_key: "
-           "Expected num of records is : %d, Found number of records : %d\n",
-           rec_num,num_recs);
+           "Expected and found %d records\n",
+           rec_num );
+
   if( context.result.p_result_madw != NULL )
   {
     osm_mad_pool_put( &p_osmt->mad_pool, context.result.p_result_madw );
@@ -874,12 +922,10 @@ osmt_get_service_by_name( IN osmtest_t *
   OSM_LOG_ENTER( &p_osmt->log, osmt_get_service_by_name );
 
   if( osm_log_is_active( &p_osmt->log, OSM_LOG_VERBOSE ) )
-  {
     osm_log( &p_osmt->log, OSM_LOG_VERBOSE,
              "osmt_get_service_by_name: "
-             "Getting Service Record by Name:%s.\n",
+             "Getting service record: name:%s\n",
              sr_name);
-  }
 
   /*
    * Do a blocking query for this record in the subnet.
@@ -893,78 +939,90 @@ osmt_get_service_by_name( IN osmtest_t *
 
   context.p_osmt = p_osmt;
 
+  /* prepare the data used for this query */
   req.query_type = OSMV_QUERY_SVC_REC_BY_NAME;
   req.timeout_ms = p_osmt->opt.transaction_timeout;
   req.retry_cnt = p_osmt->opt.retry_count;
   req.flags = OSM_SA_FLAGS_SYNC;
   req.query_context = &context;
   req.pfn_query_cb = osmtest_query_res_cb;
+  req.sm_key = 0;
+
   cl_memclr(service_name, sizeof(service_name));
   cl_memcpy(service_name, sr_name, (strlen(sr_name)+1)*sizeof(char));
   req.p_query_input = service_name;
-  req.sm_key = 0;
 
   status = osmv_query_sa( p_osmt->h_bind, &req );
   if( status != IB_SUCCESS )
   {
     osm_log( &p_osmt->log, OSM_LOG_ERROR,
-             "osmt_get_service_by_name: ERR 0365: "
-             "ib_query failed (%s).\n", ib_get_err_str( status ) );
+             "osmt_get_service_by_name: ERR 4A0E: "
+             "ib_query failed (%s)\n", ib_get_err_str( status ) );
     goto Exit;
   }
 
   status = context.result.status;
+  num_recs =  context.result.result_cnt;
 
   if( status != IB_SUCCESS )
   {
-    /*  The context struct is not init OR result with illegal number of records */
-    num_recs = 0;
-    if (status != IB_INVALID_PARAMETER)
-    {
-      osm_log( &p_osmt->log, OSM_LOG_ERROR,
-               "osmt_get_service_by_name: ERR 0370: "
-               "ib_query failed (%s).\n", ib_get_err_str( status ) );
-    }
+    char mad_stat_err[256];
+    /*  If the failure is due to IB_SA_MAD_STATUS_NO_RECORDS and rec_num is 0,
+        then this is fine. */
     if( status == IB_REMOTE_ERROR )
+      strcpy(mad_stat_err, ib_get_mad_status_str( 
+        osm_madw_get_mad_ptr(context.result.p_result_madw) ) );
+    else
+      strcpy(mad_stat_err, ib_get_err_str(status) );
+
+    if( status == IB_REMOTE_ERROR && 
+        !strcmp(mad_stat_err, "IB_SA_MAD_STATUS_NO_RECORDS") &&
+        rec_num == 0 )
     {
       osm_log( &p_osmt->log, OSM_LOG_ERROR,
                "osmt_get_service_by_name: "
-               "Remote error = %s.\n",
-               ib_get_mad_status_str( osm_madw_get_mad_ptr
-                                      ( context.result.
-                                        p_result_madw ) ) );
-    }
-    goto Exit;
+               "IS EXPECTED ERROR ^^^^\n");
+      status = IB_SUCCESS;
   }
   else
   {
-    num_recs =  context.result.result_cnt;
+      osm_log( &p_osmt->log, OSM_LOG_ERROR,
+               "osmt_get_service_by_name: ERR 4A0F: "
+               "Query failed:%s (%s)\n",
+               ib_get_err_str(status),
+               mad_stat_err );
+      goto Exit;
+    }
   }
 
-  if ( num_recs != rec_num )
+  if ( rec_num && num_recs != rec_num )
   {
     osm_log( &p_osmt->log, OSM_LOG_ERROR,
-             "osmt_get_service_by_name: "
-             "Unmatched record number, Expeceted : %d, Got : %u.\n",
+             "osmt_get_service_by_name: ERR 4A10: "
+             "Unmatched number of records: expected:%d, received:%u\n",
              rec_num, num_recs);
     status = IB_REMOTE_ERROR;
     goto Exit;
   }
 
   p_rec = osmv_get_query_svc_rec( context.result.p_result_madw, 0 );
+  *p_out_rec = *p_rec;
+
+  if (num_recs)
+  {
   osm_log( &p_osmt->log, OSM_LOG_VERBOSE,
            "osmt_get_service_by_name: "
-           "Found Service Record by Name:%s ID:0x%016" PRIx64 ".\n",
+             "Found service record: name:%s id:0x%016" PRIx64 "\n",
            sr_name, cl_ntoh64(p_rec->service_id));
 
   osm_dump_service_record(&p_osmt->log, p_rec, OSM_LOG_DEBUG);
-  *p_out_rec = *p_rec;
+  }
 
  Exit:
   osm_log( &p_osmt->log, OSM_LOG_VERBOSE,
            "osmt_get_service_by_name: "
-           "Expected num of records is : %d, Found number of records : %u\n",
-           rec_num,num_recs);
+           "Expected and found %d records\n",
+           rec_num );
 
   if( context.result.p_result_madw != NULL )
   {
@@ -1002,7 +1060,7 @@ osmt_get_all_services_and_check_names( I
   {
     osm_log( &p_osmt->log, OSM_LOG_VERBOSE,
              "osmt_get_all_services_and_check_names: "
-             "Getting All Service Records\n");
+             "Getting all service records\n");
   }
   /*
    * Do a blocking query for this record in the subnet.
@@ -1028,8 +1086,8 @@ osmt_get_all_services_and_check_names( I
   if( status != IB_SUCCESS )
   {
     osm_log( &p_osmt->log, OSM_LOG_ERROR,
-             "osmt_get_all_services_and_check_names: ERR 0371: "
-             "ib_query failed (%s).\n", ib_get_err_str( status ) );
+             "osmt_get_all_services_and_check_names: ERR 4A12: "
+             "ib_query failed (%s)\n", ib_get_err_str( status ) );
     goto Exit;
   }
 
@@ -1040,14 +1098,14 @@ osmt_get_all_services_and_check_names( I
     if (status != IB_INVALID_PARAMETER)
     {
       osm_log( &p_osmt->log, OSM_LOG_ERROR,
-               "osmt_get_all_services_and_check_names: ERR 0372: "
-               "ib_query failed (%s).\n", ib_get_err_str( status ) );
+               "osmt_get_all_services_and_check_names: ERR 4A13: "
+               "ib_query failed (%s)\n", ib_get_err_str( status ) );
     }
     if( status == IB_REMOTE_ERROR )
     {
       osm_log( &p_osmt->log, OSM_LOG_ERROR,
                "osmt_get_all_services_and_check_names: "
-               "Remote error = %s.\n",
+               "Remote error = %s\n",
                ib_get_mad_status_str( osm_madw_get_mad_ptr
                                       ( context.result.
                                         p_result_madw ) ) );
@@ -1058,14 +1116,14 @@ osmt_get_all_services_and_check_names( I
   num_recs = context.result.result_cnt;
   osm_log( &p_osmt->log, OSM_LOG_VERBOSE,
              "osmt_get_all_services_and_check_names: "
-             "Received %u records.\n", num_recs );
+             "Received %u records\n", num_recs );
     
   for( i = 0; i < num_recs; i++ )
     {
       p_rec = osmv_get_query_svc_rec( context.result.p_result_madw, i );
       osm_log( &p_osmt->log, OSM_LOG_VERBOSE,
                "osmt_get_all_services_and_check_names: "
-               "Found Service Record by Name:%s ID:0x%016" PRIx64 ".\n",
+               "Found service record: name:%s id:0x%016" PRIx64 "\n",
                p_rec->service_name, cl_ntoh64(p_rec->service_id));
       osm_dump_service_record(&p_osmt->log, p_rec, OSM_LOG_VERBOSE);
       for ( j = 0; j < num_of_valid_names; j++) 
@@ -1091,8 +1149,8 @@ osmt_get_all_services_and_check_names( I
       if (p_checked_names[j] == 0) 
       {
           osm_log( &p_osmt->log, OSM_LOG_ERROR,
-                   "osmt_get_all_services_and_check_names: ERR 0377: "
-                   "Missing Valid Service Name:%s\n",p_valid_service_names_arr[j]);
+                   "osmt_get_all_services_and_check_names: ERR 4A14: "
+                   "Missing valid service: name:%s\n",p_valid_service_names_arr[j]);
           status = IB_ERROR;
           goto Exit;
       }
@@ -1124,7 +1182,7 @@ osmt_delete_service_by_name(IN osmtest_t
 
   osm_log( &p_osmt->log, OSM_LOG_INFO,
            "osmt_delete_service_by_name: "
-           "Trying to Delete Service: Name:%s.\n",
+           "Trying to Delete service name:%s\n",
            sr_name);
 
   cl_memclr( &svc_rec, sizeof( svc_rec ) );
@@ -1132,17 +1190,10 @@ osmt_delete_service_by_name(IN osmtest_t
   status = osmt_get_service_by_name(p_osmt, sr_name,rec_num, &svc_rec);
   if (status != IB_SUCCESS)
   {
-      if (IsServiceExist) 
           osm_log( &p_osmt->log, OSM_LOG_ERROR,
-                 "osmt_delete_service_by_name: ERR 001 "
-                 "Nothing to delete - failed to find service by name: %s \n", sr_name);
-      else
-      {
-          osm_log( &p_osmt->log, OSM_LOG_INFO,
-                 "osmt_delete_service_by_name: "
-                 "Record should not exist, i.e. BAD flow\n");
-          status = IB_SUCCESS;
-      }
+             "osmt_delete_service_by_name: ERR 4A15: "
+             "Failed to get service: name:%s\n",
+             sr_name );
       goto ExitNoDel;
   }
 
@@ -1175,29 +1226,57 @@ osmt_delete_service_by_name(IN osmtest_t
   if( status != IB_SUCCESS )
   {
     osm_log( &p_osmt->log, OSM_LOG_ERROR,
-             "osmt_delete_service_by_name: ERR 0373: "
-             "ib_query failed (%s).\n", ib_get_err_str( status ) );
+             "osmt_delete_service_by_name: ERR 4A16: "
+             "ib_query failed (%s)\n", ib_get_err_str( status ) );
     goto Exit;
   }
 
   status = context.result.status;
-
+  if ( IsServiceExist )
+  {
+    /* If IsServiceExist = 1 then we should succeed here */
   if( status != IB_SUCCESS )
   {
     osm_log( &p_osmt->log, OSM_LOG_ERROR,
-             "osmt_delete_service_by_name: ERR 0374: "
-             "ib_query failed (%s).\n", ib_get_err_str( status ) );
+               "osmt_delete_service_by_name: ERR 4A17: "
+               "ib_query failed (%s)\n", ib_get_err_str( status ) );
 
     if( status == IB_REMOTE_ERROR )
     {
       osm_log( &p_osmt->log, OSM_LOG_ERROR,
-               "osmt_delete_service_by_name: "
-               "Remote error = %s.\n",
+                 "osmt_delete_service_by_name: ERR 4A18: "
+                 "Remote error = %s\n",
                ib_get_mad_status_str( osm_madw_get_mad_ptr
                                       ( context.result.
                                         p_result_madw ) ) );
     }
-    goto Exit;
+    }
+  }
+  else
+  {
+    /* If IsServiceExist = 0 then we should fail here */
+    if ( status == IB_SUCCESS )
+    {
+      osm_log( &p_osmt->log, OSM_LOG_ERROR,
+               "osmt_delete_service_by_name: ERR 4A19: "
+               "Succeeded to delete service:%s which "
+               "shouldn't exist", 
+               sr_name );
+      status = IB_ERROR;
+    }
+    else
+    {
+      /* The deletion should have failed, since the service_name
+         shouldn't exist. */
+      osm_log( &p_osmt->log, OSM_LOG_ERROR,
+               "osmt_run_service_records_flow: "
+               "IS EXPECTED ERROR ^^^^\n");
+      osm_log( &p_osmt->log, OSM_LOG_INFO,
+               "osmt_delete_service_by_name: "
+               "Failed to delete service_name:%s\n",
+               sr_name );
+      status = IB_SUCCESS;
+    }      
   }
 
  Exit:
@@ -1362,144 +1441,256 @@ osmt_run_service_records_flow( IN osmtes
   /* Let OpenSM handle it */
   usleep(100);
 
+  /* Make sure service_name[0] exists */
   status = osmt_get_service_by_name(p_osmt,
                                     (char*)service_name[0],1, &srv_rec);
   if (status != IB_SUCCESS)
   {
+    osm_log( &p_osmt->log, OSM_LOG_ERROR,
+             "osmt_run_service_records_flow: ERR 4A1A: "
+             "Fail to find service: name:%s\n",
+             (char*)service_name[0] );
+    status = IB_ERROR;
     goto Exit;
   }
 
+  /* Make sure service_name[1] exists */
   status = osmt_get_service_by_name(p_osmt,
                                     (char*)service_name[1],1, &srv_rec);
   if (status != IB_SUCCESS)
   {
+    osm_log( &p_osmt->log, OSM_LOG_ERROR,
+             "osmt_run_service_records_flow: ERR 4A1B: "
+             "Fail to find service: name:%s\n",
+             (char*)service_name[1] );
+    status = IB_ERROR;
     goto Exit;
   }
 
+  /* Make sure service_name[2] exists */
   status = osmt_get_service_by_name(p_osmt,
                                     (char*)service_name[2],1, &srv_rec);
   if (status != IB_SUCCESS)
   {
+     osm_log( &p_osmt->log, OSM_LOG_ERROR,
+             "osmt_run_service_records_flow: ERR 4A1C: "
+             "Fail to find service: name:%s\n",
+             (char*)service_name[2] );
+    status = IB_ERROR;
     goto Exit;
   }
 
-  /*  Try to get osmt.srvc.4 b4 (there should be 1 record) and after 10 sec - It should be deleted */
+  /* Make sure service_name[3] exists. */
+  /* After 10 seconds the service should not exist: service_lease = 10 */
   status = osmt_get_service_by_name(p_osmt,
                                     (char*)service_name[3],1, &srv_rec);
   if (status != IB_SUCCESS)
   {
+     osm_log( &p_osmt->log, OSM_LOG_ERROR,
+             "osmt_run_service_records_flow: ERR 4A1D: "
+             "Fail to find service: name:%s\n",
+             (char*)service_name[3] );
+    status = IB_ERROR;
     goto Exit;
   }
+
   sleep(10);
+
   status = osmt_get_service_by_name(p_osmt,
                                     (char*)service_name[3],0, &srv_rec);
-  if (status == IB_SUCCESS)
+  if (status != IB_SUCCESS)
   {
+    osm_log( &p_osmt->log, OSM_LOG_ERROR,
+             "osmt_run_service_records_flow: ERR 4A1E: "
+             "Found service: name:%s that should have been "
+             "deleted due to service lease expiring\n",
+             (char*)service_name[3] );
+    status = IB_ERROR;
     goto Exit;
   }
-  /*  Check that for the current Service ID only one record exists */
+
+  /*  Check that for service: id[5] only one record exists */
   status = osmt_get_service_by_id(p_osmt, 1, cl_ntoh64(id[5]),&srv_rec);
   if (status != IB_SUCCESS)
   {
+     osm_log( &p_osmt->log, OSM_LOG_ERROR,
+             "osmt_run_service_records_flow: ERR 4A1F: "
+             "Found number of records!=1 for "
+              "service: id:0x%016" PRIx64 "\n",
+              id[5] );
+     status = IB_ERROR;
     goto Exit;
   }
 
-  /*  Bad Flow of Get with invalid Service ID */
+  /*  Bad Flow of Get with invalid Service ID: id[7] */
   status = osmt_get_service_by_id(p_osmt, 0,cl_ntoh64(id[7]),&srv_rec);
-  if (status == IB_SUCCESS)
+  if (status != IB_SUCCESS)
   {
+    osm_log( &p_osmt->log, OSM_LOG_ERROR,
+             "osmt_run_service_records_flow: ERR 4A20: "
+             "Found service: id:0x%016 " PRIx64 
+             "that is invalid\n",
+             id[7] );
+    status = IB_ERROR;
     goto Exit;
   }
-  /*  Check that for correct name and ID we get record set b4 */
+
+  /*  Check by both id and service name: id[0], service_name[0] */
   status = osmt_get_service_by_id_and_name(p_osmt, 1, cl_ntoh64(id[0]),
                                            (char*)service_name[0], &srv_rec);
   if (status != IB_SUCCESS)
   {
+    osm_log( &p_osmt->log, OSM_LOG_ERROR,
+             "osmt_run_service_records_flow: ERR 4A21: "
+             "Fail to find service: id:0x%016 " PRIx64
+             "name:%s\n",
+             id[0],
+             (char*)service_name[0] );
+    status = IB_ERROR;
     goto Exit;
   }
+  
+  /*  Check by both id and service name: id[5], service_name[6] */
   status = osmt_get_service_by_id_and_name(p_osmt, 1, cl_ntoh64(id[5]),
                                            (char*)service_name[6], &srv_rec);
   if (status != IB_SUCCESS)
   {
+    osm_log( &p_osmt->log, OSM_LOG_ERROR,
+             "osmt_run_service_records_flow: ERR 4A22: "
+             "Fail to find service: id:0x%016 " PRIx64
+             "name:%s\n",
+             id[5],
+             (char*)service_name[6] );
+    status = IB_ERROR;
     goto Exit;
   }
 
-  /* Bad Flow of Get with valid name and invalid ID */
+  /* Bad Flow of Get with invalid name(service_name[3]) and valid ID(id[0]) */
   status = osmt_get_service_by_id_and_name(p_osmt, 0, cl_ntoh64(id[0]),
                                            (char*)service_name[3], &srv_rec);
-  if (status == IB_SUCCESS)
+  if (status != IB_SUCCESS)
   {
+    osm_log( &p_osmt->log, OSM_LOG_ERROR,
+             "osmt_run_service_records_flow: ERR 4A23: "
+             "Found service: id:0x%016" PRIx64
+             "name:%s which is an invalid service\n",
+             id[0],
+             (char*)service_name[3] );
+    status = IB_ERROR;
     goto Exit;
   }
-  /*  Bad Flow of Get with unmatched name (exists but not with the following ID) and valid ID */
+
+  /*  Bad Flow of Get with unmatched name(service_name[5]) and id(id[3]) (both valid) */
   status = osmt_get_service_by_id_and_name(p_osmt, 0, cl_ntoh64(id[3]),
                                            (char*)service_name[5], &srv_rec);
-  if (status == IB_SUCCESS)
+  if (status != IB_SUCCESS)
   {
+    osm_log( &p_osmt->log, OSM_LOG_ERROR,
+             "osmt_run_service_records_flow: ERR 4A24: "
+             "Found service: id:0x%016" PRIx64
+             "name:%s which is an invalid service\n",
+             id[3],
+             (char*)service_name[5] );
+    status = IB_ERROR;
     goto Exit;
   }
 
+  /* Bad Flow of Get with service name that doesn't exist (service_name[4]) */
   status = osmt_get_service_by_name(p_osmt,
                                     (char*)service_name[4],0, &srv_rec);
-  if (status == IB_SUCCESS)
+  if (status != IB_SUCCESS)
   {
+    osm_log( &p_osmt->log, OSM_LOG_ERROR,
+             "osmt_run_service_records_flow: ERR 4A25: "
+             "Found service: name:%s that shouldn't exist\n",
+             (char*)service_name[4] );
+    status = IB_ERROR;
     goto Exit;
   }
-  /*  Bad Flow : Check that getting osmt.srvc.6 brings no records since another service has been updated with the same ID - osmt.srvc.7 */
+
+  /*  Bad Flow : Check that getting service_name[5] brings no records since another service
+      has been updated with the same ID (service_name[6] */
   status = osmt_get_service_by_name(p_osmt,
                                     (char*)service_name[5],0, &srv_rec);
-  if (status == IB_SUCCESS)
+  if (status != IB_SUCCESS)
   {
+    osm_log( &p_osmt->log, OSM_LOG_ERROR,
+             "osmt_run_service_records_flow: ERR 4A26: "
+             "Found service: name:%s which is an "
+             "invalid service\n",
+             (char*)service_name[5] );
+    status = IB_ERROR;
     goto Exit;
   }
-  /*  Check that getting osmt.srvc.7 by name ONLY is valid since we do not support key&name association, also trusted queries */
+
+  /*  Check that getting service_name[6] by name ONLY is valid,
+      since we do not support key&name association, also trusted queries */
   status = osmt_get_service_by_name(p_osmt,
                                     (char*)service_name[6],1, &srv_rec);
   if (status != IB_SUCCESS)
   {
+    osm_log( &p_osmt->log, OSM_LOG_ERROR,
+             "osmt_run_service_records_flow: ERR 4A27: "
+             "Fail to find service: name:%s\n",
+             (char*)service_name[6] );
+    status = IB_ERROR;
     goto Exit;
   }
 
   /*  Test Service Key */
   cl_memclr(service_key,16*sizeof(uint8_t));
+
+  /* Check for service_name[5] with service_key=0 - the service shouldn't
+     exist with this name. */
   status = osmt_get_service_by_name_and_key (p_osmt,
                                              (char*)service_name[5],
                                              0, service_key,&srv_rec);  
-  if (status == IB_SUCCESS)
+  if (status != IB_SUCCESS)
   {
+    osm_log( &p_osmt->log, OSM_LOG_ERROR,
+             "osmt_run_service_records_flow: ERR 4A28: "
+             "Found service: name:%s key:0 which is an "
+             "invalid service (wrong name)\n",
+             (char*)service_name[5] );
+    status = IB_ERROR;
     goto Exit;
   }
-  else
-  {
-    status = IB_SUCCESS;
-  }
+
+  /* Check for service_name[6] with service_key=0 - the service should
+     exist with different key. */
   status = osmt_get_service_by_name_and_key (p_osmt,
                                              (char*)service_name[6],
                                              0, service_key,&srv_rec);
-  if (status == IB_SUCCESS)
+  if (status != IB_SUCCESS)
   {
+    osm_log( &p_osmt->log, OSM_LOG_ERROR,
+             "osmt_run_service_records_flow: ERR 4A29: "
+             "Found service: name:%s key:0 which is an "
+             "invalid service (wrong service_key)\n",
+             (char*)service_name[6] );
+    status = IB_ERROR;
     goto Exit;
   }
-  else
-  {
-    status = IB_SUCCESS;
-  }
       
+  /* check for service_name[6] with the correct service_key */
   for (i=0;i <= 15;i++) 
     service_key[i]=i + 1;
   status = osmt_get_service_by_name_and_key (p_osmt,
                                              (char*)service_name[6],
-                                             0, service_key,&srv_rec);
-  if (status == IB_SUCCESS)
+                                             1, service_key, &srv_rec);
+  if (status != IB_SUCCESS)
   {
+    osm_log( &p_osmt->log, OSM_LOG_ERROR,
+             "osmt_run_service_records_flow: ERR 4A2A: "
+             "Fail to find service: name:%s with "
+             "correct service key\n",
+             (char*)service_name[6] );
+    status = IB_ERROR;
     goto Exit;
   }
-  else
-  {
-    status = IB_SUCCESS;
-  }
 
 #ifdef VENDOR_RMPP_SUPPORT
+  /* These ar the only service_names which are valid */
   cl_memcpy(&service_valid_names[0],&service_name[0],sizeof(uint8_t)*64);
   cl_memcpy(&service_valid_names[1],&service_name[2],sizeof(uint8_t)*64);
   cl_memcpy(&service_valid_names[2],&service_name[6],sizeof(uint8_t)*64);
@@ -1507,79 +1698,101 @@ osmt_run_service_records_flow( IN osmtes
   status = osmt_get_all_services_and_check_names(p_osmt,service_valid_names,3, &num_recs);
   if (status != IB_SUCCESS)
   {
+    osm_log( &p_osmt->log, OSM_LOG_ERROR,
+             "osmt_run_service_records_flow: ERR 4A2B: "
+             "Fail to find all services that should exist\n" );
+    status = IB_ERROR;
     goto Exit;
   }
 #endif
 
+  /* Delete service_name[0] */ 
   status = osmt_delete_service_by_name(p_osmt,1,
                                        (char*)service_name[0],1);
   if (status != IB_SUCCESS)
   {
+    osm_log( &p_osmt->log, OSM_LOG_ERROR,
+             "osmt_run_service_records_flow: ERR 4A2C: "
+             "Fail to delete service: name:%s\n",
+             (char*)service_name[0] );
+    status = IB_ERROR;
     goto Exit;
   }
 
+  /* Make sure deletion of service_name[0] succeeded */
   status = osmt_get_service_by_name(p_osmt,
-                                    (char*)service_name[0],1, &srv_rec);
-  if (status == IB_SUCCESS)
+                                    (char*)service_name[0],0, &srv_rec);
+  if (status != IB_SUCCESS)
   {
     osm_log( &p_osmt->log, OSM_LOG_ERROR,
-             "osmt_run_service_records_flow: ERR 001 "
-             "Expected not to find osmt.srvc.1 \n");
+             "osmt_run_service_records_flow: ERR 4A2D: "
+             "Found service: name:%s that was deleted\n",
+             (char*)service_name[0] );
     status = IB_ERROR;
     goto Exit;
   }
-  osm_log( &p_osmt->log, OSM_LOG_ERROR,
-           "osmt_run_service_records_flow: "
-           "IS EXPECTED ERR ^^^^\n");
-
-  sleep(3);
 
+  /* Make sure service_name[1] doesn't exist (expired service lease) */
   status = osmt_get_service_by_name(p_osmt,
-                                    (char*)service_name[1],1, &srv_rec);
-  if (status == IB_SUCCESS)
+                                    (char*)service_name[1],0, &srv_rec);
+  if (status != IB_SUCCESS)
   {
     osm_log( &p_osmt->log, OSM_LOG_ERROR,
-             "osmt_run_service_records_flow: ERR 001 "
-             "Expected not to find osmt.srvc.2 \n");
+             "osmt_run_service_records_flow: ERR 4A2E: "
+             "Found service: name:%s that should have expired\n",
+             (char*)service_name[1] );
     status = IB_ERROR;
     goto Exit;
   }
-  else
-  {
-    osm_log( &p_osmt->log, OSM_LOG_ERROR,
-             "osmt_run_service_records_flow: "
-             "IS EXPECTED ERR ^^^^\n");
-    status = IB_SUCCESS;
-  }
 
+  /* Make sure service_name[2] exists */
   status = osmt_get_service_by_name(p_osmt,
                                     (char*)service_name[2],1, &srv_rec);
   if (status != IB_SUCCESS)
   {
     osm_log( &p_osmt->log, OSM_LOG_ERROR,
-             "osmt_run_service_records_flow: ERR 001 "
-             "Expected to find service osmt.srvc.3\n" );
+             "osmt_run_service_records_flow: ERR 4A2F: "
+             "Fail to find service: name:%s\n",
+             (char*)service_name[2] );
+    status = IB_ERROR;
     goto Exit;
   }
-  status = osmt_delete_service_by_name(p_osmt,1,
-                                       (char*)service_name[6],1);
+
+  /*  Bad Flow - try to delete non-existent service_name[5] */
+  status = osmt_delete_service_by_name(p_osmt,0,
+                                       (char*)service_name[5],0);
   if (status != IB_SUCCESS)
   {
+    osm_log( &p_osmt->log, OSM_LOG_ERROR,
+             "osmt_run_service_records_flow: ERR 4A30: "
+             "Succeed to delete non-existent service: name:%s\n",
+             (char*)service_name[5] );
+    status = IB_ERROR;
     goto Exit;
   }
 
-  /*  Bad Flow */
-  status = osmt_delete_service_by_name(p_osmt,0,
-                                       (char*)service_name[5],1);
-  if (status == IB_SUCCESS)
+  /* Delete service_name[2] */
+  status = osmt_delete_service_by_name(p_osmt,1,
+                                       (char*)service_name[2],1);
+  if (status != IB_SUCCESS)
   {
+    osm_log( &p_osmt->log, OSM_LOG_ERROR,
+             "osmt_run_service_records_flow: ERR 4A31: "
+             "Fail to delete service: name:%s\n",
+             (char*)service_name[2] );
+    status = IB_ERROR;
     goto Exit;
   }
 
+  /* Delete service_name[6] */
   status = osmt_delete_service_by_name(p_osmt,1,
-                                       (char*)service_name[2],1);
+                                       (char*)service_name[6],1);
   if (status != IB_SUCCESS)
   {
+    osm_log( &p_osmt->log, OSM_LOG_ERROR,
+             "osmt_run_service_records_flow: ERR 4A32: "
+             "Failed to delete service name:%s\n",
+             (char*)service_name[6] );
     goto Exit;
   }
 
Index: opensm/osm_sa_service_record.c
===================================================================
--- opensm/osm_sa_service_record.c	(revision 5403)
+++ opensm/osm_sa_service_record.c	(working copy)
@@ -798,6 +798,13 @@ osm_sr_rcv_process_get_method(
   p_recvd_service_rec =
     (ib_service_record_t*)ib_sa_mad_get_payload_ptr( p_sa_mad );
 
+  if( osm_log_is_active( p_rcv->p_log, OSM_LOG_DEBUG ) )
+  {
+    osm_dump_service_record( p_rcv->p_log,
+                             p_recvd_service_rec,
+                             OSM_LOG_DEBUG );
+  }
+
   cl_qlist_init(&sr_match_item.sr_list);
   sr_match_item.p_service_rec = p_recvd_service_rec;
   sr_match_item.comp_mask = p_sa_mad->comp_mask;




More information about the general mailing list