[Asterisk-code-review] test.c: Fix couting of tests and failures in XML output (asterisk[18])

George Joseph asteriskteam at digium.com
Mon Apr 3 07:59:22 CDT 2023


George Joseph has uploaded this change for review. ( https://gerrit.asterisk.org/c/asterisk/+/20030 )


Change subject: test.c: Fix couting of tests and failures in XML output
......................................................................

test.c: Fix couting of tests and failures in XML output

The unit test XML output was counting all registered tests as "run"
even when only a subset were actually requested to be run and
the "failures" attribute was missing.

* The "tests" attribute of the "testsuite" element in the
  output XML now reflects only the tests actually requested
  to be executed instead of all the tests registered.

* The "failures" attribute was added to the "testsuite"
  element.

Change-Id: Ia137814b5aeb0e1a44c75034bd3615c26021da69
---
A doc/CHANGES-staging/test.txt
M main/test.c
2 files changed, 31 insertions(+), 3 deletions(-)



  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/30/20030/1

diff --git a/doc/CHANGES-staging/test.txt b/doc/CHANGES-staging/test.txt
new file mode 100644
index 0000000..69cc8df
--- /dev/null
+++ b/doc/CHANGES-staging/test.txt
@@ -0,0 +1,8 @@
+Subject: test.c
+
+The "tests" attribute of the "testsuite" element in the 
+output XML now reflects only the tests actually requested
+to be executed instead of all the tests registered.
+
+The "failures" attribute was added to the "testsuite"
+element.
diff --git a/main/test.c b/main/test.c
index 9eefbd0..7ec505b 100644
--- a/main/test.c
+++ b/main/test.c
@@ -715,8 +715,8 @@
 		/* update total counts as well during this iteration
 		 * even if the current test did not execute this time */
 		last_results.total_time += test->time;
-		last_results.total_tests++;
 		if (test->state != AST_TEST_NOT_RUN) {
+			last_results.total_tests++;
 			if (test->state == AST_TEST_PASS) {
 				last_results.total_passed++;
 			} else {
@@ -793,10 +793,10 @@
 		 */
 		fprintf(f_xml, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
 		fprintf(f_xml, "<testsuites>\n");
-		fprintf(f_xml, "\t<testsuite errors=\"0\" time=\"%u.%u\" tests=\"%u\" "
+		fprintf(f_xml, "\t<testsuite errors=\"0\" time=\"%u.%u\" tests=\"%u\" failures=\"%u\" "
 				"name=\"AsteriskUnitTests\">\n",
 				last_results.total_time / 1000, last_results.total_time % 1000,
-				last_results.total_tests);
+				last_results.total_tests, last_results.total_failed);
 		fprintf(f_xml, "\t\t<properties>\n");
 		fprintf(f_xml, "\t\t\t<property name=\"version\" value=\"%s\"/>\n", ast_get_version());
 		fprintf(f_xml, "\t\t</properties>\n");

-- 
To view, visit https://gerrit.asterisk.org/c/asterisk/+/20030
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: 18
Gerrit-Change-Id: Ia137814b5aeb0e1a44c75034bd3615c26021da69
Gerrit-Change-Number: 20030
Gerrit-PatchSet: 1
Gerrit-Owner: George Joseph <gjoseph at digium.com>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20230403/c90966d7/attachment.html>


More information about the asterisk-code-review mailing list