test/threads: add unit test
[dpdk.git] / app / test / test_distributor_perf.c
index 371a14b..ee43214 100644 (file)
 #include <rte_cycles.h>
 #include <rte_common.h>
 #include <rte_mbuf.h>
+
+#ifdef RTE_EXEC_ENV_WINDOWS
+static int
+test_distributor_perf(void)
+{
+       printf("distributor perf not supported on Windows, skipping test\n");
+       return TEST_SKIPPED;
+}
+
+#else
+
 #include <rte_distributor.h>
 #include <rte_pause.h>
 
@@ -108,7 +119,6 @@ static int
 handle_work(void *arg)
 {
        struct rte_distributor *d = arg;
-       unsigned int count = 0;
        unsigned int num = 0;
        int i;
        unsigned int id = __atomic_fetch_add(&worker_idx, 1, __ATOMIC_RELAXED);
@@ -120,11 +130,9 @@ handle_work(void *arg)
        num = rte_distributor_get_pkt(d, id, buf, buf, num);
        while (!quit) {
                worker_stats[id].handled_packets += num;
-               count += num;
                num = rte_distributor_get_pkt(d, id, buf, buf, num);
        }
        worker_stats[id].handled_packets += num;
-       count += num;
        rte_distributor_return_pkt(d, id, buf, num);
        return 0;
 }
@@ -196,6 +204,7 @@ quit_workers(struct rte_distributor *d, struct rte_mempool *p)
        rte_mempool_put_bulk(p, (void *)bufs, num_workers);
 
        rte_distributor_process(d, NULL, 0);
+       rte_distributor_flush(d);
        rte_eal_mp_wait_lcore();
        quit = 0;
        worker_idx = 0;
@@ -266,4 +275,6 @@ test_distributor_perf(void)
        return 0;
 }
 
+#endif /* !RTE_EXEC_ENV_WINDOWS */
+
 REGISTER_TEST_COMMAND(distributor_perf_autotest, test_distributor_perf);