Skip to content
Snippets Groups Projects
Unverified Commit 6f8e4b44 authored by Elemer Lelik's avatar Elemer Lelik Committed by GitHub
Browse files

Merge pull request #149 from erititan/master

OOP conformance tests added
parents 3e004dcb da61a41a
No related branches found
No related tags found
No related merge requests found
Showing
with 3879 additions and 0 deletions
##############################################################################
# Copyright (c) 2000-2020 Ericsson Telecom AB
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v2.0
# which accompanies this distribution, and is available at
# https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html
#
# Contributors:
# Kirjak, Adrien
#
# not ready
##############################################################################
#TOPDIR := ..
#include $(TOPDIR)/Makefile.regression
#ifdef LCOV
#COVERAGE_FLAG := -C
#endif
MAKE := make
#DIRS := negative_tests positive_tests
DIRS := positive_tests
WORKING_DIR := $(shell pwd)
# It can be built manually.
run clean:
echo "hello"
@for dir in $(DIRS); do make $@ -C $$dir || exit; done
.PHONY: all clean run
Positive tests
+ included
- excluded
tree -P *.ttcn
.
├── 50101_classes
│ ├── 5010101_scope_rules
│ │ ├── Sem_5010101_scopeRules_001.ttcn +
│ │ └── Sem_5010101_scopeRules_002.ttcn +
│ ├── 5010102_abstract_classes
│ │ └── Sem_5010102_abstractClasses_001.ttcn +
│ ├── 5010103_external_classes
│ │ ├── Sem_5010103_externalClasses_001.ttcn +
│ │ └── Sem_5010103_externalClasses_002.ttcn -
│ ├── 5010104_final_classes
│ │ └── Sem_5010104_finalClasses_001.ttcn +
│ ├── 5010105_constructors
│ │ ├── Sem_5010105_Constructors_001.ttcn +
│ │ └── Sem_5010105_Constructors_002.ttcn +
│ ├── 5010106_destructors
│ │ └── Sem_5010106_Destructors_001.ttcn +
│ ├── 5010107_methods
│ │ ├── NegSem_5010107_Methods_003.ttcn !!!
│ │ ├── Sem_5010107_Methods_001.ttcn +
│ │ ├── Sem_5010107_Methods_002.ttcn +
│ │ └── Sem_5010107_Methods_003.ttcn +
│ ├── 5010108_method_invocation
│ │ └── Sem_5010108_MethodInvocation_001.ttcn +
│ ├── 5010109_visibility
│ │ ├── Sem_5010109_Visibility_001.ttcn -
│ │ ├── Sem_5010109_Visibility_002.ttcn +
│ │ └── Sem_5010109_Visibility_003.ttcn +
│ └── 50101_top_level
│ ├── Sem_50101_top_level_001.ttcn +
│ ├── Sem_50101_top_level_002.ttcn +
│ ├── Sem_50101_top_level_003.ttcn +
│ ├── Sem_50101_top_level_004.ttcn +
│ ├── Sem_50101_top_level_005.ttcn -
│ ├── Sem_50101_top_level_006.ttcn -
│ ├── Sem_50101_top_level_007.ttcn +
│ └── Sem_50101_top_level_008.ttcn +
└── 50102_objects
├── 5010202_object_references
│ └── Sem_5010202_ObjectReferences_001.ttcn +
├── 5010203_null_reference
│ ├── NegSem_5010203_NullReference_001.ttcn !!!
│ └── Sem_5010203_NullReference_001.ttcn +
├── 5010204_select_class-statement
│ └── Sem_5010204_SelectClassStatement_001.ttcn +
├── 5010205_of_operator
│ └── Sem_5010205_OfOperator_001.ttcn +
└── 5010206_casting
└── Sem_5010206_Casting_001.ttcn +
Sem_5010101_scopeRules_001.ttcn
Sem_5010101_scopeRules_002.ttcn
Sem_5010102_abstractClasses_001.ttcn
Sem_5010103_externalClasses_001.ttcn
#Sem_5010103_externalClasses_002.ttcn
Sem_5010104_finalClasses_001.ttcn
Sem_5010105_Constructors_001.ttcn
Sem_5010105_Constructors_002.ttcn
Sem_5010106_Destructors_001.ttcn
Sem_5010107_Methods_001.ttcn
Sem_5010107_Methods_002.ttcn
Sem_5010107_Methods_003.ttcn
NegSem_5010107_Methods_003.ttcn
Sem_5010108_MethodInvocation_001.ttcn
#Sem_5010109_Visibility_001.ttcn
Sem_5010109_Visibility_002.ttcn
Sem_5010109_Visibility_003.ttcn
Sem_50101_top_level_001.ttcn
Sem_50101_top_level_002.ttcn
Sem_50101_top_level_003.ttcn
Sem_50101_top_level_004.ttcn
#Sem_50101_top_level_005.ttcn
#Sem_50101_top_level_006.ttcn
Sem_50101_top_level_007.ttcn
Sem_50101_top_level_008.ttcn
Sem_5010202_ObjectReferences_001.ttcn
Sem_5010203_NullReference_001.ttcn
NegSem_5010203_NullReference_001.ttcn
Sem_5010204_SelectClassStatement_001.ttcn
Sem_5010205_OfOperator_001.ttcn
Sem_5010206_Casting_001.ttcn
#Sem_50201_Functions_001.ttcn
#Sem_50202_ExternalFunctions_001.ttcn
#Sem_50203_invoking_functions_001.ttcn
#Sem_50204_altsteps_001.ttcn
#Sem_50205_test_cases_001.ttcn
Negative tests
├── 50101_classes
│ ├── 5010101_scope_rules
│ │ └── NegSem_5010101_scopeRules_001.ttcn +
│ ├── 5010102_abstract_classes
│ │ └── NegSem_5010102_abstractClasses_001.ttcn +
│ ├── 5010103_external_classes
│ │ ├── NegSem_5010103_externalClasses_001.ttcn +
│ │ └── NegSem_5010103_externalClasses_002.ttcn +
│ ├── 5010104_final_classes
│ │ └── NegSem_5010104_finalClasses_001.ttcn +
│ ├── 5010105_constructors
│ ├── 5010106_destructors
│ ├── 5010107_methods
│ │ ├── NegSem_5010107_Methods_001.ttcn +
│ │ ├── NegSem_5010107_Methods_002.ttcn +
│ │ ├── NegSem_5010107_Methods_003a.ttcn + (NegSem_5010107_Methods_003.ttcn --> @ positive test cases)
│ │ └── NegSem_5010107_Methods_004.ttcn +
│ ├── 5010108_method_invocation
│ ├── 5010109_visibility
│ │ ├── NegSem_5010109_Visibility_001.ttcn +
│ │ ├── NegSem_5010109_Visibility_002.ttcn +
│ │ ├── NegSem_5010109_Visibility_003.ttcn +
│ │ └── NegSem_5010109_Visibility_004.ttcn +
│ └── 50101_top_level
│ ├── NegSem_50101_top_level_001.ttcn +
│ ├── NegSem_50101_top_level_002.ttcn +
│ ├── NegSem_50101_top_level_003.ttcn +
│ ├── NegSem_50101_top_level_004a.ttcn +
│ ├── NegSem_50101_top_level_004.ttcn +
│ ├── NegSem_50101_top_level_005.ttcn +
│ ├── NegSem_50101_top_level_006a.ttcn +
│ ├── NegSem_50101_top_level_006.ttcn +
│ ├── NegSem_50101_top_level_007.ttcn +
│ ├── NegSem_50101_top_level_008.ttcn +
│ ├── NegSem_50101_top_level_009.ttcn +
│ ├── NegSem_50101_top_level_010.ttcn +
│ └── NegSem_50101_top_level_011.ttcn +
└── 50102_objects
├── 5010202_object_references
│ ├── NegSem_5010202_ObjectReferences_001.ttcn +
│ └── NegSem_5010202_ObjectReferences_002.ttcn -
├── 5010203_null_reference
│ └── NegSem_5010203_NullReference_001.ttcn --> @positive tet cases
├── 5010204_select_class-statement
│ └── NegSem_5010204_SelectClassStatement_001.ttcn -
├── 5010205_of_operator
└── 5010206_casting
└── NegSem_5010206_Casting_001.ttcn -
===============================================================
The following test cases passed:
================================
[50101_classes.script]: 'NegSem_5010101_scopeRules_001'
[50101_classes.script]: 'NegSem_5010102_abstractClasses_001'
[50101_classes.script]: 'NegSem_5010103_externalClasses_001a'
[50101_classes.script]: 'NegSem_5010103_externalClasses_001b'
[50101_classes.script]: 'NegSem_5010103_externalClasses_002'
[50101_classes.script]: 'NegSem_5010104_finalClasses_001'
[50101_classes.script]: 'NegSem_5010107_Methods_003a'
[50101_classes.script]: 'NegSem_5010107_Methods_004'
[50101_classes.script]: 'NegSem_5010109_Visibility_001'
[50101_classes.script]: 'NegSem_5010109_Visibility_002'
[50101_classes.script]: 'NegSem_5010109_Visibility_004'
[50101_classes.script]: 'NegSem_50101_top_level_001'
[50101_classes.script]: 'NegSem_50101_top_level_002'
[50101_classes.script]: 'NegSem_50101_top_level_003'
[50101_classes.script]: 'NegSem_50101_top_level_004'
[50101_classes.script]: 'NegSem_50101_top_level_006'
[50101_classes.script]: 'NegSem_50101_top_level_006a'
[50101_classes.script]: 'NegSem_50101_top_level_007'
[50101_classes.script]: 'NegSem_50101_top_level_008'
[50101_classes.script]: 'NegSem_50101_top_level_008a'
[50101_classes.script]: 'NegSem_50101_top_level_008b'
[50101_classes.script]: 'NegSem_50101_top_level_009'
[50101_classes.script]: 'NegSem_50101_top_level_010'
[50101_classes.script]: 'NegSem_50101_top_level_011'
[50101_classes.script]: 'NegSem_50101_top_level_011a'
[50101_objects.script]: 'NegSem_5010206_Casting_001'
The following test cases failed:
================================
[50101_classes.script]: 'NegSem_5010107_Methods_001'
[50101_classes.script]: 'NegSem_5010107_Methods_002'
[50101_classes.script]: 'NegSem_5010109_Visibility_003'
[50101_classes.script]: 'NegSem_50101_top_level_004a'
[50101_classes.script]: 'NegSem_50101_top_level_005'
[50101_objects.script]: 'NegSem_5010202_ObjectReferences_001'
The following test cases are inconclusive:
==========================================
None.
Memory leak detected in the following test cases:
None.
Abnormal termination occured during the following test cases:
None.
===============================================================
32 test cases from 2 script files were executed
Total number of executed test cases: 32
PASSED test cases: 26
FAILED test cases: 6
INCONCLUSIVE test cases: 0
Abnormally terminated test cases: 0
Memory leaked test cases: 0
Session saved to log file 'SA_log.report'
Elapsed time in this session: 1 seconds
.******************************************************************************
.* Copyright (c) ETSI 2020.
.*
.* This file is subject to copyrights owned by ETSI. Non-exclusive permission
.* is hereby granted, free of charge, to copy, reproduce and amend this file
.* under the following conditions: It is provided "as is", without warranty of any
.* kind, expressed or implied.
.*
.* ETSI shall never be liable for any claim, damages, or other liability arising
.* from its use or inability of use.This permission does not apply to any documentation
.* associated with this file for which ETSI keeps all rights reserved. The present
.* copyright notice shall be included in all copies of whole or part of this
.* file and shall not imply any sub-license right.
.*
.* Modified by: Elemer Lelik
.*
.******************************************************************************/
text.
:lang eng.
.*
:docname.Test Description
:docno.
:rev.
:date.2020-11-11
.*
:prep. Elemer Lelik
:subresp.
:appr.
:checked.
.*
:title.ETSI TTCN3 Negative Conformance Test
:contents level=3.
.*---------------------------------------------------------------------*
:h1.PREREQUISITES AND PREPARATIONS
.*---------------------------------------------------------------------*
.*---------------------------------------------------------------------*
:h2.Scope of the Test Object
.*---------------------------------------------------------------------*
:xmp tab=1 nokeep.
This TD contains negative OOP test modules from ETSI TTCN3 Conformance Test's 50101_modules folders.
:exmp.
.*---------------------------------------------------------------------*
:h2.Test Tools
.*---------------------------------------------------------------------*
:p.:us.Software Tools:eus.
:xmp tab=2 nokeep.
SAtester_OOP.pl
:exmp.
:np.
.*---------------------------------------------------------------------*
:h1.REQUIREMENT-BASED TESTS
.*---------------------------------------------------------------------*
.*---------------------------------------------------------------------*
:h2. 5010101_scope_rules folder
.*---------------------------------------------------------------------*
*---------------------------------------------------------------------*
:h3. NegSem_5010101_scopeRules_001 negative test
.*---------------------------------------------------------------------*
:xmp tab=0.
<TC - NegSem_5010101_scopeRules_001 >
<COMPILE>
<MODULE TTCN NegSem_5010101_scopeRules_001 NegSem_5010101_scopeRules_001.ttcn >
/*****************************************************************
** @author STF 572
** @version 0.0.1
** @purpose 5.1.1.1, Ensure that reusing identifiers of members of the component type specified in the runs on clause of the class for members and inside methods for formal parameters and local declarations is not allowed
** @verdict pass reject
*****************************************************************/
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=568714
module NegSem_5010101_scopeRules_001 "TTCN-3:2018 Object-Oriented" {
type component GeneralComp {
const integer c_i := 5;
}
public type class MyClass runs on GeneralComp {
public const integer c_i := 8; //not allowed
function DoNothing(integer c_i := 11) { //not allowed
log("Not allowed this type of reusing IDs.");
}
}
testcase TC_NegSem_5010101_scopeRules_001() runs on GeneralComp {
//var MyClass v_a := MyClass.create(); FIXME!!!
var MyClass v_a := MyClass.create(8);
if (v_a.c_i != c_i) {
setverdict(pass);
} else {
setverdict(fail);
}
}
control {
execute(TC_NegSem_5010101_scopeRules_001());
}
}
<END_MODULE>
<RESULT COUNT>
error
<END_RESULT>
<END_TC>
:exmp
.*---------------------------------------------------------------------*
:h2. 5010102_abstract_classes folder
.*---------------------------------------------------------------------*
*---------------------------------------------------------------------*
:h3. NegSem_5010102_abstractClasses_001 negative test
.*---------------------------------------------------------------------*
:xmp tab=0.
<TC - NegSem_5010102_abstractClasses_001 >
<COMPILE>
<MODULE TTCN NegSem_5010102_abstractClasses_001 NegSem_5010102_abstractClasses_001.ttcn >
/*****************************************************************
** @author STF 572
** @version 0.0.1
** @purpose 5.1.1.2, Ensure that abstract classes cannot be explicitly instantiated.
** @verdict pass reject
*****************************************************************/
module NegSem_5010102_abstractClasses_001 "TTCN-3:2018 Object-Oriented" {
type component GeneralComp {
}
public type class @abstract t_class_abstract {
// public function log_sending(); //FIXME!!
public function log_sending() {};
}
public type class t_class_subclass extends t_class_abstract { // ???? not needed
public function log_sending() {
log("Sending messages!!!");
}
}
testcase TC_NegSem_5010102_abstractClasses_001() runs on GeneralComp {
var t_class_abstract v_a := t_class_abstract.create(); //not allowed
setverdict(pass);
}
control {
execute(TC_NegSem_5010102_abstractClasses_001());
}
}
<END_MODULE>
<RESULT COUNT>
error: Cannot create an instance of abstract class type
<END_RESULT>
<END_TC>
:exmp
.*---------------------------------------------------------------------*
:h2. 5010103_external_classes folder
.*---------------------------------------------------------------------*
*---------------------------------------------------------------------*
:h3. NegSem_5010103_externalClasses_001a negative test
.*---------------------------------------------------------------------*
:xmp tab=0.
<TC - NegSem_5010103_externalClasses_001a >
<COMPILE>
<MODULE TTCN NegSem_5010103_externalClasses_001a NegSem_5010103_externalClasses_001a.ttcn >
/*****************************************************************
** @author STF 572
** @version 0.0.1
** @purpose 5.1.1.3, Ensure that external classes shall not contain fields or functions with a body.
** @verdict pass reject
*****************************************************************/
module NegSem_5010103_externalClasses_001a "TTCN-3:2018 Object-Oriented" {
type component GeneralComp {
}
type external class Java_Int_List {
function add(integer v) { //not allowed
log("Add v to integer list");
}
function get(integer index) return integer;
// const charstring c_a := "ret"; //not allowed
}
testcase TC_NegSem_5010103_externalClasses_001a() runs on GeneralComp {
//empty testcase
setverdict(pass);
}
control {
execute(TC_NegSem_5010103_externalClasses_001a());
}
}
<END_MODULE>
<RESULT COUNT>
error: An external class cannot contain a function
<END_RESULT>
<END_TC>
:exmp
*---------------------------------------------------------------------*
:h3. NegSem_5010103_externalClasses_001b negative test
.*---------------------------------------------------------------------*
:xmp tab=0.
<TC - NegSem_5010103_externalClasses_001b >
<COMPILE>
<MODULE TTCN NegSem_5010103_externalClasses_001b NegSem_5010103_externalClasses_001b.ttcn >
/*****************************************************************
** @author STF 572
** @version 0.0.1
** @purpose 5.1.1.3, Ensure that external classes shall not contain fields or functions with a body.
** @verdict pass reject
*****************************************************************/
module NegSem_5010103_externalClasses_001b "TTCN-3:2018 Object-Oriented" {
type component GeneralComp {
}
type external class Java_Int_List {
// function add(integer v) { //not allowed
// log("Add v to integer list");
// }
function get(integer index) return integer;
const charstring c_a := "ret"; //not allowed
}
testcase TC_NegSem_5010103_externalClasses_001b() runs on GeneralComp {
//empty testcase
setverdict(pass);
}
control {
execute(TC_NegSem_5010103_externalClasses_001b());
}
}
<END_MODULE>
<RESULT COUNT>
error: An external class cannot contain a constant
<END_RESULT>
<END_TC>
:exmp
*---------------------------------------------------------------------*
:h3. NegSem_5010103_externalClasses_002 negative test
.*---------------------------------------------------------------------*
:xmp tab=0.
<TC - NegSem_5010103_externalClasses_002 >
<COMPILE>
<MODULE TTCN NegSem_5010103_externalClasses_002 NegSem_5010103_externalClasses_002.ttcn >
/*****************************************************************
** @author STF 572
** @version 0.0.1
** @purpose 5.1.1.3, Ensure that external classes shall not be derived from non-external classes.
** @verdict pass reject
*****************************************************************/
module NegSem_5010103_externalClasses_002 "TTCN-3:2018 Object-Oriented" {
type component GeneralComp {
}
type class @abstract Collection_Interface {
//function add(integer v) ; //FIXME!!!
function add(integer v) {};
}
type external class Java_Int_List extends Collection_Interface { //not allowed
function add(integer v);
function get(integer index) return integer;
}
testcase TC_NegSem_5010103_externalClasses_002() runs on GeneralComp {
//empty testcase
setverdict(pass);
}
control {
execute(TC_NegSem_5010103_externalClasses_002());
}
}
<END_MODULE>
<RESULT COUNT>
error: An external class cannot extend an internal class
<END_RESULT>
<END_TC>
:exmp
*---------------------------------------------------------------------*
:h3. NegSem_5010104_finalClasses_001 negative test
.*---------------------------------------------------------------------*
:xmp tab=0.
<TC - NegSem_5010104_finalClasses_001 >
<COMPILE>
<MODULE TTCN NegSem_5010104_finalClasses_001 NegSem_5010104_finalClasses_001.ttcn >
/*****************************************************************
** @author STF 572
** @version 0.0.1
** @purpose 5.1.1.4, Ensure that final classes cannot be abstract.
** @verdict pass reject
*****************************************************************/
module NegSem_5010104_finalClasses_001 "TTCN-3:2018 Object-Oriented" {
type component GeneralComp {
}
type class @final @abstract FinalClass { //not allowed
function doSomething() return charstring { //not allowed
return "something";
}
}
testcase TC_NegSem_5010104_finalClasses_001() runs on GeneralComp {
var FinalClass v_a := FinalClass.create();
if (v_a.doSomething() == "something") {
setverdict(pass);
} else {
setverdict(fail);
}
}
control {
execute(TC_NegSem_5010104_finalClasses_001());
}
}
<END_MODULE>
<RESULT COUNT>
error: Final classes cannot be abstract
<END_RESULT>
<END_TC>
:exmp
.*---------------------------------------------------------------------*
:h2. 5010107_methods folder
.*---------------------------------------------------------------------*
*---------------------------------------------------------------------*
:h3. NegSem_5010107_Methods_001 negative test
.*---------------------------------------------------------------------*
:xmp tab=0.
<TC - NegSem_5010107_Methods_001 >
<COMPILE>
<MODULE TTCN NegSem_5010107_Methods_001 NegSem_5010107_Methods_001.ttcn >
/*****************************************************************
** @author STF 572
** @version 0.0.1
** @purpose 5.1.1.7, Ensure that public methods shall be overridden only by public methods.
** @verdict pass reject
*****************************************************************/
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=568716
module NegSem_5010107_Methods_001 "TTCN-3:2018 Object-Oriented" {
type component GeneralComp {
}
type class MySuperClass {
var octetstring v_o;
public function doSomething() return integer {
return oct2int(this.v_o);
}
}
type class MySubClass extends MySuperClass {
private function doSomething() return integer { //not allowed FIXME !!!error should be thrown here !!!
return 1;
}
}
/* testcase TC_NegSem_5010107_Methods_001() runs on GeneralComp {
var MySubClass v_a := MySubClass.create('AAFF'O) //: MySuperClass(); FIXME !!!
if (v_a.doSomething() == 1) {
setverdict(pass);
} else {
setverdict(fail);
}
}
control {
execute(TC_NegSem_5010107_Methods_001());
}
*/
}
<END_MODULE>
<RESULT COUNT>
error
<END_RESULT>
<END_TC>
:exmp
*---------------------------------------------------------------------*
:h3. NegSem_5010107_Methods_002 negative test
.*---------------------------------------------------------------------*
:xmp tab=0.
<TC - NegSem_5010107_Methods_002 >
<COMPILE>
<MODULE TTCN NegSem_5010107_Methods_002 NegSem_5010107_Methods_002.ttcn >
/*****************************************************************
** @author STF 572
** @version 0.0.1
** @purpose 5.1.1.7, Ensure that protected methods may be overridden by public or protected methods only.
** @verdict pass reject
*****************************************************************/
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=568742
module NegSem_5010107_Methods_002 "TTCN-3:2018 Object-Oriented" {
type component GeneralComp {
}
type class MySuperClass {
var octetstring v_o;
function doSomething() return integer { //protected method
return oct2int(this.v_o);
}
}
type class MySubClass extends MySuperClass {
private function doSomething() return integer { //not allowed error should be thrown here FIXME!!!
return 1;
}
}
/* testcase TC_NegSem_5010107_Methods_002() runs on GeneralComp {
var MySubClass v_a := MySubClass.create('AAFF'O) // : MySuperClass(); FIXME!!!
if (v_a.doSomething() == 1) {
setverdict(pass);
} else {
setverdict(fail);
}
}
control {
execute(TC_NegSem_5010107_Methods_002());
}
*/
}
<END_MODULE>
<RESULT COUNT>
error
<END_RESULT>
<END_TC>
:exmp
*---------------------------------------------------------------------*
:h3. NegSem_5010107_Methods_003a negative test
.*---------------------------------------------------------------------*
:xmp tab=0.
<TC - NegSem_5010107_Methods_003a >
<COMPILE>
<MODULE TTCN NegSem_5010107_Methods_003a NegSem_5010107_Methods_003a.ttcn >
/*****************************************************************
** @author STF 572
** @version 0.0.1
** @purpose 5.1.1.7, Ensure that The return type of an overriding function shall be the same as the return type of the overridden function with the same template restrictions and modifiers.
** @verdict pass reject
*****************************************************************/
module NegSem_5010107_Methods_003 "TTCN-3:2018 Object-Oriented" {
type component GeneralComp {
}
type integer Mytype1;
type charstring Mytype2;
type class MySuperClass {
var octetstring v_o;
function doSomething() return Mytype1 {
return oct2int(this.v_o);
}
}
type class MySubClass extends MySuperClass {
// /*protected*/ function doSomething() return Mytype2 { // not allowed
public function doSomething() return Mytype2 { //not allowed
return "1";
}
}
testcase TC_NegSem_5010107_Methods_003() runs on GeneralComp {
var MySubClass v_a := MySubClass.create('AAFF'O) //: MySuperClass(); FIXME!!!
if (v_a.doSomething() == "1") {
setverdict(pass);
} else {
setverdict(fail);
}
}
control {
execute(TC_NegSem_5010107_Methods_003());
}
}
<END_MODULE>
<RESULT COUNT>
error: The prototype of method `doSomething' is not identical to that of inherited method
<END_RESULT>
<END_TC>
:exmp
*---------------------------------------------------------------------*
:h3. NegSem_5010107_Methods_004 negative test
.*---------------------------------------------------------------------*
:xmp tab=0.
<TC - NegSem_5010107_Methods_004 >
<COMPILE>
<MODULE TTCN NegSem_5010107_Methods_004 NegSem_5010107_Methods_004.ttcn >
/*****************************************************************
** @author STF 572
** @version 0.0.1
** @purpose 5.1.1.7, Ensure that is 'runs on, mtc, system' clauses are not permitted on methods.
** @verdict pass reject
*****************************************************************/
module NegSem_5010107_Methods_004 "TTCN-3:2018 Object-Oriented" {
type component GeneralComp {
}
type class MySuperClass runs on GeneralComp {
var octetstring v_o;
function doSomething() return integer runs on GeneralComp { //not allowed
return oct2int(this.v_o);
}
}
type class MySubClass extends MySuperClass {
function doSomething() return integer runs on GeneralComp {
return 1;
}
}
testcase TC_NegSem_5010107_Methods_004() runs on GeneralComp {
var MySubClass v_a := MySubClass.create('AAFF'O) //: MySuperClass(); FIXME!!!
if (v_a.doSomething() == 1) {
setverdict(pass);
} else {
setverdict(fail);
}
}
control {
execute(TC_NegSem_5010107_Methods_004());
}
}
<END_MODULE>
<RESULT COUNT>
error: at or before token `runs': syntax error, unexpected RunsKeyword
<END_RESULT>
<END_TC>
:exmp
.*---------------------------------------------------------------------*
:h2. 5010109_visibility folder
.*---------------------------------------------------------------------*
*---------------------------------------------------------------------*
:h3. NegSem_5010109_Visibility_001 negative test
.*---------------------------------------------------------------------*
:xmp tab=0.
<TC - NegSem_5010109_Visibility_001 >
<COMPILE>
<MODULE TTCN NegSem_5010109_Visibility_001 NegSem_5010109_Visibility_001.ttcn >
/*****************************************************************
** @author STF 572
** @version 0.0.1
** @purpose 5.1.1.9, Ensure that fields can be declared as private or protected only.
** @verdict pass reject
*****************************************************************/
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=568755
module NegSem_5010109_Visibility_001 "TTCN-3:2018 Object-Oriented" {
type component GeneralComp {
}
type class MyClass {
public var integer v_i; // not allowed should not compile!!! FIXME!!!
}
/* testcase TC_NegSem_5010109_Visibility_001() runs on GeneralComp {
var MyClass v_a := MyClass.create(1);
if (v_a.v_i == 1) {
setverdict(pass);
} else {
setverdict(fail);
}
}
control {
execute(TC_NegSem_5010109_Visibility_001());
}
*/
}
<END_MODULE>
<RESULT COUNT>
error: Class members cannot be public
<END_RESULT>
<END_TC>
:exmp
*---------------------------------------------------------------------*
:h3. NegSem_5010109_Visibility_002 negative test
.*---------------------------------------------------------------------*
:xmp tab=0.
<TC - NegSem_5010109_Visibility_002 >
<COMPILE>
<MODULE TTCN NegSem_5010109_Visibility_002 NegSem_5010109_Visibility_002.ttcn >
/*****************************************************************
** @author STF 572
** @version 0.0.1
** @purpose 5.1.1.9, Ensure that a field of any visibility cannot be overridden in a subclass.
** @verdict pass reject
*****************************************************************/
module NegSem_5010109_Visibility_002 "TTCN-3:2018 Object-Oriented" {
type component GeneralComp {
}
type charstring MyType;
type class MySuperClass {
private var MyType v_my;
}
type class MySubClass extends MySuperClass {
var MyType v_my; //not allowed
}
testcase TC_NegSem_5010109_Visibility_002() runs on GeneralComp {
var MySubClass v_a := MySubClass.create("abc");
if (v_a.v_my == "abc") {
setverdict(pass);
} else {
setverdict(fail);
}
}
control {
execute(TC_NegSem_5010109_Visibility_002());
}
}
<END_MODULE>
<RESULT COUNT>
error: variable `@NegSem_5010109_Visibility_002.MySubClass.v_my' shadows inherited member
<END_RESULT>
<END_TC>
:exmp
*---------------------------------------------------------------------*
:h3. NegSem_5010109_Visibility_003 negative test
.*---------------------------------------------------------------------*
:xmp tab=0.
<TC - NegSem_5010109_Visibility_003 >
<COMPILE>
<MODULE TTCN NegSem_5010109_Visibility_003 NegSem_5010109_Visibility_003.ttcn >
/*****************************************************************
** @author STF 572
** @version 0.0.1
** @purpose 5.1.1.9, Ensure that a public member function can only be overridden by another public member function.
** @verdict pass reject
*****************************************************************/
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=568743
module NegSem_5010109_Visibility_003 "TTCN-3:2018 Object-Oriented" {
type component GeneralComp {
}
type class MySuperClass {
var integer v_i;
public function f_add(integer inint) return integer {
return this.v_i + inint;
}
}
type class MySubClass extends MySuperClass {
function f_add(integer inint) return integer { //not allowed should throw an error here FIXME!!!
return this.v_i + 1;
}
}
/* testcase TC_NegSem_5010109_Visibility_003() runs on GeneralComp {
var MySubClass v_a := MySubClass.create(1);
if (v_a.f_add(2) == 3) {
setverdict(pass);
} else {
setverdict(fail);
}
}
control {
execute(TC_NegSem_5010109_Visibility_003());
}
*/
}
<END_MODULE>
<RESULT COUNT>
error
<END_RESULT>
<END_TC>
:exmp
*---------------------------------------------------------------------*
:h3. NegSem_5010109_Visibility_004 negative test
.*---------------------------------------------------------------------*
:xmp tab=0.
<TC - NegSem_5010109_Visibility_004 >
<COMPILE>
<MODULE TTCN NegSem_5010109_Visibility_004 NegSem_5010109_Visibility_004.ttcn >
/*****************************************************************
** @author STF 572
** @version 0.0.1
** @purpose 5.1.1.9, Ensure that private members can only be accessed directly from inside their surrounding class's scope.
** @verdict pass reject
*****************************************************************/
module NegSem_5010109_Visibility_004 "TTCN-3:2018 Object-Oriented" {
type component GeneralComp {
}
type class MyClass {
private var integer v_i;
}
testcase TC_NegSem_5010109_Visibility_004() runs on GeneralComp {
var MyClass v_a := MyClass.create(1);
if (v_a.v_i == 1) { //not allowed
setverdict(pass);
} else {
setverdict(fail);
}
}
control {
execute(TC_NegSem_5010109_Visibility_004());
}
}
<END_MODULE>
<RESULT COUNT>
error: The member definition `v_i' in class type `MyClass' is not visible in this scope
<END_RESULT>
<END_TC>
:exmp
.*---------------------------------------------------------------------*
:h2. 50101_top_level folder
.*---------------------------------------------------------------------*
*---------------------------------------------------------------------*
:h3. NegSem_50101_top_level_001 negative test
.*---------------------------------------------------------------------*
:xmp tab=0.
<TC - NegSem_50101_top_level_001 >
<COMPILE>
<MODULE TTCN NegSem_50101_top_level_001 NegSem_50101_top_level_001.ttcn >
/*****************************************************************
** @author STF 572
** @version 0.0.1
** @purpose 5.1.1.0, Ensure that a class members' names are unique.
** @verdict pass reject
*****************************************************************/
module NegSem_50101_top_level_001 "TTCN-3:2018 Object-Oriented" {
type component GeneralComp {
}
public type class t_class_member_overloading {
var integer v_i := 10;
var integer v_i := 5; // not allowed
}
testcase TC_NegSem_50101_top_level_001() runs on GeneralComp {
//var t_class_member_overloading v_a := t_class_member_overloading.create(); FIXME!!!
var t_class_member_overloading v_a := t_class_member_overloading.create(10);
if (v_a.v_i == 5) {
setverdict(pass);
} else {
setverdict(fail);
}
}
control {
execute(TC_NegSem_50101_top_level_001());
}
}
<END_MODULE>
<RESULT COUNT>
error: Duplicate definition with name `v_i'
<END_RESULT>
<END_TC>
:exmp
*---------------------------------------------------------------------*
:h3. NegSem_50101_top_level_002 negative test
.*---------------------------------------------------------------------*
:xmp tab=0.
<TC - NegSem_50101_top_level_002 >
<COMPILE>
<MODULE TTCN NegSem_50101_top_level_002 NegSem_50101_top_level_002.ttcn >
/*****************************************************************
** @author STF 572
** @version 0.0.1
** @purpose 5.1.1.0, Ensure that a class members' names are unique.
** @verdict pass reject
*****************************************************************/
module NegSem_50101_top_level_002 "TTCN-3:2018 Object-Oriented" {
type component GeneralComp {
}
public type class t_class_member_overloading {
var integer v_i := 10;
public function v_i() return integer { // not allowed
return 5;
}
}
testcase TC_NegSem_50101_top_level_002() runs on GeneralComp {
//var t_class_member_overloading v_a := t_class_member_overloading.create(); FIXME!!!
var t_class_member_overloading v_a := t_class_member_overloading.create(10);
if (v_a.v_i() == 5) {
setverdict(pass);
} else {
setverdict(fail);
}
}
control {
execute(TC_NegSem_50101_top_level_002());
}
}
<END_MODULE>
<RESULT COUNT>
error: Duplicate definition with name `v_i'
<END_RESULT>
<END_TC>
:exmp
*---------------------------------------------------------------------*
:h3. NegSem_50101_top_level_003 negative test
.*---------------------------------------------------------------------*
:xmp tab=0.
<TC - NegSem_50101_top_level_003 >
<COMPILE>
<MODULE TTCN NegSem_50101_top_level_003 NegSem_50101_top_level_003.ttcn >
/*****************************************************************
** @author STF 572
** @version 0.0.1
** @purpose 5.1.1.0, Ensure that templates are not allowed for class types.
** @verdict pass reject
*****************************************************************/
module NegSem_50101_top_level_003 "TTCN-3:2018 Object-Oriented" {
type component GeneralComp {
}
public type template class t_templ_class_const_field { //not allowed
private const charstring cons_ver_id := "0.0.1";
public function get_cons_verid() return charstring {
return this.cons_ver_id;
}
}
testcase TC_NegSem_50101_top_level_003() runs on GeneralComp {
//var t_templ_class_const_field v_a := t_templ_class_const_field.create(); FIXME!!!
var t_templ_class_const_field v_a := t_templ_class_const_field.create("0.0.1");
if (v_a.get_cons_verid() == "0.0.1") {
setverdict(pass);
} else {
setverdict(fail);
}
}
control {
execute(TC_NegSem_50101_top_level_003());
}
}
<END_MODULE>
<RESULT COUNT>
error: at or before token `template': syntax error, unexpected TemplateKeyword, expecting ClassKeyword
<END_RESULT>
<END_TC>
:exmp
*---------------------------------------------------------------------*
:h3. NegSem_50101_top_level_004 negative test
.*---------------------------------------------------------------------*
:xmp tab=0.
<TC - NegSem_50101_top_level_004 >
<COMPILE>
<MODULE TTCN NegSem_50101_top_level_004 NegSem_50101_top_level_004.ttcn >
/*****************************************************************
** @author STF 572
** @version 0.0.1
** @purpose 5.1.1.0, Ensure that passing of object references to the create operation of a component type or a function started on another component is not allowed.
** @verdict pass reject
*****************************************************************/
module NegSem_50101_top_level_004 "TTCN-3:2018 Object-Oriented" {
type component GeneralComp {
}
/* type component MyNotEmptyComponent{
const charstring c_MyCstr := "def";
function doSomething(in MyEmptyClass e) {
log("Nothing in MyEmptyClass e");
}
}
*/ //FIXME!!!
type component MyNotEmptyComponent{
const charstring c_MyCstr := "def";
}
function doSomething(in MyEmptyClass e) runs on MyNotEmptyComponent {
log("Nothing in MyEmptyClass e");
}
public type class MyEmptyClass runs on GeneralComp {
}
testcase TC_NegSem_50101_top_level_004_01() runs on GeneralComp {
var MyEmptyClass v_MyClass := MyEmptyClass.create();
var GeneralComp v_MyComponent := GeneralComp.create(v_MyClass); //not allowed
setverdict(pass);
}
/* testcase TC_NegSem_50101_top_level_004_02() runs on GeneralComp {
var MyEmptyClass v_MyClass := MyEmptyClass.create();
var MyNotEmptyComponent v_MyComponent := MyNotEmptyComponent.create alive;
v_MyComponent.start(doSomething(v_MyClass)); //not allowed
setverdict(pass);
}
*/
control {
execute(TC_NegSem_50101_top_level_004_01());
// execute(TC_NegSem_50101_top_level_004_02());
}
}
<END_MODULE>
<RESULT COUNT>
error: First operand of operation
<END_RESULT>
<END_TC>
:exmp
*---------------------------------------------------------------------*
:h3. NegSem_50101_top_level_004a negative test
.*---------------------------------------------------------------------*
:xmp tab=0.
<TC - NegSem_50101_top_level_004a >
<COMPILE>
<MODULE TTCN NegSem_50101_top_level_004a NegSem_50101_top_level_004a.ttcn >
/*****************************************************************
** @author STF 572
** @version 0.0.1
** @purpose 5.1.1.0, Ensure that passing of object references to the create operation of a component type or a function started on another component is not allowed.
** @verdict pass reject
*****************************************************************/
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=568744
module NegSem_50101_top_level_004a "TTCN-3:2018 Object-Oriented" {
type component GeneralComp {
}
/* type component MyNotEmptyComponent{
const charstring c_MyCstr := "def";
function doSomething(in MyEmptyClass e) {
log("Nothing in MyEmptyClass e");
}
}
*/ //FIXME!!!
type component MyNotEmptyComponent{
const charstring c_MyCstr := "def";
}
function doSomething(in MyEmptyClass e) runs on MyNotEmptyComponent {
log("Nothing in MyEmptyClass e");
}
public type class MyEmptyClass runs on GeneralComp {
}
/* testcase TC_NegSem_50101_top_level_004_01() runs on GeneralComp {
var MyEmptyClass v_MyClass := MyEmptyClass.create();
var GeneralComp v_MyComponent := GeneralComp.create(v_MyClass); //not allowed
setverdict(pass);
}
*/
testcase TC_NegSem_50101_top_level_004_02() runs on GeneralComp {
var MyEmptyClass v_MyClass := MyEmptyClass.create();
var MyNotEmptyComponent v_MyComponent := MyNotEmptyComponent.create alive;
v_MyComponent.start(doSomething(v_MyClass)); //not allowed
setverdict(pass);
}
control {
// execute(TC_NegSem_50101_top_level_004_01());
execute(TC_NegSem_50101_top_level_004_02());
}
}
<END_MODULE>
<RESULT COUNT>
error: TBD
<END_RESULT>
<END_TC>
:exmp
*---------------------------------------------------------------------*
:h3. NegSem_50101_top_level_005 negative test
.*---------------------------------------------------------------------*
:xmp tab=0.
<TC - NegSem_50101_top_level_005 >
<COMPILE>
<MODULE TTCN NegSem_50101_top_level_005 NegSem_50101_top_level_005.ttcn >
/*****************************************************************
** @author STF 572
** @version 0.0.1
** @purpose 5.1.1.0, Ensure that subtyping definition is not allowed for class types via the normal subtype definition.
** @verdict pass reject
*****************************************************************/
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=568745
module NegSem_50101_top_level_005 "TTCN-3:2018 Object-Oriented"{
type component GeneralComp {
}
public type class t_empty_class {
}
type t_empty_class MyClassType; //not allowed FIXME!!!
testcase TC_NegSem_50101_top_level_005() runs on GeneralComp {
var t_empty_class v_a := t_empty_class.create()
setverdict(pass);
}
control {
execute(TC_NegSem_50101_top_level_005());
}
}
<END_MODULE>
<RESULT COUNT>
error:
<END_RESULT>
<END_TC>
:exmp
*---------------------------------------------------------------------*
:h3. NegSem_50101_top_level_006 negative test
.*---------------------------------------------------------------------*
:xmp tab=0.
<TC - NegSem_50101_top_level_006 >
<COMPILE>
<MODULE TTCN NegSem_50101_top_level_006 NegSem_50101_top_level_006.ttcn >
/*****************************************************************
** @author STF 572
** @version 0.0.1
** @purpose 5.1.1.0, Ensure that local/global constants or module parameters of class type or containing class type fields or elements are not allowed.
** @verdict pass reject
*****************************************************************/
module NegSem_50101_top_level_006 "TTCN-3:2018 Object-Oriented" {
type component GeneralComp {
}
public type class t_class_simple_class {
private var hexstring v_hstr := 'AF37D'H;
public function get_hexstr() return hexstring {
return v_hstr;
}
}
const t_class_simple_class const_simple := t_class_simple_class.create(); // not allowed
//modulepar t_class_simple_class mod_par_simple; // not allowed
testcase TC_NegSem_50101_top_level_006() runs on GeneralComp {
//var t_class_simple_class v_a := t_class_simple_class.create(); FIXME!!!
var t_class_simple_class v_a := t_class_simple_class.create('AF37D'H);
if (v_a.get_hexstr() == 'AF37D'H) {
setverdict(pass);
} else {
setverdict(fail);
}
}
control {
execute(TC_NegSem_50101_top_level_006());
}
}
<END_MODULE>
<RESULT COUNT>
error: Constant cannot be defined for class type
<END_RESULT>
<END_TC>
:exmp
*---------------------------------------------------------------------*
:h3. NegSem_50101_top_level_006a negative test
.*---------------------------------------------------------------------*
:xmp tab=0.
<TC - NegSem_50101_top_level_006a >
<COMPILE>
<MODULE TTCN NegSem_50101_top_level_006a NegSem_50101_top_level_006a.ttcn >
/*****************************************************************
** @author STF 572
** @version 0.0.1
** @purpose 5.1.1.0, Ensure that local/global constants or module parameters of class type or containing class type fields or elements are not allowed.
** @verdict pass reject
*****************************************************************/
module NegSem_50101_top_level_006 "TTCN-3:2018 Object-Oriented" {
type component GeneralComp {
}
public type class t_class_simple_class {
private var hexstring v_hstr := 'AF37D'H;
public function get_hexstr() return hexstring {
return v_hstr;
}
}
//const t_class_simple_class const_simple := t_class_simple_class.create(); // not allowed
modulepar t_class_simple_class mod_par_simple; // not allowed
testcase TC_NegSem_50101_top_level_006() runs on GeneralComp {
//var t_class_simple_class v_a := t_class_simple_class.create(); FIXME!!!
var t_class_simple_class v_a := t_class_simple_class.create('AF37D'H);
if (v_a.get_hexstr() == 'AF37D'H) {
setverdict(pass);
} else {
setverdict(fail);
}
}
control {
execute(TC_NegSem_50101_top_level_006());
}
}
<END_MODULE>
<RESULT COUNT>
error: Type of module parameter cannot be or embed class type
<END_RESULT>
<END_TC>
:exmp
*---------------------------------------------------------------------*
:h3. NegSem_50101_top_level_007 negative test
.*---------------------------------------------------------------------*
:xmp tab=0.
<TC - NegSem_50101_top_level_007 >
<COMPILE>
<MODULE TTCN NegSem_50101_top_level_007 NegSem_50101_top_level_007.ttcn >
/*****************************************************************
** @author STF 572
** @version 0.0.1
** @purpose 5.1.1.0, Ensure that class type cannot be the contained value of an anytype value.
** @verdict pass reject
*****************************************************************/
module NegSem_50101_top_level_007 "TTCN-3:2018 Object-Oriented" {
type component GeneralComp {
}
public type class t_class_anytype_class {
//empty class
}
testcase TC_NegSem_50101_top_level_007() runs on GeneralComp {
var t_class_anytype_class v_class := t_class_anytype_class.create();
var anytype v_Myanytype;
v_Myanytype.t_class_anytype_class := v_class; // not allowed
setverdict(pass);
}
control {
execute(TC_NegSem_50101_top_level_007());
}
}
<END_MODULE>
<RESULT COUNT>
error: Reference to non-existent field
<END_RESULT>
<END_TC>
:exmp
*---------------------------------------------------------------------*
:h3. NegSem_50101_top_level_008 negative test
.*---------------------------------------------------------------------*
:xmp tab=0.
<TC - NegSem_50101_top_level_008 >
<COMPILE>
<MODULE TTCN NegSem_50101_top_level_008 NegSem_50101_top_level_008.ttcn >
/*****************************************************************
** @author STF 572
** @version 0.0.1
** @purpose 5.1.1.0, Ensure that the functions of a class shall not have a runs on, mtc or system clause.
** @verdict pass reject
*****************************************************************/
module NegSem_50101_top_level_008 "TTCN-3:2018 Object-Oriented" {
type component GeneralComp {
}
public type class t_class_with_utility_functions {
public function isRightCharstring(in charstring arg_cstr) runs on GeneralComp return boolean { //not allowed
if (arg_cstr == "def") {
return true;
} else {
return false;
}
}
/* public function isPositive(in integer arg_int) mtc GeneralComp return boolean { //not allowed
if (arg_int > 0) {
return true;
} else {
return false;
}
}
public function isNegative(in integer arg_int) system GeneralComp return boolean { //not allowed
if (arg_int < 0) {
return true;
} else {
return false;
}
}
*/
const integer c_int := 5057;
}
testcase TC_NegSem_50101_top_level_008() runs on GeneralComp {
var t_class_with_utility_functions v_a := t_class_with_utility_functions.create();
if (v_a.c_int == 5057) {
setverdict(pass);
} else {
setverdict(fail);
}
}
control {
execute(TC_NegSem_50101_top_level_008());
}
}
<END_MODULE>
<RESULT COUNT>
error: at or before token `runs': syntax error
<END_RESULT>
<END_TC>
:exmp
*---------------------------------------------------------------------*
:h3. NegSem_50101_top_level_008a negative test
.*---------------------------------------------------------------------*
:xmp tab=0.
<TC - NegSem_50101_top_level_008a >
<COMPILE>
<MODULE TTCN NegSem_50101_top_level_008a NegSem_50101_top_level_008a.ttcn >
/*****************************************************************
** @author STF 572
** @version 0.0.1
** @purpose 5.1.1.0, Ensure that the functions of a class shall not have a runs on, mtc or system clause.
** @verdict pass reject
*****************************************************************/
module NegSem_50101_top_level_008a "TTCN-3:2018 Object-Oriented" {
type component GeneralComp {
}
public type class t_class_with_utility_functions {
/* public function isRightCharstring(in charstring arg_cstr) runs on GeneralComp return boolean { //not allowed
if (arg_cstr == "def") {
return true;
} else {
return false;
}
}
*/
public function isPositive(in integer arg_int) mtc GeneralComp return boolean { //not allowed
if (arg_int > 0) {
return true;
} else {
return false;
}
}
/* public function isNegative(in integer arg_int) system GeneralComp return boolean { //not allowed
if (arg_int < 0) {
return true;
} else {
return false;
}
}
*/
const integer c_int := 5057;
}
testcase TC_NegSem_50101_top_level_008() runs on GeneralComp {
var t_class_with_utility_functions v_a := t_class_with_utility_functions.create();
if (v_a.c_int == 5057) {
setverdict(pass);
} else {
setverdict(fail);
}
}
control {
execute(TC_NegSem_50101_top_level_008());
}
}
<END_MODULE>
<RESULT COUNT>
error: at or before token `mtc': syntax error
<END_RESULT>
<END_TC>
:exmp
*---------------------------------------------------------------------*
:h3. NegSem_50101_top_level_008b negative test
.*---------------------------------------------------------------------*
:xmp tab=0.
<TC - NegSem_50101_top_level_008b >
<COMPILE>
<MODULE TTCN NegSem_50101_top_level_008b NegSem_50101_top_level_008b.ttcn >
/*****************************************************************
** @author STF 572
** @version 0.0.1
** @purpose 5.1.1.0, Ensure that the functions of a class shall not have a runs on, mtc or system clause.
** @verdict pass reject
*****************************************************************/
module NegSem_50101_top_level_008 "TTCN-3:2018 Object-Oriented" {
type component GeneralComp {
}
public type class t_class_with_utility_functions {
/* public function isRightCharstring(in charstring arg_cstr) runs on GeneralComp return boolean { //not allowed
if (arg_cstr == "def") {
return true;
} else {
return false;
}
}
public function isPositive(in integer arg_int) mtc GeneralComp return boolean { //not allowed
if (arg_int > 0) {
return true;
} else {
return false;
}
}
*/ public function isNegative(in integer arg_int) system GeneralComp return boolean { //not allowed
if (arg_int < 0) {
return true;
} else {
return false;
}
}
const integer c_int := 5057;
}
testcase TC_NegSem_50101_top_level_008() runs on GeneralComp {
var t_class_with_utility_functions v_a := t_class_with_utility_functions.create();
if (v_a.c_int == 5057) {
setverdict(pass);
} else {
setverdict(fail);
}
}
control {
execute(TC_NegSem_50101_top_level_008());
}
}
<END_MODULE>
<RESULT COUNT>
error: at or before token `system': syntax error
<END_RESULT>
<END_TC>
:exmp
*---------------------------------------------------------------------*
:h3. NegSem_50101_top_level_009 negative test
.*---------------------------------------------------------------------*
:xmp tab=0.
<TC - NegSem_50101_top_level_009 >
<COMPILE>
<MODULE TTCN NegSem_50101_top_level_009 NegSem_50101_top_level_009.ttcn >
/*****************************************************************
** @author STF 572
** @version 0.0.1
** @purpose 5.1.1.0, Ensure that the runs on type of a class shall be runs on compatible with the runs on type of the behaviour creating a class.
** @verdict pass reject
*****************************************************************/
module NegSem_50101_top_level_009 "TTCN-3:2018 Object-Oriented" {
type port MyPort message {
inout integer;
} with { extension "internal"}
type component GeneralComp {
var integer v_c:=1;
}
type component TestComp {
const charstring c_cstr := "Sunday";
port MyPort p1;
}
public type class t_class_non_compatible runs on GeneralComp {
public function f_skip_weekend() return charstring {
return "Monday";
}
}
testcase TC_NegSem_50101_top_level_009() runs on TestComp {
var t_class_non_compatible v_a := t_class_non_compatible.create(); // not allowed
if (v_a.f_skip_weekend() == "Monday") {
setverdict(pass);
} else {
setverdict(fail);
}
}
control {
execute(TC_NegSem_50101_top_level_009());
}
}
<END_MODULE>
<RESULT COUNT>
error: Runs on clause mismatch
<END_RESULT>
<END_TC>
:exmp
*---------------------------------------------------------------------*
:h3. NegSem_50101_top_level_010 negative test
.*---------------------------------------------------------------------*
:xmp tab=0.
<TC - NegSem_50101_top_level_010 >
<COMPILE>
<MODULE TTCN NegSem_50101_top_level_010 NegSem_50101_top_level_010.ttcn >
/*****************************************************************
** @author STF 572
** @version 0.0.1
** @purpose 5.1.1.0, Ensure that The runs on type of a class shall be runs on compatible with the runs on type of the superclass.
** @verdict pass reject
*****************************************************************/
module NegSem_50101_top_level_010 "TTCN-3:2018 Object-Oriented" {
type component GeneralComp {
}
type port Myport message {
inout octetstring;
} with { extension "internal" } //FIXME !!!!
type component MessageComp {
port Myport p1;
};
public type class t_superclass_with_incompatible runs on MessageComp {
var octetstring v_o := '1100'O;
public function sending_vo() {
log(this.v_o);
}
}
public type class t_subclass extends t_superclass_with_incompatible runs on GeneralComp {
}
testcase TC_NegSem_50101_top_level_010() runs on GeneralComp {
//var t_subclass v_a := t_subclass.create(); // not allowed FIXME!!!
var t_subclass v_a := t_subclass.create('1100'O); // not allowed
if (v_a.v_o == '1100'O) {
setverdict(pass);
} else {
setverdict(fail);
}
}
control {
execute(TC_NegSem_50101_top_level_010());
}
}
<END_MODULE>
<RESULT COUNT>
error: The `runs on' component type of the subclass, `@NegSem_50101_top_level_010.GeneralComp', is not compatible with the `runs on' component type of the superclass
<END_RESULT>
<END_TC>
:exmp
*---------------------------------------------------------------------*
:h3. NegSem_50101_top_level_011 negative test
.*---------------------------------------------------------------------*
:xmp tab=0.
<TC - NegSem_50101_top_level_011 >
<COMPILE>
<MODULE TTCN NegSem_50101_top_level_011 NegSem_50101_top_level_011.ttcn >
/*****************************************************************
** @author STF 572
** @version 0.0.1
** @purpose 5.1.1.0, Ensure that The mtc and system type of a class shall be mtc and system compatible with the mtc and system types of the superclass, respectively.
** @verdict pass reject
*****************************************************************/
module NegSem_50101_top_level_011 "TTCN-3:2018 Object-Oriented" {
type component GeneralComp {
var integer v_c:=1;
}
type port Myport message {
inout octetstring;
} with { extension "internal"}
type component MessageComp {
port Myport p1;
}
public type class t_superclass_with_incompatible_system system GeneralComp {
var hexstring v_h := '1100FAD'H;
}
public type class t_subclass_system extends t_superclass_with_incompatible_system system MessageComp { // not allowed FIXME!!!
}
public type class t_superclass_with_incompatible_mtc mtc GeneralComp {
var integer v_i := 9919;
}
// public type class t_subclass_mtc extends t_superclass_with_incompatible_mtc mtc MessageComp { // not allowed FIXME!!!
// }
//testcase TC_NegSem_50101_top_level_011_01() system GeneralComp runs on MessageComp { FIXME!!!
testcase TC_NegSem_50101_top_level_011_01() runs on MessageComp system GeneralComp {
// var t_subclass_system v_a := t_subclass_system.create(); // not allowed FIXME!!!
var t_subclass_system v_a := t_subclass_system.create('1100FAD'H); // not allowed
if (v_a.v_h == '1100FAD'H) {
setverdict(pass);
} else {
setverdict(fail);
}
}
/* testcase TC_NegSem_50101_top_level_011_02() runs on MessageComp {
// var t_subclass_mtc v_a := t_subclass_mtc.create(); // not allowed FIXME!!!
var t_subclass_mtc v_a := t_subclass_mtc.create(9919); // not allowed
if (v_a.v_i == 9919) {
setverdict(pass);
} else {
setverdict(fail);
}
}
*/
control {
execute(TC_NegSem_50101_top_level_011_01());
// execute(TC_NegSem_50101_top_level_011_02());
}
}
<END_MODULE>
<RESULT COUNT>
error: The `system' component type of the subclass, `@NegSem_50101_top_level_011.MessageComp', is not compatible with the `system' component type of the superclass
<END_RESULT>
<END_TC>
:exmp
*---------------------------------------------------------------------*
:h3. NegSem_50101_top_level_011a negative test
.*---------------------------------------------------------------------*
:xmp tab=0.
<TC - NegSem_50101_top_level_011a >
<COMPILE>
<MODULE TTCN NegSem_50101_top_level_011a NegSem_50101_top_level_011a.ttcn >
/*****************************************************************
** @author STF 572
** @version 0.0.1
** @purpose 5.1.1.0, Ensure that The mtc and system type of a class shall be mtc and system compatible with the mtc and system types of the superclass, respectively.
** @verdict pass reject
*****************************************************************/
module NegSem_50101_top_level_011 "TTCN-3:2018 Object-Oriented" {
type component GeneralComp {
var integer v_c:=1;
}
type port Myport message {
inout octetstring;
} with { extension "internal"}
type component MessageComp {
port Myport p1;
}
public type class t_superclass_with_incompatible_system system GeneralComp {
var hexstring v_h := '1100FAD'H;
}
// public type class t_subclass_system extends t_superclass_with_incompatible_system system MessageComp { // not allowed FIXME!!!
// }
public type class t_superclass_with_incompatible_mtc mtc GeneralComp {
var integer v_i := 9919;
}
public type class t_subclass_mtc extends t_superclass_with_incompatible_mtc mtc MessageComp { // not allowed FIXME!!!
}
/* //testcase TC_NegSem_50101_top_level_011_01() system GeneralComp runs on MessageComp { FIXME!!!
testcase TC_NegSem_50101_top_level_011_01() runs on MessageComp system GeneralComp {
// var t_subclass_system v_a := t_subclass_system.create(); // not allowed FIXME!!!
var t_subclass_system v_a := t_subclass_system.create('1100FAD'H); // not allowed
if (v_a.v_h == '1100FAD'H) {
setverdict(pass);
} else {
setverdict(fail);
}
}
*/
testcase TC_NegSem_50101_top_level_011_02() runs on MessageComp {
// var t_subclass_mtc v_a := t_subclass_mtc.create(); // not allowed FIXME!!!
var t_subclass_mtc v_a := t_subclass_mtc.create(9919); // not allowed
if (v_a.v_i == 9919) {
setverdict(pass);
} else {
setverdict(fail);
}
}
control {
// execute(TC_NegSem_50101_top_level_011_01());
execute(TC_NegSem_50101_top_level_011_02());
}
}
<END_MODULE>
<RESULT COUNT>
error: The `mtc' component type of the subclass, `@NegSem_50101_top_level_011.MessageComp', is not compatible with the `mtc' component type of the superclass
<END_RESULT>
<END_TC>
:exmp
.*---------------------------------------------------------------------*
:h1.References
.*---------------------------------------------------------------------*
:list.
:li D='[1]'.1/1/174 02-CRL 113 200/5 Uen
:nl.Statement of Compliance for TITAN project
:li D='[2]'.ETSI ES 203 790 V1.1.1
:nl.Testing and Test Control Notation version 3.,
:nl.TTCN-3 Language Extensions: Object-Oriented Features
:elist.
.******************************************************************************
.* Copyright (c) ETSI 2020.
.*
.* This file is subject to copyrights owned by ETSI. Non-exclusive permission
.* is hereby granted, free of charge, to copy, reproduce and amend this file
.* under the following conditions: It is provided "as is", without warranty of any
.* kind, expressed or implied.
.*
.* ETSI shall never be liable for any claim, damages, or other liability arising
.* from its use or inability of use.This permission does not apply to any documentation
.* associated with this file for which ETSI keeps all rights reserved. The present
.* copyright notice shall be included in all copies of whole or part of this
.* file and shall not imply any sub-license right.
.*
.* Modified by: Elemer Lelik
.*
.******************************************************************************/
text.
:lang eng.
.*
:docname.Test Description
:docno.
:rev.
:date.2020-11-11
.*
:prep. Elemer Lelik
:subresp.
:appr.
:checked.
.*
:title.ETSI TTCN3 Negative Conformance Test
:contents level=3.
.*---------------------------------------------------------------------*
:h1.PREREQUISITES AND PREPARATIONS
.*---------------------------------------------------------------------*
.*---------------------------------------------------------------------*
:h2.Scope of the Test Object
.*---------------------------------------------------------------------*
:xmp tab=1 nokeep.
This TD contains negative OOP test modules from ETSI TTCN3 Conformance Test's 50101_modules folders.
:exmp.
.*---------------------------------------------------------------------*
:h2.Test Tools
.*---------------------------------------------------------------------*
:p.:us.Software Tools:eus.
:xmp tab=2 nokeep.
SAtester_OOP.pl
:exmp.
:np.
.*---------------------------------------------------------------------*
:h1.REQUIREMENT-BASED TESTS
.*---------------------------------------------------------------------*
.*---------------------------------------------------------------------*
:h2. 5010202_object_references folder
.*---------------------------------------------------------------------*
*---------------------------------------------------------------------*
:h3. NegSem_5010202_ObjectReferences_001 negative test
.*---------------------------------------------------------------------*
:xmp tab=0.
<TC - NegSem_5010202_ObjectReferences_001 >
<COMPILE>
<MODULE TTCN NegSem_5010202_ObjectReferences_001 NegSem_5010202_ObjectReferences_001.ttcn >
/*****************************************************************
** @author STF 572
** @version 0.0.1
** @purpose 5.1.2.2, Ensure that Object References shall not be passed as actual parameter or part of an actual parameter.
** @verdict pass reject
*****************************************************************/
module NegSem_5010202_ObjectReferences_001 "TTCN-3:2018 Object-Oriented" {
type component GeneralComp {
}
type class MyClass {
var integer x;
public function setX(integer x) {
this.x := x;
}
public function getX() return integer {
return this.x;
}
}
function f_something(MyClass my) runs on GeneralComp {
my.setX(1);
}
testcase TC_NegSem_5010202_ObjectReferences_001() runs on GeneralComp {
var MyClass v_a := MyClass.create(7);
var GeneralComp v_MyGeneralComp := GeneralComp.create;
v_MyGeneralComp.start(f_something(v_a)); //not allowed // C++ error is thrown
if (v_a.getX() == 7) {
setverdict(pass);
} else {
setverdict(fail);
}
}
control {
execute(TC_NegSem_5010202_ObjectReferences_001());
}
}
<END_MODULE>
<RESULT COUNT>
error: TBD
<END_RESULT>
<END_TC>
:exmp
.*---------------------------------------------------------------------*
:h2. 5010206_casting folder
.*---------------------------------------------------------------------*
*---------------------------------------------------------------------*
:h3. NegSem_5010206_Casting_001 negative test
.*---------------------------------------------------------------------*
:xmp tab=0.
<TC - NegSem_5010206_Casting_001 >
<COMPILE>
<MODULE TTCN NegSem_5010206_Casting_001 NegSem_5010206_Casting_001.ttcn >
/*****************************************************************
** @author STF 572
** @version 0.0.1
** @purpose 5.1.2.6, Ensure that if the class the object is being cast to is not in the set of superclasses or the concrete class of the object, the cast operation shall result in an error.
** @verdict pass reject
*****************************************************************/
module NegSem_5010206_Casting_001 "TTCN-3:2018 Object-Oriented" {
type component GeneralComp {
}
type class MySuperClass {
//empty class
}
type class MySubClass extends MySuperClass {
//empty class
}
type class MyOtherClass {
const integer x:= 111;
}
testcase TC_NegSem_5010206_Casting_001 () runs on GeneralComp {
//FIXME !!! var MyOtherClass v_a := MyOtherClass.create();
var MyOtherClass v_a := MyOtherClass.create(111);
var MySubClass v_b := v_a => MySubClass; //not allowed
if (v_b of MySubClass) {
setverdict(pass);
} else {
setverdict(fail);
}
}
control {
execute(TC_NegSem_5010206_Casting_001());
}
}
<END_MODULE>
<RESULT COUNT>
error: Cannot cast an object of class type
<END_RESULT>
<END_TC>
:exmp
.*---------------------------------------------------------------------*
:h1.References
.*---------------------------------------------------------------------*
:list.
:li D='[1]'.1/1/174 02-CRL 113 200/5 Uen
:nl.Statement of Compliance for TITAN project
:li D='[2]'.ETSI ES 203 790 V1.1.1
:nl.Testing and Test Control Notation version 3.,
:nl.TTCN-3 Language Extensions: Object-Oriented Features
:elist.
// README to negative conformance tests
How to run:
The tests can be started all at once:
./run_test_all
How to run scripts individually:
./SAtester_OOP.pl scriptname.script
#!/usr/bin/perl -w
###############################################################################
# Copyright (c) 2000-2020 Ericsson Telecom AB
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v2.0
# which accompanies this distribution, and is available at
# https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html
###############################################################################
##
## File : SAtester.pl
## Description: Tester utility for Semantic Analyser, TITAN
## Written by : Endre Szalai (Endre.Szalai@ericsson.com)
##
## TODO: exit status always 0, investigate why; workaround: catch the notify
## printout from the compiler
require 5.6.1;
use strict;
use Getopt::Long;
###############################################################################
### Global Variables
###############################################################################
# Whether to stop on test case failures (1) or not (0)
my $sa_halt_on_errors = '';
# Whether to list available test cases or not
my $sa_list_TCs = 0;
# Whether to show info or not
my $sa_info = 0;
# Whether to use matching in test case selection
my $sa_tc_select = '';
# Name of the logfile
my $sa_logFile = '';
my $sa_LOG;
# Elapsed time in this session
my $sessionTime;
# Whether to show command line info or not
my $sa_printHelp_cmd = 0;
# Whether to show detailed info or not
my $sa_printHelp_doc = 0;
# Use function-test runtime or not
my $sa_titanRuntime2 = 1;
# Enable coverage or not
my $sa_coverageEnabled = 0;
# Files existed before a test case execution
my %sa_existedFiles;
# Store input TD files from which TCs are collected
my @sa_scriptFiles;
# Store information about the TCs to execute
my @sa_tcList2Execute;
# Store test case data
my @sa_TCInfo;
# Timeout for system calls in seconds
my $sa_timeout = 30;
# Max time to wait for a license, in multiple of 10 minutes
my $max_cycles = 6;
# Execution statistics
# Number of TCs: PASSED, FAILED, ERROR verdicts,
# abnormally terminated, memory leaked
my @sa_executionStatistics = (0, 0, 0, 0, 0);
# Command to invoke the titan compiler
my $sa_compilerCmd;
# Command to invoke the titan Makefile generator
my $sa_mfgenCmd;
# Command to invoke the runtime execution
my $sa_runtimeCmd;
# commonly used regexps
my $sa_re_TCheader = "\\n\\s*<\\s*TC\\s*-\\s*(.+?)\\s*>\\s*\\n";
my $sa_re_MODULEheader = "\\n\\s*<\\s*MODULE\\s+(\\S+)\\s+(\\S+)\\s+(\\S+)\\s*>";
my $sa_re_MODULEbody = "${sa_re_MODULEheader}\\s*(.+?)\\n\\s*<\\s*END_MODULE\\s*>";
my $sa_re_RESULTheader = "\\n\\s*<\\s*RESULT\\s*(IF_PASS|IF_FAIL)?\\s*(LTRT|FTRT)?\\s*(POSITIVE|NEGATIVE)?\\s*(?:COUNT\\s+(\\d+))?.*?>";
my $sa_re_RESULTbody = "${sa_re_RESULTheader}\\s*(.*?)\\s*\\n\\s*<\\s*END_RESULT\\s*>";
my $sa_re_EXPECTEDbody = "\\s*<\\s*VERDICT_LEAF\\s+(PASS|FAIL)\\s*>\\s*";
my $sa_re_MemoryLeak = "(?:unallocated\\s+blocks\\s*:\\s*)|(?:Memory\\s+leakage\\s+detected)";
# separator for printouts
my $sa_separator = "===============================================================\n";
# Detailed info about the usage
my $sa_detailedInfo = '
Purpose
-------
The tester program was written especially for testing the semantic analyser
functionality in TITAN. A generic test flow looks like:
- generate input sources (TTCN-3 and/or ASN.1)
- compile them with the TITAN compiler
- check that the error messages are as expected (negative testing)
- check that the modules are compiled both with TITAN and gcc
(positive testing)
Test cases and all information needed to execute them are stored in one file, in
the Test Description files (*.script) in EDML format. The tester program uses
this file to execute the test according to the flow described above in a fully
automatic way..
Unlike in a simple test method, where a test may be passed or failed, in
regression test it might be important, why a test case is failed (e.g. due to a
not yet implemented feature). Therefore, each test case may have two separate
expected behaviour (called leaves later on). The first is the case when the test
purpose is expected to work in a specific way (IF_PASS leaf). The other, when
the test case is expected to fail, but why it fails is also interesting (IF_FAIL
leaf). Each test case may have both leaves and a specific selector points out
which leaf is expected to occur. This also means, that a test case passes, if
the selected leaf is passed (which may be the IF_FAIL leaf). Therefore, the
tester needs to check test cases that are failed, as only in those cases the
current result is not as expected.
Features
--------
The tester program has the following features:
1. Support for one-by-one and batched execution of test cases.
2. Support for unlimited number of input modules: ASN.1,
TTCN-3 and runtime config files for TITAN.
3. Support for compilation of the modules using TITAN and
GCC. It also supports single mode execution of the test suite.
Makefile and test port files generation is automatic.
5. Automatic cleanup after each test case.
6. Flexible pattern matching for the test case printout using
Perl regexps combined with different matching logic.
7. Support for regression testing process.
Reference
---------
For a list of command line options, execute the tester program with
SAtester.pl -help
A test case structure in the EDML files looks like:
test case block:
<TC - test case name>
compile block:
[<COMPILE|COMPILEGCC|EXECUTE|EXECUTE_PARALLEL>] (default is COMPILE)
leaf selector block:
<VERDICT_LEAF (PASS|FAIL)>
module block(s):
<MODULE TTCN|ASN|CFG modulename filename>
... text from here is written to the filename specified above ...
<END_MODULE>
... several module sections may follow ...
result block(s):
<RESULT IF_PASS|IF_FAIL [POSITIVE|NEGATIVE|COUNT number]> (default is POSITIVE)
... pattern in Perl regexp format ...
<END_RESULT>
... several result sections may follow ...
<END_TC>
Each block header/footer must be single-line, i.e. newline is not allowed.
The compile block instructs the SAtester to:
COMPILE compile the modules using TITAN only
COMPILEGCC compile the modules using TITAN and GCC afterwards
(the Makefile is automatically generated)
EXECUTE after compilation, execute the executable test suite
the first runtime configuration file is passed to TITAN
(single mode execution)
EXECUTE_PARALLEL after compilation, execute the executable test suite
(parallel mode execution)
If any of the actions fail, the test case result will be "ERROR". This block is
optional, the default value is COMPILE.
The leaf selector block helps the regression testing process, where not only the
verdict itself, but the expected verdict is interesting. The value may be PASS
or FAIL. The leaf selector selects which RESULT blocks to use when matching the
printout from the compiler(s).
A module block instructs the SAtester to produce a source module
or a runtime configuration file:
TTCN The module is treated as a TTCN-3 module
ASN The module is treated as an ASN.1 module
CFG The module is treated as a runtime configuration file
modulename Name of the module
filename Name of the file to be produced
The text within this section is written as is to "filename". You may specify as
many modules as you need.
A result block instructs the SAtester how to check result as soon the actions in
the compile block is finished successfully.
Either:
POSITIVE Indicates a positive pattern match (i.e. =~ syntax in Perl)
with the supplied pattern is needed to continue
NEGATIVE Indicates a negative pattern match (i.e. !~ syntax in Perl)
with the supplied pattern is needed to continue
Or:
COUNT Indicates that instead of a direct pattern match, perform
a counting of the supplied pattern. If the number of pattern-
matches equals to the supplied number in COUNT section, the
execution continues
POSITIVE or NEGATIVE can be used for simple pattern match, i.e. whether the
pattern is present or not.
COUNT can be used to detect that a pattern how many times are present.
Result blocks are evaluated in the order of their appearence. If any of the
result block is failed, the verdict will be "FAILED" and execution continues
with the next test case (if any). Entries in the result header are optional, the
default value is "POSITIVE".
Memory leak printouts are automatically detected. If one is found, the current
verdict will be "FAIL".
Example
-------
//line comments are written for understanding only
// Name of the test case
<TC - TTCN-3::Subtypes, list of values: Anytype>
// compile with TITAN only
<COMPILE>
// "anytype" is not supported, so use the FAIL-leaf
// in result matching
<VERDICT_LEAF FAIL>
// Specify one module
<MODULE TTCN ModuleA ModuleA.ttcn>
module ModuleA {
type anytype MyType ( 10, 11.0, Nonexi, false );
}
<END_MODULE>
// PASS-leaf of the result matching
// used if VERDICT_LEAF is "PASS"
// expecting exactly 1 "no imported or local definition nonexi"
<RESULT IF_PASS COUNT 1>
(?im)\berror\b.+?no.+?definition.+?nonexi
<END_RESULT>
// expecting exactly 1 "error", so no other error shall
// occur than the previous error
<RESULT IF_PASS COUNT 1>
(?is)\berror\b
<END_RESULT>
// expecting a notification that no code is generated due
// to the error
<RESULT IF_PASS POSITIVE>
(?im)\bnotify\b.+?\bcode\b.+?\bnot\b.+?\bgenerated\b
<END_RESULT>
// FAIL-leaf of the result matching
// used if VERDICT_LEAF is "FAIL"
// expecting exactly 1 "parse error"
<RESULT IF_FAIL COUNT 1>
(?im)parse.+?error
<END_RESULT>
// expecting exactly 1 "error", so no other error shall
// occur than the parse error
<RESULT IF_FAIL COUNT 1>
(?is)\berror\b
<END_RESULT>
<END_TC>
Information about Perl regular expressions can be found at:
www.perl.com
Guides
------
1. Use the IF_FAIL leaf only, if the test case is expected to fail because of a
missing functionality that will not be implemented in the current project. Using
IF_FAIL leaves for limitations that are expected to disappear within a project
is just an unnecessary overhead.
2. Whenever a TR is issued, this should be mentioned in the test case, within
the source module where the error occured, e.g.
<MODULE TTCN ModuleA ModuleA.ttcn>
module ModuleA {
// TR 623: length restriction of charstrings
type record of charstring MyType7 length(0..666-Nonexi);
}
<END_MODULE>
3. Always expect a specific error message, but be a bit flexible in pattern
matching. Always check that no other errors occured. E.g.:
<RESULT IF_PASS COUNT 1>
(?im)\berror\b.+?no.+?definition.+?nonexi
<END_RESULT>
<RESULT IF_PASS COUNT 1>
(?is)\berror\b
<END_RESULT>
<RESULT IF_PASS POSITIVE>
(?im)\bnotify\b.+?\bcode\b.+?\bnot\b.+?\bgenerated\b
<END_RESULT>
Note the non-case sensitive matching; that only 1 error is expected and that no
code is expected to be generated.
Known issues
------------
On cygwin, fork does not always work and Perl stops with an error like:
264 [main] perl 2216 fork_copy: linked dll data/bss pass 0 failed,
0x412000..0x412370, done 0, windows pid 1832, Win32 error 487
';
# easterEgg
my $sa_egg = '
\\\\\\\\|////
\\\\ - - //
#( @ @ )#
\ o /
\ * /
---------------------oOOo--oOOo-------------------------
"Do or do not. There is no try." - Yoda
------------------------ooooO---Ooooo-------------------
( ) ( )
\ | | /
(_| |_)
-- This amazing code was created by McHalls --
';
###############################################################################
## Subs
###############################################################################
sub sa_commandLineInfo();
sub sa_log($);
sub sa_processArgs($);
sub sa_processCommandLine();
sub sa_readFile($);
sub sa_writeFile($$);
sub sa_collectTCs();
sub sa_isInList(\@$);
sub sa_getTCInfo(\@$$);
sub sa_parseTCs();
sub sa_writeModulesOfTC(\@);
sub sa_deleteModulesOfTC(\@);
sub sa_fetchExecutableName();
sub sa_executeCommand($);
sub sa_compileTC(\@);
sub sa_printResult($$);
sub sa_checkTCResult(\@$);
sub sa_executeTCs();
# Print command line information
sub sa_commandLineInfo () {
sa_log("\nPerl utility to execute test cases for Semantic Analyser\n");
sa_log("Contact: Endre Szalai (Endre.Szalai\@ericsson.com)\n");
sa_log("Usage: SA_tester.pl\n");
sa_log(" [-halt] [-list] [-help] [-doc] [-rt2] [-coverage]\n");
sa_log(" [-select <pattern>]\n");
sa_log(" [-timeout <timeout>]\n");
sa_log(" [<TDfile1.script>] ... [<TDfileN.script>]\n");
sa_log(" [\"<test case name1>\"] ... [\"<test case nameM>\"]\n");
sa_log(" [-log <logfilename>]\n");
sa_log("Where\n");
sa_log(" -halt halt on any errors\n");
sa_log(" -list list available test cases\n");
sa_log(" -help display command line parameters\n");
sa_log(" -doc display complete documentation\n");
sa_log(" -rt2 use function-test runtime\n");
sa_log(" -coverage enable coverage");
sa_log(" <pattern> select test cases if pattern is present in the\n");
sa_log(" name of the test case\n");
sa_log(" <timeout> maximum execution time of a system call\n");
sa_log(" in seconds (default is $sa_timeout)\n");
sa_log(" <logfilename> name of the logfile\n");
sa_log(" NOTE: do NOT use the .log file extension !\n");
sa_log(" <TDfile.script> name of the TD file(s) to collect test cases from\n");
sa_log(" <test case name> name of the test case(s) to execute\n");
sa_log("If no TDfile(s) are defined, all script files from the current\n");
sa_log("directory are considered.\n");
sa_log("If no test cases are defined, all test cases from the script files\n");
sa_log("are executed.\n\n");
}
# Log entries
sub sa_log($) {
print $_[0];
if (defined($sa_LOG)) { print $sa_LOG $_[0]; }
}
# Process the command line
sub sa_processArgs($) {
if ($_[0] =~ /\.script$/m) { $sa_scriptFiles[scalar @sa_scriptFiles] = $_[0]; }
else { $sa_tcList2Execute[scalar @sa_tcList2Execute] = $_[0]; }
}
sub sa_processCommandLine() {
die unless (GetOptions('halt' => \$sa_halt_on_errors,
'list' => \$sa_list_TCs,
'credit' => \$sa_info,
'help' => \$sa_printHelp_cmd,
'doc' => \$sa_printHelp_doc,
'rt2' => \$sa_titanRuntime2,
'coverage' => \$sa_coverageEnabled,
'log=s' => \$sa_logFile,
'timeout=s' => \$sa_timeout,
'select=s' => \$sa_tc_select,
'maxcycle=s'=> \$max_cycles,
"<>" => \&sa_processArgs));
if ($sa_info) {print $sa_egg; exit(1);}
if ($sa_logFile ne '') {
die "Never use '.log' extension as TITAN's cleanup may remove it, specify a different name\n"
unless ($sa_logFile !~ /.*\.log$/is);
open ($sa_LOG, ">$sa_logFile") or die "Cannot open log file: '$sa_logFile': $!\n";}
if ($sa_printHelp_cmd) {sa_commandLineInfo(); exit(1);}
if ($sa_printHelp_doc) {sa_log ($sa_detailedInfo); exit(1);}
}
# Read and return the content of a file
sub sa_readFile($) {
# $_[0] : name of the file
my $Buffer;
sa_log("Parsing file $_[0]...\n");
open (TMP, "$_[0]") or die "Cannot open script file: '$_[0]': $!\n";
read(TMP, $Buffer, -s "$_[0]");
close (TMP);
# remove carriage returns
# Unix/windows: \n \r combo
if ($Buffer =~ /\n/s) {$Buffer =~ s/\r//g;}
# Mac: only \r
else {$Buffer =~ s/\r/\n/g;}
return $Buffer;
}
# Write a file
sub sa_writeFile($$) {
# $_[0] : name of the file
# $_[1] : content of the file
sa_log("Flushing file $_[0]...\n");
open (TMP, ">$_[0]") or die "Cannot open file: '$_[0]': $!\n";
print(TMP $_[1]);
close (TMP);
}
# Checks whether a TC is on the list
sub sa_isInList(\@$) {
my $poi = $_[0];
foreach my $val (@{$poi}) {
if ($val eq $_[1]) {return 1;}
}
return 0;
}
# Collect test cases from command line and/or script files
sub sa_collectTCs() {
# No script files are defined, collect all script files from
# current directory
if (scalar @sa_scriptFiles == 0) {
my @list = split (/\s/, `ls *.script`);
foreach my $filename (@list) { $sa_scriptFiles[scalar @sa_scriptFiles] = $filename; }
}
# no test cases specified, collect from available script files
if (scalar @sa_tcList2Execute == 0) {
foreach my $filename (@sa_scriptFiles) {
my $Buffer = sa_readFile($filename);
while ($Buffer =~ s/^.*?${sa_re_TCheader}//s) {
my $tcName = $1;
if (sa_isInList(@sa_tcList2Execute,$tcName))
{sa_log( "WARNING: Test case name is not unique: '$tcName'\n");}
# execute test case if match with pattern or no pattern available
if ((not $sa_tc_select) or
($sa_tc_select and ($tcName =~ /$sa_tc_select/))) {
$sa_tcList2Execute[scalar @sa_tcList2Execute] = $tcName;
}
}
}
}
my $sa_nrOfTCs2Execute = scalar @sa_tcList2Execute;
my $nrOfScriptFiles = scalar @sa_scriptFiles;
sa_log( "$sa_nrOfTCs2Execute test cases from $nrOfScriptFiles script files to be executed\n");
my $tmp = ($sa_halt_on_errors) ? "halting on errors\n" : "ignoring errors\n";
sa_log( "Mode: $tmp");
}
# Gather execution information according to:
# [N] Nth test case
# [0] test case name
# [1] "COMPILE", "COMPILEGCC" or "EXECUTE"
# [2][N] Nth module
# [0] module type ("ASN", "TTCN" or "CFG")
# [1] module name (if ASN or TTCN)/execution mode (if CFG)
# [2] filename to use for the module
# [3] content of the module
# [3]{'PASS'|'FAIL'}[N] Nth result for expected result leaf PASS|FAIL
# [0] result type ("POSITIVE" or "NEGATIVE")
# [1] match expression
# [2] number of coccurances (if "COUNT" used in RESULT)
# [4] name of the source script file
# [5] expected test case result leaf selector (PASS, FAIL)
# [6] verdict of the TC
# [7] flag whether memory leak is detected or not (defined/not defined)
# [8] flag whether abnormal termination is detected or not (defined/not defined)
sub sa_getTCInfo(\@$$) {
my ($poi, $Buffer, $filename) = @_;
my $tcidx = scalar @{$poi};
if ($Buffer =~ s/${sa_re_TCheader}//s) { $poi->[$tcidx][0] = $1; }
else { die "ERROR: Cannot find test case name in current block\n"; }
if ($Buffer =~ s/<\s*EXECUTE\s*>//m) { $poi->[$tcidx][1] = 'EXECUTE'; }
elsif ($Buffer =~ s/<\s*EXECUTE_PARALLEL\s*>//m) { $poi->[$tcidx][1] = 'EXECUTE_PARALLEL'; }
elsif ($Buffer =~ s/<\s*COMPILEGCC\s*>//m) { $poi->[$tcidx][1] = 'COMPILEGCC'; }
else { $poi->[$tcidx][1] = 'COMPILE'; }
if ($Buffer =~ /${sa_re_EXPECTEDbody}/m) { $poi->[$tcidx][5] = $1; }
else { $poi->[$tcidx][5] = 'PASS'; }
my $idx = 0;
while ($Buffer =~ s/${sa_re_MODULEbody}//s) {
$poi->[$tcidx][2][$idx][0] = $1;
$poi->[$tcidx][2][$idx][1] = $2;
$poi->[$tcidx][2][$idx][2] = $3;
$poi->[$tcidx][2][$idx][3] = $4;
$idx++;
}
while ($Buffer =~ s/${sa_re_RESULTbody}//s) {
my $expectedVerdict;
if (defined($1)) {
$expectedVerdict = ($1 eq 'IF_FAIL') ? 'FAIL':'PASS';
} else { $expectedVerdict = 'PASS'; }
my $idx = (defined($poi->[$tcidx][3]{$expectedVerdict}))
? scalar @{$poi->[$tcidx][3]{$expectedVerdict}} : 0;
if (defined($2)) {
# Skip matching strings intended for the load-test run-time when
# "-rt2" is used. Vice versa.
if ($2 eq 'LTRT' and $sa_titanRuntime2
or $2 eq 'FTRT' and not $sa_titanRuntime2) { next; }
}
if (defined($3)) {
$poi->[$tcidx][3]{$expectedVerdict}[$idx][0] = ($3 ne '') ? $3 : 'POSITIVE';}
else {$poi->[$tcidx][3]{$expectedVerdict}[$idx][0] = 'POSITIVE';}
if (defined($4)) { $poi->[$tcidx][3]{$expectedVerdict}[$idx][2] = $4; }
$poi->[$tcidx][3]{$expectedVerdict}[$idx][1] = $5;
eval { '' =~ /$poi->[$tcidx][3]{$expectedVerdict}[$idx][1]/ };
if ($@) {
sa_log("In file $filename, test case '$poi->[$tcidx][0]'\n");
sa_log " Syntax error in provided pattern:\n $poi->[$tcidx][3]{$expectedVerdict}[$idx][1]\n$@\n";
exit(1);
}
}
$poi->[$tcidx][4] = $filename;
$poi->[$tcidx][6] = 'NONE';
}
# Parse test case data
sub sa_parseTCs() {
# give only a list of the test cases
if ($sa_list_TCs) {
sa_log( "Collected test cases:\n");
my $idx = 1;
# collect test case data from all specified script files
foreach my $filename (@sa_scriptFiles) {
my $Buffer = sa_readFile($filename);
while ($Buffer =~ s/^.*?(${sa_re_TCheader}.+?<END_TC>)//s) {
sa_getTCInfo(@sa_TCInfo, $1, $filename);
}
}
foreach my $poi (@sa_TCInfo) {
sa_log( "$idx. '$poi->[0]' \n");
sa_log( " source:$poi->[4]; leaf:$poi->[5]\n");
$idx++;
}
exit(1);
}
foreach my $filename (@sa_scriptFiles) {
my $Buffer = sa_readFile($filename);
while ($Buffer =~ s/^.*?(${sa_re_TCheader}.+?<END_TC>)//s) {
if (not sa_isInList(@sa_tcList2Execute,$2)) { next; }
sa_getTCInfo(@sa_TCInfo, $1, $filename);
}
}
}
# Writes the modules of the TC
sub sa_writeModulesOfTC(\@) {
my $root = $_[0];
foreach my $poi (@{$root->[2]}) {
open(TMP, "> $poi->[2]") or die "Can't create file '$poi->[2]': $!\n";
sa_log("Module $poi->[1] (file $poi->[2]):\n");
sa_log("$poi->[3]\n");
print TMP $poi->[3] . "\n";
close (TMP);
}
}
# Deletes the files(modules) of the TC
sub sa_deleteModulesOfTC(\@) {
my $root = $_[0];
sa_log( "Cleanup... ");
if (-f 'Makefile') {
my $makefile;
`make clean 2>&1`;
$makefile = sa_readFile('Makefile');
while ($makefile =~ s/^(\s*USER_SOURCES\s*=\s*)(\w+\.cc)/$1/im) {
if (not exists($sa_existedFiles{$2})) {
if (unlink $2) {sa_log( "$2 ");}
}
}
while ($makefile =~ s/^(\s*USER_HEADERS\s*=\s*)(\w+\.hh)/$1/im) {
if (not exists($sa_existedFiles{$2})) {
if (unlink $2) {sa_log( "$2 ");}
}
}
}
if (unlink "Makefile") {sa_log( "Makefile ");}
foreach my $poi (@{$root->[2]}) {
if (unlink $poi->[2]) {sa_log( "$poi->[2] ");}
# remove possible generated code
if ($poi->[0] eq 'TTCN') {
if (unlink "$poi->[1].cc") {sa_log( "$poi->[1].cc ");}
if (unlink "$poi->[1].hh") {sa_log( "$poi->[1].hh ");}
} else {
my $tmp = $poi->[1];
$tmp =~ s/\-/_/g;
if (unlink "$tmp.cc") {sa_log( "$tmp.cc ");}
if (unlink "$tmp.hh") {sa_log( "$tmp.hh ");}
}
}
sa_log("\n");
}
# Fetch the executable name from Makefile
sub sa_fetchExecutableName() {
my $makefile = sa_readFile('Makefile');
if ($makefile =~ /^\s*EXECUTABLE\s*=\s*(\w+)/im) { return $1; }
die "ERROR: Executable name is not found in generated Makefile\n";
}
# Perform a system call
# return value: (status, output)
# status = 0 on success
# status = 1 on command timeout
# status = 2 on abnormal termination
# output: collected printout from the process
sub sa_executeCommand($) {
# Silly Perl does not allow to capture STDERR, only STDOUT.
# As a workaround, ask the shell to redirect STDERR to STDOUT.
# It's OK until TITAN writes everything to STDERR (as it is today)
my $command = "$_[0] 2>&1";
my $subRes = "";
my $pid;
my $exitStatus = 0;
sa_log( "$_[0]\n");
# run as a separate Perl program to be able to use timeout
eval {
local $SIG{ALRM} = sub { die "timeout\n" }; # NB: \n required
alarm $sa_timeout; # send an alarm signal in specified time
# call via exec to be able to catch the exit status
# (without exec, the shell always return with 0 exit status)
$pid = open(TMP, "exec $command |");
die "ERROR: Cannot fork: $!\n" unless ($pid);
while (<TMP>) { $subRes .= $_; }
close(TMP);
$exitStatus = $? & 128; # whether core dump occured
alarm 0;
};
sa_log("$subRes\n");
if ($@) { # an error occured (thought, not only at timeout)
sa_log("\nSoftly killing forked process $pid\n");
kill 1, $pid;
sa_log("ERROR: system call '$command' is not finished within $sa_timeout seconds\n");
return (1, $subRes);
}
if ($exitStatus) { # core dump occured
sa_log("\nERROR: system call '$command' is terminated abnormally\n");
return (2, $subRes);
}
return (0, $subRes);
}
# Compile the stuff now
# return value: (status, output)
# status = 0 on success
# status = 1 on ERROR
# status = 2 on test case FAIL (compiler related ERROR)
sub sa_compileTC(\@) {
my $root = $_[0];
my $modules2compile = '';
my $configFile = '';
my $subRes = '';
my $res;
my $cycles = 0;
foreach my $poi (@{$root->[2]}) {
if ($poi->[0] eq "CFG") {$configFile = $poi->[2]; next;}
$modules2compile .= " $poi->[2]";
}
if ($modules2compile eq '') {
sa_log( "WARNING: test case '$root->[0]' does not contain any modules, skipping\n");
return (1, '');
}
sa_log( "Compiling sources...\n");
my $runtimeOption = '';
if ($sa_titanRuntime2) { $runtimeOption = '-R'; }
do {
if ($cycles) { sleep(60 * 10); }
$cycles++;
($res, $subRes) = sa_executeCommand("$sa_compilerCmd $runtimeOption -k $modules2compile");
# Purify message, when no floating license available. Sleep for a while
# and retry.
# -continue-without-license=yes
} while (($subRes =~ /\-continue\-without\-license\=yes/mi) and ($cycles <= $max_cycles));
if ($res) { return (2, $subRes); }
my $resultBuffer = $subRes;
if ($root->[1] eq "COMPILE") { return (0, $resultBuffer); }
sa_log( "Generating test port skeletons...\n");
($res, $subRes) = sa_executeCommand("$sa_compilerCmd $runtimeOption -t -f $modules2compile");
if ($res) { return (1, $subRes); }
$resultBuffer .= $subRes;
sa_log( "Generating Makefile...\n");
($res, $subRes) = sa_executeCommand("$sa_mfgenCmd $runtimeOption -s -f $modules2compile *.cc*");
if ($res) { return (1, $subRes); }
$resultBuffer .= $subRes;
if (not (-e 'Makefile')) {
sa_log( "ERROR: Makefile could not be generated\n");
sa_log ($subRes);
return (1, $subRes);
}
if ($root->[1] eq "EXECUTE_PARALLEL") {
sa_log("Patching Makefile for parallel mode...\n");
my $Buffer = sa_readFile('Makefile');
$Buffer =~ s/^\s*TTCN3_LIB\s*=\s*(ttcn3\S*)\s*$/TTCN3_LIB = $1-parallel/im;
unlink 'Makefile';
sa_writeFile('Makefile', $Buffer);
}
sa_log("Building...\n");
my $coverage_args = $sa_coverageEnabled ? "CXXFLAGS=\"-fprofile-arcs -ftest-coverage -g\" LDFLAGS=\"-fprofile-arcs -ftest-coverage -g -lgcov\"" : "";
($res, $subRes) = sa_executeCommand("make " . $coverage_args);
if ($res) { return (1, $subRes); }
$resultBuffer .= $subRes;
my $exeName = sa_fetchExecutableName();
if (not (-e $exeName)) {
sa_log( "ERROR: GCC compilation error, no executable produced ('$exeName')\n");
if ($sa_halt_on_errors) {
sa_log( "\nTest execution interrupted (no cleanup).\n\n");
exit(1);
}
return (1, $subRes);
}
if ($root->[1] eq "COMPILEGCC") { return (0, $resultBuffer); }
# go on with execution
sa_log("Fetched executable name: $exeName\n");
if ($root->[1] eq "EXECUTE") {
sa_log( "Executing in single mode...\n");
if ($configFile eq '') {
sa_log( "ERROR: No runtime config file is specified in the test case\n");
return (1, $subRes);
}
($res, $subRes) = sa_executeCommand("./$exeName $configFile");
if ($res) { return (1, $subRes); }
$resultBuffer .= $subRes;
return (0, $resultBuffer);
} else {
sa_log( "Executing in parallel mode...\n");
if ($configFile eq '') {
($res, $subRes) = sa_executeCommand("$sa_runtimeCmd $exeName");
} else {
($res, $subRes) = sa_executeCommand("$sa_runtimeCmd $exeName $configFile");
}
if ($res) { return (1, $subRes); }
$resultBuffer .= $subRes;
return (0, $resultBuffer);
}
}
# Print a test case result
# $_[0] name of the test case
# $_[1] verdict
sub sa_printResult($$) {
sa_log( "\nTest case '$_[0]' \n '$_[1]'\n".$sa_separator);
}
# Check test case result based on RESULT lists
sub sa_checkTCResult(\@$) {
my ($root, $resultBuffer) = @_;
my $result = 'PASS';
my $expectedResult = $root->[5];
if (not defined($root->[3])) {
sa_log( "ERROR: No RESULT section in test case '$root->[0]'\n");
sa_printResult($root->[0], 'ERROR');
$root->[6] = 'ERROR';
return;
}
foreach my $poi (@{$root->[3]{$expectedResult}}) {
# match with each result
if ($poi->[1] !~ /\S/) {next;}
if (($poi->[0] eq 'POSITIVE') and defined($poi->[2])) { # counter match
my $counter = 0;
my $tmpBuf = $resultBuffer;
while ($tmpBuf =~ s/$poi->[1]//) { $counter++; }
if ($counter != $poi->[2]) {
sa_log( "Failing at counting: pattern '$poi->[1]'\nexpected '$poi->[2]' times, found '$counter' times\n");
$result = 'FAIL'; last;
} else { sa_log("Passed matching pattern (counting $counter times): '$poi->[1]'\n"); }
} else { # simple pattern match
if ($poi->[0] eq 'POSITIVE') {
if ($resultBuffer !~ /$poi->[1]/si) {
sa_log( "Failing at pattern (expected, not found):\n$poi->[1]\n");
$result = 'FAIL'; last;
} else { sa_log("Passed matching pattern (expected): '$poi->[1]'\n"); }
} else { # NEGATIVE
if ($resultBuffer =~ /$poi->[1]/si) {
sa_log( "Failing at pattern (not expected but found):\n$poi->[1]\n");
$result = 'FAIL'; last;
} else { sa_log("Passed matching pattern (not expected): '$poi->[1]'\n"); }
}
}
}
# Check if there is any memory leak in compiler
if ($resultBuffer =~ /${sa_re_MemoryLeak}/mi) {
sa_log( "WARNING: Memory leak detected in compiler, setting verdict to 'FAIL'\n");
$root->[7] = 'memory leak detected';
$result = 'FAIL';
}
sa_printResult($root->[0], $result);
if ($sa_halt_on_errors and ($result ne 'PASS')) {
sa_log( "\nTest execution interrupted (no cleanup).\n\n");
exit(1);
}
$root->[6] = $result;
}
# Execute test cases
sub sa_executeTCs() {
my $flag;
# Log general info
sa_log($sa_separator);
sa_log("Date : " . `date`);
sa_log("User : " . `whoami`);
if (defined($ENV{HOST})) {
sa_log("Host : $ENV{HOST}\n");
} else {
sa_log("Host : <unknown>\n");
}
sa_log("Platform : " . `uname -a`);
sa_log("g++ : " . `which g++ | grep g++`);
sa_log("g++ vers.: " . `g++ -dumpversion`);
if (defined($ENV{TTCN3_DIR})) {
sa_log( "compiler : $sa_compilerCmd\n");
sa_log( "TTCN3_DIR: $ENV{TTCN3_DIR}\n");
} else {
sa_log( "compiler : " . `which compiler | grep compiler`);
sa_log( "TTCN3_DIR: <undefined>\n");
}
sa_log("Location : $ENV{PWD}\n");
sa_log( `$sa_compilerCmd -v 2>&1` . "\n");
my $sa_nrOfTCs2Execute = scalar @sa_tcList2Execute;
my $sa_nrOfTCs2Executed = 1;
# test case execution
foreach my $poi (@sa_TCInfo) {
sa_log ("\n\n$sa_separator Executing test case: '$poi->[0]'\n");
sa_log (" leaf: $poi->[5] ; mode: $poi->[1] ; source: $poi->[4] ;");
sa_log (" index: $sa_nrOfTCs2Executed of $sa_nrOfTCs2Execute\n$sa_separator");
opendir(DIR, '.') || die "can't opendir '.': $!";
foreach my $f (readdir(DIR)) { $sa_existedFiles{$f} = $f; }
closedir DIR;
sa_writeModulesOfTC(@{$poi});
my ($res, $resultBuffer) = sa_compileTC(@{$poi});
if ($res == 1) { # error
sa_printResult($poi->[0], 'ERROR');
$poi->[6] = 'ERROR';
next;
} elsif ($res == 2) { # compiler hanged or terminated abnormally
sa_printResult($poi->[0], 'FAIL');
$poi->[6] = 'FAIL';
$poi->[8] = 'hanged or abnormal termination';
next;
}
# Check result now
sa_checkTCResult(@{$poi}, $resultBuffer);
sa_deleteModulesOfTC(@{$poi});
$sa_nrOfTCs2Executed++;
}
sa_log("\n\n$sa_separator");
$flag = 0;
sa_log("The following test cases passed:\n");
sa_log("================================\n");
foreach my $poi (@sa_TCInfo) {
if ($poi->[6] eq 'PASS') {
sa_log(" [$poi->[4]]: '$poi->[0]' \n");
$sa_executionStatistics[0]++;
$flag = 1;
}
}
if (not $flag) { sa_log(" None.\n"); }
$flag = 0;
sa_log("The following test cases failed:\n");
sa_log("================================\n");
foreach my $poi (@sa_TCInfo) {
if ($poi->[6] eq 'FAIL') {
sa_log(" [$poi->[4]]: '$poi->[0]' \n");
$sa_executionStatistics[1]++;
$flag = 1;
}
}
if (not $flag) { sa_log(" None.\n"); }
$flag = 0;
sa_log("The following test cases are inconclusive:\n");
sa_log("==========================================\n");
foreach my $poi (@sa_TCInfo) {
if ($poi->[6] eq 'ERROR') {
sa_log(" [$poi->[4]]: '$poi->[0]' \n");
$sa_executionStatistics[2]++;
$flag = 1;
}
}
if (not $flag) { sa_log(" None.\n"); }
$flag = 0;
sa_log("\nMemory leak detected in the following test cases:\n");
foreach my $poi (@sa_TCInfo) {
if (defined($poi->[7])) {
sa_log(" [$poi->[4]]: '$poi->[0]' \n");
$sa_executionStatistics[4]++;
$flag = 1;
}
}
if (not $flag) { sa_log(" None.\n"); }
$flag = 0;
sa_log("\nAbnormal termination occured during the following test cases:\n");
foreach my $poi (@sa_TCInfo) {
if (defined($poi->[8])) {
sa_log(" [$poi->[4]]: '$poi->[0]' \n");
$sa_executionStatistics[3]++;
$flag = 1;
}
}
if (not $flag) { sa_log(" None.\n"); }
my $sa_nrOfTCs2Execute = scalar @sa_tcList2Execute;
my $nrOfScriptFiles = scalar @sa_scriptFiles;
sa_log("\n\n$sa_separator");
sa_log("$sa_nrOfTCs2Execute test cases from $nrOfScriptFiles script files were executed\n");
sa_log("Total number of executed test cases: $sa_nrOfTCs2Execute\n");
sa_log(" PASSED test cases: $sa_executionStatistics[0]\n");
sa_log(" FAILED test cases: $sa_executionStatistics[1]\n");
sa_log(" INCONCLUSIVE test cases: $sa_executionStatistics[2]\n");
sa_log(" Abnormally terminated test cases: $sa_executionStatistics[3]\n");
sa_log(" Memory leaked test cases: $sa_executionStatistics[4]\n");
if ($sa_nrOfTCs2Execute != $sa_executionStatistics[0] + $sa_executionStatistics[1] +
$sa_executionStatistics[2]) { sa_log( "INTERNAL ERROR: Statistics mismatch\n"); }
if (defined($sa_LOG)) {sa_log("Session saved to log file '$sa_logFile'\n");}
return ($sa_nrOfTCs2Execute==$sa_executionStatistics[0]);
}
###############################################################################
## M A I N
###############################################################################
$sessionTime = time();
$sa_compilerCmd = (defined $ENV{TTCN3_DIR}) ?
"$ENV{TTCN3_DIR}/bin/compiler" : 'compiler';
$sa_mfgenCmd = (defined $ENV{TTCN3_DIR}) ?
"$ENV{TTCN3_DIR}/bin/ttcn3_makefilegen" : 'ttcn3_makefilegen';
$sa_runtimeCmd = (defined $ENV{TTCN3_DIR}) ?
"$ENV{TTCN3_DIR}/bin/ttcn3_start" : 'ttcn3_start';
sa_processCommandLine();
sa_collectTCs();
sa_parseTCs();
my $isAllPassed = sa_executeTCs();
$sessionTime = time() - $sessionTime;
sa_log("Elapsed time in this session: $sessionTime seconds\n");
if (defined($sa_LOG)) { close $sa_LOG; }
exit($isAllPassed?0:1);
module Temp {
}
#!/bin/bash
SCRIPTFLAGS=
while [ $# -gt 0 ]; do
case $1 in
"-coverage") SCRIPTFLAGS+=" -coverage"; shift 1 ;;
"-rt2") SCRIPTFLAGS=" -rt2"; shift 1 ;;
*) echo "Usage: $0 [-rt2] [-coverage]"; exit 1 ;;
esac
done
echo "Batch execution of SA tests: creating 1 report for each script file"
echo "You must have a symlink in this directory named perl and pointing to perl 5.6.0 or higher"
echo "./SAtester_OOP.pl $SCRIPTFLAGS -log SA_log.report *.script"
./SAtester_OOP.pl $SCRIPTFLAGS -log SA_log.report *.script
/******************************************************************************
* Copyright (c) ETSI 2020.
*
* This file is subject to copyrights owned by ETSI. Non-exclusive permission
* is hereby granted, free of charge, to copy, reproduce and amend this file
* under the following conditions: It is provided "as is", without warranty of any
* kind, expressed or implied.
*
* ETSI shall never be liable for any claim, damages, or other liability arising
* from its use or inability of use.This permission does not apply to any documentation
* associated with this file for which ETSI keeps all rights reserved. The present
* copyright notice shall be included in all copies of whole or part of this
* file and shall not imply any sub-license right.
*
* Modified by: Elemer Lelik
*
/*****************************************************************
** @author STF 572
** @version 0.0.1
** @purpose 5.1.1.1, Ensure that identifiers from the higher(module) scope can be reused.
** @verdict pass accept
*****************************************************************/
module Sem_5010101_scopeRules_001 "TTCN-3:2018 Object-Oriented" {
const float c_f := 5.551;
type component GeneralComp {
}
public type class t_class_scope {
const float c_f := 2.5;
public function get_cf() return float {
return this.c_f;
}
}
testcase TC_Sem_5010101_scopeRules_001() runs on GeneralComp {
// var t_class_scope v_a := t_class_scope.create(); FIXME!!!
var t_class_scope v_a := t_class_scope.create(2.5);
if (v_a.get_cf() == 2.5 and Sem_5010101_scopeRules_001.c_f == 5.551) {
setverdict(pass);
} else {
setverdict(fail);
}
if (v_a.get_cf()!= Sem_5010101_scopeRules_001.c_f) {
setverdict(pass);
} else {
setverdict(fail);
}
}
control {
execute(TC_Sem_5010101_scopeRules_001());
}
}
/******************************************************************************
* Copyright (c) ETSI 2020.
*
* This file is subject to copyrights owned by ETSI. Non-exclusive permission
* is hereby granted, free of charge, to copy, reproduce and amend this file
* under the following conditions: It is provided "as is", without warranty of any
* kind, expressed or implied.
*
* ETSI shall never be liable for any claim, damages, or other liability arising
* from its use or inability of use.This permission does not apply to any documentation
* associated with this file for which ETSI keeps all rights reserved. The present
* copyright notice shall be included in all copies of whole or part of this
* file and shall not imply any sub-license right.
*
* Modified by: Elemer Lelik
*
/*****************************************************************
** @author STF 572
** @version 0.0.1
** @purpose 5.1.1.1, Ensure that identifiers of member declarations can be reused inside methods for formal parameter and local declarations.
** @verdict pass accept
*****************************************************************/
module Sem_5010101_scopeRules_002 "TTCN-3:2018 Object-Oriented" {
type component GeneralComp {
}
public type class t_class_scope {
const integer a := 88;
public function formalParameterScope(integer a := 87) return boolean {
return this.a != a;
}
}
testcase TC_Sem_5010101_scopeRules_002() runs on GeneralComp {
//var t_class_scope v_a := t_class_scope.create(); FIXME!!!
var t_class_scope v_a := t_class_scope.create(88);
if (v_a.formalParameterScope()) {
setverdict(pass);
} else {
setverdict(fail);
}
}
control {
execute(TC_Sem_5010101_scopeRules_002());
}
}
/******************************************************************************
* Copyright (c) ETSI 2020.
*
* This file is subject to copyrights owned by ETSI. Non-exclusive permission
* is hereby granted, free of charge, to copy, reproduce and amend this file
* under the following conditions: It is provided "as is", without warranty of any
* kind, expressed or implied.
*
* ETSI shall never be liable for any claim, damages, or other liability arising
* from its use or inability of use.This permission does not apply to any documentation
* associated with this file for which ETSI keeps all rights reserved. The present
* copyright notice shall be included in all copies of whole or part of this
* file and shall not imply any sub-license right.
*
* Modified by: Elemer Lelik
*
/*****************************************************************
** @author STF 572
** @version 0.0.1
** @purpose 5.1.1.2, Ensure that abstract classes are used correctly.
** @verdict pass accept
*****************************************************************/
module Sem_5010102_abstractClasses_001 "TTCN-3:2018 Object-Oriented" {
type component GeneralComp {
}
public type class @abstract t_class_abstract {
//public function doSomethingSpecial(integer v_arg) return integer; FIXME!!!!
public function @abstract doSomethingSpecial(integer v_arg) return integer;
}
public type class t_class_subclass extends t_class_abstract {
public function doSomethingSpecial(integer v_arg) return integer {
return v_arg + 1;
}
}
testcase TC_Sem_5010102_abstractClasses_001() runs on GeneralComp {
var t_class_subclass v_a := t_class_subclass.create();
if (v_a.doSomethingSpecial(64) == 65) {
setverdict(pass);
} else {
setverdict(fail);
}
}
control {
execute(TC_Sem_5010102_abstractClasses_001());
}
}
// This external class skeleton source file was generated by the
// TTCN-3 Compiler of the TTCN-3 Test Executor version 7/CAX 105 7730 R2A
// for (ethlel@HU-00001378) on Thu Dec 3 19:59:19 2020
// Copyright (c) 2000-2020 Ericsson Telecom AB
// You may modify this file. Complete the bodies of empty functions and
// add your member functions here.
#include <TTCN3.hh>
namespace Sem__5010103__externalClasses__001 {
#include "Int_List.hh"
void Int__List::add(const INTEGER& v)
{
}
INTEGER Int__List::get(const INTEGER& index)
{
}
Int__List::Int__List()
: OBJECT()
{
}
Int__List::~Int__List()
{
try {
} catch (...) {
fprintf(stderr, "Unhandled exception or dynamic test case error in destructor of class `Int__List'");
exit(EXIT_FAILURE);
}
}
void Int__List::log() const
{
TTCN_Logger::log_event_str("Int_List: { ");
TTCN_Logger::log_event_str(" }");
}
} /* end of namespace */
// This external class skeleton header file was generated by the
// TTCN-3 Compiler of the TTCN-3 Test Executor version 7/CAX 105 7730 R2A
// for (ethlel@HU-00001378) on Thu Dec 3 19:59:19 2020
// Copyright (c) 2000-2020 Ericsson Telecom AB
// You may modify this file. Add your attributes and prototypes of your
// member functions here.
#ifndef Int__List_HH
#define Int__List_HH
class Int__List : public OBJECT {
public:
static const char* class_name() { return "Int_List"; }
protected:
virtual void add(const INTEGER& v);
protected:
virtual INTEGER get(const INTEGER& index);
public:
/* default constructor */
Int__List();
public:
virtual ~Int__List();
public:
virtual void log() const;
};
#endif
/******************************************************************************
* Copyright (c) ETSI 2020.
*
* This file is subject to copyrights owned by ETSI. Non-exclusive permission
* is hereby granted, free of charge, to copy, reproduce and amend this file
* under the following conditions: It is provided "as is", without warranty of any
* kind, expressed or implied.
*
* ETSI shall never be liable for any claim, damages, or other liability arising
* from its use or inability of use.This permission does not apply to any documentation
* associated with this file for which ETSI keeps all rights reserved. The present
* copyright notice shall be included in all copies of whole or part of this
* file and shall not imply any sub-license right.
*
* Modified by: Elemer Lelik
*
/*****************************************************************
** @author STF 572
** @version 0.0.1
** @purpose 5.1.1.3, Ensure that external classes are used correctly.
** @verdict pass accept
*****************************************************************/
module Sem_5010103_externalClasses_001 "TTCN-3:2018 Object-Oriented" {
type component GeneralComp {
}
type external class /*Java_*/Int_List {
function add(integer v);
function get(integer index) return integer;
}
testcase TC_Sem_5010103_externalClasses_001() runs on GeneralComp {
//empty testcase
setverdict(pass);
}
control {
execute(TC_Sem_5010103_externalClasses_001());
}
}
/******************************************************************************
* Copyright (c) ETSI 2020.
*
* This file is subject to copyrights owned by ETSI. Non-exclusive permission
* is hereby granted, free of charge, to copy, reproduce and amend this file
* under the following conditions: It is provided "as is", without warranty of any
* kind, expressed or implied.
*
* ETSI shall never be liable for any claim, damages, or other liability arising
* from its use or inability of use.This permission does not apply to any documentation
* associated with this file for which ETSI keeps all rights reserved. The present
* copyright notice shall be included in all copies of whole or part of this
* file and shall not imply any sub-license right.
*
* Modified by: Elemer Lelik
*
/*****************************************************************
** @author STF 572
** @version 0.0.1
** @purpose 5.1.1.3, Ensure that If an internal class defines an external function, it shall be derived from an external class either directly or indirectly.
** @verdict pass accept
*****************************************************************/
module Sem_5010103_externalClasses_002 "TTCN-3:2018 Object-Oriented" {
type component GeneralComp {
}
type external class /*Java_*/Int2_List {
function add(integer v);
function get(integer index) return integer;
}
type class t_internal_class extends /*Java_*/Int2_List {
external function add(integer v);
}
testcase TC_Sem_5010103_externalClasses_002() runs on GeneralComp {
//empty testcase
setverdict(pass);
}
control {
execute(TC_Sem_5010103_externalClasses_002());
}
}
/******************************************************************************
* Copyright (c) ETSI 2020.
*
* This file is subject to copyrights owned by ETSI. Non-exclusive permission
* is hereby granted, free of charge, to copy, reproduce and amend this file
* under the following conditions: It is provided "as is", without warranty of any
* kind, expressed or implied.
*
* ETSI shall never be liable for any claim, damages, or other liability arising
* from its use or inability of use.This permission does not apply to any documentation
* associated with this file for which ETSI keeps all rights reserved. The present
* copyright notice shall be included in all copies of whole or part of this
* file and shall not imply any sub-license right.
*
* Modified by: Elemer Lelik
*
/*****************************************************************
** @author STF 572
** @version 0.0.1
** @purpose 5.1.1.4, Ensure that final classes are used correctly.
** @verdict pass accept
*****************************************************************/
module Sem_5010104_finalClasses_001 "TTCN-3:2018 Object-Oriented" {
type component GeneralComp {
}
type class @final FinalClass {
//function doSomething() return charstring { FIXME!!! without visibility qualifier, protected is assumed
public function doSomething() return charstring {
return "something";
}
}
testcase TC_Sem_5010104_finalClasses_001() runs on GeneralComp {
var FinalClass v_a := FinalClass.create();
if (v_a.doSomething() == "something") {
setverdict(pass);
} else {
setverdict(fail);
}
}
control {
execute(TC_Sem_5010104_finalClasses_001());
}
}
/******************************************************************************
* Copyright (c) ETSI 2020.
*
* This file is subject to copyrights owned by ETSI. Non-exclusive permission
* is hereby granted, free of charge, to copy, reproduce and amend this file
* under the following conditions: It is provided "as is", without warranty of any
* kind, expressed or implied.
*
* ETSI shall never be liable for any claim, damages, or other liability arising
* from its use or inability of use.This permission does not apply to any documentation
* associated with this file for which ETSI keeps all rights reserved. The present
* copyright notice shall be included in all copies of whole or part of this
* file and shall not imply any sub-license right.
*
* Modified by: Elemer Lelik
*
/*****************************************************************
** @author STF 572
** @version 0.0.1
** @purpose 5.1.1.5, Ensure that class constructor can be used with formal parameter.
** @verdict pass accept
*****************************************************************/
module Sem_5010105_Constructors_001 "TTCN-3:2018 Object-Oriented" {
type component GeneralComp {
}
type class MyClass {
var integer v_i;
var charstring v_id;
create(integer v_i, charstring v_id) {
this.v_i := v_i;
this.v_id := v_id;
}
public function get_vi() return integer {
return this.v_i;
}
public function get_vid() return charstring {
return this.v_id;
}
}
testcase TC_Sem_5010105_Constructors_001() runs on GeneralComp {
var MyClass v_a := MyClass.create(5, "abc");
if (v_a.get_vi() == 5 and v_a.get_vid() == "abc") {
setverdict(pass);
} else {
setverdict(fail);
}
}
control {
execute(TC_Sem_5010105_Constructors_001());
}
}
/******************************************************************************
* Copyright (c) ETSI 2020.
*
* This file is subject to copyrights owned by ETSI. Non-exclusive permission
* is hereby granted, free of charge, to copy, reproduce and amend this file
* under the following conditions: It is provided "as is", without warranty of any
* kind, expressed or implied.
*
* ETSI shall never be liable for any claim, damages, or other liability arising
* from its use or inability of use.This permission does not apply to any documentation
* associated with this file for which ETSI keeps all rights reserved. The present
* copyright notice shall be included in all copies of whole or part of this
* file and shall not imply any sub-license right.
*
* Modified by: Elemer Lelik
*
/*****************************************************************
** @author STF 572
** @version 0.0.1
** @purpose 5.1.1.5, Ensure that the constructor of the superclass is executed
** before the constructor body of the subclass.
** @verdict pass accept
*****************************************************************/
module Sem_5010105_Constructors_002 "TTCN-3:2018 Object-Oriented" {
type component GeneralComp {
}
type class MySuperClass {
/* public*/ var octetstring v_o;
create(octetstring v_o) {
this.v_o := v_o;
}
public function get_vo() return octetstring {
return this.v_o;
}
}
type class MySubClass extends MySuperClass {
/*public*/ var template charstring vt_cstr;
create(template charstring vt_cstr) : MySuperClass('AA5600'O) {
this.vt_cstr := vt_cstr;
}
}
testcase TC_Sem_5010105_Constructors_002() runs on GeneralComp {
var MySubClass v_a := MySubClass.create( pattern "?abc*");
if (v_a.get_vo() == 'AA5600'O) {
setverdict(pass);
} else {
setverdict(fail);
}
}
control {
execute(TC_Sem_5010105_Constructors_002());
}
}
// This Test Port skeleton source file was generated by the
// TTCN-3 Compiler of the TTCN-3 Test Executor version 7/CAX 105 7730 R2A
// for Global Warning (james00@GlobalWarning1) on Tue Nov 10 10:16:29 2020
// Copyright (c) 2000-2020 Ericsson Telecom AB
// You may modify this file. Complete the body of empty functions and
// add your member functions here.
#include "MyPort.hh"
namespace Sem__5010106__Destructors__001 {
MyPort::MyPort(const char *par_port_name)
: MyPort_BASE(par_port_name)
{
}
MyPort::~MyPort()
{
}
void MyPort::set_parameter(const char * /*parameter_name*/,
const char * /*parameter_value*/)
{
}
/*void MyPort::Handle_Fd_Event(int fd, boolean is_readable,
boolean is_writable, boolean is_error) {}*/
void MyPort::Handle_Fd_Event_Error(int /*fd*/)
{
}
void MyPort::Handle_Fd_Event_Writable(int /*fd*/)
{
}
void MyPort::Handle_Fd_Event_Readable(int /*fd*/)
{
}
/*void MyPort::Handle_Timeout(double time_since_last_call) {}*/
void MyPort::user_map(const char * /*system_port*/, Map_Params& /*params*/)
{
}
void MyPort::user_unmap(const char * /*system_port*/, Map_Params& /*params*/)
{
}
void MyPort::user_start()
{
}
void MyPort::user_stop()
{
}
void MyPort::outgoing_send(const INTEGER& /*send_par*/)
{
}
} /* end of namespace */
// This Test Port skeleton header file was generated by the
// TTCN-3 Compiler of the TTCN-3 Test Executor version 7/CAX 105 7730 R2A
// for Global Warning (james00@GlobalWarning1) on Tue Nov 10 10:16:29 2020
// Copyright (c) 2000-2020 Ericsson Telecom AB
// You may modify this file. Add your attributes and prototypes of your
// member functions here.
#ifndef MyPort_HH
#define MyPort_HH
#include "Sem_5010106_Destructors_001.hh"
namespace Sem__5010106__Destructors__001 {
class MyPort : public MyPort_BASE {
public:
MyPort(const char *par_port_name = NULL);
~MyPort();
void set_parameter(const char *parameter_name,
const char *parameter_value);
private:
/* void Handle_Fd_Event(int fd, boolean is_readable,
boolean is_writable, boolean is_error); */
void Handle_Fd_Event_Error(int fd);
void Handle_Fd_Event_Writable(int fd);
void Handle_Fd_Event_Readable(int fd);
/* void Handle_Timeout(double time_since_last_call); */
protected:
void user_map(const char *system_port, Map_Params& params);
void user_unmap(const char *system_port, Map_Params& params);
void user_start();
void user_stop();
void outgoing_send(const INTEGER& send_par);
};
} /* end of namespace */
#endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment