vppinfra: fix spinlock and rwlock tests 15/21015/2
authorFlorin Coras <fcoras@cisco.com>
Thu, 1 Aug 2019 17:54:06 +0000 (10:54 -0700)
committerFlorin Coras <florin.coras@gmail.com>
Thu, 1 Aug 2019 19:16:37 +0000 (19:16 +0000)
Type: fix

Change-Id: I67b72b5ad03b972198c27bc0d927867f41b0e20b
Signed-off-by: Florin Coras <fcoras@cisco.com>
src/vppinfra/CMakeLists.txt
src/vppinfra/test_rwlock.c
src/vppinfra/test_spinlock.c

index c6a55b3..8af6120 100644 (file)
@@ -255,7 +255,7 @@ if(VPP_BUILD_VPPINFRA_TESTS)
   )
     add_vpp_executable(test_${test}
       SOURCES test_${test}.c
-      LINK_LIBRARIES vppinfra
+      LINK_LIBRARIES vppinfra pthread
       )
   endforeach()
 
index 8b6f927..ad1c7bc 100644 (file)
@@ -110,12 +110,12 @@ test_rwlock (rwlock_test_main_t * rtm, f64 * elapse_time)
       for (uword t_num = 0; t_num < rtm->threads_per_core; t_num++)
        {
          uword t_index = cores_set * rtm->threads_per_core + t_num;
-         if (error = pthread_create (&pthread[t_index], NULL,
-                                     &read_shared_counter, rtm))
+         if ((error = pthread_create (&pthread[t_index], NULL,
+                                      &read_shared_counter, rtm)))
            clib_unix_warning ("pthread_create failed with %d", error);
 
-         if (error = pthread_setaffinity_np (pthread[t_index],
-                                             sizeof (cpu_set_t), &cpuset))
+         if ((error = pthread_setaffinity_np (pthread[t_index],
+                                              sizeof (cpu_set_t), &cpuset)))
            clib_unix_warning ("pthread_set_affinity_np failed with %d",
                               error);
        }
@@ -138,12 +138,12 @@ test_rwlock (rwlock_test_main_t * rtm, f64 * elapse_time)
       for (uword t_num = 0; t_num < rtm->threads_per_core; t_num++)
        {
          uword t_index = cores_set * rtm->threads_per_core + t_num;
-         if (error = pthread_create (&pthread[t_index], NULL,
-                                     &write_shared_counter, rtm))
+         if ((error = pthread_create (&pthread[t_index], NULL,
+                                      &write_shared_counter, rtm)))
            clib_unix_warning ("pthread_create failed with %d", error);
 
-         if (error = pthread_setaffinity_np (pthread[t_index],
-                                             sizeof (cpu_set_t), &cpuset))
+         if ((error = pthread_setaffinity_np (pthread[t_index],
+                                              sizeof (cpu_set_t), &cpuset)))
            clib_unix_warning ("pthread_set_affinity_np failed with %d",
                               error);
        }
@@ -157,7 +157,7 @@ test_rwlock (rwlock_test_main_t * rtm, f64 * elapse_time)
   for (uword thread_num = 0; thread_num < total_threads; thread_num++)
     {
       f64 *time;
-      if (error = pthread_join (pthread[thread_num], (void *) &time))
+      if ((error = pthread_join (pthread[thread_num], (void *) &time)))
        clib_unix_warning ("pthread_join failed with %d", error);
       *elapse_time += *time;
       vec_free (time);
index fd750d9..4ea0fca 100644 (file)
@@ -84,12 +84,12 @@ test_spinlock (spinlock_test_main_t * stm, f64 * elapse_time)
       for (uword t_num = 0; t_num < stm->threads_per_core; t_num++)
        {
          uword t_index = cores_set * stm->threads_per_core + t_num;
-         if (error = pthread_create (&pthread[t_index], NULL,
-                                     &inc_shared_counter, stm))
+         if ((error = pthread_create (&pthread[t_index], NULL,
+                                      &inc_shared_counter, stm)))
            clib_unix_warning ("pthread_create failed with %d", error);
 
-         if (error = pthread_setaffinity_np (pthread[t_index],
-                                             sizeof (cpu_set_t), &cpuset))
+         if ((error = pthread_setaffinity_np (pthread[t_index],
+                                              sizeof (cpu_set_t), &cpuset)))
            clib_unix_warning ("pthread_setaffinity_np failed with %d",
                               error);
        }
@@ -103,7 +103,7 @@ test_spinlock (spinlock_test_main_t * stm, f64 * elapse_time)
   for (uword thread_num = 0; thread_num < num_threads; thread_num++)
     {
       f64 *time;
-      if (error = pthread_join (pthread[thread_num], (void *) &time))
+      if ((error = pthread_join (pthread[thread_num], (void *) &time)))
        clib_unix_warning ("pthread_join failed with %d", error);
       *elapse_time += *time;
       vec_free (time);