test: skip tests when missing requirements
[dpdk.git] / app / test / test_hash_readwrite_lf.c
index 343a338..2664f51 100644 (file)
@@ -126,11 +126,9 @@ get_enabled_cores_list(void)
        uint32_t i = 0;
        uint16_t core_id;
        uint32_t max_cores = rte_lcore_count();
-       for (core_id = 0; core_id < RTE_MAX_LCORE && i < max_cores; core_id++) {
-               if (rte_lcore_is_enabled(core_id)) {
-                       enabled_core_ids[i] = core_id;
-                       i++;
-               }
+       RTE_LCORE_FOREACH(core_id) {
+               enabled_core_ids[i] = core_id;
+               i++;
        }
 
        if (i != max_cores) {
@@ -738,7 +736,7 @@ test_hash_add_no_ks_lookup_hit(struct rwc_perf *rwc_perf_results, int rwc_lf,
                                                        enabled_core_ids[i]);
 
                        for (i = 1; i <= rwc_core_cnt[n]; i++)
-                               if (rte_eal_wait_lcore(i) < 0)
+                               if (rte_eal_wait_lcore(enabled_core_ids[i]) < 0)
                                        goto err;
 
                        unsigned long long cycles_per_lookup =
@@ -810,7 +808,7 @@ test_hash_add_no_ks_lookup_miss(struct rwc_perf *rwc_perf_results, int rwc_lf,
                        if (ret < 0)
                                goto err;
                        for (i = 1; i <= rwc_core_cnt[n]; i++)
-                               if (rte_eal_wait_lcore(i) < 0)
+                               if (rte_eal_wait_lcore(enabled_core_ids[i]) < 0)
                                        goto err;
 
                        unsigned long long cycles_per_lookup =
@@ -886,7 +884,7 @@ test_hash_add_ks_lookup_hit_non_sp(struct rwc_perf *rwc_perf_results,
                        if (ret < 0)
                                goto err;
                        for (i = 1; i <= rwc_core_cnt[n]; i++)
-                               if (rte_eal_wait_lcore(i) < 0)
+                               if (rte_eal_wait_lcore(enabled_core_ids[i]) < 0)
                                        goto err;
 
                        unsigned long long cycles_per_lookup =
@@ -939,7 +937,7 @@ test_hash_add_ks_lookup_hit_sp(struct rwc_perf *rwc_perf_results, int rwc_lf,
                }
                for (n = 0; n < NUM_TEST; n++) {
                        unsigned int tot_lcore = rte_lcore_count();
-                       if (tot_lcore < rwc_core_cnt[n])
+                       if (tot_lcore < rwc_core_cnt[n] + 1)
                                goto finish;
 
                        printf("\nNumber of readers: %u\n", rwc_core_cnt[n]);
@@ -962,7 +960,7 @@ test_hash_add_ks_lookup_hit_sp(struct rwc_perf *rwc_perf_results, int rwc_lf,
                        if (ret < 0)
                                goto err;
                        for (i = 1; i <= rwc_core_cnt[n]; i++)
-                               if (rte_eal_wait_lcore(i) < 0)
+                               if (rte_eal_wait_lcore(enabled_core_ids[i]) < 0)
                                        goto err;
 
                        unsigned long long cycles_per_lookup =
@@ -1037,7 +1035,7 @@ test_hash_add_ks_lookup_miss(struct rwc_perf *rwc_perf_results, int rwc_lf, int
                        if (ret < 0)
                                goto err;
                        for (i = 1; i <= rwc_core_cnt[n]; i++)
-                               if (rte_eal_wait_lcore(i) < 0)
+                               if (rte_eal_wait_lcore(enabled_core_ids[i]) < 0)
                                        goto err;
 
                        unsigned long long cycles_per_lookup =
@@ -1132,12 +1130,12 @@ test_hash_multi_add_lookup(struct rwc_perf *rwc_perf_results, int rwc_lf,
                                for (i = rwc_core_cnt[n] + 1;
                                     i <= rwc_core_cnt[m] + rwc_core_cnt[n];
                                     i++)
-                                       rte_eal_wait_lcore(i);
+                                       rte_eal_wait_lcore(enabled_core_ids[i]);
 
                                writer_done = 1;
 
                                for (i = 1; i <= rwc_core_cnt[n]; i++)
-                                       if (rte_eal_wait_lcore(i) < 0)
+                                       if (rte_eal_wait_lcore(enabled_core_ids[i]) < 0)
                                                goto err;
 
                                unsigned long long cycles_per_lookup =
@@ -1221,7 +1219,7 @@ test_hash_add_ks_lookup_hit_extbkt(struct rwc_perf *rwc_perf_results,
                        writer_done = 1;
 
                        for (i = 1; i <= rwc_core_cnt[n]; i++)
-                               if (rte_eal_wait_lcore(i) < 0)
+                               if (rte_eal_wait_lcore(enabled_core_ids[i]) < 0)
                                        goto err;
 
                        unsigned long long cycles_per_lookup =
@@ -1256,10 +1254,10 @@ test_hash_readwrite_lf_main(void)
        int htm;
        int use_jhash = 0;
        int ext_bkt = 0;
-       if (rte_lcore_count() == 1) {
-               printf("More than one lcore is required "
-                       "to do read write lock-free concurrency test\n");
-               return -1;
+
+       if (rte_lcore_count() < 2) {
+               printf("Not enough cores for hash_readwrite_lf_autotest, expecting at least 2\n");
+               return TEST_SKIPPED;
        }
 
        setlocale(LC_NUMERIC, "");