using lua features to implement a syntax based test
play

Using Lua features to implement a syntax-based test generator - PowerPoint PPT Presentation

Introduction LGen Implementation Analysis of Work Using Lua features to implement a syntax-based test generator Cleverton Hentz 1 and Anamaria Martins Moreira 1 1 Departamento de Informtica e Matemtica Aplicada Universidade Federal do Rio


  1. Introduction LGen Implementation Analysis of Work Using Lua features to implement a syntax-based test generator Cleverton Hentz 1 and Anamaria Martins Moreira 1 1 Departamento de Informática e Matemática Aplicada Universidade Federal do Rio Grande do Norte July 2, 2013 1 / 23

  2. Introduction LGen Implementation Analysis of Work Motivation - Syntax-based Testing • Grammars are used in many categories of software to describe inputs or some other information. Some examples: • compilers and interpreters; • software engineering tools; • software product line (SPL) configuration descriptions; • wireless sensor networks settings; • XML (eXtensible Markup Language) specification files. • Software testing cost can be reduced and its accuracy increased with systematization and automation. • Coverage criteria limit the number of test cases, keeping a minimum quality and seeking a good set of tests. • Syntax-based testing is one testing systematization technique. • It uses the grammar description of the artifact as basis for the definition of the coverage criteria and of the needed test cases. 2 / 23

  3. Introduction LGen Implementation Analysis of Work Motivation - The Lua Language - www.lua.org • Powerful, fast, lightweight, embeddable scripting language. • Combines simple procedural syntax with powerful data description constructs based on associative arrays and extensible semantics. • Dynamically typed and interpreted. • Ideal for configuration, scripting, and rapid prototyping. • Has interesting features for the implementation of generators: coroutines and functions as first class objets. Ana Lúcia De Moura and Roberto Ierusalimschy. Revisiting coroutines. ACM Trans. Program. Lang. Syst. , 31(2):6:1–6:31, February 2009. 3 / 23

  4. Introduction LGen Implementation Analysis of Work Objectives • Tool for generating sentences based on the specification of the language; • Basic infrastructure for the generation of sentences with flexibility in coverage criteria; • Validation of Lua language features in the implementation of test generators. and now: • Expanding the application domain • Validation and improvement of the tool (flexibility, optimizations, etc.) 4 / 23

  5. Introduction LGen Implementation Analysis of Work Grammar Based Criteria Classical grammar coverage criteria • Terminal Symbol Coverage: the test suite must contain every terminal symbol of grammar; • Production Coverage: the test suite must contain every production rule of grammar; • Derivation Coverage: the test suite must contain every possible string derivable from grammar. • LGen implements two coverage criteria: Terminal Symbol Coverage and Production Coverage ; • Derivation Coverage is attained, when possible, when no other coverage criterion is used. 5 / 23

  6. Introduction LGen Implementation Analysis of Work The Lua Language • Extension language created by the group TeCGraf of PUC-Rio: • Support for several platforms; • Dynamically typed; • Higher order functions; • Tables as the main data structure. • Functions: Function example • Functions in Lua can be anonymous; function g ( f ) • Any value can be passed return function (a , b ) return 2+ f (a , b ) end , true back and forth to a function; end • Multiple values can be returned. 6 / 23

  7. Introduction LGen Implementation Analysis of Work The Lua Language • Extension language created by the group TeCGraf of PUC-Rio: • Support for several platforms; • Dynamically typed; • Higher order functions; • Tables as the main data structure. • Functions: Function example • Functions in Lua can be anonymous; function g ( f ) • Any value can be passed return function (a , b ) return 2+ f (a , b ) end , true back and forth to a function; end • Multiple values can be returned. 6 / 23

  8. Introduction LGen Implementation Analysis of Work Coroutines • Coroutines characteristics: • Own stack; • Exclusive instruction pointer; • Only one coroutine is performed at a time; • User is responsible for controlling the execution. • Functions for handling coroutines: Corotinas co = coroutine . create ( function ( ) • create: creates a new print ( " Hello co " , coroutine . y i e l d ( ) ) end ) coroutine; • resume: activates a coroutine . resume ( co ) coroutine . resume ( co ) » Hello co coroutine; • yield: suspends a coroutine. wco = coroutine . wrap ( function ( ) print ( " Hello wco" , coroutine . y i e l d ( ) ) end ) • The function wrap creates a wco ( ) coroutine and encapsulates it in a wco ( ) » Hello wco function. 7 / 23

  9. Introduction LGen Implementation Analysis of Work Coroutines • Coroutines characteristics: • Own stack; • Exclusive instruction pointer; • Only one coroutine is performed at a time; • User is responsible for controlling the execution. • Functions for handling coroutines: Corotinas co = coroutine . create ( function ( ) • create: creates a new print ( " Hello co " , coroutine . y i e l d ( ) ) end ) coroutine; • resume: activates a coroutine . resume ( co ) coroutine . resume ( co ) » Hello co coroutine; • yield: suspends a coroutine. wco = coroutine . wrap ( function ( ) print ( " Hello wco" , coroutine . y i e l d ( ) ) end ) • The function wrap creates a wco ( ) coroutine and encapsulates it in a wco ( ) » Hello wco function. 7 / 23

  10. Introduction LGen Implementation Analysis of Work Coroutines • Coroutines characteristics: • Own stack; • Exclusive instruction pointer; • Only one coroutine is performed at a time; • User is responsible for controlling the execution. • Functions for handling coroutines: Corotinas co = coroutine . create ( function ( ) • create: creates a new print ( " Hello co " , coroutine . y i e l d ( ) ) end ) coroutine; • resume: activates a coroutine . resume ( co ) coroutine . resume ( co ) » Hello co coroutine; • yield: suspends a coroutine. wco = coroutine . wrap ( function ( ) print ( " Hello wco" , coroutine . y i e l d ( ) ) end ) • The function wrap creates a wco ( ) coroutine and encapsulates it in a wco ( ) » Hello wco function. 7 / 23

  11. Introduction LGen Implementation Analysis of Work Overview of the Tool Generation Input Grammar Translator Lua Specification Valid Sentences Engine Lua Language Generator (LGen) Selected Coverage Criterion • Input Grammar: grammar described with EBNF based notation; • Lua Specification: input grammar translated into a Lua table; • Selected Coverage Criterion: the selected coverage criterion used in generation process; • Valid Sentences: set of valid sentences for the specified by input grammar. Translator: Generation Engine: • Implemented with Meta-Environment and • Implemented in Lua; Lua PEG; • Provides infrastructure for implementing • Input notation supported: EBNF and coverage criteria. ANTLR. 8 / 23

  12. Introduction LGen Implementation Analysis of Work Overview of the Tool Generation Input Grammar Translator Lua Specification Valid Sentences Engine Lua Language Generator (LGen) Selected Coverage Criterion • Input Grammar: grammar described with EBNF based notation; • Lua Specification: input grammar translated into a Lua table; • Selected Coverage Criterion: the selected coverage criterion used in generation process; • Valid Sentences: set of valid sentences for the specified by input grammar. Translator: Generation Engine: • Implemented with Meta-Environment and • Implemented in Lua; Lua PEG; • Provides infrastructure for implementing • Input notation supported: EBNF and coverage criteria. ANTLR. 8 / 23

  13. Introduction LGen Implementation Analysis of Work Overview of the Tool Generation Input Grammar Translator Lua Specification Valid Sentences Engine Lua Language Generator (LGen) Selected Coverage Criterion • Input Grammar: grammar described with EBNF based notation; • Lua Specification: input grammar translated into a Lua table; • Selected Coverage Criterion: the selected coverage criterion used in generation process; • Valid Sentences: set of valid sentences for the specified by input grammar. Translator: Generation Engine: • Implemented with Meta-Environment and • Implemented in Lua; Lua PEG; • Provides infrastructure for implementing • Input notation supported: EBNF and coverage criteria. ANTLR. 8 / 23

  14. Introduction LGen Implementation Analysis of Work Translator • Component responsible for the recognition and translation of the input notation; • Initially implemented in ASF+SDF and currently has a version of Lua PEG; • Input notation could be EBNF based or ANTLR. Notation EBNF Lua Specification Operation = Header_operation , G. Operation = seq (V. Header_operation , "=" , seq ( terminal ( " = " ) , Level1_substitution ; V. Level1_substitution ) ) Level1_substitution = G. Level1_substitution = a l t ( I d e n t i t y _ s u b s t i t u t i o n | V. I d e n t i t y _ s u b s t i t u t i o n , Becomes_equal_substitution ; V. Becomes_equal_substitution ) 9 / 23

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend