stif/TestEngine/src/TestEngine.cpp
branchRCL_3
changeset 8 cfe32394fcd5
parent 0 a03f92240627
child 10 381827f66490
equal deleted inserted replaced
7:8a14024f954a 8:cfe32394fcd5
  1349 
  1349 
  1350         ReadEngineDefaultsL( parser, settings );
  1350         ReadEngineDefaultsL( parser, settings );
  1351 
  1351 
  1352         SetLoggerSettings( loggerSettings ) ;
  1352         SetLoggerSettings( loggerSettings ) ;
  1353 
  1353 
  1354         ReadTestModulesL( parser );
  1354         TRAP(r, ReadTestModulesL( parser ));
       
  1355         if(r != KErrNone)
       
  1356             {
       
  1357             __TRACE(KError, (CStifLogger::ERed, _L("Reading test modules finished with error [%d]"), r));
       
  1358             User::Leave(r);
       
  1359             }
  1355 
  1360 
  1356         CleanupStack::PopAndDestroy( settings );
  1361         CleanupStack::PopAndDestroy( settings );
  1357         CleanupStack::PopAndDestroy( parser );
  1362         CleanupStack::PopAndDestroy( parser );
  1358         __TRACE( KInit, ( _L( "Configuration file reading finished" ) ) );
  1363         __TRACE( KInit, ( _L( "Configuration file reading finished" ) ) );
  1359         }
  1364         }
  1828     CStifSectionParser* sectionParser = NULL;
  1833     CStifSectionParser* sectionParser = NULL;
  1829     CStifItemParser* item = NULL;
  1834     CStifItemParser* item = NULL;
  1830 
  1835 
  1831     sectionParser = aParser->SectionL(aSectionStart, aSectionEnd);
  1836     sectionParser = aParser->SectionL(aSectionStart, aSectionEnd);
  1832 
  1837 
       
  1838     TBool sectionOK;
       
  1839 
  1833     while(sectionParser)
  1840     while(sectionParser)
  1834         {
  1841         {
       
  1842         sectionOK = ETrue;
  1835         __TRACE(KInit, (_L("Found '%S' and '%S' sections"), &aSectionStart, &aSectionEnd));
  1843         __TRACE(KInit, (_L("Found '%S' and '%S' sections"), &aSectionStart, &aSectionEnd));
  1836         CleanupStack::PushL(sectionParser);
  1844         CleanupStack::PushL(sectionParser);
  1837         __TRACE(KInit, (_L("Starting to read module information")));
  1845         __TRACE(KInit, (_L("Starting to read module information")));
  1838 
  1846 
  1839         // Get name of module
  1847         // Get name of module
  1840         _LIT(KModuleName, "ModuleName=");
  1848         _LIT(KModuleName, "ModuleName=");
  1841         item = sectionParser->GetItemLineL(KModuleName);
  1849         item = sectionParser->GetItemLineL(KModuleName);
  1842         CleanupStack::PushL(item);
  1850         CleanupStack::PushL(item);
  1843         if(!item)
  1851         if(!item)
  1844             {
  1852             {
  1845             CleanupStack::PopAndDestroy(item);
  1853             __TRACE(KError, (CStifLogger::ERed, _L("'%S' not found from Module section. Skipping whole section."), &KModuleName));
  1846             __TRACE(KError, (CStifLogger::ERed, _L("'%S' not found from Module section"), &KModuleName));
  1854             sectionOK = EFalse;
  1847             LeaveIfErrorWithNotify(KErrNotFound);
       
  1848             }
  1855             }
  1849         else
  1856         else
  1850             {
  1857             {
  1851             __TRACE(KInit, (_L("'%S' found"), &KModuleName));
  1858             __TRACE(KInit, (_L("'%S' found"), &KModuleName));
  1852             }
  1859             }
  1853 
  1860 
  1854         TPtrC name;
       
  1855         TName moduleName;
  1861         TName moduleName;
  1856         TInt ret(KErrNone);
  1862         TInt ret(KErrNone);
  1857         ret = item->GetString(KModuleName, name);
  1863 
  1858         if(ret != KErrNone)
  1864         if(sectionOK)
  1859             {
  1865             {
  1860             CleanupStack::PopAndDestroy(item);
  1866             TPtrC name;
  1861             __TRACE(KError, (CStifLogger::ERed, _L("Module name parsing left with error %d"), ret));
  1867             ret = item->GetString(KModuleName, name);
  1862             LeaveIfErrorWithNotify(ret);
  1868             if(ret != KErrNone)
  1863             }
       
  1864         else
       
  1865             {
       
  1866             __TRACE(KInit, (_L("Module '%S' found from ini-file"), &name));
       
  1867             moduleName.Copy(name);
       
  1868             moduleName.LowerCase();
       
  1869             ret = aModuleList->AddTestModule(moduleName);
       
  1870             if(ret != KErrNone && ret != KErrAlreadyExists)
       
  1871                 {
  1869                 {
  1872                 CleanupStack::PopAndDestroy(item);
  1870                 __TRACE(KError, (CStifLogger::ERed, _L("Module name parsing ended with error [%d]. Skipping whole section"), ret));
  1873                 __TRACE(KError, (CStifLogger::ERed, _L("Could not add module to list of modules. Error %d"), ret));
  1871                 sectionOK = EFalse;
  1874                 LeaveIfErrorWithNotify(ret);
       
  1875 				}
       
  1876             }
       
  1877         CleanupStack::PopAndDestroy(item);
       
  1878 
       
  1879         //Get pointer to added module
       
  1880         CTestModuleInfo* moduleInfo = aModuleList->GetModule(moduleName);
       
  1881         if(!moduleInfo)
       
  1882             {
       
  1883             __TRACE(KError, (CStifLogger::ERed, _L("Could not add get module info from list")));
       
  1884             LeaveIfErrorWithNotify(KErrNotFound);
       
  1885 			}
       
  1886 
       
  1887         // Get ini file, if it exists
       
  1888         __TRACE(KInit, (_L("Start parsing ini file")));
       
  1889         _LIT(KIniFile, "IniFile=");
       
  1890         item = sectionParser->GetItemLineL(KIniFile);
       
  1891         if(item)
       
  1892             {
       
  1893             __TRACE(KInit, (_L("'%S' found"), &KIniFile));
       
  1894             CleanupStack::PushL(item);
       
  1895             TPtrC iniFile;
       
  1896             ret = item->GetString(KIniFile, iniFile);
       
  1897             if(ret == KErrNone)
       
  1898                 {
       
  1899                 // Module inifile (might be empty) OK
       
  1900                 TFileName filename;
       
  1901                 filename.Copy(iniFile);
       
  1902                 TStifUtil::CorrectFilePathL( filename );
       
  1903                 filename.LowerCase();
       
  1904                 __TRACE(KInit, (CStifLogger::EBold, _L("Initialization file '%S' found, file can be empty"), &iniFile));
       
  1905                 moduleInfo->SetIniFile(filename);
       
  1906                 }
  1872                 }
  1907             else
  1873             else
  1908                 {
  1874                 {
  1909                 __TRACE(KInit, (_L("Initialization file not found")));
  1875                 __TRACE(KInit, (_L("Module '%S' found from ini-file"), &name));
       
  1876                 moduleName.Copy(name);
       
  1877                 moduleName.LowerCase();
       
  1878                 ret = aModuleList->AddTestModule(moduleName);
       
  1879                 if(ret != KErrNone && ret != KErrAlreadyExists)
       
  1880                     {
       
  1881                     CleanupStack::PopAndDestroy(item);
       
  1882                     __TRACE(KError, (CStifLogger::ERed, _L("Could not add module to list of modules. Error %d"), ret));
       
  1883                     LeaveIfErrorWithNotify(ret);
       
  1884                     }
  1910                 }
  1885                 }
  1911             CleanupStack::PopAndDestroy(item);
  1886             }
  1912             }
  1887         CleanupStack::PopAndDestroy(item);
  1913         else
  1888 
  1914             {
  1889         //Get pointer to added module
  1915             __TRACE(KInit, (_L("'%S' not found"), &KIniFile));
  1890         if(sectionOK)
  1916             }
  1891             {
  1917 
  1892             CTestModuleInfo* moduleInfo = aModuleList->GetModule(moduleName);
  1918         // Get config (testcase) file
  1893             if(!moduleInfo)
  1919         __TRACE(KInit, (_L("Start parsing cfg files")));
       
  1920         TPtrC cfgTag;
       
  1921         for(TInt i = 0; i < 2; i++)
       
  1922             {
       
  1923             //Set tag for config files
       
  1924             if(i == 0)
       
  1925                 {
  1894                 {
  1926                 cfgTag.Set(_L("ConfigFile="));
  1895                 __TRACE(KError, (CStifLogger::ERed, _L("Could not add get module info from list")));
       
  1896                 LeaveIfErrorWithNotify(KErrNotFound);
  1927                 }
  1897                 }
  1928                 else
  1898     
       
  1899             // Get ini file, if it exists
       
  1900             __TRACE(KInit, (_L("Start parsing ini file")));
       
  1901             _LIT(KIniFile, "IniFile=");
       
  1902             item = sectionParser->GetItemLineL(KIniFile);
       
  1903             if(item)
  1929                 {
  1904                 {
  1930                 cfgTag.Set(_L("TestCaseFile="));
  1905                 __TRACE(KInit, (_L("'%S' found"), &KIniFile));
  1931                 }
       
  1932             //Read data
       
  1933             item = sectionParser->GetItemLineL(cfgTag);
       
  1934             while(item)
       
  1935                 {
       
  1936                 CleanupStack::PushL(item);
  1906                 CleanupStack::PushL(item);
  1937                 __TRACE(KInit, (_L("Item '%S' found"), &cfgTag));
  1907                 TPtrC iniFile;
  1938                 TPtrC cfgFile;
  1908                 ret = item->GetString(KIniFile, iniFile);
  1939                 ret = item->GetString(cfgTag, cfgFile);
       
  1940                 if(ret == KErrNone)
  1909                 if(ret == KErrNone)
  1941                     {
  1910                     {
  1942                     TFileName ifile;
  1911                     // Module inifile (might be empty) OK
  1943                     ifile.Copy(cfgFile);
  1912                     TFileName filename;
  1944                     TStifUtil::CorrectFilePathL( ifile );
  1913                     filename.Copy(iniFile);
  1945                     ifile.LowerCase();
  1914                     TStifUtil::CorrectFilePathL( filename );
  1946                     __TRACE(KInit, (_L("Configuration file '%S' found"), &ifile));
  1915                     filename.LowerCase();
  1947                     moduleInfo->AddCfgFile(ifile);
  1916                     __TRACE(KInit, (CStifLogger::EBold, _L("Initialization file '%S' found, file can be empty"), &iniFile));
       
  1917                     moduleInfo->SetIniFile(filename);
  1948                     }
  1918                     }
  1949                 else
  1919                 else
  1950                     {
  1920                     {
  1951                     __TRACE(KInit, (_L("Configuration file not found")));
  1921                     __TRACE(KInit, (_L("Initialization file not found")));
  1952                     }
  1922                     }
  1953                 CleanupStack::PopAndDestroy(item);
  1923                 CleanupStack::PopAndDestroy(item);
  1954                 item = sectionParser->GetNextItemLineL(cfgTag);
       
  1955                 }
  1924                 }
  1956             }
  1925             else
  1957 
  1926                 {
  1958         __TRACE(KInit, (_L("Module '%S' information read correctly"), &moduleName));
  1927                 __TRACE(KInit, (_L("'%S' not found"), &KIniFile));
       
  1928                 }
       
  1929     
       
  1930             // Get config (testcase) file
       
  1931             __TRACE(KInit, (_L("Start parsing cfg files")));
       
  1932             TPtrC cfgTag;
       
  1933             for(TInt i = 0; i < 2; i++)
       
  1934                 {
       
  1935                 //Set tag for config files
       
  1936                 if(i == 0)
       
  1937                     {
       
  1938                     cfgTag.Set(_L("ConfigFile="));
       
  1939                     }
       
  1940                     else
       
  1941                     {
       
  1942                     cfgTag.Set(_L("TestCaseFile="));
       
  1943                     }
       
  1944                 //Read data
       
  1945                 item = sectionParser->GetItemLineL(cfgTag);
       
  1946                 while(item)
       
  1947                     {
       
  1948                     CleanupStack::PushL(item);
       
  1949                     __TRACE(KInit, (_L("Item '%S' found"), &cfgTag));
       
  1950                     TPtrC cfgFile;
       
  1951                     ret = item->GetString(cfgTag, cfgFile);
       
  1952                     if(ret == KErrNone)
       
  1953                         {
       
  1954                         TFileName ifile;
       
  1955                         ifile.Copy(cfgFile);
       
  1956                         TStifUtil::CorrectFilePathL( ifile );
       
  1957                         ifile.LowerCase();
       
  1958                         __TRACE(KInit, (_L("Configuration file '%S' found"), &ifile));
       
  1959                         moduleInfo->AddCfgFile(ifile);
       
  1960                         }
       
  1961                     else
       
  1962                         {
       
  1963                         __TRACE(KInit, (_L("Configuration file not found")));
       
  1964                         }
       
  1965                     CleanupStack::PopAndDestroy(item);
       
  1966                     item = sectionParser->GetNextItemLineL(cfgTag);
       
  1967                     }
       
  1968                 }
       
  1969     
       
  1970             __TRACE(KInit, (_L("Module '%S' information read correctly"), &moduleName));
       
  1971             }
       
  1972         else
       
  1973             {
       
  1974             __TRACE(KError, (_L("Module '%S' information skipped"), &moduleName));
       
  1975             }
  1959 
  1976 
  1960         // Get next section...
  1977         // Get next section...
  1961         CleanupStack::PopAndDestroy(sectionParser);
  1978         CleanupStack::PopAndDestroy(sectionParser);
  1962         sectionParser = aParser->NextSectionL(aSectionStart, aSectionEnd);
  1979         sectionParser = aParser->NextSectionL(aSectionStart, aSectionEnd);
  1963         }
  1980         }
  1996     // Parse Test Module information
  2013     // Parse Test Module information
  1997     _LIT(KTestModuleStart, "[New_Module]");
  2014     _LIT(KTestModuleStart, "[New_Module]");
  1998     _LIT(KTestModuleEnd, "[End_Module]");
  2015     _LIT(KTestModuleEnd, "[End_Module]");
  1999 
  2016 
  2000     __TRACE(KInit, (_L("Starting to search module sections")));
  2017     __TRACE(KInit, (_L("Starting to search module sections")));
  2001     ParseTestModulesL(aParser, moduleList, KTestModuleStart, KTestModuleEnd);
  2018     TRAPD(err, ParseTestModulesL(aParser, moduleList, KTestModuleStart, KTestModuleEnd));
       
  2019     if(err != KErrNone)
       
  2020         {
       
  2021         __TRACE(KError, (CStifLogger::ERed, _L("Parsing test modules returned error [%d]"), err));
       
  2022         User::Leave(err);
       
  2023         }
  2002     __TRACE(KInit, (CStifLogger::EBold, _L("End parsing test modules")));
  2024     __TRACE(KInit, (CStifLogger::EBold, _L("End parsing test modules")));
  2003     __TRACE(KInit, (_L("")));
  2025     __TRACE(KInit, (_L("")));
  2004 
  2026 
  2005     //Now, find included test modules and also add them to CTestModuleList object.
  2027     //Now, find included test modules and also add them to CTestModuleList object.
  2006     _LIT(KIncludeModuleStart, "[New_Include_Module]");
  2028     _LIT(KIncludeModuleStart, "[New_Include_Module]");