SlideShare a Scribd company logo
1 of 33
Richard Thomson
Senior Software Engineer, NVIDIA
@LegalizeAdulthd
http://LegalizeAdulthood.wordpress.com
legalize@xmission.com
Outline
 Adding test support in CMakeLists.txt
 Running Tests with CTest
 Viewing Test Trends in CDash
Tests in CMake
 Tests are commands
 Tests pass when:
 Process return code is zero
 Process output matches success regex
 Process output does not match fail regex
CMakeLists.txt Requirements
 Call enable_testing() after project()
 Call add_test() to add each test command
add_test Syntax
add_test(
NAME <name>
COMMAND <command> [<arg>...]
[CONFIGURATIONS <config>...]
[WORKING_DIRECTORY <dir>]
[COMMAND_EXPAND_LISTS]
)
add_test Arguments
 <name> names the test
 Multiple tests can run the same command
 <command> can be a CMake target
 <arg> can use generator expressions
 Use absolute paths for working directory
 Use COMMAND_EXPAND_LISTS if your
arguments can expand to empty strings
Setting Test Properties
Tests are configured through properties
set_property(
TEST <test>
PROPERTY <name> [<value>...] )
set_tests_properties(
<test> [<test> ...]
PROPERTIES <prop> <value>
[<prop> <value>...] )
Use ; separated value lists with set_tests_properties
Common Test Properties
 Running tests
 ENVIRONMENT
 WORKING_DIRECTORY
 DEPENDS
 FIXTURES_SETUP
 FIXTURES_REQUIRED
 FIXTURES_CLEANUP
 DISABLED
 PROCESSORS
 RESOURCE_GROUPS
 RESOURCE_LOCK
 RUN_SERIAL
 TIMEOUT
 TIMEOUT_AFTER_MATCH
 Success determination:
 PASS_REGULAR_EXPRESSION
 FAIL_REGULAR_EXPRESSION
 SKIP_REGULAR_EXPRESSION
 SKIP_RETURN_CODE
 WILL_FAIL
 Test organization:
 LABELS
Configuring Test Result
 WILL_FAIL
 Inverts the success/fail sense
 SKIP_RETURN_CODE
 If command returns this code, test is skipped
 PASS_REGULAR_EXPRESSION
 FAIL_REGULAR_EXPRESSION
 SKIP_REGULAR_EXPRESSION
 Evaluated against test output to determine test
result
 LABELS property contains a list of label
names
 Use with –L <regex> argument to ctest to
select tests to run by regex match
Organizing Tests
Test Dependencies
 Does one test depend on another test to be
run first?
 Use the DEPENDS property to specify the
relationship
 Only controls order of test execution;
dependent test is run regardless of success
of the dependency
Test Fixtures
 Use a fixture to orchestrate set up and tear
down for a test case
 A fixture is just a name
 Test fixture set up is just a test with
FIXTURES_SETUP property
 Test fixture tear down is just a test with
FIXTURES_CLEANUP property
 Test using a fixture has
FIXTURES_REQUIRED property
Test Fixture Example
set_tests_properties(startServer
PROPERTIES FIXTURES_SETUP server)
set_tests_properties(stopServer
PROPERTIES FIXTURES_CLEANUP server)
set_tests_properties(databaseUp
PROPERTIES FIXTURES_SETUP database)
set_tests_properties(clientNoDB
PROPERTIES FIXTURES_REQUIRED server)
set_tests_properties(client
PROPERTIES
FIXTURES_REQUIRED "server;database")
How CTest Works
 enable_testing establishes the location of a
cmake script in the build directory
 add_test writes commands to the cmake
script
 ctest processes the script to run tests
 Run ctest from the location of the cmake
script (usually top-level build directory)
Running CTest
 ctest [args...]
 -C <config> select config to run
 needed for multi-config generators
 -R <regex>, -E <regex>
 Specify tests to run/exclude based on test name
 --timeout <seconds>
 --stop-time <time-of-day>
 -j <n> for parallel execution
 --resource-spec-file <path>
 -L <regex> to select tests by label
Test Resource Constraints
 Tests might need lots of CPU
 Tests might need lots of RAM
 Tests might need lots of GPU
 etc.
 Running tests in parallel can cause false
failures due of resource exhaustion
 RUN_SERIAL property can force a test to run
alone
RESOURCE_LOCK Property
 A resource is just a name
 Tests requiring the resource have the name
in its RESOURCE_LOCK property
 Only one test per named resource will run
at a time
RESOURCE_GROUPS
Property
 Specify quantity of resources in each group
needed by a test
 Configure the resources available in a
JSON file
 Check the documentation for details of
specifying and configuring resources
GoogleTest Support 3.9
include(GoogleTest)
gtest_add_tests(
TARGET <target>
[SOURCES file1...]
[EXTRA_ARGS arg1...]
[WORKING_DIRECTORY dir]
[TEST_PREFIX prefix]
[TEST_SUFFIX suffix]
[SKIP_DEPENDENCY]
[TEST_LIST outVar]
)
GoogleTest Support 3.9
 Scans source files to identify tests
 Adds one CTest test case per Google Test
test case
 Variable containing test names can be used
to further customize test cases
 Misses parameterized tests
 Misses tests defined through custom
macros
GoogleTest Support 3.10
include(GoogleTest)
gtest_discover_tests(
TARGET <target>
[EXTRA_ARGS arg1...]
[WORKING_DIRECTORY dir]
[TEST_PREFIX prefix]
[TEST_SUFFIX suffix]
[NO_PRETTY_TYPES]
[NO_PRETTY_VALUES]
[PROPERTIES name1 value1...]
[TEST_LIST outVar]
[DISCOVERY_TIMEOUT seconds]
)
GoogleTest Support 3.10
 Runs test executable to get test names
 Tests names aren't available until CTest is
run
 Can't easily further customize tests via
properties at CMake configuration time
 Customization can be done by including
additional hand-written files into the
generated CTest script
CDash
 CDash is a web based dashborad for test
results and trends (FOSS)
 CTest can prepare results for submission to
CDash
 CDash organizes data from pipeline steps
according to models that are displayed in
tracks in the dashboard
CDash Tracks and Step
Display
 Track
 Step
CDash Steps
 Start
 Update
 Configure
 Build
 Test
 Coverage
 Always displays results in the Coverage track
 MemCheck
 Always displays results in the Dynamic Analysis
track
 Submit
CDash Models
 Every pipeline is associated with a model
 Model defines default steps and error behavior
 Nightly
 Excludes MemCheck step, continues if Update fails
 Continuous
 Excludes MemCheck step, stops if Update fails
 Experimental
 Excludes Update and MemCheck steps
Executing Steps and Pipelines
 ctest -M <model> -T <step> --track <track>
 At least -M or -T must be specified
 Needs a CDash configuration in place
 ex: ctest -M Nightly --track "Nightly Master"
CDash Configuration
 Mostly handled by CTest module
 include(CTest)
 After project()
 CTest module defines BUILD_TESTING
 Allows you to add custom test-only build code
 CTest module calls enable_testing() for you
 Requires CTestConfig.cmake at top-level
Sample CTestConfig.cmake
# Name used by CDash to refer to the project
set(CTEST_PROJECT_NAME "Foo")
# Start of day to organize results by day
set(CTEST_NIGHTLY_START_TIME "01:00:00 UTC")
# CDash submission details
set(CTEST_DROP_METHOD "http")
set(CTEST_DROP_SITE "my.cdash.org")
set(CTEST_DROP_LOCATION
"/submit.php?project=${CTEST_PROJECT_NAME}")
set(CTEST_DROP_SITE_CDASH YES)
# Show command lines in logs
set(CTEST_USE_LAUNCHERS YES)
Simpler CTestConfig.cmake
(3.14+)
# Name used by CDash to refer to the project
set(CTEST_PROJECT_NAME "Foo")
# Start of day to organize results by day
set(CTEST_NIGHTLY_START_TIME "01:00:00 UTC")
# CDash submission details
set(CTEST_SUBMIT_URL
"http://my.cdash.org/submit.php?project=${CTEST_PROJECT_NAME}")
# Show command lines in logs
set(CTEST_USE_LAUNCHERS YES)
Custom Pipeline Execution
 Write a custom CMake script that calls
ctest_xxx commands
 Invoke with ctest -S <script>
 Allows arbitrary payloads to be uploaded to
CDash
Custom Test Results
 ATTACHED_FILES,
ATTACHED_FILES_ON_FAIL properties
specify a list of files to be attached to the
test results in the Upload step
 MEASUREMENT property allows a test to
specify a single value that can be tracked
for that test in CDash
 CTest snoops test output for XML fragments
to define measurements; see docs for
details.
Going Further
 Consult the CMake, CTest and CDash
documentation for more details
 More details and examples provided in
"Professional CMake: A Practical Guide" by
Craig Scott, http://crascit.com

More Related Content

What's hot

OpenSearch
OpenSearchOpenSearch
OpenSearchhchen1
 
MySQL 8.0 EXPLAIN ANALYZE
MySQL 8.0 EXPLAIN ANALYZEMySQL 8.0 EXPLAIN ANALYZE
MySQL 8.0 EXPLAIN ANALYZENorvald Ryeng
 
톰캣 운영 노하우
톰캣 운영 노하우톰캣 운영 노하우
톰캣 운영 노하우jieunsys
 
MySQL Slow Query log Monitoring using Beats & ELK
MySQL Slow Query log Monitoring using Beats & ELKMySQL Slow Query log Monitoring using Beats & ELK
MySQL Slow Query log Monitoring using Beats & ELKYoungHeon (Roy) Kim
 
Architecting for the Cloud using NetflixOSS - Codemash Workshop
Architecting for the Cloud using NetflixOSS - Codemash WorkshopArchitecting for the Cloud using NetflixOSS - Codemash Workshop
Architecting for the Cloud using NetflixOSS - Codemash WorkshopSudhir Tonse
 
ClickHouse Unleashed 2020: Our Favorite New Features for Your Analytical Appl...
ClickHouse Unleashed 2020: Our Favorite New Features for Your Analytical Appl...ClickHouse Unleashed 2020: Our Favorite New Features for Your Analytical Appl...
ClickHouse Unleashed 2020: Our Favorite New Features for Your Analytical Appl...Altinity Ltd
 
High Performance, High Reliability Data Loading on ClickHouse
High Performance, High Reliability Data Loading on ClickHouseHigh Performance, High Reliability Data Loading on ClickHouse
High Performance, High Reliability Data Loading on ClickHouseAltinity Ltd
 
ProxySQL High Avalability and Configuration Management Overview
ProxySQL High Avalability and Configuration Management OverviewProxySQL High Avalability and Configuration Management Overview
ProxySQL High Avalability and Configuration Management OverviewRené Cannaò
 
PromQL Deep Dive - The Prometheus Query Language
PromQL Deep Dive - The Prometheus Query Language PromQL Deep Dive - The Prometheus Query Language
PromQL Deep Dive - The Prometheus Query Language Weaveworks
 
ClickHouse Query Performance Tips and Tricks, by Robert Hodges, Altinity CEO
ClickHouse Query Performance Tips and Tricks, by Robert Hodges, Altinity CEOClickHouse Query Performance Tips and Tricks, by Robert Hodges, Altinity CEO
ClickHouse Query Performance Tips and Tricks, by Robert Hodges, Altinity CEOAltinity Ltd
 
Clickhouse Capacity Planning for OLAP Workloads, Mik Kocikowski of CloudFlare
Clickhouse Capacity Planning for OLAP Workloads, Mik Kocikowski of CloudFlareClickhouse Capacity Planning for OLAP Workloads, Mik Kocikowski of CloudFlare
Clickhouse Capacity Planning for OLAP Workloads, Mik Kocikowski of CloudFlareAltinity Ltd
 
MongoDB World 2019: Tips and Tricks++ for Querying and Indexing MongoDB
MongoDB World 2019: Tips and Tricks++ for Querying and Indexing MongoDBMongoDB World 2019: Tips and Tricks++ for Querying and Indexing MongoDB
MongoDB World 2019: Tips and Tricks++ for Querying and Indexing MongoDBMongoDB
 
2 TomcatによるWebアプリケーションサーバ構築 第4章 Tomcatの構成(2)-デプロイ
2 TomcatによるWebアプリケーションサーバ構築 第4章 Tomcatの構成(2)-デプロイ2 TomcatによるWebアプリケーションサーバ構築 第4章 Tomcatの構成(2)-デプロイ
2 TomcatによるWebアプリケーションサーバ構築 第4章 Tomcatの構成(2)-デプロイEnpel
 
Tuning PostgreSQL for High Write Throughput
Tuning PostgreSQL for High Write Throughput Tuning PostgreSQL for High Write Throughput
Tuning PostgreSQL for High Write Throughput Grant McAlister
 
Building an Observability platform with ClickHouse
Building an Observability platform with ClickHouseBuilding an Observability platform with ClickHouse
Building an Observability platform with ClickHouseAltinity Ltd
 
A Fast Intro to Fast Query with ClickHouse, by Robert Hodges
A Fast Intro to Fast Query with ClickHouse, by Robert HodgesA Fast Intro to Fast Query with ClickHouse, by Robert Hodges
A Fast Intro to Fast Query with ClickHouse, by Robert HodgesAltinity Ltd
 
ClickHouse Features for Advanced Users, by Aleksei Milovidov
ClickHouse Features for Advanced Users, by Aleksei MilovidovClickHouse Features for Advanced Users, by Aleksei Milovidov
ClickHouse Features for Advanced Users, by Aleksei MilovidovAltinity Ltd
 
Introduction to the Mysteries of ClickHouse Replication, By Robert Hodges and...
Introduction to the Mysteries of ClickHouse Replication, By Robert Hodges and...Introduction to the Mysteries of ClickHouse Replication, By Robert Hodges and...
Introduction to the Mysteries of ClickHouse Replication, By Robert Hodges and...Altinity Ltd
 

What's hot (20)

OpenSearch
OpenSearchOpenSearch
OpenSearch
 
MySQL 8.0 EXPLAIN ANALYZE
MySQL 8.0 EXPLAIN ANALYZEMySQL 8.0 EXPLAIN ANALYZE
MySQL 8.0 EXPLAIN ANALYZE
 
톰캣 운영 노하우
톰캣 운영 노하우톰캣 운영 노하우
톰캣 운영 노하우
 
MySQL Slow Query log Monitoring using Beats & ELK
MySQL Slow Query log Monitoring using Beats & ELKMySQL Slow Query log Monitoring using Beats & ELK
MySQL Slow Query log Monitoring using Beats & ELK
 
Architecting for the Cloud using NetflixOSS - Codemash Workshop
Architecting for the Cloud using NetflixOSS - Codemash WorkshopArchitecting for the Cloud using NetflixOSS - Codemash Workshop
Architecting for the Cloud using NetflixOSS - Codemash Workshop
 
ClickHouse Unleashed 2020: Our Favorite New Features for Your Analytical Appl...
ClickHouse Unleashed 2020: Our Favorite New Features for Your Analytical Appl...ClickHouse Unleashed 2020: Our Favorite New Features for Your Analytical Appl...
ClickHouse Unleashed 2020: Our Favorite New Features for Your Analytical Appl...
 
High Performance, High Reliability Data Loading on ClickHouse
High Performance, High Reliability Data Loading on ClickHouseHigh Performance, High Reliability Data Loading on ClickHouse
High Performance, High Reliability Data Loading on ClickHouse
 
ProxySQL High Avalability and Configuration Management Overview
ProxySQL High Avalability and Configuration Management OverviewProxySQL High Avalability and Configuration Management Overview
ProxySQL High Avalability and Configuration Management Overview
 
Nginx
NginxNginx
Nginx
 
PromQL Deep Dive - The Prometheus Query Language
PromQL Deep Dive - The Prometheus Query Language PromQL Deep Dive - The Prometheus Query Language
PromQL Deep Dive - The Prometheus Query Language
 
ClickHouse Query Performance Tips and Tricks, by Robert Hodges, Altinity CEO
ClickHouse Query Performance Tips and Tricks, by Robert Hodges, Altinity CEOClickHouse Query Performance Tips and Tricks, by Robert Hodges, Altinity CEO
ClickHouse Query Performance Tips and Tricks, by Robert Hodges, Altinity CEO
 
Clickhouse Capacity Planning for OLAP Workloads, Mik Kocikowski of CloudFlare
Clickhouse Capacity Planning for OLAP Workloads, Mik Kocikowski of CloudFlareClickhouse Capacity Planning for OLAP Workloads, Mik Kocikowski of CloudFlare
Clickhouse Capacity Planning for OLAP Workloads, Mik Kocikowski of CloudFlare
 
MongoDB World 2019: Tips and Tricks++ for Querying and Indexing MongoDB
MongoDB World 2019: Tips and Tricks++ for Querying and Indexing MongoDBMongoDB World 2019: Tips and Tricks++ for Querying and Indexing MongoDB
MongoDB World 2019: Tips and Tricks++ for Querying and Indexing MongoDB
 
2 TomcatによるWebアプリケーションサーバ構築 第4章 Tomcatの構成(2)-デプロイ
2 TomcatによるWebアプリケーションサーバ構築 第4章 Tomcatの構成(2)-デプロイ2 TomcatによるWebアプリケーションサーバ構築 第4章 Tomcatの構成(2)-デプロイ
2 TomcatによるWebアプリケーションサーバ構築 第4章 Tomcatの構成(2)-デプロイ
 
Tuning PostgreSQL for High Write Throughput
Tuning PostgreSQL for High Write Throughput Tuning PostgreSQL for High Write Throughput
Tuning PostgreSQL for High Write Throughput
 
Building an Observability platform with ClickHouse
Building an Observability platform with ClickHouseBuilding an Observability platform with ClickHouse
Building an Observability platform with ClickHouse
 
A Fast Intro to Fast Query with ClickHouse, by Robert Hodges
A Fast Intro to Fast Query with ClickHouse, by Robert HodgesA Fast Intro to Fast Query with ClickHouse, by Robert Hodges
A Fast Intro to Fast Query with ClickHouse, by Robert Hodges
 
ClickHouse Features for Advanced Users, by Aleksei Milovidov
ClickHouse Features for Advanced Users, by Aleksei MilovidovClickHouse Features for Advanced Users, by Aleksei Milovidov
ClickHouse Features for Advanced Users, by Aleksei Milovidov
 
Query logging with proxysql
Query logging with proxysqlQuery logging with proxysql
Query logging with proxysql
 
Introduction to the Mysteries of ClickHouse Replication, By Robert Hodges and...
Introduction to the Mysteries of ClickHouse Replication, By Robert Hodges and...Introduction to the Mysteries of ClickHouse Replication, By Robert Hodges and...
Introduction to the Mysteries of ClickHouse Replication, By Robert Hodges and...
 

Similar to Automated Testing with CMake, CTest and CDash

Pragmatic unittestingwithj unit
Pragmatic unittestingwithj unitPragmatic unittestingwithj unit
Pragmatic unittestingwithj unitliminescence
 
Intro to Testing in Zope, Plone
Intro to Testing in Zope, PloneIntro to Testing in Zope, Plone
Intro to Testing in Zope, PloneQuintagroup
 
Apex Testing and Best Practices
Apex Testing and Best PracticesApex Testing and Best Practices
Apex Testing and Best PracticesJitendra Zaa
 
Adding unit tests with tSQLt to the database deployment pipeline
Adding unit tests with tSQLt to the database deployment pipelineAdding unit tests with tSQLt to the database deployment pipeline
Adding unit tests with tSQLt to the database deployment pipelineEduardo Piairo
 
Building frameworks over Selenium
Building frameworks over SeleniumBuilding frameworks over Selenium
Building frameworks over SeleniumCristian COȚOI
 
Example of TAF with batch execution of test cases
 Example of TAF with batch execution of test cases  Example of TAF with batch execution of test cases
Example of TAF with batch execution of test cases COMAQA.BY
 
Cassandra Day NY 2014: Getting Started with the DataStax C# Driver
Cassandra Day NY 2014: Getting Started with the DataStax C# DriverCassandra Day NY 2014: Getting Started with the DataStax C# Driver
Cassandra Day NY 2014: Getting Started with the DataStax C# DriverDataStax Academy
 
Adding unit tests to the database deployment pipeline
Adding unit tests to the database deployment pipelineAdding unit tests to the database deployment pipeline
Adding unit tests to the database deployment pipelineEduardo Piairo
 
Practical Glusto Example
Practical Glusto ExamplePractical Glusto Example
Practical Glusto ExampleGluster.org
 
Adding unit tests with tSQLt to the database deployment pipeline
 Adding unit tests with tSQLt to the database deployment pipeline Adding unit tests with tSQLt to the database deployment pipeline
Adding unit tests with tSQLt to the database deployment pipelineEduardo Piairo
 
Presto Testing Tools: Benchto & Tempto (Presto Boston Meetup 10062015)
Presto Testing Tools: Benchto & Tempto (Presto Boston Meetup 10062015)Presto Testing Tools: Benchto & Tempto (Presto Boston Meetup 10062015)
Presto Testing Tools: Benchto & Tempto (Presto Boston Meetup 10062015)Matt Fuller
 
Google App Engine Developer - Day3
Google App Engine Developer - Day3Google App Engine Developer - Day3
Google App Engine Developer - Day3Simon Su
 
Infrastructure-as-Code (IaC) using Terraform
Infrastructure-as-Code (IaC) using TerraformInfrastructure-as-Code (IaC) using Terraform
Infrastructure-as-Code (IaC) using TerraformAdin Ermie
 
Protractor framework – how to make stable e2e tests for Angular applications
Protractor framework – how to make stable e2e tests for Angular applicationsProtractor framework – how to make stable e2e tests for Angular applications
Protractor framework – how to make stable e2e tests for Angular applicationsLudmila Nesvitiy
 
Intro to tsql unit 14
Intro to tsql   unit 14Intro to tsql   unit 14
Intro to tsql unit 14Syed Asrarali
 

Similar to Automated Testing with CMake, CTest and CDash (20)

Mxunit
MxunitMxunit
Mxunit
 
Pragmatic unittestingwithj unit
Pragmatic unittestingwithj unitPragmatic unittestingwithj unit
Pragmatic unittestingwithj unit
 
Intro to Testing in Zope, Plone
Intro to Testing in Zope, PloneIntro to Testing in Zope, Plone
Intro to Testing in Zope, Plone
 
Apex Testing and Best Practices
Apex Testing and Best PracticesApex Testing and Best Practices
Apex Testing and Best Practices
 
Adding unit tests with tSQLt to the database deployment pipeline
Adding unit tests with tSQLt to the database deployment pipelineAdding unit tests with tSQLt to the database deployment pipeline
Adding unit tests with tSQLt to the database deployment pipeline
 
Nativescript angular
Nativescript angularNativescript angular
Nativescript angular
 
Aspects of 10 Tuning
Aspects of 10 TuningAspects of 10 Tuning
Aspects of 10 Tuning
 
Scala test
Scala testScala test
Scala test
 
Scala test
Scala testScala test
Scala test
 
Building frameworks over Selenium
Building frameworks over SeleniumBuilding frameworks over Selenium
Building frameworks over Selenium
 
Example of TAF with batch execution of test cases
 Example of TAF with batch execution of test cases  Example of TAF with batch execution of test cases
Example of TAF with batch execution of test cases
 
Cassandra Day NY 2014: Getting Started with the DataStax C# Driver
Cassandra Day NY 2014: Getting Started with the DataStax C# DriverCassandra Day NY 2014: Getting Started with the DataStax C# Driver
Cassandra Day NY 2014: Getting Started with the DataStax C# Driver
 
Adding unit tests to the database deployment pipeline
Adding unit tests to the database deployment pipelineAdding unit tests to the database deployment pipeline
Adding unit tests to the database deployment pipeline
 
Practical Glusto Example
Practical Glusto ExamplePractical Glusto Example
Practical Glusto Example
 
Adding unit tests with tSQLt to the database deployment pipeline
 Adding unit tests with tSQLt to the database deployment pipeline Adding unit tests with tSQLt to the database deployment pipeline
Adding unit tests with tSQLt to the database deployment pipeline
 
Presto Testing Tools: Benchto & Tempto (Presto Boston Meetup 10062015)
Presto Testing Tools: Benchto & Tempto (Presto Boston Meetup 10062015)Presto Testing Tools: Benchto & Tempto (Presto Boston Meetup 10062015)
Presto Testing Tools: Benchto & Tempto (Presto Boston Meetup 10062015)
 
Google App Engine Developer - Day3
Google App Engine Developer - Day3Google App Engine Developer - Day3
Google App Engine Developer - Day3
 
Infrastructure-as-Code (IaC) using Terraform
Infrastructure-as-Code (IaC) using TerraformInfrastructure-as-Code (IaC) using Terraform
Infrastructure-as-Code (IaC) using Terraform
 
Protractor framework – how to make stable e2e tests for Angular applications
Protractor framework – how to make stable e2e tests for Angular applicationsProtractor framework – how to make stable e2e tests for Angular applications
Protractor framework – how to make stable e2e tests for Angular applications
 
Intro to tsql unit 14
Intro to tsql   unit 14Intro to tsql   unit 14
Intro to tsql unit 14
 

More from Richard Thomson

Vintage Computing Festival Midwest 18 2023-09-09 What's In A Terminal.pdf
Vintage Computing Festival Midwest 18 2023-09-09 What's In A Terminal.pdfVintage Computing Festival Midwest 18 2023-09-09 What's In A Terminal.pdf
Vintage Computing Festival Midwest 18 2023-09-09 What's In A Terminal.pdfRichard Thomson
 
Feature and platform testing with CMake
Feature and platform testing with CMakeFeature and platform testing with CMake
Feature and platform testing with CMakeRichard Thomson
 
SIMD Processing Using Compiler Intrinsics
SIMD Processing Using Compiler IntrinsicsSIMD Processing Using Compiler Intrinsics
SIMD Processing Using Compiler IntrinsicsRichard Thomson
 
Cross Platform Mobile Development with Visual Studio 2015 and C++
Cross Platform Mobile Development with Visual Studio 2015 and C++Cross Platform Mobile Development with Visual Studio 2015 and C++
Cross Platform Mobile Development with Visual Studio 2015 and C++Richard Thomson
 
Consuming and Creating Libraries in C++
Consuming and Creating Libraries in C++Consuming and Creating Libraries in C++
Consuming and Creating Libraries in C++Richard Thomson
 
C traps and pitfalls for C++ programmers
C traps and pitfalls for C++ programmersC traps and pitfalls for C++ programmers
C traps and pitfalls for C++ programmersRichard Thomson
 

More from Richard Thomson (9)

Vintage Computing Festival Midwest 18 2023-09-09 What's In A Terminal.pdf
Vintage Computing Festival Midwest 18 2023-09-09 What's In A Terminal.pdfVintage Computing Festival Midwest 18 2023-09-09 What's In A Terminal.pdf
Vintage Computing Festival Midwest 18 2023-09-09 What's In A Terminal.pdf
 
Feature and platform testing with CMake
Feature and platform testing with CMakeFeature and platform testing with CMake
Feature and platform testing with CMake
 
BEFLIX
BEFLIXBEFLIX
BEFLIX
 
SIMD Processing Using Compiler Intrinsics
SIMD Processing Using Compiler IntrinsicsSIMD Processing Using Compiler Intrinsics
SIMD Processing Using Compiler Intrinsics
 
Modern C++
Modern C++Modern C++
Modern C++
 
Cross Platform Mobile Development with Visual Studio 2015 and C++
Cross Platform Mobile Development with Visual Studio 2015 and C++Cross Platform Mobile Development with Visual Studio 2015 and C++
Cross Platform Mobile Development with Visual Studio 2015 and C++
 
Consuming and Creating Libraries in C++
Consuming and Creating Libraries in C++Consuming and Creating Libraries in C++
Consuming and Creating Libraries in C++
 
Web mashups with NodeJS
Web mashups with NodeJSWeb mashups with NodeJS
Web mashups with NodeJS
 
C traps and pitfalls for C++ programmers
C traps and pitfalls for C++ programmersC traps and pitfalls for C++ programmers
C traps and pitfalls for C++ programmers
 

Recently uploaded

AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplatePresentation.STUDIO
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...masabamasaba
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...SelfMade bd
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrandmasabamasaba
 
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...WSO2
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park masabamasaba
 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Bert Jan Schrijver
 
WSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaSWSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaSWSO2
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareJim McKeeth
 
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benonimasabamasaba
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrainmasabamasaba
 
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...chiefasafspells
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...masabamasaba
 
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open SourceWSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open SourceWSO2
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfonteinmasabamasaba
 
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2
 
WSO2Con2024 - From Blueprint to Brilliance: WSO2's Guide to API-First Enginee...
WSO2Con2024 - From Blueprint to Brilliance: WSO2's Guide to API-First Enginee...WSO2Con2024 - From Blueprint to Brilliance: WSO2's Guide to API-First Enginee...
WSO2Con2024 - From Blueprint to Brilliance: WSO2's Guide to API-First Enginee...WSO2
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisamasabamasaba
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2
 

Recently uploaded (20)

AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
 
WSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaSWSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaS
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK Software
 
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
 
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open SourceWSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
 
WSO2Con2024 - From Blueprint to Brilliance: WSO2's Guide to API-First Enginee...
WSO2Con2024 - From Blueprint to Brilliance: WSO2's Guide to API-First Enginee...WSO2Con2024 - From Blueprint to Brilliance: WSO2's Guide to API-First Enginee...
WSO2Con2024 - From Blueprint to Brilliance: WSO2's Guide to API-First Enginee...
 
Abortion Pill Prices Boksburg [(+27832195400*)] 🏥 Women's Abortion Clinic in ...
Abortion Pill Prices Boksburg [(+27832195400*)] 🏥 Women's Abortion Clinic in ...Abortion Pill Prices Boksburg [(+27832195400*)] 🏥 Women's Abortion Clinic in ...
Abortion Pill Prices Boksburg [(+27832195400*)] 🏥 Women's Abortion Clinic in ...
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
 

Automated Testing with CMake, CTest and CDash

  • 1. Richard Thomson Senior Software Engineer, NVIDIA @LegalizeAdulthd http://LegalizeAdulthood.wordpress.com legalize@xmission.com
  • 2. Outline  Adding test support in CMakeLists.txt  Running Tests with CTest  Viewing Test Trends in CDash
  • 3. Tests in CMake  Tests are commands  Tests pass when:  Process return code is zero  Process output matches success regex  Process output does not match fail regex
  • 4. CMakeLists.txt Requirements  Call enable_testing() after project()  Call add_test() to add each test command
  • 5. add_test Syntax add_test( NAME <name> COMMAND <command> [<arg>...] [CONFIGURATIONS <config>...] [WORKING_DIRECTORY <dir>] [COMMAND_EXPAND_LISTS] )
  • 6. add_test Arguments  <name> names the test  Multiple tests can run the same command  <command> can be a CMake target  <arg> can use generator expressions  Use absolute paths for working directory  Use COMMAND_EXPAND_LISTS if your arguments can expand to empty strings
  • 7. Setting Test Properties Tests are configured through properties set_property( TEST <test> PROPERTY <name> [<value>...] ) set_tests_properties( <test> [<test> ...] PROPERTIES <prop> <value> [<prop> <value>...] ) Use ; separated value lists with set_tests_properties
  • 8. Common Test Properties  Running tests  ENVIRONMENT  WORKING_DIRECTORY  DEPENDS  FIXTURES_SETUP  FIXTURES_REQUIRED  FIXTURES_CLEANUP  DISABLED  PROCESSORS  RESOURCE_GROUPS  RESOURCE_LOCK  RUN_SERIAL  TIMEOUT  TIMEOUT_AFTER_MATCH  Success determination:  PASS_REGULAR_EXPRESSION  FAIL_REGULAR_EXPRESSION  SKIP_REGULAR_EXPRESSION  SKIP_RETURN_CODE  WILL_FAIL  Test organization:  LABELS
  • 9. Configuring Test Result  WILL_FAIL  Inverts the success/fail sense  SKIP_RETURN_CODE  If command returns this code, test is skipped  PASS_REGULAR_EXPRESSION  FAIL_REGULAR_EXPRESSION  SKIP_REGULAR_EXPRESSION  Evaluated against test output to determine test result
  • 10.  LABELS property contains a list of label names  Use with –L <regex> argument to ctest to select tests to run by regex match Organizing Tests
  • 11. Test Dependencies  Does one test depend on another test to be run first?  Use the DEPENDS property to specify the relationship  Only controls order of test execution; dependent test is run regardless of success of the dependency
  • 12. Test Fixtures  Use a fixture to orchestrate set up and tear down for a test case  A fixture is just a name  Test fixture set up is just a test with FIXTURES_SETUP property  Test fixture tear down is just a test with FIXTURES_CLEANUP property  Test using a fixture has FIXTURES_REQUIRED property
  • 13. Test Fixture Example set_tests_properties(startServer PROPERTIES FIXTURES_SETUP server) set_tests_properties(stopServer PROPERTIES FIXTURES_CLEANUP server) set_tests_properties(databaseUp PROPERTIES FIXTURES_SETUP database) set_tests_properties(clientNoDB PROPERTIES FIXTURES_REQUIRED server) set_tests_properties(client PROPERTIES FIXTURES_REQUIRED "server;database")
  • 14. How CTest Works  enable_testing establishes the location of a cmake script in the build directory  add_test writes commands to the cmake script  ctest processes the script to run tests  Run ctest from the location of the cmake script (usually top-level build directory)
  • 15. Running CTest  ctest [args...]  -C <config> select config to run  needed for multi-config generators  -R <regex>, -E <regex>  Specify tests to run/exclude based on test name  --timeout <seconds>  --stop-time <time-of-day>  -j <n> for parallel execution  --resource-spec-file <path>  -L <regex> to select tests by label
  • 16. Test Resource Constraints  Tests might need lots of CPU  Tests might need lots of RAM  Tests might need lots of GPU  etc.  Running tests in parallel can cause false failures due of resource exhaustion  RUN_SERIAL property can force a test to run alone
  • 17. RESOURCE_LOCK Property  A resource is just a name  Tests requiring the resource have the name in its RESOURCE_LOCK property  Only one test per named resource will run at a time
  • 18. RESOURCE_GROUPS Property  Specify quantity of resources in each group needed by a test  Configure the resources available in a JSON file  Check the documentation for details of specifying and configuring resources
  • 19. GoogleTest Support 3.9 include(GoogleTest) gtest_add_tests( TARGET <target> [SOURCES file1...] [EXTRA_ARGS arg1...] [WORKING_DIRECTORY dir] [TEST_PREFIX prefix] [TEST_SUFFIX suffix] [SKIP_DEPENDENCY] [TEST_LIST outVar] )
  • 20. GoogleTest Support 3.9  Scans source files to identify tests  Adds one CTest test case per Google Test test case  Variable containing test names can be used to further customize test cases  Misses parameterized tests  Misses tests defined through custom macros
  • 21. GoogleTest Support 3.10 include(GoogleTest) gtest_discover_tests( TARGET <target> [EXTRA_ARGS arg1...] [WORKING_DIRECTORY dir] [TEST_PREFIX prefix] [TEST_SUFFIX suffix] [NO_PRETTY_TYPES] [NO_PRETTY_VALUES] [PROPERTIES name1 value1...] [TEST_LIST outVar] [DISCOVERY_TIMEOUT seconds] )
  • 22. GoogleTest Support 3.10  Runs test executable to get test names  Tests names aren't available until CTest is run  Can't easily further customize tests via properties at CMake configuration time  Customization can be done by including additional hand-written files into the generated CTest script
  • 23. CDash  CDash is a web based dashborad for test results and trends (FOSS)  CTest can prepare results for submission to CDash  CDash organizes data from pipeline steps according to models that are displayed in tracks in the dashboard
  • 24. CDash Tracks and Step Display  Track  Step
  • 25. CDash Steps  Start  Update  Configure  Build  Test  Coverage  Always displays results in the Coverage track  MemCheck  Always displays results in the Dynamic Analysis track  Submit
  • 26. CDash Models  Every pipeline is associated with a model  Model defines default steps and error behavior  Nightly  Excludes MemCheck step, continues if Update fails  Continuous  Excludes MemCheck step, stops if Update fails  Experimental  Excludes Update and MemCheck steps
  • 27. Executing Steps and Pipelines  ctest -M <model> -T <step> --track <track>  At least -M or -T must be specified  Needs a CDash configuration in place  ex: ctest -M Nightly --track "Nightly Master"
  • 28. CDash Configuration  Mostly handled by CTest module  include(CTest)  After project()  CTest module defines BUILD_TESTING  Allows you to add custom test-only build code  CTest module calls enable_testing() for you  Requires CTestConfig.cmake at top-level
  • 29. Sample CTestConfig.cmake # Name used by CDash to refer to the project set(CTEST_PROJECT_NAME "Foo") # Start of day to organize results by day set(CTEST_NIGHTLY_START_TIME "01:00:00 UTC") # CDash submission details set(CTEST_DROP_METHOD "http") set(CTEST_DROP_SITE "my.cdash.org") set(CTEST_DROP_LOCATION "/submit.php?project=${CTEST_PROJECT_NAME}") set(CTEST_DROP_SITE_CDASH YES) # Show command lines in logs set(CTEST_USE_LAUNCHERS YES)
  • 30. Simpler CTestConfig.cmake (3.14+) # Name used by CDash to refer to the project set(CTEST_PROJECT_NAME "Foo") # Start of day to organize results by day set(CTEST_NIGHTLY_START_TIME "01:00:00 UTC") # CDash submission details set(CTEST_SUBMIT_URL "http://my.cdash.org/submit.php?project=${CTEST_PROJECT_NAME}") # Show command lines in logs set(CTEST_USE_LAUNCHERS YES)
  • 31. Custom Pipeline Execution  Write a custom CMake script that calls ctest_xxx commands  Invoke with ctest -S <script>  Allows arbitrary payloads to be uploaded to CDash
  • 32. Custom Test Results  ATTACHED_FILES, ATTACHED_FILES_ON_FAIL properties specify a list of files to be attached to the test results in the Upload step  MEASUREMENT property allows a test to specify a single value that can be tracked for that test in CDash  CTest snoops test output for XML fragments to define measurements; see docs for details.
  • 33. Going Further  Consult the CMake, CTest and CDash documentation for more details  More details and examples provided in "Professional CMake: A Practical Guide" by Craig Scott, http://crascit.com