Skip to content

Commit 97bc0f4

Browse files
dagarLorenzMeier
authored andcommittedJan 2, 2017
gather test results
1 parent cddef87 commit 97bc0f4

File tree

7 files changed

+172
-12
lines changed

7 files changed

+172
-12
lines changed
 

‎CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,7 @@ find_package(PythonInterp REQUIRED)
271271
# cmake modules
272272
#
273273
enable_testing()
274+
include(CTest)
274275

275276
#=============================================================================
276277
# generate compile command database

‎CTestConfig.cmake

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
## This file should be placed in the root directory of your project.
2+
## Then modify the CMakeLists.txt file in the root directory of your
3+
## project to incorporate the testing dashboard.
4+
##
5+
## # The following are required to submit to the CDash dashboard:
6+
## ENABLE_TESTING()
7+
## INCLUDE(CTest)
8+
9+
set(CTEST_PROJECT_NAME "PX4 Firmware")
10+
set(CTEST_NIGHTLY_START_TIME "00:00:00 EST")
11+
12+
set(CTEST_DROP_METHOD "http")
13+
set(CTEST_DROP_SITE "my.cdash.org")
14+
set(CTEST_DROP_LOCATION "/submit.php?project=PX4+Firmware")
15+
set(CTEST_DROP_SITE_CDASH TRUE)

‎Makefile

+6-6
Original file line numberDiff line numberDiff line change
@@ -278,17 +278,17 @@ unittest: posix_sitl_default
278278
$(call cmake-build,unittest,$(SRC_DIR)/unittests)
279279
@(cd build_unittest && ctest -j2 --output-on-failure)
280280

281-
run_tests_posix: posix_sitl_default
282-
@(cd build_posix_sitl_default/ && ctest --output-on-failure)
281+
run_tests_posix:
282+
@$(call PX4_RUN,$(MAKE) --no-print-directory posix_sitl_default test_results_junit)
283283

284284
tests: unittest run_tests_posix
285285

286286
tests_coverage:
287-
@(PX4_CODE_COVERAGE=1 CCACHE_DISABLE=1 ${MAKE} tests)
288-
@(lcov --directory . --capture --quiet --output-file coverage.info)
289-
@(lcov --remove coverage.info '/usr/*' --quiet --output-file coverage.info)
287+
@$(call PX4_RUN,$(MAKE) --no-print-directory tests PX4_CODE_COVERAGE=1 CCACHE_DISABLE=1)
288+
@$(call PX4_RUN,lcov --directory . --capture --quiet --output-file coverage.info)
289+
@$(call PX4_RUN,lcov --remove coverage.info '/usr/*' --quiet --output-file coverage.info)
290290
#@(lcov --list coverage.info)
291-
@(genhtml coverage.info --quiet --output-directory coverage-html)
291+
@$(call PX4_RUN,genhtml coverage.info --quiet --output-directory coverage-html)
292292

293293
package_firmware:
294294
@zip --junk-paths Firmware.zip `find Binaries/. -name \*.px4`

‎Tools/CTest2JUnit.xsl

+120
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
2+
<xsl:output method="xml" indent="yes"/>
3+
<xsl:template match="/Site">
4+
<xsl:variable name="Name"><xsl:value-of select="@Name"/></xsl:variable>
5+
<xsl:variable name="Hostname"><xsl:value-of select="@Hostname"/></xsl:variable>
6+
<xsl:variable name="TestCount"><xsl:value-of select="count(//TestList/Test)"/> </xsl:variable>
7+
<xsl:variable name="ErrorCount"><xsl:value-of select="count(//TestList/Test[@Status='error'])"/> </xsl:variable>
8+
<xsl:variable name="FailureCount"><xsl:value-of select="count(//Testing/Test[@Status='failed'])"/> </xsl:variable>
9+
<testsuite name="{$Name}" hostname="{$Hostname}" errors="0" failures="{$FailureCount}" tests="{$TestCount}">
10+
<xsl:variable name="BuildName"><xsl:value-of select="@BuildName"/></xsl:variable>
11+
<xsl:variable name="BuildStamp"><xsl:value-of select="@BuildStamp"/></xsl:variable>
12+
<xsl:variable name="Generator"><xsl:value-of select="@Generator"/></xsl:variable>
13+
<xsl:variable name="CompilerName"><xsl:value-of select="@CompilerName"/></xsl:variable>
14+
<xsl:variable name="OSName"><xsl:value-of select="@OSName"/></xsl:variable>
15+
<xsl:variable name="OSRelease"><xsl:value-of select="@OSRelease"/></xsl:variable>
16+
<xsl:variable name="OSVersion"><xsl:value-of select="@OSVersion"/></xsl:variable>
17+
<xsl:variable name="OSPlatform"><xsl:value-of select="@OSPlatform"/></xsl:variable>
18+
<xsl:variable name="Is64Bits"><xsl:value-of select="@Is64Bits"/></xsl:variable>
19+
<xsl:variable name="VendorString"><xsl:value-of select="@VendorString"/></xsl:variable>
20+
<xsl:variable name="VendorID"><xsl:value-of select="@VendorID"/></xsl:variable>
21+
<xsl:variable name="FamilyID"><xsl:value-of select="@FamilyID"/></xsl:variable>
22+
<xsl:variable name="ModelID"><xsl:value-of select="@ModelID"/></xsl:variable>
23+
<xsl:variable name="ProcessorCacheSize"><xsl:value-of select="@ProcessorCacheSize"/></xsl:variable>
24+
<xsl:variable name="NumberOfLogicalCPU"><xsl:value-of select="@NumberOfLogicalCPU"/></xsl:variable>
25+
<xsl:variable name="NumberOfPhysicalCPU"><xsl:value-of select="@NumberOfPhysicalCPU"/></xsl:variable>
26+
<xsl:variable name="TotalVirtualMemory"><xsl:value-of select="@TotalVirtualMemory"/></xsl:variable>
27+
<xsl:variable name="TotalPhysicalMemory"><xsl:value-of select="@TotalPhysicalMemory"/></xsl:variable>
28+
<xsl:variable name="LogicalProcessorsPerPhysical"><xsl:value-of select="@LogicalProcessorsPerPhysical"/></xsl:variable>
29+
<xsl:variable name="ProcessorClockFrequency"><xsl:value-of select="@ProcessorClockFrequency"/></xsl:variable>
30+
<properties>
31+
<property name="BuildName" value="{$BuildName}" />
32+
<property name="BuildStamp" value="{$BuildStamp}" />
33+
<property name="Name" value="{$Name}" />
34+
<property name="Generator" value="{$Generator}" />
35+
<property name="CompilerName" value="{$CompilerName}" />
36+
<property name="OSName" value="{$OSName}" />
37+
<property name="Hostname" value="{$Hostname}" />
38+
<property name="OSRelease" value="{$OSRelease}" />
39+
<property name="OSVersion" value="{$OSVersion}" />
40+
<property name="OSPlatform" value="{$OSPlatform}" />
41+
<property name="Is64Bits" value="{$Is64Bits}" />
42+
<property name="VendorString" value="{$VendorString}" />
43+
<property name="VendorID" value="{$VendorID}" />
44+
<property name="FamilyID" value="{$FamilyID}" />
45+
<property name="ModelID" value="{$ModelID}" />
46+
<property name="ProcessorCacheSize" value="{$ProcessorCacheSize}" />
47+
<property name="NumberOfLogicalCPU" value="{$NumberOfLogicalCPU}" />
48+
<property name="NumberOfPhysicalCPU" value="{$NumberOfPhysicalCPU}" />
49+
<property name="TotalVirtualMemory" value="{$TotalVirtualMemory}" />
50+
<property name="TotalPhysicalMemory" value="{$TotalPhysicalMemory}" />
51+
<property name="LogicalProcessorsPerPhysical" value="{$LogicalProcessorsPerPhysical}" />
52+
<property name="ProcessorClockFrequency" value="{$ProcessorClockFrequency}" />
53+
</properties>
54+
<xsl:apply-templates select="Testing/Test"/>
55+
56+
<system-out>
57+
BuildName: <xsl:value-of select="$BuildName" />
58+
BuildStamp: <xsl:value-of select="$BuildStamp" />
59+
Name: <xsl:value-of select="$Name" />
60+
Generator: <xsl:value-of select="$Generator" />
61+
CompilerName: <xsl:value-of select="$CompilerName" />
62+
OSName: <xsl:value-of select="$OSName" />
63+
Hostname: <xsl:value-of select="$Hostname" />
64+
OSRelease: <xsl:value-of select="$OSRelease" />
65+
OSVersion: <xsl:value-of select="$OSVersion" />
66+
OSPlatform: <xsl:value-of select="$OSPlatform" />
67+
Is64Bits: <xsl:value-of select="$Is64Bits" />
68+
VendorString: <xsl:value-of select="$VendorString" />
69+
VendorID: <xsl:value-of select="$VendorID" />
70+
FamilyID: <xsl:value-of select="$FamilyID" />
71+
ModelID: <xsl:value-of select="$ModelID" />
72+
ProcessorCacheSize: <xsl:value-of select="$ProcessorCacheSize" />
73+
NumberOfLogicalCPU: <xsl:value-of select="$NumberOfLogicalCPU" />
74+
NumberOfPhysicalCPU: <xsl:value-of select="$NumberOfPhysicalCPU" />
75+
TotalVirtualMemory: <xsl:value-of select="$TotalVirtualMemory" />
76+
TotalPhysicalMemory: <xsl:value-of select="$TotalPhysicalMemory" />
77+
LogicalProcessorsPerPhysical: <xsl:value-of select="$LogicalProcessorsPerPhysical" />
78+
ProcessorClockFrequency: <xsl:value-of select="$ProcessorClockFrequency" />
79+
</system-out>
80+
</testsuite>
81+
</xsl:template>
82+
83+
<xsl:template match="Testing/Test">
84+
<xsl:variable name="testcasename"><xsl:value-of select= "Name"/></xsl:variable>
85+
<xsl:variable name="testclassname"><xsl:value-of select= " concat('this', substring(Path,2))"/></xsl:variable>
86+
<xsl:variable name="exectime">
87+
<xsl:for-each select="Results/NamedMeasurement">
88+
<xsl:if test="@name = 'Execution Time'">
89+
<xsl:value-of select="."/>
90+
</xsl:if>
91+
</xsl:for-each>
92+
</xsl:variable>
93+
94+
<testcase name="{$testcasename}" classname="{$testclassname}" time="{$exectime}">
95+
<xsl:if test="@Status = 'passed'">
96+
</xsl:if>
97+
<xsl:if test="@Status = 'failed'">
98+
<xsl:variable name="failtype">
99+
<xsl:for-each select="Results/NamedMeasurement">
100+
<xsl:if test="@name = 'Exit Code'">
101+
<xsl:value-of select="."/>
102+
</xsl:if>
103+
</xsl:for-each>
104+
</xsl:variable>
105+
<xsl:variable name="failcode">
106+
<xsl:for-each select="Results/NamedMeasurement">
107+
<xsl:if test="@name = 'Exit Value'">
108+
<xsl:value-of select="."/>
109+
</xsl:if>
110+
</xsl:for-each>
111+
</xsl:variable>
112+
<failure message="{$failtype} ({$failcode})"><xsl:value-of select="Results/Measurement/Value/text()" /></failure>
113+
</xsl:if>
114+
<xsl:if test="@Status = 'notrun'">
115+
<skipped><xsl:value-of select="Results/Measurement/Value/text()" /></skipped>
116+
</xsl:if>
117+
</testcase>
118+
</xsl:template>
119+
120+
</xsl:stylesheet>

‎circle.yml

+9-5
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,19 @@ checkout:
1212

1313
dependencies:
1414
pre:
15-
- docker pull px4io/px4-dev-nuttx:2016-12-26
15+
- docker pull px4io/px4-dev-base
1616

1717
test:
1818
override:
19-
- docker run --rm -v `pwd`:`pwd`:rw -e CI=true -w=`pwd` -e LOCAL_USER_ID=$UID -it px4io/px4-dev-nuttx:2016-12-26 /bin/bash -c "make quick_check"
19+
- PX4_DOCKER=1 make tests
20+
# copy test results for circleci
21+
- mkdir -p $CIRCLE_TEST_REPORTS/unittests/ && cp build_unittest/test_detail.xml $CIRCLE_TEST_REPORTS/unittests/
22+
- mkdir -p $CIRCLE_TEST_REPORTS/sitlunittests/ && cp ./build_posix_sitl_default/JUnitTestResults.xml $CIRCLE_TEST_REPORTS/sitlunittests/
23+
- make distclean
24+
- PX4_DOCKER=1 make tests_coverage
2025

2126
general:
2227
artifacts:
23-
- "build_px4fmu-v2_default/parameters.xml"
24-
- "build_px4fmu-v2_default/airframes.xml"
25-
- "build_.*/src/firmware/nuttx/.*.px4"
28+
- "coverage-html"
29+
- "coverage.info"
2630

‎src/firmware/posix/CMakeLists.txt

+18
Original file line numberDiff line numberDiff line change
@@ -187,4 +187,22 @@ foreach(test_name ${test_src_files})
187187
endif()
188188
endforeach()
189189

190+
add_custom_target(test_results
191+
COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -T Test
192+
DEPENDS px4
193+
USES_TERMINAL
194+
COMMENT "Running tests in sitl"
195+
WORKING_DIRECTORY ${PX4_BINARY_DIR})
196+
197+
add_custom_target(test_results_junit
198+
COMMAND xsltproc ${PX4_SOURCE_DIR}/Tools/CTest2JUnit.xsl Testing/`head -n 1 < Testing/TAG`/Test.xml > JUnitTestResults.xml
199+
DEPENDS test_results
200+
COMMENT "Converting ctest output to junit xml"
201+
WORKING_DIRECTORY ${PX4_BINARY_DIR})
202+
203+
add_custom_target(test_cdash_submit
204+
COMMAND ${CMAKE_CTEST_COMMAND} -D Experimental
205+
USES_TERMINAL
206+
WORKING_DIRECTORY ${PX4_BINARY_DIR})
207+
190208
# vim: set noet ft=cmake fenc=utf-8 ff=unix :

‎unittests/CMakeLists.txt

+3-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ endif()
1010
project(px4_unittests)
1111
enable_testing()
1212

13+
message(STATUS ${CONFIG})
14+
1315
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Werror -std=gnu99 -g")
1416
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Werror -std=gnu++0x -g -fno-exceptions -fno-rtti -fno-threadsafe-statics -DCONFIG_WCHAR_BUILTIN -D__CUSTOM_FILE_IO__")
1517

@@ -90,7 +92,7 @@ function(add_gtest)
9092
else()
9193
target_link_libraries(${test_name} gtest_main pthread rt ${PX4_PLATFORM})
9294
endif()
93-
add_test(NAME ${test_name} COMMAND ${test_name} WORKING_DIRECTORY ${PX4_SOURCE_DIR})
95+
add_test(NAME ${test_name} COMMAND ${test_name} --gtest_output=xml WORKING_DIRECTORY ${PX4_BINARY_DIR})
9496
add_dependencies(check ${test_name})
9597
endforeach()
9698
endfunction()

0 commit comments

Comments
 (0)
Please sign in to comment.