Quality Assurance of
Large C++ Projects
Anton Naumovich
Anton Naumovich
Engineering Manager at SolarWinds
Technical Consultant at DPI.Solutions
Developer at Microsoft (Hyper-V) in the past
We are doing backup :)
conference.corehard.by - we host a C++ conference in Minsk every season (3-4 times a year)
Quality Assurance
Quality Assurance vs Quality Control
Focus on quality of processes Finding defects in ready product
Proactively preventing defects Reactively identify defects
Goal of Quality Assurance
Improve development processes so that defects do
not arise when the product is being developed
Relative Effectiveness of Quality Techniques
Quality Technique
Informal design reviews
Formal design inspections
Informal code reviews
Formal code inspections
Modeling or prototyping
Personal desk-checking of code
Unit test
New function (component) test
Integration test
Regression test
System test
Low-volume beta test (<10 sites)
High-volume beta test (>1,000 sites)
Average Rate of Found Defects
35%
55%
25%
60%
65%
40%
30%
30%
35%
25%
40%
35%
75%
Only combination of techniques can assure 95% and higher quality
General Principle of Software Quality
Improving quality reduces development costs
Source Control
Just use it!
Pick your favourite
Build Tools
List of build tools for C++
De facto standard for build tools
Package managers are gaining popularity
Coding Standards
Importance of Coding Standards
Impossible to build a complex system without standardization
Share experience from the industry and your
project
Make code look and behave uniformly
Use only the “safest” subset of the C++ Language
Антон Семенченко. Закон иерархических компенсаций Седова и C++
Core Guidelines
Available Standards and Guidelines for C++
C++ Core Guidelines by Bjarne & Co
High Integrity C++ Coding Standard
Google C++ Style Guide
Sutter, Alexandrescu: C++ Coding Standards … and many more
Make your Guidelines extensible. Support by the Dev Team
Enrich your Guidelines as a result of problems retrospective
Automate guideline checking as a pre-commit hook for the changeset
No unchecked code in the repository!
Automate Guideline Checking
cpplint.py – regex-based tool for Google C++ Style Guide
Guideline Checker Tool – available with VS 2015 for C++ Core Guidelines
★ clang-tidy – clang-based tool for C++ Core Guidelines, Google C++ Style
Guide, and your own checks!
Uncrustify, clang-tidy: modernize – source code transformers
Code Reviews
Code Review: Best Practices
Integrate review with your issue tracking system
Independent review by 2 people increase ratio of found defects
Prefer pre-commit reviews if possible
Development Review Validataion
Code Review Systems
Review Board
Gerrit for Git
Crucible by Atlassian
… and many more
Code Review Checklist
1. Does the code implement requirements spec?
2. Is the code compliant with the Coding Standards?
3. Does the code change any existing functionality?
4. Are all non-success scenarios handled?
5. ...
Unit Testing
Unit Testing Ideology
Integrate unit tests into your project build process (as a post-build event)
Aim for 100% coverage
Design code to be testable: Test-Driven Design
Практики надежного модульного тестирования для
C++ - Юрий Ефимочев
Boost.Test
CppUnit
Google Test
CxxTest
… and more: check out Comparison of C++ unit testing frameworks
Unit Testing Frameworks
Static Code Analysis
Static Code Analysis: Basics
Your C++ Compiler:
1. Use max warning level and disable checks one-by-one if they are not reasonable
2. Use built-in static analysis checks (e.g. -Weffc++ for gcc)
3. Use several compilers because they have different checks
Run static analysis as a build or pre-commit step
More recommendations on using compilers by Jason Turner
Static Code Analysis Tools
Cppcheck - free and open-source
PVS Studio
Coverity
Copy-paste detectors (e.g. CPD)
… check out Static Code Analysis Tools for C++
Code Coverage
Code Coverage Tools
lcov for *NIX
OpenCPPCoverage for Windows
Use coverage for Unit Test runs and include
coverage report into code review checklist
Intrusive
Runtime Verifiers
Runtime Verification Tools
Application Verifier / Driver Verifier for Windows
Address Sanitizer / Memory Sanitizer / Thread Sanitizer (clang)
Undefined Behavior Sanitizer
Valgrind / Helgrind / Massif
Memory leaks: UMDH, LeakDiag
Non-intrusive
Runtime Verifiers
Assertive Programming (Programming by contract)
If it can't happen, use assertions to ensure that it won't
Leave assertions turned on in production code
(except for when it affects performance)
Collect and analyze assertions
Crash Dump Reporting/Analysis System
Check out Crash Dump Collection and Analysis System talk
Collect and analyze crash dumps from test labs and from production
Continuous Integration
Continuous Integration Tools
TeamCity: 3 agents for free
Jenkins
Team Foundation Server
Staging Repository
Mainline
Repository
Staging
Repository
Developer commits
1. Review
2. Build bots
3. Unit tests
4. Static analysis
5. Code coverage
6. Autotests
Production builds
Merge
“Free” Lunch
Thanks! Questions?
Anton.Naumovich@SolarWinds.com

Quality assurance of large c++ projects

  • 1.
    Quality Assurance of LargeC++ Projects Anton Naumovich
  • 2.
    Anton Naumovich Engineering Managerat SolarWinds Technical Consultant at DPI.Solutions Developer at Microsoft (Hyper-V) in the past We are doing backup :)
  • 3.
    conference.corehard.by - wehost a C++ conference in Minsk every season (3-4 times a year)
  • 4.
  • 5.
    Quality Assurance vsQuality Control Focus on quality of processes Finding defects in ready product Proactively preventing defects Reactively identify defects
  • 6.
    Goal of QualityAssurance Improve development processes so that defects do not arise when the product is being developed
  • 7.
    Relative Effectiveness ofQuality Techniques Quality Technique Informal design reviews Formal design inspections Informal code reviews Formal code inspections Modeling or prototyping Personal desk-checking of code Unit test New function (component) test Integration test Regression test System test Low-volume beta test (<10 sites) High-volume beta test (>1,000 sites) Average Rate of Found Defects 35% 55% 25% 60% 65% 40% 30% 30% 35% 25% 40% 35% 75% Only combination of techniques can assure 95% and higher quality
  • 8.
    General Principle ofSoftware Quality Improving quality reduces development costs
  • 9.
  • 10.
    Just use it! Pickyour favourite
  • 11.
  • 12.
    List of buildtools for C++ De facto standard for build tools Package managers are gaining popularity
  • 13.
  • 14.
    Importance of CodingStandards Impossible to build a complex system without standardization Share experience from the industry and your project Make code look and behave uniformly Use only the “safest” subset of the C++ Language Антон Семенченко. Закон иерархических компенсаций Седова и C++ Core Guidelines
  • 15.
    Available Standards andGuidelines for C++ C++ Core Guidelines by Bjarne & Co High Integrity C++ Coding Standard Google C++ Style Guide Sutter, Alexandrescu: C++ Coding Standards … and many more Make your Guidelines extensible. Support by the Dev Team Enrich your Guidelines as a result of problems retrospective
  • 16.
    Automate guideline checkingas a pre-commit hook for the changeset No unchecked code in the repository! Automate Guideline Checking cpplint.py – regex-based tool for Google C++ Style Guide Guideline Checker Tool – available with VS 2015 for C++ Core Guidelines ★ clang-tidy – clang-based tool for C++ Core Guidelines, Google C++ Style Guide, and your own checks! Uncrustify, clang-tidy: modernize – source code transformers
  • 17.
  • 18.
    Code Review: BestPractices Integrate review with your issue tracking system Independent review by 2 people increase ratio of found defects Prefer pre-commit reviews if possible Development Review Validataion
  • 19.
    Code Review Systems ReviewBoard Gerrit for Git Crucible by Atlassian … and many more
  • 20.
    Code Review Checklist 1.Does the code implement requirements spec? 2. Is the code compliant with the Coding Standards? 3. Does the code change any existing functionality? 4. Are all non-success scenarios handled? 5. ...
  • 21.
  • 22.
    Unit Testing Ideology Integrateunit tests into your project build process (as a post-build event) Aim for 100% coverage Design code to be testable: Test-Driven Design Практики надежного модульного тестирования для C++ - Юрий Ефимочев
  • 23.
    Boost.Test CppUnit Google Test CxxTest … andmore: check out Comparison of C++ unit testing frameworks Unit Testing Frameworks
  • 24.
  • 25.
    Static Code Analysis:Basics Your C++ Compiler: 1. Use max warning level and disable checks one-by-one if they are not reasonable 2. Use built-in static analysis checks (e.g. -Weffc++ for gcc) 3. Use several compilers because they have different checks Run static analysis as a build or pre-commit step More recommendations on using compilers by Jason Turner
  • 26.
    Static Code AnalysisTools Cppcheck - free and open-source PVS Studio Coverity Copy-paste detectors (e.g. CPD) … check out Static Code Analysis Tools for C++
  • 27.
  • 28.
    Code Coverage Tools lcovfor *NIX OpenCPPCoverage for Windows Use coverage for Unit Test runs and include coverage report into code review checklist
  • 29.
  • 30.
    Runtime Verification Tools ApplicationVerifier / Driver Verifier for Windows Address Sanitizer / Memory Sanitizer / Thread Sanitizer (clang) Undefined Behavior Sanitizer Valgrind / Helgrind / Massif Memory leaks: UMDH, LeakDiag
  • 31.
  • 32.
    Assertive Programming (Programmingby contract) If it can't happen, use assertions to ensure that it won't Leave assertions turned on in production code (except for when it affects performance) Collect and analyze assertions
  • 33.
    Crash Dump Reporting/AnalysisSystem Check out Crash Dump Collection and Analysis System talk Collect and analyze crash dumps from test labs and from production
  • 34.
  • 35.
    Continuous Integration Tools TeamCity:3 agents for free Jenkins Team Foundation Server
  • 36.
    Staging Repository Mainline Repository Staging Repository Developer commits 1.Review 2. Build bots 3. Unit tests 4. Static analysis 5. Code coverage 6. Autotests Production builds Merge
  • 37.
  • 38.

Editor's Notes

  • #2 Поговорим о тру-Quality Assurance: о практиках, процессах и артефактах которые помогают поддерживать качество программы. Обсудим для чего это нужно, как и в какие процессы эти практики внедрять, и каким инструментарием пользоваться в контексте С++ Почему большие проекты? Потому что именно на больших проектах количество переходит в качество и кристаллизуются новые роли, практики и процессы
  • #3 MAX Backup: ежемесячные релизы не только клиента, но и платформы. Какие же практики помогают достичь качества?
  • #6 Само понятие QA пришло из промышленного производства На просторах СНГ под QA понимается то, что в англоязычном мире называется QC QA: процессы качества производства, предотвращение дефектов. QC: нахождение дефектов в готовом продукте
  • #7 Основная задача Quality Assurance - улучшить процессы так, чтобы дефект не появлялся, или не доживал до релиза
  • #8 Каждая индивидуальная техника не может обеспечить качество более 75% что неприемлемо для продакшена Только комбинация техник может гарантировать 95+ процент нахождения дефектов
  • #15 Важность стандартизации больших систем Закон иерархических компенсаций Седова
  • #16 В прошлом году появились поддерживаемые Можно и нужно основать Гайдлайны должны прочувствованы и поддерживаться командой, и включать в себя опыт конкретного проекта
  • #17 Один из основополагающих принципов разработки - все что автоматизируемо, должно быть автоматизированно Автоматизируйте проверку стиля, и не допускайте непроверенный код в репозиторий
  • #19 Code Review выполняет множество функций Две головы лучше одной Передача знаний о разных частях кода внутри команды
  • #21 !! добавить группы