Extension of Interface Signature Descriptions for Automatic Test Generation Evgeny Chernov Institute for System Programming of RAS SYRCoSE 2008
2 Overview 1) Problem with testing big software system. 2) Extension of interface signature by specialized types. 3) Properties of specialized types. 4) Results of practical work.
3 Introduction Problem: tests for big system (>1000 interfaces). Possible solution: automatic generation of shallow (low quality) tests. It based on: Formal description of interfaces to test. Some specialized information about parameters. Problem: How to get such specialized information for all interfaces?
4 Suggested Solution The set of standard types is extended by specialized types. Standard types are replaced (if necessary) by specialized types in signature. Specialized type less_1 specifies that parameter should be less or equal to 1.
5 Specialized Types Specialized type has the following properties: Name Data type – standard type that can be replaced by the specialized type Base type – specialized type-parent (for inheritance) Kind – {normal, once-only, common for parameter, common for return value} Value Constraint Init/Final code Auxiliary code Proxy-value
6 Value of Specialized Type ‘Value’ specifies a way of initialization directly. Specialized TypeGenerated code value = 3Par_N = 3; value = “Test string”Par_N = “Test string”; value = truePar_N = true; value = create_param()Par_N = create_param(); value = $obj.first()SomeClass Obj; OtherClass Par_N = Obj.first(); N – is a number of parameter, which is using the specialized type with corresponding value.
7 Constraint of Specialized Type ‘Constraint’ attribute contains constraint on parameter. Specialized TypeGenerated code constraint = “$0 == 1”SomeClass Obj; Obj.someMethod(Par_1, Par_2, …); If (!(Par_1 == 1)) { /* printing error message */ } If (!(Par_2 != NULL)) { /* printing error message */ } If (!(Obj.isEmpty() == false)) { /* printing error message */ } constraint = “$0 != NULL” constraint = “$obj.isEmpty() == false” 1 st and 2 nd specialized types are used by 1 st and 2 nd parameters, and the last one is used by object.
8 Init / Final Code in Specialized Type ‘Init code’ is inserted up before calling of target interface, ‘final code’ – after. Specialized TypeGenerated code Init code = “ for (int i = 0; i < 10; i++){ $0.append(i); } ” SomeClass Obj; // Init code for (int i = 0; i < 10; i++) { Par_1.append(i); } // Call of target interface Obj.someMethod(Par_1,…); Final code = “close($0);”Par_1 = fopen(“test.cpp”, “r+”); Obj.someMethod(Par_1); // Final code close(Par_1);
9 Auxiliary Code of Specialized Type ‘Auxiliary code’ allow to creation complex way of initialization. It contains description of additional functions or classes. New special constructions: $(type_name) – the instruction to create a variable of type ‘type_name’. $[function] – the instruction to initialize and to call corresponding function. It allows to decrease time for creation specialized types and number of mistakes.
10 Auxiliary code: Example of Using Auxiliary codeGenerated code SomeClass* create_SomeClass() { SomeClass* Obj = new SomeClass(); Obj->setEnabled(true); Obj->setFont( $(QFont *) ); Obj->setIconSet( $(QIconSet) ); return Obj; } static const char * const XPM[]={ " ", "a c #cec6bd" } SomeClass* create_SomeClass() { SomeClass* Obj = new SomeClass(); Obj->setEnabled(true); Obj->setFont(new QFont(“Times”, 10, Bold)); QPixmap Par_1_1(XPM); QIconSet Par_1(Par_1_1); Obj->setIconSet(Par_1); return Obj; }
11 Complex Specialized Type Problem: how to describe this case: Par_1 = “Some String”; Par_2 = strlen( Par_1 ); Solution: join descriptions of all dependent parameters into one complex specialized type. ‘Proxy-value’ attribute contains a list of values for initialization every parameter. ‘Proxy-value’ for our example: 1) $1=“Some String” 2) strlen( $1 );
12 Extended Description
13 Inheritance of Specialized Types One specialized type can inherit some attributes from another: Value Constraint Init/final code Auxiliary code Specialized type 2 inherits specialized type 1
14 Results of Practical Work The mechanism of specialized types has been implemented within the limits of ‘LSB Infrastructure’ project in ISP RAS. It’s based on existing LSB database. LSB database has been extended by 8 new tables tests for Qt3 library and tests for Qt4 library were created. The process of creation of tests has been executed by 3 developers and has taken 6 months. The maximal speed of creation of tests reached 500 tests per day.
15 Thank you!