Fixed a few mistakes from XML logger.
authorMarkus Kauppila <markus.kauppila@gmail.com>
Tue, 28 Jun 2011 23:15:43 +0300
changeset 5722 c464d563e3eb
parent 5721 8e5f0a26f967
child 5723 7c6e8be702c1
Fixed a few mistakes from XML logger.
test/test-automation/xml.c
test/test-automation/xml_logger.c
--- a/test/test-automation/xml.c	Tue Jun 28 17:03:38 2011 +0300
+++ b/test/test-automation/xml.c	Tue Jun 28 23:15:43 2011 +0300
@@ -197,6 +197,9 @@
 {
 	const char *doctype = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n";
 
+	//! \todo make this optional (and let the user supply the filename?)
+	const char *style = "<?xml-stylesheet type=\"text/xsl\" href=\"style.xsl\"?>\n";
+
 	memset(buffer, 0, bufferSize);
 	snprintf(buffer, bufferSize, "<%s>", rootTag);
 
@@ -205,16 +208,18 @@
 	root = rootTag; // it's fine, as long as rootTag points to static memory?
 
 	const int doctypeSize = SDL_strlen(doctype);
+	const int styleSize = SDL_strlen(style);
 	const int tagSize = SDL_strlen(buffer);
 
-	const int size = doctypeSize + tagSize + 1; // extra byte for '\0'
-	char *ret = SDL_malloc(size);
-	// copy doctype
-	strncpy(ret, doctype, doctypeSize);
-	// copy tag
-	strncpy(ret + doctypeSize, buffer, tagSize);
-	ret[size] = '\0';
-	return ret;
+	const int size = doctypeSize + styleSize + tagSize + 1; // extra byte for '\0'
+	char *retBuf = SDL_malloc(size);
+
+	// fill in the previous allocated retBuf
+	strcat(retBuf, doctype);
+	strcat(retBuf, style);
+	strcat(retBuf, buffer);
+
+	return retBuf;
 }
 
 char *
--- a/test/test-automation/xml_logger.c	Tue Jun 28 17:03:38 2011 +0300
+++ b/test/test-automation/xml_logger.c	Tue Jun 28 23:15:43 2011 +0300
@@ -52,7 +52,7 @@
 const char *messageElementName = "message";
 const char *timeElementName = "time";
 const char *assertSummaryElementName = "assertSummary";
-const char *assertCountElementName = "assertName";
+const char *assertCountElementName = "assertCount";
 const char *assertsPassedElementName = "assertsPassed";
 const char *assertsFailedElementName = "assertsFailed";
 const char *logElementName = "log";
@@ -214,6 +214,15 @@
 	char *output = XMLOpenElement(suiteElementName);
 	XMLOutputter(indentLevel++, YES, output);
 
+	output = XMLOpenElement(nameElementName);
+	XMLOutputter(indentLevel++, NO, output);
+
+	output = XMLAddContent(suiteName);
+	XMLOutputter(indentLevel, NO, output);
+
+	output = XMLCloseElement(nameElementName);
+	XMLOutputter(--indentLevel, YES, output);
+
 	output = XMLOpenElement(startTimeElementName);
 	XMLOutputter(indentLevel++, NO, output);
 
@@ -373,6 +382,17 @@
 	char *output = XMLOpenElement(assertElementName);
 	XMLOutputter(indentLevel++, YES, output);
 
+	// log assert name
+	output = XMLOpenElement(nameElementName);
+	XMLOutputter(indentLevel++, NO, output);
+
+	output = XMLAddContent(assertName);
+	XMLOutputter(indentLevel, NO, output);
+
+	output = XMLCloseElement(nameElementName);
+	XMLOutputter(--indentLevel, YES, output);
+
+
 	// log assert result
 	output = XMLOpenElement(resultElementName);
 	XMLOutputter(indentLevel++, NO, output);
@@ -414,6 +434,17 @@
 	char *output = XMLOpenElement(assertElementName);
 	XMLOutputter(indentLevel++, YES, output);
 
+	// log assert name
+	output = XMLOpenElement(nameElementName);
+	XMLOutputter(indentLevel++, NO, output);
+
+	output = XMLAddContent(assertName);
+	XMLOutputter(indentLevel, NO, output);
+
+	output = XMLCloseElement(nameElementName);
+	XMLOutputter(--indentLevel, YES, output);
+
+
 	// log assert result
 	output = XMLOpenElement(resultElementName);
 	XMLOutputter(indentLevel++, NO, output);