CoGenTe: A Tool for Code Generator Testing A. C. Rajeev

Prahladavaradan Sampath



K. C. Shashidhar

S. Ramesh

India Science Lab, General Motors Global Research and Development Bangalore, India

{rajeev.c, p.sampath, ramesh.s}@gm.com, [email protected]

ABSTRACT We present the CoGenTe tool for automated black-box testing of code generators. A code generator is a program that takes a model in a high-level modeling language as input, and outputs a program that captures the behaviour of the model. Thus, a code generator’s input and output are complex objects having not just syntactic structure but execution semantics, too. Hence, traditional test generation methods that take only syntax into account are not effective in testing code generators. CoGenTe amends this by incorporating various coverage criteria over semantics. This enables it to generate test-cases with a higher potential of revealing subtle semantic errors in code generators. CoGenTe has uncovered such issues in widely used real-life code generators: (i) lexical analyzer generators Flex and JFlex, and (ii) The MathWorks’ simulator/code generator for Stateflow.

Categories and Subject Descriptors D.2.4 [Software Engineering]: Software/Program Verification; D.2.5 [Software Engineering]: Testing and Debugging; D.3.4 [Programming Languages]: Processors

be available for inspection. These points motivate the need to rigorously validate code generators, especially when they are used in developing safety-critical software [1, 3]. CoGenTe generates test-cases to cover not only the syntactic aspects of a translation, but its complex semantic aspects, too. Syntactic coverage ensures that models containing certain syntactic constructs are accepted by a code generator. A test-case in this case is just a model; it does not include any information about the model’s behaviour. In comparison, semantic coverage ensures that certain behaviours exhibited by the models are translated correctly. Here, a test-case consists of a model, inputs to drive the model (so that it exhibits the behaviour being tested), and the corresponding outputs from the model. These inputs/outputs can be used to compare the behaviour of the model and the corresponding program generated by a code generator. This integrated generation of inputs/outputs for models is the main innovation in CoGenTe. This aspect, along with the provision of semantic coverage criteria, distinguishes CoGenTe from grammar-based testing tools (cf. Geno [9]) and related, but white-box, testing tools (cf. CESE [11]). We refer to our previous papers [13, 15, 14] for more discussion on related work.

General Terms

2.

Experimentation, Languages, Reliability, Verification

CoGenTe has two components (refer to the following figure): Test Generator (TG) and Test Harness (TH). TG is a generic component that takes two inputs: (i) syntactic and semantic meta-model of a modeling language expressed using inference rules and (ii) a test specification in the form of a coverage criterion over the meta-model, and generates a test-suite that can be used to test any code generator for this language. TH encapsulates the details of how a particular code generator takes inputs and generates outputs, and is therefore specific to the code-generator-under-test (CGUT). Since we represent semantics using inference rules, semantic coverage can be expressed in terms of coverage over these rules; behaviours appear as patterns in the inference trees built from the rules. CoGenTe employs the following coverage criteria [14]: (i) depth of inference given as an integer n (ii) rule coverage given as a set of rules (iii) rule dependency coverage given as a set of rule pairs, and (iv) behavioural coverage given as a high-level behavioural pattern. TG has three components: Inference Tree Generator (ITG), Constraint Generator (CG) and Constraint Solver (CS). They have been implemented in Standard ML. ITG identifies a set of test-goals corresponding to the given coverage criterion, and generates –using algorithms like IPO [10]– a set of inference trees covering these test-goals [14]. CG extracts the

Keywords Automatic Test Generation, Black-box Testing, Code Generators, Semantic Coverage Criteria

1.

INTRODUCTION

Code generators play a critical role in the model-based development of complex software systems. But they are prone to implementation errors owing to the complexity of the syntax and semantics of modeling languages. Also, when the modeling language evolves (which is often the case with most domain specific ones), the related code generators have to be updated to handle the new/altered constructs. In addition, the source code of third-party code generators may not ∗This author is currently with Fraunhofer IESE, Kaiserslautern, Germany, and is supported by an ERCIM “Alain Bensoussan” Fellowship Programme. Copyright is held by the author/owner(s). ASE’10, September 20–24, 2010, Antwerp, Belgium. ACM 978-1-4503-0116-9/10/09.

CoGenTe ARCHITECTURE

side-condition predicates of the rules in a tree, and CS computes a satisfying assignment which is then used to construct a test-case [13, 14]. As part of CS, we have modules based on Alloy [8], Yices [7] and custom-built solvers. The input to TH is a test-suite generated by TG. Given a test-case, TH first represents the model in CGUT’s input format. It then invokes CGUT to generate the corresponding program, and feeds the executable of this program with the inputs. The resulting outputs are compared with the expected outputs to identify the success or failure of the test-case.

3.

TWO CASE STUDIES

Lexical Analyzer Generators (LAGs): A LAG takes a list R of regular expressions as input, and outputs a lexical analyzer LA. Given a string s as input, LA generates a token sequence T corresponding to the sub-strings (of s) that match the regular expressions in R. Test-suites generated by CoGenTe, using the semantics in [15], identified issues with the implementation of look-ahead operator ‘/’ by Flex [2] and JFlex [4]. Some test results for Flex 2.5.35 and JFlex 1.4.1 are shown in the table. E.g., row-5 specifies that an LA corresponding to the regular expression list {b∗ /(a|b), a|b∗ } should match the sub-strings b and a of the input string ba with b∗ /(a|b) and a|b∗ , respectively; however, the LAs generated by Flex and JFlex do not terminate for ba. (R, s, T ) ({b∗ /(a|b), a|b∗ }, a, {(a, 2)}) ({b∗ /(a|b), a|b∗ }, b, {(b, 2)}) ({b∗ /(a|b), a|b∗ }, aa, {(a, 2), (a, 2)}) ({b∗ /(a|b), a|b∗ }, ab, {(a, 2), (b, 2)}) ({b∗ /(a|b), a|b∗ }, ba, {(b, 1), (a, 2)}) ({b∗ /(a|b), a|b∗ }, bb, {(b, 1), (b, 2)})

LA by Flex diverge {(b, 1)} diverge diverge diverge {(bb, 1)}

LA by JFlex abort {(b, 1)} abort abort diverge {(bb, 1)}

Stateflow (SF) Simulator and Code Generator: SF [5] is a widely used graphical language for describing hierarchical state-machines in embedded controller designs. An SF model, in response to an input event, executes various actions associated with its states and transitions. The semantics of SF specifies the order in which these actions are executed [12]. Test-suites generated by CoGenTe identified two issues: (i) In V6.2.1, condition/transition actions of a default transition to a state s are executed when s is reentered because of a history junction in its parent state p, if s is the only child state of p. Since a history junction overrides default transitions, these actions are not to be executed. A test-case that detected this bug consists of the model in the adjacent figure, input events e1, e2 and output actions hC2 T 2 E2 C3 T 3 E1 D2 C1 X1 T 1 E1i. But on simulation, this model executes hC2 T 2 E2 C3 T 3 E1 D2 C1 X1 T 1 C4 T 4 E1i. This bug has been fixed in V7.0 [6]. (ii) A change in semantics between V4.0 and V5.0. In V4.0, condition/transition a-

ctions are allowed on all segments in a transition; thus the model in the adjacent figure executes hC3 T 3 E3 C4 T 4 E1 D3 C1 C2 X1 T 1 T 2 E2i on events e1, e2. But V5.0 simulator raises an error on this model, indicating the out-oforder (compared to the ‘apparent graphical order ’) execution of C2 and T 1 [6].

4.

CONCLUSION

We have presented the CoGenTe tool for meta-model based testing of code generators. It incorporates the lessons learned from our work on testing of code generators [13, 15, 14] into a fully automated, scalable, end-to-end tool with a variety of syntactic and semantic coverage criteria. For future work, we note that since CoGenTe requires only a specification of the syntax and semantics of a language (and is independent of the actual transformations done by the tool-under-test), it can be used to test not just code generators but any model processing tool such as syntax checkers, optimizers and analyzers/verifiers.

5.

REFERENCES

[1] DO-178B, Software Considerations in Airborne Systems and Equipment Certification, 1992. [2] flex: The Fast Lexical Analyzer. http://flex.sourceforge.net. [3] ISO/DIS 26262-8, Road vehicles – Functional safety – Part 8: Supporting processes. [4] JFlex: The Fast Scanner Generator for Java. http://jflex.de. [5] Stateflow: Design and Simulate State Machines and Control Logic. http://www.mathworks.com/products/stateflow. [6] Stateflow and Stateflow Coder Release Notes. http://www.mathworks.com/access/helpdesk/help/ toolbox/stateflow/rn/rn_intro.html. [7] B. Dutertre and L. de Moura. The YICES SMT solver. http://yices.csl.sri.com/tool-paper.pdf. [8] D. Jackson. Alloy: A lightweight object modelling notation. ACM TOSEM, 2002. [9] R. L¨ ammel and W. Schulte. Controllable combinatorial coverage in grammar-based testing. In TestCom, 2006. [10] Y. Lei and K.-C. Tai. In-Parameter-Order: A test generation strategy for pairwise testing. In HASE’98. [11] R. Majumdar and R.-G. Xu. Directed test generation using symbolic grammars. In ASE, 2007. [12] A. C. Rajeev, P. Sampath, and S. Ramesh. An axiomatic semantics for Stateflow. In preparation. [13] P. Sampath, A. C. Rajeev, S. Ramesh, and K. C. Shashidhar. Testing model-processing tools for embedded systems. In RTAS, 2007. [14] P. Sampath, A. C. Rajeev, S. Ramesh, and K. C. Shashidhar. Behaviour directed testing of auto-code generators. In SEFM, 2008. [15] P. Sampath, A. C. Rajeev, K. C. Shashidhar, and S. Ramesh. How to test program generators? A case study using flex. In SEFM, 2007.

CoGenTe: A Tool for Code Generator Testing

Sep 24, 2010 - rating various coverage criteria over semantics. This enables ... tactic aspects of a translation, but its complex semantic as- pects, too. Syntactic ...

166KB Sizes 3 Downloads 193 Views

Recommend Documents

Code Generator Optimizations for the ST120 DSP-MCU ...
the address computations from the data computations. De- coupled .... following SLIW “groupings” (SLIW bundle templates):. Group .... definition sharing the same register. Another ..... part by the hardware loop mapping and the IF-conversion,.

Code Generator Optimizations for the ST120 DSP-MCU ...
Permission to make digital or hard copies of all or part of this work for personal or classroom use is .... In the SLIW mode, the data dependences are scoreboarded, provided they hold ...... servo Hard disk drive digital control loop. efr 5.1.0 ETSI 

yaonzu Nba 2K17 Code Generator
Weekly Ad. This week's best deals, all in one place. ... Code Generator Nba2k17 Vc Generator Android Emulator Live Free Game Generator Codes feed, Free ...

Apple Itunes Code Generator 285
Goddard Space Flight Center GSFC renews long term contract with Kinesix for ... Wallpaperwhat time do the Free Game Generator Codes Apple Itunes Gift Card ...

loedlo Psn Code Generator Software
Download and install our software: Amazon Gift Card Generator .... Codes No Survey 2017 Military Live Free Game Generator Codes on Apple TV, Free Game ...

Minecraft Generator Gift Code 978
1.5.2 Code Generator Minecraft Account Hack 2017 Mustang Live Free Game ... Tutorial Live Free Game Generator Codes on Android phone, Free Game.

Testing Against Interfaces Code
Jul 24, 2008 - Page 1 ... inadequacy, you took the time to build your own planetary death ray, a veritable ... build rule that includes java/junit as a dependency:.

Minecraft Code Generator Online 709
Page 1 ... Random Fan Fiction Story Prompt Generator - Springhole.net ... Facebook Video Games Code Generator Boat Seed Generator For Minecraft Ps3 Live ...

Psn Code Generator Safe 232
Generate free PSN codes using the new psn code generator and get online Playstation ... Generator Codes Free Psn Codes Generator Android Apk Video Games Code ... Games Free Game Generator Codes Psn Key Generator Torrent Code.

50 Psn Code Generator 704
... with this Psn Generator No Survey V1.1.5. ... using the instant download below. .... Live Free Game Generator Codes on Android phone, Code Generator Psn ...

Nba 2K17 Vc Code Generator 812 - PDFKUL.COM
Code Generator Nba 2K12 Generator No Survey Code Generator Nba2k17 Codes ... Generator Codes on Apple TV, Free Game Generator Codes Nba 2K17 ...

buogse Free Itunes Code Generator
Moyer Instruments, Inc. offers repair or calibration of analytical laboratory instruments ... what time do the Code Generator Free Itunes Codes For Apple Idplay on ...

foafka Playstation Code Generator App
PSN Code Generator - Free PSN Codes List Daily! ... Generator Psn Code Generator Ps3 App Live Free Game Generator Codes on Android phone, Free Game.

Download Amazon Gift Card Generator Tool 696
Coming to Android in 2017. ... Video Games Code Generator Free Amazon Gift Card App Live Free Game Generator Codes, Free Game Generator Codes ...

A Tool for Text Comparison
The data to be processed was a comparative corpus, the. METER ..... where xk denotes the mean value of the kth variables of all the entries within a cluster.

A new tool for teachers
Items 11 - 20 - Note: The authors wish to express their sincere thanks to Jim Davis .... of the American population) to allow confident generalizations. Children were ..... available to them and (b) whether they currently had a library card. Those to

A Tool for All Seasons
variation. Moreover, museum curators are often reluctant to allow researchers to drill deep grooves into rare hominin teeth. In contrast to conventional methods, ...

A Collaborative Tool for Synchronous Distance Education
application in a simulated distance education setting. The application combines video-conference with a networked virtual environment in which the instructor and the students can experiment ..... Virtual Campus: Trends for Higher Education and. Train

Extracting Methods to Simplify Testing Code
Jun 13, 2007 - BicycleRepairMan, and in Java by several IDEs, including IntelliJ IDEA and Eclipse.) More information, discussion, and archives:.

A Novel Design for a Biogas Generator in Developing Countries
to present a viable alternative energy source. ... ii. Acknowledgments. I am very grateful to my supervisor, Professor Shaker Meguid, for agreeing to supervise.

Online Free Itunes Code Generator 260
on Android phone, Code Generator Free Itunes Code Generator No Surveys For Mac ... Get Free Itunes Codes Apps Video Games Free Game Generator Codes ...

Amazon Gift Card Code Generator Really Works 963
Code Generator Get Free Amazon Gift Card AppCode Generator Free Amazon ... Normal Period 2017 Code Generator Amazon Gift Card Hack Cydia Apps Live ... Free Game Generator Codes on iPhone, Free Game Generator Codes Amazon.

koudwa Google Play Gift Card Code Generator No ...
Play Gift Card Generator For Android Apk Video Games Free Game Generator ... Code Generator Google Play Gift Card Free Code Generator Apk Apps rating,.