Skip to contentSkip to conversation

Enable more unit tests

PATCH In review Stephen Hemminger 3 participants 20 messages Jul 18, 2024 – Dec 2, 2025

lore
Share & tools
lore
#0 lore raw

cover Enable more unit tests

Several of the unit tests were not listed in any test suite and therefore were rarely run. When running build this was reported as errors:
WARNING: Test "alarm_autotest" is not defined in any test suite
WARNING: Test "cksum_perf_autotest" is not defined in any test suite

Put the alarm, cksum, and timer tests into the appropriate test suite. More tests should be updated (later).

Stephen Hemminger (4):
test: update alarm test
test: run cksum tests as part of perf test suite
test: make red test part of fast suite
test: run timer secondary tests as part of fast suite

 app/test/test_alarm.c           | 53 +++++++++++++--------------------
 app/test/test_cksum_perf.c      |  3 +-
 app/test/test_red.c             |  2 +-
 app/test/test_timer_secondary.c |  2 +-
 4 files changed, 23 insertions(+), 37 deletions(-)
Signature · 1 line
2.43.0
#1 lore raw

PATCH 1/4 test: update alarm test

This test should be using the TEST_ASSERT macros, and can be run as part of the fast test suite now.

---
 app/test/test_alarm.c | 53 ++++++++++++++++---------------------------
 1 file changed, 20 insertions(+), 33 deletions(-)
app/test/test_alarm.c +20 -33
index 70e97a3109..4ba8aa1af2 100644
@@ -10,7 +10,8 @@
 
 #include "test.h"
 
-#ifndef RTE_EXEC_ENV_WINDOWS
+#define US_PER_SEC 1000000
+
 static volatile int flag;
 
 static void
@@ -19,46 +20,32 @@ test_alarm_callback(void *cb_arg)
 	flag = 1;
 	printf("Callback setting flag - OK. [cb_arg = %p]\n", cb_arg);
 }
-#endif
 
 static int
 test_alarm(void)
 {
-#ifdef RTE_EXEC_ENV_FREEBSD
-	printf("The alarm API is not supported on FreeBSD\n");
-	return 0;
-#endif
+	int ret;
+
+	ret = rte_eal_alarm_set(0, test_alarm_callback, NULL);
+	TEST_ASSERT_FAIL(ret, "should not be succeed with 0 us value");
+
+	ret = rte_eal_alarm_set(UINT64_MAX - 1, test_alarm_callback, NULL);
+	TEST_ASSERT_FAIL(ret, "should not be succeed with (UINT64_MAX-1) us value");
+
+	ret = rte_eal_alarm_set(10, NULL, NULL);
+	TEST_ASSERT_FAIL(ret, "should not succeed with null callback parameter");
 
-#ifndef RTE_EXEC_ENV_WINDOWS
-	/* check if it will fail to set alarm with wrong us value */
-	printf("check if it will fail to set alarm with wrong ms values\n");
-	if (rte_eal_alarm_set(0, test_alarm_callback,
-						NULL) >= 0) {
-		printf("should not be successful with 0 us value\n");
-		return -1;
-	}
-	if (rte_eal_alarm_set(UINT64_MAX - 1, test_alarm_callback,
-						NULL) >= 0) {
-		printf("should not be successful with (UINT64_MAX-1) us value\n");
-		return -1;
-	}
-#endif
+	ret = rte_eal_alarm_cancel(NULL, NULL);
+	TEST_ASSERT_FAIL(ret, "should not succeed to remove alarm with null callback parameter");
 
-	/* check if it will fail to set alarm with null callback parameter */
-	printf("check if it will fail to set alarm with null callback parameter\n");
-	if (rte_eal_alarm_set(10 /* ms */, NULL, NULL) >= 0) {
-		printf("should not be successful to set alarm with null callback parameter\n");
-		return -1;
-	}
+	ret = rte_eal_alarm_set(US_PER_SEC, test_alarm_callback, NULL);
+	TEST_ASSERT_SUCCESS(ret, "could not set an alarm");
 
-	/* check if it will fail to remove alarm with null callback parameter */
-	printf("check if it will fail to remove alarm with null callback parameter\n");
-	if (rte_eal_alarm_cancel(NULL, NULL) == 0) {
-		printf("should not be successful to remove alarm with null callback parameter");
-		return -1;
-	}
+	ret = rte_eal_alarm_cancel(test_alarm_callback, NULL);
+	/* return is the number of the alarm set (or 0 if none or -1 if error) */
+	TEST_ASSERT(ret > 0, "could not cancel an alarm: %d", ret);
 
 	return 0;
 }
 
-REGISTER_TEST_COMMAND(alarm_autotest, test_alarm);
+REGISTER_FAST_TEST(alarm_autotest, true, true, test_alarm);
Signature · 1 line
2.43.0
#2 lore raw

Re: [PATCH 1/4] test: update alarm test

Quoted 36 lines · Stephen Hemminger

This test should be using the TEST_ASSERT macros, and can be run as part of the fast test suite now.

---
 app/test/test_alarm.c | 53 ++++++++++++++++---------------------------
 1 file changed, 20 insertions(+), 33 deletions(-)
app/test/test_alarm.c +3 -6
index 70e97a3109..4ba8aa1af2 100644
@@ -10,7 +10,8 @@
 
 #include "test.h"
 
-#ifndef RTE_EXEC_ENV_WINDOWS
+#define US_PER_SEC 1000000
+
 static volatile int flag;
 
 static void
@@ -19,46 +20,32 @@ test_alarm_callback(void *cb_arg)
 	flag = 1;
 	printf("Callback setting flag - OK. [cb_arg = %p]\n", cb_arg);
 }
-#endif
 
 static int
 test_alarm(void)
 {
-#ifdef RTE_EXEC_ENV_FREEBSD
-	printf("The alarm API is not supported on FreeBSD\n");
-	return 0;
-#endif
+	int ret;

app/test/test_alarm.c test_alarm_callback(void *cb_arg) · line 37

Quoted 10 lines
app/test/test_alarm.c +9 -0
+
+	ret = rte_eal_alarm_set(0, test_alarm_callback, NULL);
+	TEST_ASSERT_FAIL(ret, "should not be succeed with 0 us value");
+
+	ret = rte_eal_alarm_set(UINT64_MAX - 1, test_alarm_callback, NULL);
+	TEST_ASSERT_FAIL(ret, "should not be succeed with (UINT64_MAX-1) us value");
+
+	ret = rte_eal_alarm_set(10, NULL, NULL);
+	TEST_ASSERT_FAIL(ret, "should not succeed with null callback parameter");
 

+1 to use of TEST_ASSERT_FAIL, the test is a lot cleaner now. However, I think we still need the #ifdefs in it if some of it doesn't work on Windows/BSD.

/Bruce

#3 lore raw

Re: [PATCH 1/4] test: update alarm test

Quoted 52 lines · On Fri, 19 Jul 2024 11:17:43 +0100 Bruce Richardson…
Quoted 36 lines · Stephen Hemminger

This test should be using the TEST_ASSERT macros, and can be run as part of the fast test suite now.

---
 app/test/test_alarm.c | 53 ++++++++++++++++---------------------------
 1 file changed, 20 insertions(+), 33 deletions(-)
app/test/test_alarm.c +3 -6
index 70e97a3109..4ba8aa1af2 100644
@@ -10,7 +10,8 @@
 
 #include "test.h"
 
-#ifndef RTE_EXEC_ENV_WINDOWS
+#define US_PER_SEC 1000000
+
 static volatile int flag;
 
 static void
@@ -19,46 +20,32 @@ test_alarm_callback(void *cb_arg)
 	flag = 1;
 	printf("Callback setting flag - OK. [cb_arg = %p]\n", cb_arg);
 }
-#endif
 
 static int
 test_alarm(void)
 {
-#ifdef RTE_EXEC_ENV_FREEBSD
-	printf("The alarm API is not supported on FreeBSD\n");
-	return 0;
-#endif
+	int ret;

app/test/test_alarm.c test_alarm_callback(void *cb_arg) · line 37

Quoted 10 lines
app/test/test_alarm.c +9 -0
+
+	ret = rte_eal_alarm_set(0, test_alarm_callback, NULL);
+	TEST_ASSERT_FAIL(ret, "should not be succeed with 0 us value");
+
+	ret = rte_eal_alarm_set(UINT64_MAX - 1, test_alarm_callback, NULL);
+	TEST_ASSERT_FAIL(ret, "should not be succeed with (UINT64_MAX-1) us value");
+
+	ret = rte_eal_alarm_set(10, NULL, NULL);
+	TEST_ASSERT_FAIL(ret, "should not succeed with null callback parameter");
 

+1 to use of TEST_ASSERT_FAIL, the test is a lot cleaner now. However, I think we still need the #ifdefs in it if some of it doesn't work on Windows/BSD.

Quoted 1 line

/Bruce

It looks like alarm API's exist on Windows (see lib/eal/windows/eal_alarm.c) therefore should be tested but aren't being now.

#4 lore raw

Re: [PATCH 1/4] test: update alarm test

In reply to Stephen Hemminger
Quoted 5 lines · Stephen Hemminger

This test should be using the TEST_ASSERT macros, and can be run as part of the fast test suite now.

[...]

app/test/test_alarm.c test_alarm_callback(void *cb_arg) · line 51

Quoted 9 lines
app/test/test_alarm.c +4 -1
+       ret = rte_eal_alarm_cancel(test_alarm_callback, NULL);
+       /* return is the number of the alarm set (or 0 if none or -1 if error) */
+       TEST_ASSERT(ret > 0, "could not cancel an alarm: %d", ret);
 
        return 0;
 }
 
-REGISTER_TEST_COMMAND(alarm_autotest, test_alarm);
+REGISTER_FAST_TEST(alarm_autotest, true, true, test_alarm);

This test was removed from the fast-tests list as it was triggering false failures in some CI.
ee00af60170b ("test: remove strict timing requirements some tests")

Signature · 1 line
David Marchand
#5 lore raw

Re: [PATCH 1/4] test: update alarm test

Quoted 17 lines · On Tue, 6 Aug 2024 14:45:45 +0200 David Marchand <[email protected]>…
Quoted 5 lines · Stephen Hemminger

This test should be using the TEST_ASSERT macros, and can be run as part of the fast test suite now.

[...]

Quoted 7 lines
app/test/test_alarm.c +3 -0
+       ret = rte_eal_alarm_cancel(test_alarm_callback, NULL);
+       /* return is the number of the alarm set (or 0 if none or -1 if error) */
+       TEST_ASSERT(ret > 0, "could not cancel an alarm: %d", ret);
 
        return 0;
 }
Quoted 8 lines

app/test/test_alarm.c test_alarm_callback(void *cb_arg) · line 51

Quoted 2 lines
app/test/test_alarm.c +1 -1
-REGISTER_TEST_COMMAND(alarm_autotest, test_alarm);
+REGISTER_FAST_TEST(alarm_autotest, true, true, test_alarm);  

This test was removed from the fast-tests list as it was triggering false failures in some CI.
ee00af60170b ("test: remove strict timing requirements some tests")

Maybe test can be fixed to use different time values. Or like lcore tests, some yielding is needed.

#6 lore raw

Re: [PATCH 1/4] test: update alarm test

In reply to David Marchand
Quoted 17 lines · On Tue, 6 Aug 2024 14:45:45 +0200 David Marchand <[email protected]>…
Quoted 5 lines · Stephen Hemminger

This test should be using the TEST_ASSERT macros, and can be run as part of the fast test suite now.

[...]

Quoted 7 lines
app/test/test_alarm.c +3 -0
+       ret = rte_eal_alarm_cancel(test_alarm_callback, NULL);
+       /* return is the number of the alarm set (or 0 if none or -1 if error) */
+       TEST_ASSERT(ret > 0, "could not cancel an alarm: %d", ret);
 
        return 0;
 }
Quoted 6 lines

app/test/test_alarm.c test_alarm_callback(void *cb_arg) · line 51

Quoted 2 lines
app/test/test_alarm.c +1 -1
-REGISTER_TEST_COMMAND(alarm_autotest, test_alarm);
+REGISTER_FAST_TEST(alarm_autotest, true, true, test_alarm);  

This test was removed from the fast-tests list as it was triggering false failures in some CI.
ee00af60170b ("test: remove strict timing requirements some tests")

I can see why that test failed (too short an alarm), but the whole test has lots of other issues. Starting new series to address.

#7 lore raw

PATCH 2/4 test: run cksum tests as part of perf test suite

In reply to Stephen Hemminger

The cksum tests would not get run since not part of one of the test suites. Meson complains with:

WARNING: Test "cksum_perf_autotest" is not defined in any test suite

---
 app/test/test_cksum_perf.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
app/test/test_cksum_perf.c +1 -2
index 1f296cae34..0b919cd59f 100644
@@ -113,5 +113,4 @@ test_cksum_perf(void)
 	return TEST_SUCCESS;
 }
 
-
-REGISTER_TEST_COMMAND(cksum_perf_autotest, test_cksum_perf);
+REGISTER_PERF_TEST(cksum_perf_autotest, test_cksum_perf);
Signature · 1 line
2.43.0
Acked-by on v1 2/4
#8 lore raw

Re: [PATCH 2/4] test: run cksum tests as part of perf test suite

Quoted 6 lines · Stephen Hemminger

The cksum tests would not get run since not part of one of the test suites. Meson complains with:

WARNING: Test "cksum_perf_autotest" is not defined in any test suite

Quoted 18 lines
---
 app/test/test_cksum_perf.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
app/test/test_cksum_perf.c +1 -2
index 1f296cae34..0b919cd59f 100644
@@ -113,5 +113,4 @@ test_cksum_perf(void)
 	return TEST_SUCCESS;
 }
 
-
-REGISTER_TEST_COMMAND(cksum_perf_autotest, test_cksum_perf);
+REGISTER_PERF_TEST(cksum_perf_autotest, test_cksum_perf);
Signature · 1 line
2.43.0
#9 lore raw

PATCH 3/4 test: make red test part of fast suite

In reply to Stephen Hemminger

The red tests were not run because not part of any suite. Meson warning is:
WARNING: Test "red_autotest" is not defined in any test suite

---
 app/test/test_red.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
app/test/test_red.c +1 -1
index aa7538d51a..4bb17dce7a 100644
@@ -1877,6 +1877,6 @@ test_red_all(void)
 
 #endif /* !RTE_EXEC_ENV_WINDOWS */
 
-REGISTER_TEST_COMMAND(red_autotest, test_red);
+REGISTER_FAST_TEST(red_autotest, true, true, test_red);
 REGISTER_PERF_TEST(red_perf, test_red_perf);
 REGISTER_PERF_TEST(red_all, test_red_all);
Signature · 1 line
2.43.0
Acked-by on v1 3/4
#10 lore raw

Re: [PATCH 3/4] test: make red test part of fast suite

Quoted 5 lines · Stephen Hemminger

The red tests were not run because not part of any suite. Meson warning is:
WARNING: Test "red_autotest" is not defined in any test suite

Quoted 19 lines
---
 app/test/test_red.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
app/test/test_red.c +1 -1
index aa7538d51a..4bb17dce7a 100644
@@ -1877,6 +1877,6 @@ test_red_all(void)
 
 #endif /* !RTE_EXEC_ENV_WINDOWS */
 
-REGISTER_TEST_COMMAND(red_autotest, test_red);
+REGISTER_FAST_TEST(red_autotest, true, true, test_red);
 REGISTER_PERF_TEST(red_perf, test_red_perf);
 REGISTER_PERF_TEST(red_all, test_red_all);
Signature · 1 line
2.43.0
#12 lore raw

Re: [PATCH 3/4] test: make red test part of fast suite

Quoted 12 lines · David Marchand
Quoted 6 lines · Stephen Hemminger

The red tests were not run because not part of any suite. Meson warning is:
WARNING: Test "red_autotest" is not defined in any test suite

There is an open bz about this unit test.
https://bugs.dpdk.org/show_bug.cgi?id=826

Do we need a "broken tests" placeholder suite, or is it better to just leave the broken tests unassigned and warning in meson?

/Bruce

#13 lore raw

Re: [PATCH 3/4] test: make red test part of fast suite

In reply to David Marchand
Quoted 13 lines · On Tue, 6 Aug 2024 14:28:13 +0200 David Marchand <[email protected]>…
Quoted 6 lines · Stephen Hemminger

The red tests were not run because not part of any suite. Meson warning is:
WARNING: Test "red_autotest" is not defined in any test suite

There is an open bz about this unit test.
https://bugs.dpdk.org/show_bug.cgi?id=826

So bug reported but no action taken. Maybe time to turn off RED then :-)

#14 lore raw

Re: [PATCH 3/4] test: make red test part of fast suite

Quoted 11 lines · Stephen Hemminger
Quoted 7 lines · On Tue, 6 Aug 2024 14:28:13 +0200 David Marchand <[email protected]>…
Quoted 5 lines · Stephen Hemminger

The red tests were not run because not part of any suite. Meson warning is:
WARNING: Test "red_autotest" is not defined in any test suite

Quoted 7 lines
Quoted 5 lines
Quoted 1 line

There is an open bz about this unit test.
https://bugs.dpdk.org/show_bug.cgi?id=826

So bug reported but no action taken. Maybe time to turn off RED then :-)

That's an option :-) but we did not announce it in before v24.11 LTS, so it's late.
Can we schedule this for next LTS?

Signature · 1 line
David Marchand
#15 lore raw

Re: [PATCH 3/4] test: make red test part of fast suite

Quoted 19 lines · David Marchand
Quoted 16 lines · Stephen Hemminger
Quoted 12 lines · On Tue, 6 Aug 2024 14:28:13 +0200 David Marchand <[email protected]>…
Quoted 6 lines · Stephen Hemminger

The red tests were not run because not part of any suite. Meson warning is:
WARNING: Test "red_autotest" is not defined in any test suite

There is an open bz about this unit test.
https://bugs.dpdk.org/show_bug.cgi?id=826

Quoted 6 lines
Quoted 2 lines

So bug reported but no action taken. Maybe time to turn off RED then :-)

That's an option :-) but we did not announce it in before v24.11 LTS, so it's late.
Can we schedule this for next LTS?

Time to schedule removal, especially as I see Bruce re-adding this test in some testsuite.

Signature · 1 line
David Marchand
#16 lore raw

PATCH 4/4 test: run timer secondary tests as part of fast suite

In reply to Stephen Hemminger

The tests were not part of any suite so not run normally. Meson warning is:
WARNING: Test "timer_secondary_autotest" is not defined in any test suite

---
 app/test/test_timer_secondary.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
app/test/test_timer_secondary.c +1 -1
index 4e220559b4..2f98c177cd 100644
@@ -224,4 +224,4 @@ test_timer_secondary(void)
 
 #endif /* !RTE_EXEC_ENV_WINDOWS */
 
-REGISTER_TEST_COMMAND(timer_secondary_autotest, test_timer_secondary);
+REGISTER_FAST_TEST(timer_secondary_autotest, false, true, test_timer_secondary);
Signature · 1 line
2.43.0
#18 lore raw

Re: [PATCH 4/4] test: run timer secondary tests as part of fast suite

In reply to Stephen Hemminger
Quoted 21 lines · Stephen Hemminger

The tests were not part of any suite so not run normally. Meson warning is:
WARNING: Test "timer_secondary_autotest" is not defined in any test suite

---
 app/test/test_timer_secondary.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
app/test/test_timer_secondary.c +1 -2
index 4e220559b4..2f98c177cd 100644
@@ -224,4 +224,4 @@ test_timer_secondary(void)
 
 #endif /* !RTE_EXEC_ENV_WINDOWS */
 
-REGISTER_TEST_COMMAND(timer_secondary_autotest, test_timer_secondary);
+REGISTER_FAST_TEST(timer_secondary_autotest, false, true, test_timer_secondary);
--
Quoted 2 lines

2.43.0

This test timed out in GHA.

Signature · 1 line
David Marchand
#19 lore raw
In reply to Stephen Hemminger
Quoted 16 lines · Stephen Hemminger

Several of the unit tests were not listed in any test suite and therefore were rarely run. When running build this was reported as errors:
WARNING: Test "alarm_autotest" is not defined in any test suite
WARNING: Test "cksum_perf_autotest" is not defined in any test suite

Put the alarm, cksum, and timer tests into the appropriate test suite. More tests should be updated (later).

Stephen Hemminger (4):
test: update alarm test
test: run cksum tests as part of perf test suite
test: make red test part of fast suite
test: run timer secondary tests as part of fast suite

Quoted 5 lines
 app/test/test_alarm.c           | 53 +++++++++++++--------------------
 app/test/test_cksum_perf.c      |  3 +-
 app/test/test_red.c             |  2 +-
 app/test/test_timer_secondary.c |  2 +-
 4 files changed, 23 insertions(+), 37 deletions(-)

I merged the alarm test cleanups, which means patch 1 is superseded.

The red and the timer secondary tests can't be put in fast-tests.

I merged the cksum patch only and updated patchwork accordingly.

Thanks.

Signature · 1 line
David Marchand