Logiscope Presentation 03052009
Transcription
Logiscope Presentation 03052009
IBM Rational Telelogic Logiscope The source code quality enabler 12/3/2009 © 2008 IBM Corporation IBM Rational Quality Requirements for Today’s Software Today’s development standards and best practices all agree: Formal Verification & Review processes are required ! – RTCA/DO-178B, IEC 61508, MIL-STD 498, MISRA, ECSS… – CMMI, ISO/IEC 12207, … Software code quality is now clearly tied to Business Priorities – Improve stability and time-to-market – Reduce development, testing & maintenance costs – Enable cost-effective component sharing and re-use • Critical elements with important maintenance phase – Validate outsourced & offshore development – Customer and regulation acceptance – Preserve the company’s reputation 2 12/3/2009 © 2008 IBM Corporation IBM Rational Helping you meet the challenge Organizations need a Source Code Verification Process – Based on rules that are precise, known & recognized, controllable & adaptable, Organizations need a way to meet this cultural change You need Logiscope, the IBM Rational Source Code Quality Enabler! – Improves the amount of code analyzed per hour, – Optimizes your current testing process, – Compliant with quality standards and process improvement initiatives, – Implements industry-specific regulations and rules, – Adaptable to your specific needs. 3 12/3/2009 © 2008 IBM Corporation IBM Rational The Logiscope Toolset Telelogic Logiscope is the leading Quality Assessment Tool providing: – Logiscope RuleChecker • Automated Coding Rule Checking – Logiscope QualityChecker • Quality Evaluations & Graphical Code Views – Logiscope TestChecker • Structure-based Testing & Test Coverage Analysis – Logiscope Code Reducer • Find Code Similarities – Remove Duplicated Code 4 12/3/2009 © 2008 IBM Corporation IBM Rational Logiscope is used across the Lifecycle Acceptance testing User Requirements Specification Specifications System testing Integration testing Design Te Regulations stC he cke r Maintainability Requirements… Coding Code Reviews Coding Standards Unit Testing Outsourcing RuleChecker, QualityChecker & Code Reducer 5 12/3/2009 © 2008 IBM Corporation IBM Rational Logiscope RuleChecker Automated Coding Rule Checking 12/3/2009 © 2008 IBM Corporation IBM Rational Logiscope RuleChecker Code that “works” and passes all tests can be totally unacceptable! Check coding rules and display violations – Was my software developed according to my Quality Guidelines? • Prevent dangerous constructs usage Enforce consistent coding style between programmers Over 370 out-of-the-box rules – For C, C++, Ada & Java Development 7 12/3/2009 © 2008 IBM Corporation IBM Rational Logiscope RuleChecker Over 370 out-of-the-box rules! – For C, C++, Ada & Java Development • Extra predefined rule packages can be purchased separately – Customize & parameterize rules, add new rules, switch on/off – Script-based rule checking based on a parsing engine for C language – Context-free file parsing for C++, Ada & Java Integrated with development environments for transparent usage 8 12/3/2009 © 2008 IBM Corporation IBM Rational Techniques Supported by Logiscope: Programming Rule Checking What is the behavior of this code ? A bug ! if (type_error) { switch (val_buf->type) { case TYPE_CHAR: strcpy (str_buf, "char"); case TYPE_REAL: strcpy (str_buf, "real"); case TYPE_LONG: strcpy (str_buf, "long"); default: strcpy (str_buf, "unknown"); } sprintf (buf, "Wrong arg type %s for attr %s", str_buf, attr); warning_dispatch (func, buf); return False; } "Each case in a switch statement shall be terminated by a break statement" 9 12/3/2009 © 2008 IBM Corporation IBM Rational Programming Style Checking What is the behavior of this code ? for (i=0; i<(int)num_pairs; i++) { if (SIG[i] == 0.0) /* if ANY is 0 then set ALL to 1 */ for(j=0;j<(int)num_pairs;j++) SIG[j]=1.0; break; } "Each logical block shall be delimited by braces, even if it contains no or one statement." A bug ! for (i=0; i<(int)num_pairs; i++) { /* if ANY is 0 then set ALL to 1 */ if (SIG[i] == 0.0) { for(j=0;j<(int)num_pairs;j++) { SIG[j]=1.0; } break; } } Improve analyzability and reduce risk of bugs with code layout conventions 10 12/3/2009 © 2008 IBM Corporation IBM Rational Industry-specific Rule Packages Automotive Industry - MISRA C coding standard: • Not all rules can be automatically checked (“theoretical enforceability”) • Others should be enforced by code review & process Example: MISRA_Rule14 : Type char is not allowed Definition: The type char shall always be declared as unsigned char or signed char. Goal: Implementation of type char is compiler-dependant. int waiting_loop() { char inst; if ((inst = getchar()) != '\n') while (getchar() != '\n'); return(inst); } 11 12/3/2009 © 2008 IBM Corporation IBM Rational Logiscope RuleChecker Rule explanation Colored source file Sortable Rule Violations 12 12/3/2009 © 2008 IBM Corporation IBM Rational Key Benefits of Logiscope RuleChecker Prevents software coding errors – By avoiding language traps and misunderstanding Focus team effort & optimize resource utilization – Code review, testing Promotes best and consistent coding practices across the organization – Reduce cost of maintenance – Higher control of outsourced development – Deliver code that maps to your customer’s requirements Comply with industry-specific rules Ensure your code meets your expectations! 13 12/3/2009 © 2008 IBM Corporation IBM Rational Logiscope QualityChecker Quality Evaluations & Graphical Code Views 12/3/2009 © 2008 IBM Corporation IBM Rational Logiscope QualityChecker Logiscope QualityChecker provides metrics and graphical representations of the source code – Call graphs, Control graphs, Use graphs, Inheritance graphs, Kiviat graphs of Metrics, Complexity ranking… This enables a large panel of product evaluation techniques – Control Flow Analysis, – Component Coupling Analysis, – Operating System Dependency Analysis, – Code Complexity Measurement, – Self-descriptiveness Measurement (comments), – Inheritance Relationship Analysis… 15 12/3/2009 © 2008 IBM Corporation IBM Rational Logiscope QualityChecker Provides over 190 Procedural and Object-Oriented Metrics for C, C++, Ada & Java Quality Model Tailored to Project / Company Context-free file parsing for C++, Ada & Java Customizable Automated Reporting Facilities (HTML, Word) Integrated with development environments (IDEs) 16 12/3/2009 © 2008 IBM Corporation IBM Rational Control Flow Analysis with Logiscope Test Requirements: • “A function shall not have an excessive intrinsic complexity“, • “Duplicating source code shall be avoided”, • “No statement shall be located after a branching statement or an exit statement within a block“… Principles: – Represent the control flow of each function as a graph – Look for error-prone structures : • • • • 17 Non homogeneous processing flow, Lack of processing hierarchy, Lack of code factorization, Dead code… 12/3/2009 © 2008 IBM Corporation IBM Rational Control Flow Analysis with Logiscope Lack of processing hierarchy ? 18 12/3/2009 © 2008 IBM Corporation IBM Rational Control Flow Analysis with Logiscope Redundant code ? Lack of factorizing ? 19 12/3/2009 © 2008 IBM Corporation IBM Rational Control Flow Analysis with Logiscope Non-homogeneous processing ! A bug ? 20 12/3/2009 © 2008 IBM Corporation IBM Rational Control Flow Analysis with Logiscope Dead Code ! 21 12/3/2009 © 2008 IBM Corporation IBM Rational Component Coupling Analysis with Logiscope Test Requirements: Software Coding Standard – “The dependency on the OS shall be optimized / minimized”, – “The dependency on non-developmental software shall be optimized / minimized”, – “Interdependency between software unit shall be strictly limited”… Principles: f1 – Represent the call/use relations between components as a graph, – Group components into upper-level components, f2 f1(...) { ... f2(...); ... } – Analyze coupling between components. 22 12/3/2009 © 2008 IBM Corporation IBM Rational Graphical representation of the program architecture Points out programming defects – Lack of hierarchy, – Recursive calls : direct and indirect, main – Critical resources (called by numerous components)… play ram Return to source code from any point of the graphical view getcod reset dummy find_digit score make_cod rom skipline After grouping, analysis shows: – Lack of homogeneity in dependency rules format_output print prompt – Inappropriate location of functions in physical files 23 12/3/2009 © 2008 IBM Corporation IBM Rational Component Coupling Analysis – before grouping 24 12/3/2009 © 2008 IBM Corporation IBM Rational Component Coupling Analysis after grouping File Transfer Mail Fax ResCom Billing Commut After grouping & filtering, issues appear: – Lack of homogeneity in dependency rules – Inappropriate location of functions in physical files 25 12/3/2009 © 2008 IBM Corporation IBM Rational Code Quality Assessment with Logiscope Test Requirements: – "A component shall not have an excessive intrinsic complexity" TESTABILITY STABILITY Principles: PARA LEVL DRCT_CALLS – Measure complexity attributes for each component – Compare the results with threshold values RETU PATH NBCALLING PARA GOTO VOCF – Rate according to the LVAR number of measures exceeding the threshold valuesCHANGEABILITY 26 DRCT_CALLS 12/3/2009 VG STMT AVGS PARA COMF ANALYZABILITY © 2008 IBM Corporation IBM Rational Logiscope QualityChecker provides Quality Metrics Comprehensive sets of metrics All supported languages: – Cyclomatic number V(G), – Function scope – Comment frequency, – Class scope – Number of nested levels, – Application scope – Number of execution paths, – Complexity Custom metrics can be created – Combining basic metrics – Scripting new metrics – Number of macros, – etc. Object-oriented languages: – Depth of inheritance tree, – Class coupling, – Class cohesion, – Method inheritance factor, – Number of dependent methods, – etc. 27 12/3/2009 © 2008 IBM Corporation IBM Rational Code Quality Assessment with Logiscope ISO 9126 Compliant Quality Modeling – Refinement of Quality characteristics and features to measurable software quality metrics – Set performance levels / thresholds, Rating Level – Tailor to project/company needs and context FACTORS Functionality Reliability Usability Maintainability Efficiency Portability 28 CRITERIA METRICS Thresholds Excellent Analyzability Good Fair Changeability Cyclomatic number Stability Testability Number of levels [1..10] Poor Number of parameters 12/3/2009 © 2008 IBM Corporation IBM Rational Identify Priorities & Manage Resources Logiscope allows code reviewers to focus on the error-prone components – Filtered view EXCELLENT POOR 10% 3% FAIR 9% Reviewer is provided with indicators to help assessment GOOD 78% – Too many paths? – Too many parameters? Metrics indicate a typical % of complex functions / error prone modules – Missing comments? … 29 12/3/2009 © 2008 IBM Corporation IBM Rational Key Benefits of Logiscope QualityChecker Optimize resource usage – Reduce / focus Peer Review effort – Focus testing effort – Predict the testing effort Reduce future maintenance costs – Make code easier to analyze and change Reveal hidden complexity – Improve stability, testability of source code Stay in control of outsourced development Demonstrate Quality achieved to Authorities & Customers Estimate maintenance effort for third party code A clear & objective picture of the source code! 30 12/3/2009 © 2008 IBM Corporation IBM Rational Logiscope TestChecker Structure-based Testing & Test Coverage Analysis 12/3/2009 © 2008 IBM Corporation IBM Rational Logiscope TestChecker Run Tests & Measure Test coverage – How much of my system was tested? – Are my test suites efficient, and how can I improve them? • Identify redundant tests… Logiscope TestChecker enhances your testing process, without changing it: – Source files are instrumented by TestChecker, – Proceed with your preferred testing environment, – TestChecker enriches the results with coverage information. 32 12/3/2009 © 2008 IBM Corporation IBM Rational Using TestChecker in your context Instrumentation code probes may be tuned to meet application execution constraints: – choose any type of output device for dumping coverage data (file, TCP/IP, serial link, etc.); – reduce the size of the instrumented files by filtering the function or files to be instrumented; – decide how the memory that manages coverage data is implemented (statically or dynamically, type of data, etc.); Tests can be performed either on host or target platforms Provides support for various RTOS which can be used by the application under test (VxWorks, pSOS, etc.) Supports multi-threaded applications; Merges and cumulates multiple test run results. 33 12/3/2009 © 2008 IBM Corporation IBM Rational Measuring test coverage of an application HOST Host-based testing: Coverage can be displayed while test is performed Instrumented application under test Test Checker Coverage file HOST TARGET Instrumented binary Test Checker Test Checker Gateway Test Checker Real Time Libraries Host / Target link Serial or TCP/IP 34 Application Task #1 Application Task #2 Target-based testing: Coverage can be displayed while test is performed Task sending coverage traces 12/3/2009 © 2008 IBM Corporation IBM Rational Structure-Based Testing – Test Coverage Analysis with Logiscope Test Requirements: – “Complementarities and synergy between testing techniques shall be ensured”, – “Tests shall show that each software module does not perform unintended functions”, – “The level of completeness of the test shall be explicitly defined”. Decompose Decomposethe thesoftware software ininelementary elementaryobjects objects Principles: Count Countexercised exercisedobjects objects Specify Specifyadditional additionaltest testcases cases for un-exercised objects for un-exercised objects Trace Traceexercised exercisedobjects objects Execute Executetest testcases cases 35 12/3/2009 © 2008 IBM Corporation IBM Rational Decomposing the software in elementary objects BEGIN 2 statements IF (Condition) THEN 3 statements END IF 1 statement IF ((A AND B) OR C ) THEN 3 statements END IF 1 statement END 36 3s B 2s if 3s end 1s if end 1s E • Statements • Branches / Decisions • DO-178B MC/DC a b c Result 1: 2: T F T x x F T F 1: 3: T T T F x F T F 4: 2: F F x x T F T F 12/3/2009 © 2008 IBM Corporation IBM Rational Test completeness: Counting exercised objects Number of Object Tested Number of Object to be tested 37 12/3/2009 © 2008 IBM Corporation IBM Rational Tracing exercised objects 18 Covered Code Uncovered Code 19 17 16 20 13 30 21 29 3 12 22 14 28 11 2 6 8 15 23 10 27 4 1 5 7 9 25 26 24 38 12/3/2009 © 2008 IBM Corporation IBM Rational Overall program coverage At any time, the tester is provided with overall application coverage 39 12/3/2009 © 2008 IBM Corporation IBM Rational Create new test cases to improve coverage When coverage levels out, TestChecker provides the tester with the means to locate unchecked parts of code 1. Simply locate components with low coverage rate, 2. Check the untested paths, 3. Analyze the source code. 40 12/3/2009 © 2008 IBM Corporation IBM Rational Identify inefficient tests Tests which do not increase coverage are inefficient, they could be removed from the list of test cases Test4 in Suite2 is inefficient 41 12/3/2009 © 2008 IBM Corporation IBM Rational Prepare regression tests Identify which tests must be rerun in order to ensure that quality is maintained after a module has been modified. IfIf this this function function is is modified, modified, tester tester should should at at least least rerun rerun TEST_4 TEST_4 and and TEST_6 TEST_6 42 12/3/2009 © 2008 IBM Corporation IBM Rational Testing techniques Functional (Black Box) Testing – Test designed and coded pieces of software against the requirements specification with no knowledge of the internal software structure – Rarely provides complete coverage • Are requirements complete and consistent with the development application? (not always true). • Do sufficiently detailed specifications describe all code implementation? (nearly impossible) Structure-based (White Box) Testing – Test cases are based on code implementation; each test case is built to test new paths in the program. – Provides thorough testing, but is time & resource consuming • Test coverage target may be reached too late 43 12/3/2009 © 2008 IBM Corporation IBM Rational Combining testing techniques Start by defining functional tests based on the specifications Measure their coverage rate – DDP (decision to decision path) – MC/DC (Modified Condition /Decision Coverage – if applicable) When coverage rate levels out, design complementary structure-based tests Functional Testing Structure-Based Testing Missing Code Wrong Code Useless Code 44 © 2008 IBM Corporation IBM Rational Combining Testing approaches Black box functional testing only coverage Target The Strategy: Combine black box AND white box to reach the target in time efforts coverage White box structural testing only coverage Target efforts efforts 45 12/3/2009 © 2008 IBM Corporation IBM Rational Key Benefits of Logiscope TestChecker Enhances Quality and Reliability by improving test coverage – Objective measurement of test coverage – Check for undesired functionality Improves Time to market by delivering direct feedback on test case efficiency and testing progress Optimize Test resource productivity – Identify the right mix of Functional & Structure-based testing – Remove / rework inefficient tests – Identify regression tests to be run Logiscope TestChecker helps optimize your testing process! 46 12/3/2009 © 2008 IBM Corporation IBM Rational Logiscope Code Reducer Find Code Similarities Remove Duplicated Code & Reduce Maintenance cost 12/3/2009 © 2008 IBM Corporation IBM Rational Logiscope Code Reducer – introduced Q4 2008 A New Comer in the Logiscope Toolset • Find similarities in the code at the code structure level Independently of the formatting, naming of files, functions, variables, etc. NOT just an other “File Compare” tool! By identifying unnecessary duplicated code, Logiscope Code Reducer delivers an immediate Return on Investment ! 48 48 12/3/2009 © 2008 IBM Corporation IBM Rational Logiscope Code Reducer • Use cases: – Finding code similarities in the overall code of a project – Comparing 2 versions of a project and highlighting differences – Finding all instances similar to a reference code • Key issues: – Performance: e.g. Parsing of Logiscope C++ code (about 2000 files – 500 KLOC in 50 seconds!) – Accuracy: a “precision” level allows to select the set of “tokens” (e.g. language operators) to be taken into account for similarities search. The higher the level, the closer the similarities. – Usability: Pre-defined scenarios are available: e.g. “search for similar classes” in C++ or Java. 49 49 12/3/2009 © 2008 IBM Corporation IBM Rational Logiscope Code Reducer Fully integrated in the Logiscope Toolset … as a “standard” Verification Module Available for all languages supported by Logiscope 50 50 12/3/2009 © 2008 IBM Corporation IBM Rational Key Benefits for Logiscope Code Reducer Increase Software Maintainability & Quality – through appropriate code re-factoring in identifying duplicated code possibly across many source code trees. – through avoidable code duplication resulting of low quality maintenance activities. Decrease Cost of Maintenance – Changes and bugs fixes need only to be done in one place – Review, test the code only one time Control Maintenance Quality – A typical indicator of poor maintenance activity is unnecessary code duplication 51 12/3/2009 © 2008 IBM Corporation IBM Rational Other capabilities 52 12/3/2009 © 2008 IBM Corporation IBM Rational Automated, customizable Reporting 53 12/3/2009 © 2008 IBM Corporation IBM Rational Embedding Quality in your Development Process Logiscope is integrated with development environments (Visual Studio .Net, Visual Studio…) to enhance usability – Build and visualize audit results directly from the IDE – Check rules and visualize violations – Build instrumented binaries for coverage analysis – Launch Logiscope Studio for further analysis Logiscope’s complete batch mode allow organizations to: – Automate Quality Analysis for all platforms ( Windows, UNIX, Linux) – Couple Quality Analysis with Configuration Management tools (automatic quality check before check-in of code…) 54 12/3/2009 © 2008 IBM Corporation IBM Rational Microsoft Visual .NET integration Access Logiscope’s features from .NET or launch Logiscope Studio for further analysis 55 12/3/2009 © 2008 IBM Corporation IBM Rational A Summary of Telelogic Logiscope Improve resource efficiency with automated detection of error-prone code modules, unnecessary duplicated code and efficient support for code reviews! – Assess subcontractor development quality. Optimize test efficiency! – Identify redundant test suites and creating minimal test suites for regression testing. Leverage coding and quality best practices! – Use out of the box coding rules and quality model – Store your expertise describing your own best practices. – Avoid pitfalls others have faced in previous projects. Share information more easily! – Generate & post HTML/Java reports Manage today’s project complexity in an intuitive and efficient way! – Understand how the code is structured through graphical views and overview metrics – Promote code reuse, Avoid unnecessary code duplication 56 12/3/2009 © 2008 IBM Corporation IBM Rational Thank You! Questions? 12/3/2009 © 2008 IBM Corporation IBM Rational Backup 58 12/3/2009 © 2008 IBM Corporation IBM Rational Logiscope Packaging Logiscope, the leading Quality Assessment Tool set, consists of 4 main tools – Logiscope RuleChecker • Automated Coding Rule Checking – Logiscope Audit • Quality Evaluations & Graphical Code Views – Logiscope TestChecker • Structure-based Testing & Test Coverage Analysis – Logiscope CodeReducer • Find Code Similarities Covers C, C++, Ada and Java Languages – C/C++ support is configurable to suit different dialects / compilers Available for Windows, UNIX and LINUX platforms 59 12/3/2009 © 2008 IBM Corporation IBM Rational Logiscope - Customers Internal Communications – Alcatel, Bosch Telecom, Clemmesy, Ericsson, France Telecom, Fujitsu, Hewlett Packard, Lucent, Matra Communication, Motorola, Nortel Networks, Novell, Philips, Rhode & Schwarz, Samsung, Siemens, Sony, Telecom Italia, Telefonica, Thomson. Automotive and Transport – BMW, CSEE Transport, Ford, Magnetti Marelli, Matra Transport, Mercedes Benz, Michelin, PSA, RATP, Renault, Saab, SNCF, Valeo 60 12/3/2009 © 2008 IBM Corporation IBM Rational Logiscope - Customers Internal Aerospace and Defense – Airbus, Alcatel Space, Astrium, Boeing, Daimler Chrysler, CNES, Dassault, DCN, DGA, EADS, ESA, Eurocopter, Fairchild/Dornier, Honeywell, Hughes, ITT Aerospace, JPL, Lockheed Martin, MBDA, Northrop Grumman, Raytheon, RockWell Collins, SAIC, SNECMA, STNA, IIMorrow, Thales, Sagem. RTOS vendors! Energy, Industry and Process Control – Alstom, CERN, EDF/GDF, Framatome, OTIS, Schneider, Siemens Metering, Schlumberger, Westinghouse. 61 12/3/2009 © 2008 IBM Corporation