validation: tm: add checks for adequate cpu resources

Message ID 1463428485-4613-1-git-send-email-bill.fischofer@linaro.org
State New
Headers show

Commit Message

Bill Fischofer May 16, 2016, 7:54 p.m.
The shaper and scheduler tests require a minimum of two CPUs to run
reliably. Make these tests conditional and skip them with a warning to
avoid spurious failures if test is run with only a single CPU.

Signed-off-by: Bill Fischofer <bill.fischofer@linaro.org>
---
 test/validation/traffic_mngr/traffic_mngr.c | 36 +++++++++++++++++++++++++++--
 test/validation/traffic_mngr/traffic_mngr.h |  2 ++
 2 files changed, 36 insertions(+), 2 deletions(-)

Patch

diff --git a/test/validation/traffic_mngr/traffic_mngr.c b/test/validation/traffic_mngr/traffic_mngr.c
index 305b91a..5ff58f9 100644
--- a/test/validation/traffic_mngr/traffic_mngr.c
+++ b/test/validation/traffic_mngr/traffic_mngr.c
@@ -3652,6 +3652,21 @@  void traffic_mngr_test_tm_create(void)
 	dump_tm_tree(0);
 }
 
+int traffic_mngr_check_shaper(void)
+{
+	odp_cpumask_t cpumask;
+	int cpucount = odp_cpumask_all_available(&cpumask);
+
+	if (cpucount < 2) {
+		LOG_DBG("\nSkipping shaper test because cpucount = %d "
+			"is less then min number 2 required\n", cpucount);
+		LOG_DBG("Rerun with more cpu resources\n");
+		return ODP_TEST_INACTIVE;
+	}
+
+	return ODP_TEST_ACTIVE;
+}
+
 void traffic_mngr_test_shaper(void)
 {
 	CU_ASSERT(test_shaper_bw("bw1",   "node_1_1_1", 0, 1   * MBPS) == 0);
@@ -3661,6 +3676,21 @@  void traffic_mngr_test_shaper(void)
 	CU_ASSERT(test_shaper_bw("bw100", "node_1_1_2", 0, 100 * MBPS) == 0);
 }
 
+int traffic_mngr_check_scheduler(void)
+{
+	odp_cpumask_t cpumask;
+	int cpucount = odp_cpumask_all_available(&cpumask);
+
+	if (cpucount < 2) {
+		LOG_DBG("\nSkipping scheduler test because cpucount = %d "
+			"is less then min number 2 required\n", cpucount);
+		LOG_DBG("Rerun with more cpu resources\n");
+		return ODP_TEST_INACTIVE;
+	}
+
+	return ODP_TEST_ACTIVE;
+}
+
 void traffic_mngr_test_scheduler(void)
 {
 	CU_ASSERT(test_sched_queue_priority("que_prio", "node_1_1_3", 10) == 0);
@@ -3818,8 +3848,10 @@  odp_testinfo_t traffic_mngr_suite[] = {
 	ODP_TEST_INFO(traffic_mngr_test_sched_profile),
 	ODP_TEST_INFO(traffic_mngr_test_threshold_profile),
 	ODP_TEST_INFO(traffic_mngr_test_wred_profile),
-	ODP_TEST_INFO(traffic_mngr_test_shaper),
-	ODP_TEST_INFO(traffic_mngr_test_scheduler),
+	ODP_TEST_INFO_CONDITIONAL(traffic_mngr_test_shaper,
+				  traffic_mngr_check_shaper),
+	ODP_TEST_INFO_CONDITIONAL(traffic_mngr_test_scheduler,
+				  traffic_mngr_check_scheduler),
 	ODP_TEST_INFO(traffic_mngr_test_thresholds),
 	ODP_TEST_INFO(traffic_mngr_test_byte_wred),
 	ODP_TEST_INFO(traffic_mngr_test_pkt_wred),
diff --git a/test/validation/traffic_mngr/traffic_mngr.h b/test/validation/traffic_mngr/traffic_mngr.h
index 0d50751..bdac221 100644
--- a/test/validation/traffic_mngr/traffic_mngr.h
+++ b/test/validation/traffic_mngr/traffic_mngr.h
@@ -17,7 +17,9 @@  void traffic_mngr_test_sched_profile(void);
 void traffic_mngr_test_threshold_profile(void);
 void traffic_mngr_test_wred_profile(void);
 void traffic_mngr_test_shaper(void);
+int traffic_mngr_check_shaper(void);
 void traffic_mngr_test_scheduler(void);
+int traffic_mngr_check_scheduler(void);
 void traffic_mngr_test_thresholds(void);
 void traffic_mngr_test_byte_wred(void);
 void traffic_mngr_test_pkt_wred(void);