Skip to content
This repository has been archived by the owner on May 21, 2024. It is now read-only.

Commit

Permalink
Merge pull request #1486 from advancedtelematic/feat/ota-3196/Report-…
Browse files Browse the repository at this point in the history
…aktualizr-unit-test-results-on-gitlab

feat/ota-3196/Report aktualizr unit test results on gitlab
  • Loading branch information
pattivacek authored Jan 2, 2020
2 parents 2403384 + acb7f2d commit e871cc7
Show file tree
Hide file tree
Showing 7 changed files with 159 additions and 1 deletion.
4 changes: 4 additions & 0 deletions .ort.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ excludes:
- pattern: "third_party/HdrHistogram_c/**"
reason: "TEST_TOOL_OF"
comment: "This directory contains support code for tests which are not distributed."
- pattern: "third_party/junit/ctest2junit.xsl"
reason: "TEST_TOOL_OF"
comment: "This file contains support code for tests which are not distributed."
- pattern: "thirdparty.spdx"
reason: "TEST_TOOL_OF"
comment: "This file contains metadata which are not distributed."

6 changes: 6 additions & 0 deletions ci/gitlab/.gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,12 @@ coverage:
artifacts:
paths:
- build-coverage/coverage/
reports:
junit: build-coverage/report.xml
script:
- aws s3 cp s3://ota-gitlab-ci/hereotaconnect_prod.zip $CI_PROJECT_DIR/credentials.zip
- ./scripts/test.sh
- xsltproc -o build-coverage/report.xml ./third_party/junit/ctest2junit.xsl build-coverage/Testing/**/Test.xml > /dev/null

nop11:
variables:
Expand Down Expand Up @@ -136,8 +139,11 @@ debian-build+static:
artifacts:
paths:
- build-debian-testing/docs/doxygen/
reports:
junit: build-debian-testing/report.xml
script:
- ./scripts/test.sh
- xsltproc -o build-debian-testing/report.xml ./third_party/junit/ctest2junit.xsl build-debian-testing/Testing/**/Test.xml > /dev/null

bionic-pkg:
variables:
Expand Down
2 changes: 1 addition & 1 deletion cmake-modules/CodeCoverage.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ function(SETUP_TARGET_FOR_COVERAGE_LCOV)
COMMAND ${LCOV_PATH} --gcov-tool ${GCOV_PATH} -c -i -d . -o ${Coverage_NAME}.base

# Run tests
COMMAND ${Coverage_EXECUTABLE}
COMMAND ${Coverage_EXECUTABLE} ${Coverage_EXECUTABLE_ARGS}

# Capturing lcov counters and generating report
COMMAND ${LCOV_PATH} --gcov-tool ${GCOV_PATH} --directory . --capture --output-file ${Coverage_NAME}.info
Expand Down
1 change: 1 addition & 0 deletions docker/Dockerfile.debian.testing
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ RUN apt-get update && apt-get -y install --no-install-suggests --no-install-reco
strace \
valgrind \
wget \
xsltproc \
zip

RUN ln -s clang-6.0 /usr/bin/clang && \
Expand Down
1 change: 1 addition & 0 deletions docker/Dockerfile.ubuntu.bionic
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ RUN apt-get update && apt-get -y install --no-install-suggests --no-install-reco
strace \
valgrind \
wget \
xsltproc \
zip

WORKDIR /ostree
Expand Down
133 changes: 133 additions & 0 deletions third_party/junit/ctest2junit.xsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml" indent="yes"/>
<!-- convert ctest output to junit format -->
<!--
Inspired by https://stackoverflow.com/questions/6329215/how-to-get-ctest-results-in-hudson-jenkins
Based on https://github.com/zanata/zanata-tests/blob/master/scripts/CTest2JUnit.xsl
Extended by providing total Start date, total time, total test stats
-->
<xsl:template match="/Site">
<xsl:variable name="StartDate"><xsl:value-of select="Testing/StartDateTime"/></xsl:variable>
<xsl:variable name="DoTime"><xsl:value-of select="Testing/EndTestTime - Testing/StartTestTime"/></xsl:variable>
<xsl:variable name="TotalTests"><xsl:value-of select="count(Testing/Test)"/></xsl:variable>
<xsl:variable name="Skipped"><xsl:value-of select="count(Testing/Test[@Status='notrun'])"/></xsl:variable>
<xsl:variable name="Disabled"><xsl:value-of select="count(Testing/Test/Results/Measurement[Value='Disabled'])"/></xsl:variable>
<xsl:variable name="Failed"><xsl:value-of select="count(Testing/Test[@Status='failed'])"/></xsl:variable>

<testsuite time="{$DoTime}" timestamp="{$StartDate}" tests="{$TotalTests}" failures="{$Failed}" skipped="{$Skipped}" disabled="{$Disabled}">

<xsl:variable name="BuildName"><xsl:value-of select="@BuildName"/></xsl:variable>
<xsl:variable name="BuildStamp"><xsl:value-of select="@BuildStamp"/></xsl:variable>
<xsl:variable name="Name"><xsl:value-of select="@Name"/></xsl:variable>
<xsl:variable name="Generator"><xsl:value-of select="@Generator"/></xsl:variable>
<xsl:variable name="CompilerName"><xsl:value-of select="@CompilerName"/></xsl:variable>
<xsl:variable name="OSName"><xsl:value-of select="@OSName"/></xsl:variable>
<xsl:variable name="Hostname"><xsl:value-of select="@Hostname"/></xsl:variable>
<xsl:variable name="OSRelease"><xsl:value-of select="@OSRelease"/></xsl:variable>
<xsl:variable name="OSVersion"><xsl:value-of select="@OSVersion"/></xsl:variable>
<xsl:variable name="OSPlatform"><xsl:value-of select="@OSPlatform"/></xsl:variable>
<xsl:variable name="Is64Bits"><xsl:value-of select="@Is64Bits"/></xsl:variable>
<xsl:variable name="VendorString"><xsl:value-of select="@VendorString"/></xsl:variable>
<xsl:variable name="VendorID"><xsl:value-of select="@VendorID"/></xsl:variable>
<xsl:variable name="FamilyID"><xsl:value-of select="@FamilyID"/></xsl:variable>
<xsl:variable name="ModelID"><xsl:value-of select="@ModelID"/></xsl:variable>
<xsl:variable name="ProcessorCacheSize"><xsl:value-of select="@ProcessorCacheSize"/></xsl:variable>
<xsl:variable name="NumberOfLogicalCPU"><xsl:value-of select="@NumberOfLogicalCPU"/></xsl:variable>
<xsl:variable name="NumberOfPhysicalCPU"><xsl:value-of select="@NumberOfPhysicalCPU"/></xsl:variable>
<xsl:variable name="TotalVirtualMemory"><xsl:value-of select="@TotalVirtualMemory"/></xsl:variable>
<xsl:variable name="TotalPhysicalMemory"><xsl:value-of select="@TotalPhysicalMemory"/></xsl:variable>
<xsl:variable name="LogicalProcessorsPerPhysical"><xsl:value-of select="@LogicalProcessorsPerPhysical"/></xsl:variable>
<xsl:variable name="ProcessorClockFrequency"><xsl:value-of select="@ProcessorClockFrequency"/></xsl:variable>
<properties>
<property name="BuildName" value="{$BuildName} {$DoTime}" />
<property name="BuildStamp" value="{$BuildStamp}" />
<property name="Name" value="{$Name}" />
<property name="Generator" value="{$Generator}" />
<property name="CompilerName" value="{$CompilerName}" />
<property name="OSName" value="{$OSName}" />
<property name="Hostname" value="{$Hostname}" />
<property name="OSRelease" value="{$OSRelease}" />
<property name="OSVersion" value="{$OSVersion}" />
<property name="OSPlatform" value="{$OSPlatform}" />
<property name="Is64Bits" value="{$Is64Bits}" />
<property name="VendorString" value="{$VendorString}" />
<property name="VendorID" value="{$VendorID}" />
<property name="FamilyID" value="{$FamilyID}" />
<property name="ModelID" value="{$ModelID}" />
<property name="ProcessorCacheSize" value="{$ProcessorCacheSize}" />
<property name="NumberOfLogicalCPU" value="{$NumberOfLogicalCPU}" />
<property name="NumberOfPhysicalCPU" value="{$NumberOfPhysicalCPU}" />
<property name="TotalVirtualMemory" value="{$TotalVirtualMemory}" />
<property name="TotalPhysicalMemory" value="{$TotalPhysicalMemory}" />
<property name="LogicalProcessorsPerPhysical" value="{$LogicalProcessorsPerPhysical}" />
<property name="ProcessorClockFrequency" value="{$ProcessorClockFrequency}" />
</properties>
<xsl:apply-templates select="Testing/Test"/>

<system-out>
BuildName: <xsl:value-of select="$BuildName" />
BuildStamp: <xsl:value-of select="$BuildStamp" />
Name: <xsl:value-of select="$Name" />
Generator: <xsl:value-of select="$Generator" />
CompilerName: <xsl:value-of select="$CompilerName" />
OSName: <xsl:value-of select="$OSName" />
Hostname: <xsl:value-of select="$Hostname" />
OSRelease: <xsl:value-of select="$OSRelease" />
OSVersion: <xsl:value-of select="$OSVersion" />
OSPlatform: <xsl:value-of select="$OSPlatform" />
Is64Bits: <xsl:value-of select="$Is64Bits" />
VendorString: <xsl:value-of select="$VendorString" />
VendorID: <xsl:value-of select="$VendorID" />
FamilyID: <xsl:value-of select="$FamilyID" />
ModelID: <xsl:value-of select="$ModelID" />
ProcessorCacheSize: <xsl:value-of select="$ProcessorCacheSize" />
NumberOfLogicalCPU: <xsl:value-of select="$NumberOfLogicalCPU" />
NumberOfPhysicalCPU: <xsl:value-of select="$NumberOfPhysicalCPU" />
TotalVirtualMemory: <xsl:value-of select="$TotalVirtualMemory" />
TotalPhysicalMemory: <xsl:value-of select="$TotalPhysicalMemory" />
LogicalProcessorsPerPhysical: <xsl:value-of select="$LogicalProcessorsPerPhysical" />
ProcessorClockFrequency: <xsl:value-of select="$ProcessorClockFrequency" />
</system-out>
</testsuite>
</xsl:template>

<xsl:template match="Testing/Test">
<xsl:variable name="testcasename"><xsl:value-of select="Name"/></xsl:variable>
<xsl:variable name="testclassname"><xsl:value-of select=" concat('this', substring(Path,2))"/></xsl:variable>
<xsl:variable name="exectime">
<xsl:for-each select="Results/NamedMeasurement">
<xsl:if test="@name='Execution Time'">
<xsl:value-of select="Value"/>
</xsl:if>
</xsl:for-each>
</xsl:variable>

<testcase name="{$testcasename}" classname="{$testclassname}" time="{$exectime}">
<xsl:if test="@Status = 'passed'">
<system-out><xsl:value-of select="Results/Measurement/Value/text()"/></system-out>
</xsl:if>
<xsl:if test="@Status = 'failed'">
<xsl:variable name="failtype">
<xsl:for-each select="Results/NamedMeasurement">
<xsl:if test="@name = 'Exit Code'">
<xsl:value-of select="Value"/>
</xsl:if>
</xsl:for-each>
</xsl:variable>
<xsl:variable name="failcode">
<xsl:for-each select="Results/NamedMeasurement">
<xsl:if test="@name = 'Exit Value'">
<xsl:value-of select="Value"/>
</xsl:if>
</xsl:for-each>
</xsl:variable>
<failure message="{$failtype} ({$failcode})"><xsl:value-of select="Results/Measurement/Value/text()" /></failure>
</xsl:if>
<xsl:if test="@Status = 'notrun'">
<skipped><xsl:value-of select="Results/Measurement/Value/text()" /></skipped>
</xsl:if>
</testcase>
</xsl:template>

</xsl:stylesheet>

13 changes: 13 additions & 0 deletions thirdparty.spdx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Relationship: SPDXRef-DOCUMENT DESCRIBES SPDXRef-libostree
Relationship: SPDXRef-DOCUMENT DESCRIBES SPDXRef-sqlite3
Relationship: SPDXRef-DOCUMENT DESCRIBES SPDXRef-asn1c
Relationship: SPDXRef-DOCUMENT DESCRIBES SPDXRef-libp11
Relationship: SPDXRef-DOCUMENT DESCRIBES SPDXRef-ctest2junit.xsl


PackageName: googletest
Expand Down Expand Up @@ -207,6 +208,18 @@ FilesAnalyzed: false
PackageComment: <text>Dynamically linked.</text>


PackageName: ctest2junit.xsl
SPDXID: SPDXRef-ctest2junit.xsl
PackageDownloadLocation: https://github.com/manticoresoftware/manticoresearch/tree/master/misc/junit/ctest2junit.xsl
PackageHomePage: https://github.com/manticoresoftware/manticoresearch
PackageLicenseConcluded: GPLv2
PackageLicenseDeclared: GPLv2
PackageLicenseInfoFromFiles: GPLv2
PackageCopyrightText: <text>NONE</text>
FilesAnalyzed: false
PackageComment: <text>Testing only.</text>


LicenseID: LicenseRef-jsoncpp-public-domain
ExtractedText: <text>The JsonCpp library's source code, including accompanying documentation,
tests and demonstration applications, are licensed under the following
Expand Down

0 comments on commit e871cc7

Please sign in to comment.