blob: 21d3034e80b7296d42308a41a88149cd05fe391a [file] [log] [blame]
///////////////////////////////////////////////////////////////////////////////
// //
// Copyright (c) 2000-2019 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 //
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
// Module: EPTF_ILog_Test
//
// Purpose:
// This module contains function definitions for testing EPTF ILog
//
// Module Parameters:
// -
//
// Module depends on:
// <EPTF_CLL_ILog_Definitions>
// <EPTF_CLL_ILog_Functions>
// <EPTF_CLL_Base_Functions>
// <EPTF_CLL_Common_Definitions>
//
// Current Owner:
// EILDVNC
//
// Last Review Date:
// -
//
// Detailed Comments:
// -
///////////////////////////////////////////////////////////
module EPTF_ILog_Test {
import from EPTF_CLL_ILog_Definitions all;
import from EPTF_CLL_ILog_Functions all;
import from EPTF_CLL_Base_Functions all;
import from EPTF_CLL_Common_Definitions all;
////////////////////////////////////////////////////////////
type record compactRecord {
integer id,
charstring text
}
type record of compactRecord logRecord;
type record of integer logDBInt;
type record of charstring logDBChar;
type component EPTF_ILog_Test_CT extends EPTF_ILog_CT{
private var logDBInt v_db1 := {};
private var logDBChar v_db2 := {};
private var logRecord v_db3 := {};
private var logDBInt v_db4 := {};
private var logDBInt v_logDbInt := { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
private var logDBInt v_logDbInt2 := { 0, 0, 5, 1, 1, 6, 2, 2, 7, 3, 3, 8, 4, 4, 9 };
private var logDBChar v_logDbChar1 := {"Chain210", "Chain221", "Chain212", "Chain223", "Chain214", "Chain225", "Chain216", "Chain227", "Chain218", "Chain229", "1110", "1111"};
private var logRecord v_logDbRecord := {{31, "FirstOfDB3"}, {32, "SecondOfDB3"} };
private var logDBInt v_logOrder :={};
}
function f_logData1(
in integer pl_elementIdx,
in integer pl_dbId,
in integer pl_chainId,
in EPTF_IntegerList pl_paramList )
runs on EPTF_ILog_Test_CT {
log("The element index: "&int2str(pl_elementIdx)&" in db"&int2str(pl_dbId)&" with param: "&int2str(pl_paramList[0])&" in chain"&int2str(pl_chainId));
if(pl_dbId == 0 and pl_chainId == 1){
if( v_db1[pl_elementIdx] == v_logDbInt[pl_elementIdx] ){
setverdict( pass );
} else {
setverdict( fail, "Invalid value for event index. Should be: ",v_db1[pl_elementIdx], " but got: ",v_logDbInt[pl_elementIdx] );
}
} else if(pl_dbId == 1 and (pl_chainId == 2 or pl_chainId == 3)){
if( v_db2[pl_elementIdx] == v_logDbChar1[pl_elementIdx] ){
setverdict( pass );
} else {
setverdict( fail, "Invalid value for event index. Should be: ",v_db2[pl_elementIdx], " but got: ",v_logDbChar1[pl_elementIdx] );
}
}
}
function f_logData2(
in integer pl_elementIdx,
in integer pl_dbId,
in integer pl_chainId,
in EPTF_IntegerList pl_paramList )
runs on EPTF_ILog_Test_CT {
log("The element index: "&int2str(pl_elementIdx)&" in db"&int2str(pl_dbId)&" with param: "&int2str(pl_paramList[0])&" in chain"&int2str(pl_chainId));
if(pl_paramList[0] == 0){
if( v_db1[pl_elementIdx] == v_logDbInt2[pl_elementIdx] ){
setverdict( pass );
} else {
setverdict( fail, "Invalid value for event index. Should be: ",v_db1[pl_elementIdx], " but got: ",v_logDbInt2[pl_elementIdx] );
}
} else if (pl_paramList[0] == 1){
if( v_db1[pl_elementIdx] == v_logDbInt[pl_elementIdx] ){
setverdict( pass );
} else {
setverdict( fail, "Invalid value for event index. Should be: ",v_db1[pl_elementIdx], " but got: ",v_logDbInt[pl_elementIdx] );
}
}
}
function f_logData3(
in integer pl_elementIdx,
in integer pl_dbId,
in integer pl_chainId,
in EPTF_IntegerList pl_paramList )
runs on EPTF_ILog_Test_CT {
log("The element index: "&int2str(pl_elementIdx)&" in db"&int2str(pl_dbId)&" with param: "&int2str(pl_paramList[0])&" in chain"&int2str(pl_chainId));
if(pl_dbId == 0 and pl_chainId == 3){
if( v_db1[pl_elementIdx] == v_logDbInt[pl_elementIdx] ){
setverdict( pass );
} else {
setverdict( fail, "Invalid value for event index. Should be: ",v_db1[pl_elementIdx], " but got: ",v_logDbInt[pl_elementIdx] );
}
} else if(pl_dbId == 1 and (pl_chainId == 1 or pl_chainId == 2)){
if( v_db2[pl_elementIdx] == v_logDbChar1[pl_elementIdx] ){
setverdict( pass );
} else {
setverdict( fail, "Invalid value for event index. Should be: ",v_db2[pl_elementIdx], " but got: ",v_logDbChar1[pl_elementIdx] );
}
} else if(pl_dbId == 1 and (pl_chainId == 0 )){
if( v_db2[pl_elementIdx] == v_logDbChar1[pl_elementIdx] ){
setverdict( pass );
} else {
setverdict( fail, "Invalid value for event index. Should be: ",v_db2[pl_elementIdx], " but got: ",v_logDbChar1[pl_elementIdx] );
}
} else if(pl_dbId == 2 and (pl_chainId == 0 )){
if( v_db3[pl_elementIdx] == v_logDbRecord[pl_elementIdx] ){
setverdict( pass );
} else {
setverdict( fail, "Invalid value for event index. Should be: ",v_db3[pl_elementIdx], " but got: ",v_logDbRecord[pl_elementIdx] );
}
}
}
function f_logHeader(
in integer pl_chainId,
in EPTF_IntegerList pl_paramList
)
runs on EPTF_ILog_Test_CT {
var charstring vl_chainName := f_EPTF_ILog_getName(pl_chainId);
var integer vl_sizeLogOrder := sizeof(v_logOrder);
v_logOrder[vl_sizeLogOrder] := pl_chainId;
log("It is the log of chain"&int2str(pl_chainId)&" with name: "&vl_chainName&" with param: "&int2str(pl_paramList[0]));
}
///////////////////////////////////////////////////////////
// Testcase: tc_ILog_init
//
// Purpose: Test of the f_EPTF_ILog_init_CT function of the ILog feature.
//
// Action: The testcase invokes the f_EPTF_ILog_init_CT function. The verdict of the test is pass if no errors happen during the initialization.
//
// Expected Result: pass verdict. The test result is pass if the init function operates without any error.
//
///////////////////////////////////////////////////////////
testcase tc_ILog_init() runs on EPTF_ILog_Test_CT {
// Init
f_EPTF_ILog_init_CT("ILog_Test");
f_EPTF_Base_stopAll(pass);
}
///////////////////////////////////////////////////////////
// Testcase: tc_ILog_registerDB
//
// Purpose: The test of the f_EPTF_ILog_register_DB function. The tested function should register the user database with the callback functions and the user defined parameter.
// The function returns the id of the database.
//
// Action: The tc_ILog_registerDB function is invoked after initializing the EPTF_ILog_CT component. The function parameters contain the reference of
// the previously defined callback functions and user paramater. The function registers one database at a time an dthis testcase calls this function once. The
// return value has to be zero as this database is the first and only registered database.
//
// Expected Result: pass verdict. The test is successful if the returned value of the tested function is zero and no error occurs.
//
///////////////////////////////////////////////////////////
testcase tc_ILog_registerDB() runs on EPTF_ILog_Test_CT {
// Init
f_EPTF_ILog_init_CT("ILog_Test");
// Register new database
var integer vl_dbId0 := f_EPTF_ILog_register_DB(refers( f_logData1 ), {1});
if(vl_dbId0 == 0){
setverdict( pass );
} else {
setverdict( fail, "Invalid value for event index. Should be: ",0, " but got: ",vl_dbId0 );
}
f_EPTF_Base_stopAll(pass);
}
///////////////////////////////////////////////////////////
// Testcase: tc_ILog_createNewChain
//
// Purpose: The test of the f_EPTF_ILog_newChain function. This function creates a new chain for a database. This means creating a new chain or reusing an existing free one.
// The name of the chain, the callback function reference and the user defined parameter are stored in a database.
//
// Action: After the initialization process, the testcase creates a new chain with the f_EPTF_ILog_newChain function with the chain name and the callback function
// reference (used for logging the log header). The function should return 1 as the id of the new chain as it is the only one created chain.
//
// Expected Result: pass verdict.The test result is pass if the returned chain id is 1 and no errors happend.
//
///////////////////////////////////////////////////////////
testcase tc_ILog_createNewChain() runs on EPTF_ILog_Test_CT {
// Init
f_EPTF_ILog_init_CT("ILog_Test");
// Register new chain
var integer vl_chain0 := f_EPTF_ILog_newChain( "Chain11", detailed, refers(f_logHeader), {0});
if(vl_chain0 == 1 ){
setverdict( pass );
} else {
setverdict( fail, "Invalid value for event index. Should be: ",0, " but got: ",vl_chain0 );
}
f_EPTF_Base_stopAll(pass);
}
///////////////////////////////////////////////////////////
// Testcase: tc_ILog_getName
//
// Purpose: The test of the tc_ILog_getName function. This function creates a new chain. Then the test gets the name of the registered chain and checks the return value of the function.
//
// Action: After the initialization process, the testcase creates a new chain with the f_EPTF_ILog_newChain function with the chain name and the callback function
// reference (used for logging the log header). The next step is tp invoke the f_EPTF_ILog_getName function to retrieve the name of the chain. The test checks if the
// returned charstring is the expected or not.
//
// Expected Result: pass verdict.The test result is pass if the returned chain name matches the expected value.
//
///////////////////////////////////////////////////////////
testcase tc_ILog_getName() runs on EPTF_ILog_Test_CT {
// Init
f_EPTF_ILog_init_CT("ILog_Test");
var charstring vl_chainName := "Chain11";
// Register new chain
var integer vl_chain0 := f_EPTF_ILog_newChain( vl_chainName, detailed, refers(f_logHeader), {0});
var charstring vl_chainNameReturn := f_EPTF_ILog_getName(vl_chain0);
if(match (vl_chainName, vl_chainNameReturn)){
setverdict( pass );
} else {
setverdict( fail, match (vl_chainName, vl_chainNameReturn));
}
f_EPTF_Base_stopAll(pass);
}
///////////////////////////////////////////////////////////
// Testcase: tc_ILog_getName_NegativeTest_nonExistingChainId
//
// Purpose: The test of the tc_ILog_getName function. This function creates a new chain. Then the test tries to get the name of the registered chain and checks the return value of
// the function, in case of invoking the function with invalid chain id.
//
// Action: After the initialization process, the testcase creates a new chain with the f_EPTF_ILog_newChain function with the chain name and the callback function
// reference (used for logging the log header). The next step is tp invoke the f_EPTF_ILog_getName function to retrieve the name of the chain with the invalid id.
// The test checks if thereturned charstring is the expected or not, the expected value is an empty charstring.
//
// Expected Result: pass verdict.The test result is pass if the returned chain name is "".
//
///////////////////////////////////////////////////////////
testcase tc_ILog_getName_NegativeTest_nonExistingChainId() runs on EPTF_ILog_Test_CT {
// Init
f_EPTF_ILog_init_CT("ILog_Test");
var charstring vl_chainName := "";
// Register new chain
var integer vl_chain0 := f_EPTF_ILog_newChain( "Chain11", detailed, refers(f_logHeader), {0});
var integer vl_chain1 := vl_chain0 + 1;
var charstring vl_chainNameReturn := f_EPTF_ILog_getName(vl_chain1);
if(match (vl_chainName, vl_chainNameReturn)){
setverdict( pass );
} else {
setverdict( fail, match (vl_chainName, vl_chainNameReturn));
}
f_EPTF_Base_stopAll(pass);
}
///////////////////////////////////////////////////////////
// Testcase: tc_ILog_addElementToChain
//
// Purpose: Test of the f_EPTF_ILog_addToChain function. The function stores the database id and the database index of the new element on the ILog side. The function returns
// the index of the element in the user side database where it should be stored.
//
// Action: After the initialization process, the next steps are to register a user database and create a new chain. The f_EPTF_ILog_addToChain function adds ten items to the chain
// and returns the index of the elements in the user database. The index list should be {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}
//
// Expected Result: pass verdict. The test result is pass if the returned index list is the same as the above defined and no errors occur during the test.
//
///////////////////////////////////////////////////////////
testcase tc_ILog_addElementToChain() runs on EPTF_ILog_Test_CT {
// Init
f_EPTF_ILog_init_CT("ILog_Test");
// Register new database and chain
var integer vl_dbId0 := f_EPTF_ILog_register_DB(refers( f_logData1 ), {1});
var integer vl_chain0 := f_EPTF_ILog_newChain( "Chain11", detailed, refers(f_logHeader), {0});
var EPTF_IntegerList vl_chainList := {vl_chain0};
var integer vl_dbIdx;
for(var integer vl_i := 0; vl_i <10; vl_i := vl_i +1 ){
// Add element to the registered chain
vl_dbIdx := f_EPTF_ILog_addToChains(vl_dbId0, vl_chainList);
if( vl_dbIdx == vl_i ){
setverdict( pass );
} else {
setverdict( fail, "Invalid value for event index. Should be: ",vl_i, " but got: ",vl_dbIdx );
}
}
f_EPTF_Base_stopAll(pass);
}
///////////////////////////////////////////////////////////
// Testcase: tc_ILog_addElementToChain_NegativeTest_nonExistingChainId
//
// Purpose: The negative test of the f_EPTF_ILog_addToChains function with a non existing chainId. The test checks if the function handles
// properly if the chain id does not exist in the initialized component. The return value of the tested feature should be -1 in this case.
//
// Action: After the initialization process, the next steps are to register a user database and create a new chain. The next step is to invoke the
// tested function with a non existing chain id. The test checks if the return value of the function is -1 and set the verdict to pass if the value is correct.
//
// Expected Result: pass verdict. If the return value of the tested function is -1, the verdict of the testcase is set to pass.
//
///////////////////////////////////////////////////////////
testcase tc_ILog_addElementToChain_NegativeTest_nonExistingChainId() runs on EPTF_ILog_Test_CT {
// Init
f_EPTF_ILog_init_CT("ILog_Test");
// Register new database and chain
var integer vl_dbId0 := f_EPTF_ILog_register_DB(refers( f_logData1 ), {1});
var integer vl_chain0 := f_EPTF_ILog_newChain( "Chain11", detailed, refers(f_logHeader), {0});
var integer vl_chain1 := vl_chain0 + 1;
var EPTF_IntegerList vl_chainList := {vl_chain1};
var integer vl_dbIdx;
var integer vl_dbIdxErr := -1;
// Add element to the unregistered chain
vl_dbIdx := f_EPTF_ILog_addToChains(vl_dbId0, vl_chainList);
if( vl_dbIdx == vl_dbIdxErr ){
setverdict( pass );
} else {
setverdict( fail, "Invalid value for event index. Should be: ",vl_dbIdxErr, " but got: ",vl_dbIdx );
}
f_EPTF_Base_stopAll(pass);
}
///////////////////////////////////////////////////////////
// Testcase: tc_ILog_addElementToChain_NegativeTest_nonExistingDbId
//
// Purpose: The negative test of the f_EPTF_ILog_addToChains function with a non existing dbId. The test checks if the function handles
// properly if the database id does not exist in the initialized component. The return value of the tested feature should be -1 in this case.
//
// Action: After the initialization process, the next steps are to register a user database and create a new chain. The next step is to invoke the
// tested function with a non existing database id. The test checks if the return value of the function is -1 and set the verdict to pass if the value is correct.
//
// Expected Result: pass verdict. If the return value of the tested function is -1, the verdict of the testcase is set to pass.
//
///////////////////////////////////////////////////////////
testcase tc_ILog_addElementToChain_NegativeTest_nonExistingDbId() runs on EPTF_ILog_Test_CT {
// Init
f_EPTF_ILog_init_CT("ILog_Test");
// Register new database and chain
var integer vl_dbId0 := f_EPTF_ILog_register_DB(refers( f_logData1 ), {1});
var integer vl_chain0 := f_EPTF_ILog_newChain( "Chain11", detailed, refers(f_logHeader), {0});
var integer vl_dbId1 := vl_dbId0 + 1;
var EPTF_IntegerList vl_chainList := {vl_chain0};
var integer vl_dbIdx;
var integer vl_dbIdxErr := -1;
// Add element to the unregistered chain
vl_dbIdx := f_EPTF_ILog_addToChains(vl_dbId1, vl_chainList);
if( vl_dbIdx == vl_dbIdxErr ){
setverdict( pass );
} else {
setverdict( fail, "Invalid value for event index. Should be: ",vl_dbIdxErr, " but got: ",vl_dbIdx );
}
f_EPTF_Base_stopAll(pass);
}
///////////////////////////////////////////////////////////
// Testcase: tc_ILog_deleteChain
//
// Purpose: The test of the f_EPTF_ILog_deleteChain function. The purpose of this function is to delete a chain that were registered to the given database with the given id.
//
// Action: After the initialization process the testcase registers a database and creates a new chain. The next step of the testcase is to delete the created chain with the tested function. The test
// is successful if the function operates without error.
//
// Expected Result: pass verdict. If the functionoperates without errors the test result is pass.
//
///////////////////////////////////////////////////////////
testcase tc_ILog_deleteChain() runs on EPTF_ILog_Test_CT {
// Init
f_EPTF_ILog_init_CT("ILog_Test");
// Register new chain
var integer vl_chain0 := f_EPTF_ILog_newChain( "Chain11", detailed, refers(f_logHeader), {0});
// Delete the registered chain
if(f_EPTF_ILog_deleteChain(vl_chain0) == 0){
setverdict(pass);
} else {
setverdict(fail, "Error occured during the operation of the deleteChain function!");
}
f_EPTF_Base_stopAll(pass);
}
///////////////////////////////////////////////////////////
// Testcase: tc_ILog_deleteChain_NegativeTest_nonExistingChainId
//
// Purpose: Negative test of the f_EPTF_ILog_deleteChain function. The purpose of this function is to try to delete a chain, which has an id that does not exist in the initialized component.
//
// Action: After the initialization process, the testcase creates a new chain. The next step of the testcase is to delete the created chain with the non existibng chain Id. The test
// is successful if the function operates without error.
//
// Expected Result: pass verdict. If the functionoperates without errors the test result is pass.
//
///////////////////////////////////////////////////////////
testcase tc_ILog_deleteChain_NegativeTest_nonExistingChainId() runs on EPTF_ILog_Test_CT {
// Init
f_EPTF_ILog_init_CT("ILog_Test");
// Register new chain
var integer vl_chain0 := f_EPTF_ILog_newChain( "Chain11", detailed, refers(f_logHeader), {0});
var integer vl_chain1 := vl_chain0 + 1;
// Delete the unregistered chain
if(f_EPTF_ILog_deleteChain(vl_chain1) == -1){
setverdict(pass);
} else {
setverdict(fail, "Error occured during the operation of the deleteChain function!");
}
f_EPTF_Base_stopAll(pass);
}
///////////////////////////////////////////////////////////
// Testcase: tc_ILog_logChain
//
// Purpose: The test of the f_EPTF_ILog_logChain function. The purpose of this function is to create a log of a chain with the help of the callback functions. The callback functions store the
// elements of te chain in a database in order to compare the logged data with the data stored in the user database. the test is successful if the two databases are the same.
//
// Action: The first step is the initialization. After this step one user database is registered and a chain is created. The testcase adds 10 items to the chain. After this
// the chain is logged out. The testcase with the callback functions compares the user database with that one, which was filled during the logging process. If the two databases are
// the same the result of the testcase is pass.
//
// Expected Result: pass verdict. If the logging function returns the predefined values in the right order and no error occurs the result of the testcase is set to pass.
//
///////////////////////////////////////////////////////////
testcase tc_ILog_logChain() runs on EPTF_ILog_Test_CT {
// Init
f_EPTF_ILog_init_CT("ILog_Test");
// Register new chain and new database
var integer vl_dbId0 := f_EPTF_ILog_register_DB(refers( f_logData1 ), {1});
var integer vl_chain0 := f_EPTF_ILog_newChain( "Chain11", detailed, refers(f_logHeader), {0});
var EPTF_IntegerList vl_chainList := {vl_chain0};
for(var integer vl_i := 0; vl_i <10; vl_i := vl_i +1 ){
// Add new element to chain
v_db1[f_EPTF_ILog_addToChains(vl_dbId0, vl_chainList)] := vl_i;
}
// Log chain
if(f_EPTF_ILog_logChain(vl_chain0) == 0){
setverdict(pass);
} else {
setverdict(fail, "Error occured during the operation of the logChain function!");
}
f_EPTF_Base_stopAll(pass);
}
///////////////////////////////////////////////////////////
// Testcase: tc_ILog_logChain_NegativeTest_nonExistingChainId
//
// Purpose: The negative test of the tc_ILog_logChain_NegativeTest_nonExistingChainId function with a non existing chainId. The test checks if the function handles
// properly if the chain id does not exist in the initialized component. The return value of the tested feature should be -1 in this case.
//
// Action: After the initialization process, the next steps are to register a user database and create a new chain. The testcase adds elements to the created chain.
// The next step of the testcase is to log out a chain with the non existibng chain Id. The test is successful if the function operates without error.
//
// Expected Result: pass verdict. If the functionoperates without errors the test result is pass.
//
///////////////////////////////////////////////////////////
testcase tc_ILog_logChain_NegativeTest_nonExistingChainId() runs on EPTF_ILog_Test_CT {
// Init
f_EPTF_ILog_init_CT("ILog_Test");
// Register new chain and new database
var integer vl_dbId0 := f_EPTF_ILog_register_DB(refers( f_logData1 ), {1});
var integer vl_chain0 := f_EPTF_ILog_newChain( "Chain11", detailed, refers(f_logHeader), {0});
var integer vl_chain1 := vl_chain0 + 1;
var EPTF_IntegerList vl_chainList := {vl_chain0};
for(var integer vl_i := 0; vl_i <10; vl_i := vl_i +1 ){
// Add new element to chain
v_db1[f_EPTF_ILog_addToChains(vl_dbId0, vl_chainList)] := vl_i;
}
// Log out non existing chain
if(f_EPTF_ILog_logChain(vl_chain1) == -1){
setverdict(pass);
} else {
setverdict(fail, "Error occured during the operation of the logChain function!")
}
f_EPTF_Base_stopAll(pass);
}
///////////////////////////////////////////////////////////
// Testcase: tc_ILog_logChain_NegativeTest_addElementToDeletedChain
//
// Purpose: The purpose of this test is to check the behaviour of the f_EPTF_ILog_logChain and the f_EPTF_ILog_addToChains functions. The f_EPTF_ILog_logChain
// function has a boolean input parameter, which decides whether the chain has to be deleted or not. The test checks that this functions deletes the chain by trying to add
// a new element to the logged out and deleted chain.
//
// Action: After the initialization process, the next steps are to register a user database and create a new chain. The test adds ten new elements to the created chain and then log out
// the chain by using the f_EPTF_ILog_logChain function with no input parameter (the function deletes the logged chain by default). The next step is to add a new
// element to the deleted chain. In this case the f_EPTF_ILog_addToChains function should return -1, as the operation cannot be done.
//
// Expected Result: pass verdict. The verdict of the testcase is set to pass, if the return value of the last called f_EPTF_ILog_addToChains function is -1.
//
///////////////////////////////////////////////////////////
testcase tc_ILog_logChain_NegativeTest_addElementToDeletedChain() runs on EPTF_ILog_Test_CT {
// Init
f_EPTF_ILog_init_CT("ILog_Test");
// Register new chain and new database
var integer vl_dbId0 := f_EPTF_ILog_register_DB(refers( f_logData1 ), {1});
var integer vl_chain0 := f_EPTF_ILog_newChain( "Chain11", detailed, refers(f_logHeader), {0});
var EPTF_IntegerList vl_chainList := {vl_chain0};
var integer vl_dbIdx;
var integer vl_dbIdxErr := -1;
for(var integer vl_i := 0; vl_i <10; vl_i := vl_i +1 ){
// Add new element to chain
v_db1[f_EPTF_ILog_addToChains(vl_dbId0, vl_chainList)] := vl_i;
}
// Log out and delete chain
if(f_EPTF_ILog_logChain(vl_chain0) == 0){
setverdict(pass);
} else {
setverdict(fail, "Error occured during the operation of the logChain function!");
}
// Add new element to the deleted chain
vl_dbIdx := f_EPTF_ILog_addToChains(vl_dbId0, vl_chainList);
if( vl_dbIdx == vl_dbIdxErr ){
setverdict( pass );
} else {
setverdict( fail, "Invalid value for event index. Should be: ",vl_dbIdxErr, " but got: ",vl_dbIdx );
}
f_EPTF_Base_stopAll(pass);
}
///////////////////////////////////////////////////////////
// Testcase: tc_ILog_logChain_addElementToLoggedButNotDeletedChain
//
// Purpose: This testcase simulates, when a chain is logged out, but not deleted during this operation. In this case a new element can be added to the previously logged chain. The
// testcase checks the f_EPTF_ILog_logChain function with "false" input value and the f_EPTF_ILog_addToChains function. The testcase tries to add a new element
// to the previously logged chain. The testcase finally logs out the chain and checks if the elements are the expected ones.
//
// Action: After the initialization process, the next steps are to register a user database and create a new chain. The testcase adds 5 elements to the chain and logs it out without
// deleting. The next step is to add 5 more elements to the chain and log it out again. If the chain elements are the expected values in both cases the verdict of testcase is set to pass.
//
// Expected Result: pass verdict. If the chain elements are the expected values, the verdict of the testcase is set to pass.
//
///////////////////////////////////////////////////////////
testcase tc_ILog_logChain_addElementToLoggedButNotDeletedChain() runs on EPTF_ILog_Test_CT {
// Init
f_EPTF_ILog_init_CT("ILog_Test");
// Register new chain and new database
var integer vl_dbId0 := f_EPTF_ILog_register_DB(refers( f_logData2 ), {1});
var integer vl_chain0 := f_EPTF_ILog_newChain( "Chain11", detailed, refers(f_logHeader), {0});
var EPTF_IntegerList vl_chainList := {vl_chain0};
var integer vl_dbIdx;
for(var integer vl_i := 0; vl_i <5; vl_i := vl_i +1 ){
// Add new element to chain
vl_dbIdx := f_EPTF_ILog_addToChains(vl_dbId0, vl_chainList);
v_db1[vl_dbIdx] := vl_i;
}
// Log out chain
if(f_EPTF_ILog_logChain(vl_chain0, false) == 0){
setverdict(pass);
} else {
setverdict(fail, "Error occured during the operation of the logChain function!");
}
for(var integer vl_i := 5; vl_i <10; vl_i := vl_i +1 ){
// Add new element to chain
vl_dbIdx := f_EPTF_ILog_addToChains(vl_dbId0, vl_chainList);
v_db1[vl_dbIdx] := vl_i;
}
// Log out chain for the second time
if(f_EPTF_ILog_logChain(vl_chain0) == 0){
setverdict(pass);
} else {
setverdict(fail, "Error occured during the operation of the logChain function!");
}
f_EPTF_Base_stopAll(pass);
}
///////////////////////////////////////////////////////////
// Testcase: tc_ILog_logAll
//
// Purpose: The test of the f_EPTF_ILog_logAll function. This function logs out the content of all chains in order of their creation based on the registration order of the user databaases. The
// function uses the f_EPTF_ILog_logChain.
//
// Action: After the initialization process, two user databases are registered and three chains are created . All of the chains are filled with elements. The log mechanism stores the order
// the logging process by saving the chain ids in a database. This database is compared with a predefined one, which contains the right sequence. The sequence of the log
// items are also checked with the same mechanism. The test is successful if all the databases that were compared are the same.
//
// Expected Result: pass verdict. The test result is pass if the checks do not fail and no error occurs.
//
///////////////////////////////////////////////////////////
testcase tc_ILog_logAll() runs on EPTF_ILog_Test_CT {
// Init
f_EPTF_ILog_init_CT("ILog_Test");
var integer vl_dbId0 := f_EPTF_ILog_register_DB(refers( f_logData1 ), {1});
var integer vl_dbId1 := f_EPTF_ILog_register_DB(refers( f_logData1 ), {2});
var integer vl_chain0 := f_EPTF_ILog_newChain( "Chain11", detailed, refers(f_logHeader), {0});
var integer vl_chain1 := f_EPTF_ILog_newChain( "Chain21", detailed, refers(f_logHeader), {1});
var integer vl_chain2 := f_EPTF_ILog_newChain( "Chain22", detailed, refers(f_logHeader), {2});
var EPTF_IntegerList vl_chainList0 := {vl_chain0};
var EPTF_IntegerList vl_chainList1 := {vl_chain1};
var EPTF_IntegerList vl_chainList2 := {vl_chain2};
var logDBInt vl_chainOrder :={1, 2, 3};
for(var integer vl_i := 0; vl_i <10; vl_i := vl_i +1 ){
v_db1[f_EPTF_ILog_addToChains(vl_dbId0, vl_chainList0)] := vl_i;
}
for(var integer vl_j := 0; vl_j <10; vl_j := vl_j +1 ){
if(vl_j rem 2 == 0){
v_db2[f_EPTF_ILog_addToChains(vl_dbId1, vl_chainList1)] := "Chain21"&int2str(vl_j);
} else {
v_db2[f_EPTF_ILog_addToChains(vl_dbId1, vl_chainList2)] := "Chain22"&int2str(vl_j);
}
}
f_EPTF_ILog_logAll();
// The sequence of the chain numbers are stored in a database in case of the call of the f_logHeader callback function.
// The next check verifies if the sequence that was stored is the same as the expected.
if( match(vl_chainOrder, v_logOrder) ){
setverdict( pass );
} else {
setverdict( fail, match(vl_chainOrder, v_logOrder) );
}
f_EPTF_Base_stopAll(pass);
}
///////////////////////////////////////////////////////////
// Testcase: tc_ILog_logAll_firstNotDeleteSecondDeleteChains
//
// Purpose: The testcase checks the f_EPTF_ILog_logAll function with both "false" and no input values. If the function is called without input value, it uses the default (true).
// The purpose of this test is to check that the tested function does not delete the chains, in case of the false value is used as input.
//
// Action: After the initialization process, two user databases are registered and three chains are created. All chains are filled with elements. The testcase invokes the
// f_EPTF_ILog_logAll function with false input value and checks the elements that were logged out. The next step is to call the f_EPTF_ILog_logAll function again
// without input value. The callback functions that should log out the elements checks, if the chain elements are the same as the expected, just like the order of the chains during
// the logging mechanism. The last step is to the tested function for the third time and check the output. It should not log out anything as all the chain were deleted before.
//
// Expected Result: pass verdict. The test result is pass if the checks do not fail and the order of the logged chains are the same in case of the second and the third time.
//
///////////////////////////////////////////////////////////
testcase tc_ILog_logAll_firstNotDeleteSecondDeleteChains() runs on EPTF_ILog_Test_CT {
// Init
f_EPTF_ILog_init_CT("ILog_Test");
// Registering two databases and three chains
var integer vl_dbId0 := f_EPTF_ILog_register_DB(refers( f_logData1 ), {1});
var integer vl_dbId1 := f_EPTF_ILog_register_DB(refers( f_logData1 ), {2});
var integer vl_chain0 := f_EPTF_ILog_newChain( "Chain11", detailed, refers(f_logHeader), {0});
var integer vl_chain1 := f_EPTF_ILog_newChain( "Chain21", detailed, refers(f_logHeader), {1});
var integer vl_chain2 := f_EPTF_ILog_newChain( "Chain22", detailed, refers(f_logHeader), {2});
var EPTF_IntegerList vl_chainList0 := {vl_chain0};
var EPTF_IntegerList vl_chainList1 := {vl_chain1};
var EPTF_IntegerList vl_chainList2 := {vl_chain2};
var logDBInt vl_chainOrder := {1, 2, 3};
var logDBInt vl_chainOrderSecond := {1, 2, 3, 1, 2, 3}
for(var integer vl_i := 0; vl_i <10; vl_i := vl_i +1 ){
v_db1[f_EPTF_ILog_addToChains(vl_dbId0, vl_chainList0)] := vl_i;
}
for(var integer vl_j := 0; vl_j <10; vl_j := vl_j +1 ){
if(vl_j rem 2 == 0){
v_db2[f_EPTF_ILog_addToChains(vl_dbId1, vl_chainList1)] := "Chain21"&int2str(vl_j);
} else {
v_db2[f_EPTF_ILog_addToChains(vl_dbId1, vl_chainList2)] := "Chain22"&int2str(vl_j);
}
}
f_EPTF_ILog_logAll(false);
// The sequence of the chain numbers are stored in a database in case of the call of the f_logHeader callback function.
// The next check verifies if the sequence that was stored is the same as the expected.
if( match(vl_chainOrder, v_logOrder) ){
setverdict( pass );
} else {
setverdict( fail, match(vl_chainOrder, v_logOrder) );
}
f_EPTF_ILog_logAll();
if( match(vl_chainOrderSecond, v_logOrder) ){
setverdict( pass );
} else {
setverdict( fail, match(vl_chainOrder, v_logOrder) );
}
f_EPTF_ILog_logAll();
if( match(vl_chainOrderSecond, v_logOrder) ){
setverdict( pass );
} else {
setverdict( fail, match(vl_chainOrder, v_logOrder) );
}
f_EPTF_Base_stopAll(pass);
}
///////////////////////////////////////////////////////////
// Testcase: tc_ILog_logAll_withLogToMultipleChains
//
// Purpose: The test of the f_EPTF_ILog_addToChain function with empty chain list as input. The f_EPTF_ILog_addToChain function adds a new element to all of the chains in the input list.
// If the function gets an empty chain list as input, it gives the element to all the chains that were registered before. The test checks if the function adds the new element to all
// chains or not.
//
// Action: After the initialization process, one user database is registered and two chains are created. All of the chains are filled with elements in a for cycle. The function is
// called with the empty list as well. This method results in duplicated element values in the chains. The test checks if the log result is the same as a predefined reference database.
//
// Expected Result: pass verdict. The test result is pass if the checks do not fail and no error occurs.
//
///////////////////////////////////////////////////////////
testcase tc_ILog_logAll_withLogToMultipleChains() runs on EPTF_ILog_Test_CT {
// Init
f_EPTF_ILog_init_CT("ILog_Test");
// Registering one database and creating two chains
var integer vl_dbId0 := f_EPTF_ILog_register_DB(refers( f_logData2 ), {0});
var integer vl_chain0 := f_EPTF_ILog_newChain( "Chain11", detailed, refers(f_logHeader), {0});
var integer vl_chain1 := f_EPTF_ILog_newChain( "Chain21", short, refers(f_logHeader), {1});
var EPTF_IntegerList vl_chainList0 := {vl_chain0};
var EPTF_IntegerList vl_chainList1 := {vl_chain1};
var EPTF_IntegerList vl_chainList2 := {};
var logDBInt vl_chainOrder :={1, 2 };
for(var integer vl_i := 0; vl_i <5; vl_i := vl_i +1 ){
v_db1[f_EPTF_ILog_addToChains(vl_dbId0, vl_chainList0)] := vl_i;
v_db1[f_EPTF_ILog_addToChains(vl_dbId0, vl_chainList1)] := vl_i;
v_db1[f_EPTF_ILog_addToChains(vl_dbId0, vl_chainList2)] := vl_i+5;
}
f_EPTF_ILog_logAll();
// The sequence of the chain numbers are stored in a database in case of the call of the f_logHeader callback function.
// The next check verifies if the sequence that was stored is the same as the expected.
if( match(vl_chainOrder, v_logOrder) ){
setverdict( pass );
} else {
setverdict( fail, match(vl_chainOrder, v_logOrder) );
}
f_EPTF_Base_stopAll(pass);
}
///////////////////////////////////////////////////////////
// Testcase: tc_ILog_deleteAllChains
//
// Purpose: Test the f_EPTF_ILog_deleteAll function. This function deletes all the chains and queues in the ILog component, this function is used for cleanup.
//
// Action: After the initialization, the testcase registers a database and creates ten chains. After this the f_EPTF_ILog_deleteAll function is called.
// The test is successful if the function operates without error and no chains were logged out.
//
// Expected Result: pass verdict.The test result is pass if no errors occur during the test run.
//
///////////////////////////////////////////////////////////
testcase tc_ILog_deleteAllChains() runs on EPTF_ILog_Test_CT {
// Init
f_EPTF_ILog_init_CT("ILog_Test");
var integer vl_dummyInt;
for(var integer vl_i := 0; vl_i <10; vl_i := vl_i +1 ){
vl_dummyInt := f_EPTF_ILog_newChain( "Chain11", detailed, refers(f_logHeader), {vl_i});
}
f_EPTF_ILog_deleteAll();
f_EPTF_ILog_logAll();
// Checks the size of the database that registers the log sequence of the chains
if(sizeof(v_logOrder) == 0){
setverdict(pass);
} else {
setverdict(fail, "Instead of 0, "&int2str(sizeof(v_logOrder))&" chains were logged out!");
}
f_EPTF_Base_stopAll(pass);
}
///////////////////////////////////////////////////////////
// Testcase: tc_ILog_compactTest
//
// Purpose: The purpose of this test is to use all functions in order to test the reusing of chains and user database elements.
//
// Action: After the initialization, the testcase registers three databases and creates four chains. It fills all the chains with elements and then logs out the first chain (and also deletes it).
// The next step is to create a new chain. Th id of the new chain has to be the same as the id of the previously deleted chain, as the chains are reused. The test adds elements to
// the new chain and then logs out the third chain. Finally it logs out all chains and checks the sequence of logging. The f_EPTF_ILog_logAll function logs out hte second, the
// fourth and finally the last chain with the first id.
//
// Expected Result: pass verdict. If no error occurs and all the checks are ok the test verdict is set to pass.
//
///////////////////////////////////////////////////////////
testcase tc_ILog_compactTest() runs on EPTF_ILog_Test_CT {
// Init
f_EPTF_ILog_init_CT("ILog_Test");
// Registering three databases
var integer vl_dbId0 := f_EPTF_ILog_register_DB(refers( f_logData3 ), {1});
var integer vl_dbId1 := f_EPTF_ILog_register_DB(refers( f_logData3 ), {2});
var integer vl_dbId2 := f_EPTF_ILog_register_DB(refers( f_logData3 ), {3});
// Creating four chains
var integer vl_chain0 := f_EPTF_ILog_newChain( "Chain31", detailed, refers(f_logHeader), {3});
var integer vl_chain1 := f_EPTF_ILog_newChain( "Chain21", detailed, refers(f_logHeader), {1});
var integer vl_chain2 := f_EPTF_ILog_newChain( "Chain22", detailed, refers(f_logHeader), {2});
var integer vl_chain3 := f_EPTF_ILog_newChain( "Chain11", detailed, refers(f_logHeader), {0});
var EPTF_IntegerList vl_chainList0 := {vl_chain0};
var EPTF_IntegerList vl_chainList1 := {vl_chain1};
var EPTF_IntegerList vl_chainList2 := {vl_chain2};
var EPTF_IntegerList vl_chainList3 := {vl_chain3};
// Expected sequence of the logged out chain
var logDBInt vl_chainOrder :={1, 3, 2, 4, 1};
// Filling chain3 with elements
for(var integer vl_i := 0; vl_i <10; vl_i := vl_i +1 ){
v_db1[f_EPTF_ILog_addToChains(vl_dbId0, vl_chainList3)] := vl_i;
}
//Filling chain1 and chain2 with elements
for(var integer vl_j := 0; vl_j <10; vl_j := vl_j +1 ){
if(vl_j rem 2 == 0){
v_db2[f_EPTF_ILog_addToChains(vl_dbId1, vl_chainList1)] := "Chain21"&int2str(vl_j);
} else {
v_db2[f_EPTF_ILog_addToChains(vl_dbId1, vl_chainList2)] := "Chain22"&int2str(vl_j);
}
}
// Filling chain0 with elements
v_db3[f_EPTF_ILog_addToChains(vl_dbId2, vl_chainList0)] := {31, "FirstOfDB3"};
v_db3[f_EPTF_ILog_addToChains(vl_dbId2, vl_chainList0)] := {32, "SecondOfDB3"};
// Logging out and delete chain0
if(f_EPTF_ILog_logChain(vl_chain0) == 0){
setverdict(pass);
} else {
setverdict(fail, "Error occured during the operation of the logChain function!");
}
// Create a new chain
if( vl_chain0 == f_EPTF_ILog_newChain( "Chain23", detailed, refers(f_logHeader), {0})){
setverdict(pass);
} else {
setverdict(fail, "Chain wasn't reused!")
}
// Add new elements to the new chain
v_db2[f_EPTF_ILog_addToChains(vl_dbId1, vl_chainList0)] := "1110";
v_db2[f_EPTF_ILog_addToChains(vl_dbId1, vl_chainList0)] := "1111";
// Log out and delete chain2
if(f_EPTF_ILog_logChain(vl_chain2) == 0){
setverdict(pass);
} else {
setverdict(fail, "Error occured during the operation of the logChain function!");
}
// Log out and delete all remaining chains
f_EPTF_ILog_logAll();
// Check the logging sequence
if( match(vl_chainOrder, v_logOrder) ){
setverdict( pass );
} else {
setverdict( fail, match(vl_chainOrder, v_logOrder) );
}
setverdict(pass);
}
control{
execute(tc_ILog_init());
execute(tc_ILog_registerDB());
execute(tc_ILog_createNewChain());
execute(tc_ILog_getName());
execute(tc_ILog_getName_NegativeTest_nonExistingChainId());
execute(tc_ILog_addElementToChain());
execute(tc_ILog_addElementToChain_NegativeTest_nonExistingChainId());
execute(tc_ILog_addElementToChain_NegativeTest_nonExistingDbId());
execute(tc_ILog_deleteChain());
execute(tc_ILog_deleteChain_NegativeTest_nonExistingChainId());
execute(tc_ILog_logChain());
execute(tc_ILog_logChain_NegativeTest_nonExistingChainId());
execute(tc_ILog_logChain_NegativeTest_addElementToDeletedChain());
execute(tc_ILog_logChain_addElementToLoggedButNotDeletedChain());
execute(tc_ILog_logAll());
execute(tc_ILog_logAll_firstNotDeleteSecondDeleteChains());
execute(tc_ILog_logAll_withLogToMultipleChains());
execute(tc_ILog_deleteAllChains());
execute(tc_ILog_compactTest());
}
}