]> git-server-git.apps.pok.os.sepia.ceph.com Git - xfstests-dev.git/commitdiff
report: capture the time zone in the test report timestamp
authorDarrick J. Wong <djwong@kernel.org>
Wed, 15 Mar 2023 00:52:47 +0000 (17:52 -0700)
committerZorro Lang <zlang@kernel.org>
Sun, 26 Mar 2023 14:02:23 +0000 (22:02 +0800)
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.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
common/report
doc/xunit.xsd

index 1d8465027038fd5eafb7cb73f05ea083fce99a33..1817132d511fe8b7c2f68b31bd896c759cc611cd 100644 (file)
@@ -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
index ba97ccd67d785f37ddba8bc4284c70562a87b931..9295c5dc8234a7c30d475ea3ad671004c5be3307 100644 (file)
@@ -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">
         </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">