Skip to contentSkip to conversation

fstests: improve junit xml reporting

PATCH Superseded Darrick J. Wong 2 participants 16 messages Feb 15, 2023

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

v2 cover fstests: improve junit xml reporting

Hi all,

This series improves the fstests reporting code in several ways. First, change the ./check code to generate the report after every test, so that a cluster-based fstest scheduler can reschedule tests after a VM crash. Personally, I was using it to get live status on my tests dashboard.

The bulk of the patches in here improve the junit xml reporting so that we (a) actually declare which xml schema we're trying to emit and (b) capture a lot more information about what was being tested.

v2: shorten indenting in the schema file, record .dmesg files as a separate kernel-log tag, clarify what the timestamp attribute means, record the test suite start time and report generation time as separate attributes, make it possible to pass in a list of report variables, encode cdata correctly

If you're going to start using this mess, you probably ought to just pull from my git trees, which are linked below.

This is an extraordinary way to destroy everything. Enjoy! Comments and questions are, as always, welcome.

--D

fstests git tree:
https://git.kernel.org/cgit/linux/kernel/git/djwong/xfstests-dev.git/log/?h=xunit-reporting-improvements

---
 README        |    3 +
 check         |   11 +++
 common/ext4   |    5 +
 common/report |  119 +++++++++++++++++++++++-----
 common/xfs    |   10 ++
 doc/xunit.xsd |  246 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 6 files changed, 374 insertions(+), 20 deletions(-)
 create mode 100644 doc/xunit.xsd
#1 lore raw

PATCH v2 1/14 check: generate section reports between tests

From: Darrick J. Wong <[email protected]>

Generate the section report between tests so that the summary report always reflects the outcome of the most recent test. Two usecases are envisioned here -- if a cluster-based test runner anticipates that the testrun could crash the VM, they can set REPORT_DIR to (say) an NFS mount to preserve the intermediate results. If the VM does indeed crash, the scheduler can examine the state of the crashed VM and move the tests to another VM. The second usecase is a reporting agent that runs in the VM to upload live results to a test dashboard.

---
 check |    9 +++++++++
 1 file changed, 9 insertions(+)
check +9 -0
index 0bf5b22e06..14b398fd73 100755
@@ -844,6 +844,15 @@ function run_section()
 		fi
 		seqres="$REPORT_DIR/$seqnum"
 
+		# Generate the entire section report with whatever test results
+		# we have so far.  Leave the $sect_time parameter empty so that
+		# it's a little more obvious that this test run is incomplete.
+		if $do_report; then
+			_make_section_report "$section" "${#try[*]}" \
+					     "${#bad[*]}" "${#notrun[*]}" \
+					     "" &> /dev/null
+		fi
+
 		mkdir -p $RESULT_DIR
 		rm -f ${RESULT_DIR}/require_scratch*
 		rm -f ${RESULT_DIR}/require_test*
#2 lore raw

Re: [PATCH 01/14] check: generate section reports between tests

Quoted 28 lines · Darrick J. Wong

From: Darrick J. Wong <[email protected]>

Generate the section report between tests so that the summary report always reflects the outcome of the most recent test. Two usecases are envisioned here -- if a cluster-based test runner anticipates that the testrun could crash the VM, they can set REPORT_DIR to (say) an NFS mount to preserve the intermediate results. If the VM does indeed crash, the scheduler can examine the state of the crashed VM and move the tests to another VM. The second usecase is a reporting agent that runs in the VM to upload live results to a test dashboard.

---
 check |    9 +++++++++
 1 file changed, 9 insertions(+)
check +2 -0
index 0bf5b22e06..14b398fd73 100755
@@ -844,6 +844,15 @@ function run_section()
 		fi
 		seqres="$REPORT_DIR/$seqnum"
 
+		# Generate the entire section report with whatever test results
+		# we have so far.  Leave the $sect_time parameter empty so that

check function run_section() · line 858

Quoted 10 lines
check +7 -0
+		# it's a little more obvious that this test run is incomplete.
+		if $do_report; then
+			_make_section_report "$section" "${#try[*]}" \
+					     "${#bad[*]}" "${#notrun[*]}" \
+					     "" &> /dev/null
+		fi
+
 		mkdir -p $RESULT_DIR
 		rm -f ${RESULT_DIR}/require_scratch*
 		rm -f ${RESULT_DIR}/require_test*

This works for me, thanks!

Reviewed-and-tested-by Leah Rumancik <[email protected]>
#3 lore raw

PATCH v2 2/14 report: derive an xml schema for the xunit report

In reply to Darrick J. Wong

From: Darrick J. Wong <[email protected]>

The "xunit" report format emits an XML document that more or less follows the junit xml schema. However, there are two major exceptions:

1. fstests does not emit an @errors attribute on the testsuite element because we don't have the concept of unanticipated errors such as "unchecked throwables".

2. The system-out/system-err elements sound like they belong under the testcase element, though the schema itself imprecisely says "while the test was executed". The schema puts them under the top-level testsuite element, but we put them under the testcase element.

Define an xml schema for the xunit report format, and update the xml headers to link to the schema file. This enables consumers of the reports to check mechanically that the incoming document follows the format.

---
 common/report |   15 +++-
 doc/xunit.xsd |  226 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 238 insertions(+), 3 deletions(-)
 create mode 100644 doc/xunit.xsd
common/report +12 -3
index 64f9c86648..1d84650270 100644
@@ -48,9 +48,18 @@ _xunit_make_section_report()
 	if [ -z "$date_time" ]; then
 		date_time=$(date +"%F %T")
 	fi
-	local stats="failures=\"$bad_count\" skipped=\"$notrun_count\" tests=\"$tests_count\" time=\"$sect_time\""
-	local hw_info="hostname=\"$HOST\" timestamp=\"${date_time/ /T}\" "
-	echo "<testsuite name=\"xfstests\" $stats  $hw_info >" >> $REPORT_DIR/result.xml
+
+	local fstests_ns="https://git.kernel.org/pub/scm/fs/xfs/xfstests-dev.git"
+	cat >> $REPORT_DIR/result.xml << ENDL
+<testsuite
+ xmlns="$fstests_ns"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="$fstests_ns $fstests_ns/tree/doc/xunit.xsd"
+
+ name="xfstests"
+ failures="$bad_count" skipped="$notrun_count" tests="$tests_count" time="$sect_time"
+ hostname="$HOST" timestamp="${date_time/ /T}">
+ENDL
 
 	# Properties
 	echo -e "\t<properties>" >> $REPORT_DIR/result.xml
doc/xunit.xsd new file +226 -0

226 lines not on this page · raw message

#4 lore raw

PATCH v2 3/14 report: capture the time zone in the test report timestamp

In reply to Darrick J. Wong

From: Darrick J. Wong <[email protected]>

Make sure we put the time zone of the system running the test in the timestamp that is recorded in the xunit report. `date "+%F %T"' reports the local time zone, not UTC.

---
 common/report |    9 ++++++---
 doc/xunit.xsd |    4 ++--
 2 files changed, 8 insertions(+), 5 deletions(-)
common/report +6 -3
index 1d84650270..1817132d51 100644
@@ -38,6 +38,7 @@ _xunit_make_section_report()
 	local bad_count="$3"
 	local notrun_count="$4"
 	local sect_time="$5"
+	local timestamp
 
 	if [ $sect_name == '-no-sections-' ]; then
 		sect_name='global'
@@ -45,8 +46,10 @@ _xunit_make_section_report()
 	local report=$tmp.report.xunit.$sect_name.xml
 	# Header
 	echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" > $REPORT_DIR/result.xml
-	if [ -z "$date_time" ]; then
-		date_time=$(date +"%F %T")
+	if [ -n "$date_time" ]; then
+		timestamp="$(date -Iseconds --date="$date_time")"
+	else
+		timestamp="$(date -Iseconds)"
 	fi
 
 	local fstests_ns="https://git.kernel.org/pub/scm/fs/xfs/xfstests-dev.git"
@@ -58,7 +61,7 @@ _xunit_make_section_report()
 
  name="xfstests"
  failures="$bad_count" skipped="$notrun_count" tests="$tests_count" time="$sect_time"
- hostname="$HOST" timestamp="${date_time/ /T}">
+ hostname="$HOST" timestamp="$timestamp">
 ENDL
 
 	# Properties
doc/xunit.xsd +2 -2
index ba97ccd67d..9295c5dc82 100644
@@ -12,7 +12,7 @@
     <xs:element name="testsuite" type="testsuite"/>
     <xs:simpleType name="ISO8601_DATETIME_PATTERN">
         <xs:restriction base="xs:dateTime">
-            <xs:pattern value="[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}"/>
+            <xs:pattern value="[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}[+-][0-9]{2}:[0-9]{2}"/>
         </xs:restriction>
     </xs:simpleType>
     <xs:element name="testsuites">
@@ -184,7 +184,7 @@
         </xs:attribute>
         <xs:attribute name="timestamp" type="ISO8601_DATETIME_PATTERN" use="required">
             <xs:annotation>
-                <xs:documentation xml:lang="en">when the test was executed. Timezone may not be specified.</xs:documentation>
+                <xs:documentation xml:lang="en">when the test was executed. Timezone must be specified as an offset from UTC.</xs:documentation>
             </xs:annotation>
         </xs:attribute>
         <xs:attribute name="hostname" use="required">
#5 lore raw

PATCH v2 4/14 report: clarify the meaning of the timestamp attribute

In reply to Darrick J. Wong

From: Darrick J. Wong <[email protected]>

We've never specified what the timestamp attribute of the testsuite element actually means, and it history is rather murky.

Prior to the introduction of the xml report format in commit f9fde7db2f, the "date_time" variable was used only to scrape dmesg via the /dev/kmsg device after each test. If /dev/kmsg was not a writable path, the variable was not set at all. In this case, the report timestamp would be blank.

In commit ffdecf7498a1, Ted changed the xunit report code to handle empty date_time values by setting date_time to the time of report generation. This change was done to handle the case where no tests are run at all. However, it did not change the behavior that date_time is not set if /dev/kmsg is not writable.

Clear up all this confusion by defining the timestamp attribute to reflect the start time of the most recent test, regardless of the state of /dev/kmsg. If no tests are run, then define the attribute to be the time of report generation.

---
 check         |    1 +
 common/report |    8 +++++---
 doc/xunit.xsd |    2 +-
 3 files changed, 7 insertions(+), 4 deletions(-)
check +1 -0
index 14b398fd73..f2be3d7d7d 100755
@@ -917,6 +917,7 @@ function run_section()
 		# to be reported for each test
 		(echo 1 > $DEBUGFS_MNT/clear_warn_once) > /dev/null 2>&1
 
+		test_start_time="$(date +"%F %T")"
 		if [ "$DUMP_OUTPUT" = true ]; then
 			_run_seq 2>&1 | tee $tmp.out
 			# Because $? would get tee's return code
common/report +5 -3
index 1817132d51..8e19e9f557 100644
@@ -46,8 +46,8 @@ _xunit_make_section_report()
 	local report=$tmp.report.xunit.$sect_name.xml
 	# Header
 	echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" > $REPORT_DIR/result.xml
-	if [ -n "$date_time" ]; then
-		timestamp="$(date -Iseconds --date="$date_time")"
+	if [ -n "$test_start_time" ]; then
+		timestamp="$(date -Iseconds --date="$test_start_time")"
 	else
 		timestamp="$(date -Iseconds)"
 	fi
@@ -61,7 +61,9 @@ _xunit_make_section_report()
 
  name="xfstests"
  failures="$bad_count" skipped="$notrun_count" tests="$tests_count" time="$sect_time"
- hostname="$HOST" timestamp="$timestamp">
+ hostname="$HOST"
+ timestamp="$timestamp"
+>
 ENDL
 
 	# Properties
doc/xunit.xsd +1 -1
index 9295c5dc82..653f486871 100644
@@ -184,7 +184,7 @@
         </xs:attribute>
         <xs:attribute name="timestamp" type="ISO8601_DATETIME_PATTERN" use="required">
             <xs:annotation>
-                <xs:documentation xml:lang="en">when the test was executed. Timezone must be specified as an offset from UTC.</xs:documentation>
+                <xs:documentation xml:lang="en">Time that the last testcase was started. If no tests are started, this is the time the report was generated. Timezone must be specified as an offset from UTC.</xs:documentation>
             </xs:annotation>
         </xs:attribute>
         <xs:attribute name="hostname" use="required">
#6 lore raw

PATCH v2 5/14 report: record fstests start and report generation timestamps

In reply to Darrick J. Wong

From: Darrick J. Wong <[email protected]>

Report two new timestamps in the xml report: the time that ./check was started, and the time that the report was generated. We introduce new timestamps to minimize breakage with parsing scripts.

---
 check         |    1 +
 common/report |    4 +++-
 doc/xunit.xsd |   10 ++++++++++
 3 files changed, 14 insertions(+), 1 deletion(-)
check +1 -0
index f2be3d7d7d..1a58a2b269 100755
@@ -668,6 +668,7 @@ _run_seq() {
 
 _detect_kmemleak
 _prepare_test_list
+fstests_start_time="$(date +"%F %T")"
 
 if $OPTIONS_HAVE_SECTIONS; then
 	trap "_summary; exit \$status" 0 1 2 3 15
common/report +3 -1
index 8e19e9f557..be991b55f5 100644
@@ -62,7 +62,9 @@ _xunit_make_section_report()
  name="xfstests"
  failures="$bad_count" skipped="$notrun_count" tests="$tests_count" time="$sect_time"
  hostname="$HOST"
- timestamp="$timestamp"
+  start_timestamp="$(date -Iseconds --date="$fstests_start_time")"
+        timestamp="$timestamp"
+ report_timestamp="$(date -Iseconds)"
 >
 ENDL
 
doc/xunit.xsd +10 -0
index 653f486871..3ed72f2f86 100644
@@ -187,6 +187,16 @@
                 <xs:documentation xml:lang="en">Time that the last testcase was started. If no tests are started, this is the time the report was generated. Timezone must be specified as an offset from UTC.</xs:documentation>
             </xs:annotation>
         </xs:attribute>
+        <xs:attribute name="report_timestamp" type="ISO8601_DATETIME_PATTERN" use="required">
+            <xs:annotation>
+                <xs:documentation xml:lang="en">Time that the report was generated.</xs:documentation>
+            </xs:annotation>
+        </xs:attribute>
+        <xs:attribute name="start_timestamp" type="ISO8601_DATETIME_PATTERN" use="required">
+            <xs:annotation>
+                <xs:documentation xml:lang="en">Time that fstests was started.</xs:documentation>
+            </xs:annotation>
+        </xs:attribute>
         <xs:attribute name="hostname" use="required">
             <xs:annotation>
                 <xs:documentation xml:lang="en">Host on which the tests were executed. 'localhost' should be used if the hostname cannot be determined.</xs:documentation>
#7 lore raw

PATCH v2 6/14 report: encode cdata sections correctly

In reply to Darrick J. Wong

From: Darrick J. Wong <[email protected]>

The XML report format captures the contents of .full and .out.bad files in CDATA sections. CDATA sections are supposed to be a stream of verbatim data, terminated with a "]]>". Hence XML entities such as quotation marks and angle brackes should not be escaped, and an actual bracket-bracket-gt sequence in those files /does/ need escaping.

Create a separate filtering function so that these files are encoded properly.

---
 common/report |   11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
common/report +8 -3
index be991b55f5..eb169175bc 100644
@@ -19,6 +19,11 @@ encode_xml()
 		-e 's/"/\&quot;/g'
 }
 
+encode_cdata()
+{
+	cat -v | sed -e 's/]]>/]]]]><![CDATA[>/g'
+}
+
 #
 # Xunit format report functions
 _xunit_add_property()
@@ -128,7 +133,7 @@ _xunit_make_testcase_report()
 		if [ -z "$quiet" -a -s "$full_file" ]; then
 			echo -e "\t\t<system-out>" >> $report
 			printf	'<![CDATA[\n' >>$report
-			cat "$full_file" | tr -dc '[:print:][:space:]' | encode_xml >>$report
+			cat "$full_file" | tr -dc '[:print:][:space:]' | encode_cdata >>$report
 			printf ']]>\n'	>>$report
 			echo -e "\t\t</system-out>" >> $report
 		fi
@@ -137,13 +142,13 @@ _xunit_make_testcase_report()
 		elif [ -f "$dmesg_file" ]; then
 			echo -e "\t\t<system-err>" >> $report
 			printf	'<![CDATA[\n' >>$report
-			cat "$dmesg_file" | tr -dc '[:print:][:space:]' | encode_xml >>$report
+			cat "$dmesg_file" | tr -dc '[:print:][:space:]' | encode_cdata >>$report
 			printf ']]>\n'	>>$report
 			echo -e "\t\t</system-err>" >> $report
 		elif [ -s "$outbad_file" ]; then
 			echo -e "\t\t<system-err>" >> $report
 			printf	'<![CDATA[\n' >>$report
-			$diff "$out_src" "$outbad_file" | encode_xml >>$report
+			$diff "$out_src" "$outbad_file" | encode_cdata >>$report
 			printf ']]>\n'	>>$report
 			echo -e "\t\t</system-err>" >> $report
 		fi
#8 lore raw

PATCH v2 7/14 report: encode the kernel log as a separate xml element

In reply to Darrick J. Wong

From: Darrick J. Wong <[email protected]>

Record the .dmesg file in a new <kernel-log> element instead of multiplexing it with <system-err>. This means that the xml report can now capture kernel log and bad golden output.

---
 common/report |   11 +++++------
 doc/xunit.xsd |   14 ++++++++++++--
 2 files changed, 17 insertions(+), 8 deletions(-)
common/report +5 -6
index eb169175bc..2e5959312a 100644
@@ -137,15 +137,14 @@ _xunit_make_testcase_report()
 			printf ']]>\n'	>>$report
 			echo -e "\t\t</system-out>" >> $report
 		fi
-		if [ -n "$quiet" ]; then
-		   :
-		elif [ -f "$dmesg_file" ]; then
-			echo -e "\t\t<system-err>" >> $report
+		if [ -z "$quiet" -a -f "$dmesg_file" ]; then
+			echo -e "\t\t<kernel-log>" >> $report
 			printf	'<![CDATA[\n' >>$report
 			cat "$dmesg_file" | tr -dc '[:print:][:space:]' | encode_cdata >>$report
 			printf ']]>\n'	>>$report
-			echo -e "\t\t</system-err>" >> $report
-		elif [ -s "$outbad_file" ]; then
+			echo -e "\t\t</kernel-log>" >> $report
+		fi
+		if [ -z "$quiet" -a -s "$outbad_file" ]; then
 			echo -e "\t\t<system-err>" >> $report
 			printf	'<![CDATA[\n' >>$report
 			$diff "$out_src" "$outbad_file" | encode_cdata >>$report
doc/xunit.xsd +12 -2
index 3ed72f2f86..d287eaf5a2 100644
@@ -131,7 +131,7 @@
                                 </xs:complexType>
                             </xs:element>
                         </xs:choice>
-                        <xs:choice minOccurs="0" maxOccurs="2">
+                        <xs:choice minOccurs="0" maxOccurs="3">
                             <xs:element name="system-out" minOccurs="0" maxOccurs="1">
                                 <xs:annotation>
                                     <xs:documentation xml:lang="en">Data that was written to the .full log file while the test was executed.</xs:documentation>
@@ -144,7 +144,17 @@
                             </xs:element>
                             <xs:element name="system-err" minOccurs="0" maxOccurs="1">
                                 <xs:annotation>
-                                    <xs:documentation xml:lang="en">Kernel log or data that was compared to the golden output file after the test was executed.</xs:documentation>
+                                    <xs:documentation xml:lang="en">Data that was compared to the golden output file after the test was executed.</xs:documentation>
+                                </xs:annotation>
+                                <xs:simpleType>
+                                    <xs:restriction base="pre-string">
+                                        <xs:whiteSpace value="preserve"/>
+                                    </xs:restriction>
+                                </xs:simpleType>
+                            </xs:element>
+                            <xs:element name="kernel-log" minOccurs="0" maxOccurs="1">
+                                <xs:annotation>
+                                    <xs:documentation xml:lang="en">Kernel log recorded while the test was executed.</xs:documentation>
                                 </xs:annotation>
                                 <xs:simpleType>
                                     <xs:restriction base="pre-string">
#9 lore raw

PATCH v2 8/14 report: sort properties by name

In reply to Darrick J. Wong

From: Darrick J. Wong <[email protected]>

When we're generating a junit xml report, always sort the properties by name. This makes it easier for humans to find a particular property.

---
 common/report |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
common/report +2 -2
index 2e5959312a..3ec2d88178 100644
@@ -32,7 +32,7 @@ _xunit_add_property()
 	local value="${!name}"
 
 	if [ ! -z "$value" ]; then
-		echo -e "\t\t<property name=\"$name\" value=\"$value\"/>" >> $REPORT_DIR/result.xml
+		echo -e "\t\t<property name=\"$name\" value=\"$value\"/>"
 	fi
 }
 _xunit_make_section_report()
@@ -77,7 +77,7 @@ ENDL
 	echo -e "\t<properties>" >> $REPORT_DIR/result.xml
 	for p in "${REPORT_ENV_LIST[@]}"; do
 		_xunit_add_property "$p"
-	done
+	done | sort >> $REPORT_DIR/result.xml
 	echo -e "\t</properties>" >> $REPORT_DIR/result.xml
 	if [ -f $report ]; then
 		cat $report >> $REPORT_DIR/result.xml
#10 lore raw

PATCH v2 9/14 report: pass property value to _xunit_add_property

In reply to Darrick J. Wong

From: Darrick J. Wong <[email protected]>

Change this helper to require the caller to pass the value as the second parameter. This prepares us to start reporting a lot more information about a test run, not all of which are encoded as bash variables.

---
 common/report |   11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
common/report +6 -5
index 3ec2d88178..2ab83928db 100644
@@ -29,12 +29,13 @@ encode_cdata()
 _xunit_add_property()
 {
 	local name="$1"
-	local value="${!name}"
+	local value="$2"
 
-	if [ ! -z "$value" ]; then
-		echo -e "\t\t<property name=\"$name\" value=\"$value\"/>"
-	fi
+	test -z "$value" && return
+
+	echo -e "\t\t<property name=\"$name\" value=\"$value\"/>"
 }
+
 _xunit_make_section_report()
 {
 	# xfstest:section ==> xunit:testsuite
@@ -76,7 +77,7 @@ ENDL
 	# Properties
 	echo -e "\t<properties>" >> $REPORT_DIR/result.xml
 	for p in "${REPORT_ENV_LIST[@]}"; do
-		_xunit_add_property "$p"
+		_xunit_add_property "$p" "${!p}"
 	done | sort >> $REPORT_DIR/result.xml
 	echo -e "\t</properties>" >> $REPORT_DIR/result.xml
 	if [ -f $report ]; then
#11 lore raw

PATCH v2 10/14 report: encode xml entities in property values

In reply to Darrick J. Wong

From: Darrick J. Wong <[email protected]>

Avoid trouble with the properties reported in the xml reports by translating xml-tricky characters in the property values into their xml entity equivalents.

IOWs, if someone sets a property "NAME" to the value 'BOBBY"; DROP TABLES;', the xml will be formatted:

<property name="NAME" value="BOBBY&quot;; DROP TABLES;"/>

Thus avoiding XML problems.

---
 common/report |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
common/report +4 -1
index 2ab83928db..946ee4887c 100644
@@ -33,7 +33,10 @@ _xunit_add_property()
 
 	test -z "$value" && return
 
-	echo -e "\t\t<property name=\"$name\" value=\"$value\"/>"
+	local xname="$(echo "$name" | encode_xml)"
+	local xvalue="$(echo "$value" | encode_xml)"
+
+	echo -e "\t\t<property name=\"$xname\" value=\"$xvalue\"/>"
 }
 
 _xunit_make_section_report()
#12 lore raw

PATCH v2 11/14 report: collect basic information about a test run

In reply to Darrick J. Wong

From: Darrick J. Wong <[email protected]>

Record various generic information about an fstests run when generating a junit xml report. This includes the cpu architecture, the kernel revision, the CPU, memory, and numa node counts, and some information about the block devices passed in.

---
 common/report |   44 +++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 43 insertions(+), 1 deletion(-)
common/report +43 -1
index 946ee4887c..90d4f980d1 100644
@@ -24,6 +24,42 @@ encode_cdata()
 	cat -v | sed -e 's/]]>/]]]]><![CDATA[>/g'
 }
 
+# Fill out REPORT_VARS with information about the block device referred to by
+# the passed-in bash variable.
+__generate_blockdev_report_vars() {
+	local bdev_var="$1"
+	local bdev="${!bdev_var}"
+
+	test -z "$bdev" && return
+	test -b "$bdev" || return
+	local sysfs_bdev="$(_sysfs_dev "$bdev")"
+
+	REPORT_VARS["${bdev_var}_SIZE_KB"]="$(( "$(blockdev --getsz "$bdev")" / 2 ))"
+	REPORT_VARS["${bdev_var}_ROTATIONAL"]="$(cat "$sysfs_bdev/queue/rotational" 2>/dev/null)"
+	REPORT_VARS["${bdev_var}_DAX"]="$(cat "$sysfs_bdev/queue/dax" 2>/dev/null)"
+	REPORT_VARS["${bdev_var}_DISCARD"]="$(sed -e 's/[1-9][0-9]*/1/g' "$sysfs_bdev/queue/discard_max_bytes" 2>/dev/null)"
+	REPORT_VARS["${bdev_var}_WRITE_ZEROES"]="$(sed -e 's/[1-9][0-9]*/1/g' "$sysfs_bdev/queue/write_zeroes_max_bytes" 2>/dev/null)"
+	REPORT_VARS["${bdev_var}_PHYS_BLOCK_BYTES"]="$(cat "$sysfs_bdev/queue/physical_block_size" 2>/dev/null)"
+	REPORT_VARS["${bdev_var}_LBA_BYTES"]="$(cat "$sysfs_bdev/queue/logical_block_size" 2>/dev/null)"
+	REPORT_VARS["${bdev_var}_ZONES"]="$(cat "$sysfs_bdev/queue/nr_zones" 2>/dev/null)"
+}
+
+# Fill out REPORT_VARS with tidbits about our test runner configuration.
+# Caller is required to declare REPORT_VARS to be an associative array.
+__generate_report_vars() {
+	REPORT_VARS["ARCH"]="$(uname -m)"
+	REPORT_VARS["KERNEL"]="$(uname -r)"
+	REPORT_VARS["CPUS"]="$(getconf _NPROCESSORS_ONLN 2>/dev/null)"
+	REPORT_VARS["MEM_KB"]="$(grep MemTotal: /proc/meminfo | awk '{print $2}')"
+	REPORT_VARS["SWAP_KB"]="$(grep SwapTotal: /proc/meminfo | awk '{print $2}')"
+
+	test -e /sys/devices/system/node/possible && \
+		REPORT_VARS["NUMA_NODES"]="$(cat /sys/devices/system/node/possible 2>/dev/null)"
+
+	__generate_blockdev_report_vars "TEST_DEV"
+	__generate_blockdev_report_vars "SCRATCH_DEV"
+}
+
 #
 # Xunit format report functions
 _xunit_add_property()
@@ -77,11 +113,17 @@ _xunit_make_section_report()
 >
 ENDL
 
+	declare -A REPORT_VARS
+	__generate_report_vars
+
 	# Properties
 	echo -e "\t<properties>" >> $REPORT_DIR/result.xml
+	(for key in "${!REPORT_VARS[@]}"; do
+		_xunit_add_property "$key" "${REPORT_VARS["$key"]}"
+	done;
 	for p in "${REPORT_ENV_LIST[@]}"; do
 		_xunit_add_property "$p" "${!p}"
-	done | sort >> $REPORT_DIR/result.xml
+	done) | sort >> $REPORT_DIR/result.xml
 	echo -e "\t</properties>" >> $REPORT_DIR/result.xml
 	if [ -f $report ]; then
 		cat $report >> $REPORT_DIR/result.xml
#13 lore raw

PATCH v2 12/14 report: record xfs-specific information about a test run

In reply to Darrick J. Wong

From: Darrick J. Wong <[email protected]>

Report various XFS-specific information about a test run.

---
 common/report |    2 ++
 common/xfs    |   10 ++++++++++
 2 files changed, 12 insertions(+)
common/report +2 -0
index 90d4f980d1..d538fc38a9 100644
@@ -58,6 +58,8 @@ __generate_report_vars() {
 
 	__generate_blockdev_report_vars "TEST_DEV"
 	__generate_blockdev_report_vars "SCRATCH_DEV"
+
+	test "$FSTYP" = "xfs" && __generate_xfs_report_vars
 }
 
 #
common/xfs +10 -0
index 97c049e2ca..ea8f54e03b 100644
@@ -2,6 +2,16 @@
 # XFS specific common functions.
 #
 
+__generate_xfs_report_vars() {
+	__generate_blockdev_report_vars TEST_RTDEV
+	__generate_blockdev_report_vars TEST_LOGDEV
+	__generate_blockdev_report_vars SCRATCH_RTDEV
+	__generate_blockdev_report_vars SCRATCH_LOGDEV
+
+	REPORT_VARS["XFS_ALWAYS_COW"]="$(cat /sys/fs/xfs/debug/always_cow 2>/dev/null)"
+	REPORT_VARS["XFS_LARP"]="$(cat /sys/fs/xfs/debug/larp 2>/dev/null)"
+}
+
 _setup_large_xfs_fs()
 {
 	fs_size=$1
#14 lore raw

PATCH v2 13/14 report: record ext*-specific information about a test run

In reply to Darrick J. Wong

From: Darrick J. Wong <[email protected]>

Report various ext* specific information about a test run.

---
 common/ext4   |    5 +++++
 common/report |    1 +
 2 files changed, 6 insertions(+)
common/ext4 +5 -0
index 8fd6dbc682..3dcbfe17c9 100644
@@ -2,6 +2,11 @@
 # ext4 specific common functions
 #
 
+__generate_ext4_report_vars() {
+	__generate_blockdev_report_vars TEST_LOGDEV
+	__generate_blockdev_report_vars SCRATCH_LOGDEV
+}
+
 _setup_large_ext4_fs()
 {
 	local fs_size=$1
common/report +1 -0
index d538fc38a9..e22e2f8558 100644
@@ -60,6 +60,7 @@ __generate_report_vars() {
 	__generate_blockdev_report_vars "SCRATCH_DEV"
 
 	test "$FSTYP" = "xfs" && __generate_xfs_report_vars
+	[[ "$FSTYP" == ext[0-9]* ]] && __generate_ext4_report_vars
 }
 
 #
#15 lore raw

PATCH v2 14/14 report: allow test runners to inject arbitrary values

In reply to Darrick J. Wong

From: Darrick J. Wong <[email protected]>

Per Ted's request, add to the test section reporting code the ability for test runners to point to a file containing colon-separated key value pairs. These key value pairs will be recorded in the report file as extra properties.

---
 README        |    3 +++
 common/report |   10 ++++++++++
 2 files changed, 13 insertions(+)
README +3 -0
index 4c4f22f853..a8c67cea4d 100644
@@ -245,6 +245,9 @@ Misc:
    this option is supported for all filesystems currently only -overlay is
    expected to run without issues. For other filesystems additional patches
    and fixes to the test suite might be needed.
+ - Set REPORT_VARS_FILE to a file containing colon-separated name-value pairs
+   that will be recorded in the test section report.  Names must be unique.
+   Whitespace surrounding the colon will be removed.
 
 ______________________
 USING THE FSQA SUITE
common/report +10 -0
index e22e2f8558..4b45f7c803 100644
@@ -44,9 +44,19 @@ __generate_blockdev_report_vars() {
 	REPORT_VARS["${bdev_var}_ZONES"]="$(cat "$sysfs_bdev/queue/nr_zones" 2>/dev/null)"
 }
 
+__import_report_vars() {
+	local fname="$1"
+
+	while IFS=':' read key value; do
+		REPORT_VARS["${key%% }"]="${value## }"
+	done < "$1"
+}
+
 # Fill out REPORT_VARS with tidbits about our test runner configuration.
 # Caller is required to declare REPORT_VARS to be an associative array.
 __generate_report_vars() {
+	test "$REPORT_VARS_FILE" && __import_report_vars "$REPORT_VARS_FILE"
+
 	REPORT_VARS["ARCH"]="$(uname -m)"
 	REPORT_VARS["KERNEL"]="$(uname -r)"
 	REPORT_VARS["CPUS"]="$(getconf _NPROCESSORS_ONLN 2>/dev/null)"