featuremgmt/featuremgr/test/rtest/src/t_fmgrstartup.cpp
branchRCL_3
changeset 10 31a8f755b7fe
parent 8 fa9941cf3867
child 23 26645d81f48d
equal deleted inserted replaced
9:667e88a979d7 10:31a8f755b7fe
     1 // Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
     1 // Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
    20 
    20 
    21 static TInt TheProcessHandleCount = 0;
    21 static TInt TheProcessHandleCount = 0;
    22 static TInt TheThreadHandleCount = 0;
    22 static TInt TheThreadHandleCount = 0;
    23 static TInt TheAllocatedCellsCount = 0;
    23 static TInt TheAllocatedCellsCount = 0;
    24 
    24 
    25 #ifdef EXTENDED_FEATURE_MANAGER_TEST
    25 #ifdef _DEBUG
    26 static const TInt KBurstRate = 20;
    26 static const TInt KBurstRate = 20;
    27 #endif
    27 #endif
    28 
    28 
    29 ///////////////////////////////////////////////////////////////////////////////////////
    29 ///////////////////////////////////////////////////////////////////////////////////////
    30 
    30 
    31 static RTest TheTest(_L("t_fmgrstartup"));
    31 static RTest TheTest(_L("t_fmgrstartup"));
       
    32 
       
    33 #ifdef EXTENDED_FEATURE_MANAGER_TEST
    32 _LIT( KZOrgFeaturesFile, "Z:\\Private\\10205054\\features.dat" );
    34 _LIT( KZOrgFeaturesFile, "Z:\\Private\\10205054\\features.dat" );
    33 #ifdef EXTENDED_FEATURE_MANAGER_TEST
    35 _LIT( KFeaturesFile, "C:\\Private\\102836E5\\features.dat" );
    34 _LIT( KZFeaturesFile, "C:\\Private\\102836E5\\features.dat" );
    36 _LIT( KFeaturesDir, "C:\\Private\\102836E5\\" );
    35 _LIT( KZFeaturesDir, "C:\\Private\\102836E5\\" );
    37 #endif
    36 #else
       
    37 _LIT( KZFeaturesFile, "Z:\\Private\\10205054\\features.dat" );
       
    38 _LIT( KZFeaturesDir, "Z:\\Private\\10205054\\" );
       
    39 #endif // EXTENDED_FEATURE_MANAGER_TEST
       
    40 
    38 
    41 ///////////////////////////////////////////////////////////////////////////////////////
    39 ///////////////////////////////////////////////////////////////////////////////////////
    42 
    40 
    43 //Deletes all created test files.
    41 //Deletes all created test files.
    44 void DestroyTestEnv()
    42 void DestroyTestEnv()
    45     {
    43     {
       
    44     //KFeaturesDir is defined only if EXTENDED_FEATURE_MANAGER_TEST is defined     
       
    45 #ifdef EXTENDED_FEATURE_MANAGER_TEST
       
    46     RFs fs;
       
    47     TInt err = fs.Connect();
       
    48     if(err == KErrNone)
       
    49         {
       
    50         (void)fs.Delete(KFeaturesFile);
       
    51         }
       
    52     fs.Close();
       
    53 #endif        
    46     }
    54     }
    47 
    55 
    48 ///////////////////////////////////////////////////////////////////////////////////////
    56 ///////////////////////////////////////////////////////////////////////////////////////
    49 ///////////////////////////////////////////////////////////////////////////////////////
    57 ///////////////////////////////////////////////////////////////////////////////////////
    50 //Test macros and functions
    58 //Test macros and functions
   130 @SYMTestActions         
   138 @SYMTestActions         
   131 @SYMTestExpectedResults Test must not fail
   139 @SYMTestExpectedResults Test must not fail
   132 @SYMDEF                 DEF144262
   140 @SYMDEF                 DEF144262
   133 */
   141 */
   134 void FeatMgrServerStartupOomTest()
   142 void FeatMgrServerStartupOomTest()
   135 //TODO - panics in CFeatMgrServer::LoadPluginsL() because the error is KErrNoMemory
       
   136     {
   143     {
   137     TInt err = KErrNoMemory;
   144     TInt err = KErrNoMemory;
   138     TInt failingAllocationNo = 0;
   145     TInt failingAllocationNo = 0;
   139     TheTest.Printf(_L("Iteration:\r\n"));
   146     TheTest.Printf(_L("Iteration:\r\n"));
   140     while(err == KErrNoMemory)
   147     while(err == KErrNoMemory)
   169     for(;err<KErrNone;++cnt)
   176     for(;err<KErrNone;++cnt)
   170         {
   177         {
   171         TheTest.Printf(_L("===Iteration %d. Simulated error:\r\n"), cnt);       
   178         TheTest.Printf(_L("===Iteration %d. Simulated error:\r\n"), cnt);       
   172         for (TInt fsError=KErrNotFound;fsError>=KErrBadName;--fsError)
   179         for (TInt fsError=KErrNotFound;fsError>=KErrBadName;--fsError)
   173             {
   180             {
   174             if(fsError == KErrNotFound || fsError == KErrCorrupt || fsError == KErrPathNotFound || fsError == KErrEof)
   181 //            if(fsError == KErrNotFound || fsError == KErrCorrupt || fsError == KErrPathNotFound || fsError == KErrEof)
   175                 {
   182 //                {
   176                 continue;//TODO: the server code panics
   183 //                continue;//The server code panics
   177                 }
   184 //                }
   178             TheTest.Printf(_L("%d "), fsError);
   185             TheTest.Printf(_L("%d "), fsError);
   179             (void)fs.SetErrorCondition(fsError, cnt);
   186             (void)fs.SetErrorCondition(fsError, cnt);
   180             TRAP(err, CreateAndDestroyFeatMgrServerL());
   187             TRAP(err, CreateAndDestroyFeatMgrServerL());
   181             (void)fs.SetErrorCondition(KErrNone);
   188             (void)fs.SetErrorCondition(KErrNone);
   182             }
   189             }
   184         }
   191         }
   185     fs.Close();
   192     fs.Close();
   186     TheTest.Printf(_L("\r\n===File I/O error simulation test succeeded on iteration %d===\r\n"), cnt);
   193     TheTest.Printf(_L("\r\n===File I/O error simulation test succeeded on iteration %d===\r\n"), cnt);
   187     }
   194     }
   188 
   195 
   189 void PreTest()
   196 void CreateTestEnv()
   190     {
   197     {
   191     // Connect session
   198     //KFeaturesDir is defined only if EXTENDED_FEATURE_MANAGER_TEST is defined     
   192     RFs fsSession;
   199 #ifdef EXTENDED_FEATURE_MANAGER_TEST    
   193     User::LeaveIfError(fsSession.Connect()); 
   200     RFs fs;
   194     
   201     TInt err = fs.Connect();
   195     TEntry entry;
   202     TEST2(err, KErrNone);
   196     TInt err = fsSession.Entry(KZFeaturesDir, entry);
   203     
   197     if (err == KErrNotFound)
   204     err = fs.MkDir(KFeaturesDir);
   198         {
   205     TEST (err == KErrNone || err == KErrAlreadyExists);
   199         err = fsSession.MkDir(KZFeaturesDir);
   206     
   200         }
   207     (void)fs.Delete(KFeaturesFile);
       
   208     err = BaflUtils::CopyFile(fs, KZOrgFeaturesFile, KFeaturesDir);
   201     TEST2 (err, KErrNone);
   209     TEST2 (err, KErrNone);
   202     err = BaflUtils::CopyFile(fsSession, KZOrgFeaturesFile, KZFeaturesDir);
   210     
   203     TEST2 (err, KErrNone);
   211     fs.Close();
   204     
   212 #endif
   205     // close file server session
       
   206     fsSession.Close();
       
   207 
       
   208     }
       
   209 
       
   210 void PostTest()
       
   211     {
       
   212     // Connect session
       
   213     RFs fsSession;
       
   214     User::LeaveIfError(fsSession.Connect()); 
       
   215     
       
   216     TEntry entry;
       
   217     TInt err = fsSession.Entry(KZFeaturesDir, entry);
       
   218     if (err == KErrNone)
       
   219         {
       
   220         err = BaflUtils::DeleteFile(fsSession,KZFeaturesFile);
       
   221         TEST2 (err, KErrNone);
       
   222         
       
   223         }
       
   224     TEST2 (err, KErrNone);
       
   225     
       
   226     // close file server session
       
   227     fsSession.Close();
       
   228     }
   213     }
   229 
   214 
   230 void DoTestsL()
   215 void DoTestsL()
   231     {
   216     {
   232     CActiveScheduler* scheduler = new CActiveScheduler;
   217     CActiveScheduler* scheduler = new CActiveScheduler;
   233     TEST(scheduler != NULL);
   218     TEST(scheduler != NULL);
   234     CActiveScheduler::Install(scheduler);
   219     CActiveScheduler::Install(scheduler);
   235     
   220     
   236     TheTest.Start(_L("@SYMTestCaseID:PDS-EFM-CT-4109 CFeatMgrServer::NewLC() OOM test"));
   221     TheTest.Start(_L("@SYMTestCaseID:PDS-EFM-CT-4109 CFeatMgrServer::NewLC() OOM test"));
   237     PreTest();
       
   238     FeatMgrServerStartupOomTest();
   222     FeatMgrServerStartupOomTest();
   239 
   223 
   240     TheTest.Next(_L("@SYMTestCaseID:PDS-EFM-CT-4110 CFeatMgrServer::NewLC() file I/O error simulation test"));
   224     TheTest.Next(_L("@SYMTestCaseID:PDS-EFM-CT-4110 CFeatMgrServer::NewLC() file I/O error simulation test"));
   241     FeatMgrServerStartupFileIoTest();
   225     FeatMgrServerStartupFileIoTest();
   242     PostTest();
       
   243     
   226     
   244     delete scheduler;
   227     delete scheduler;
   245     }
   228     }
   246 
   229 
   247 TInt E32Main()
   230 TInt E32Main()
   251     CTrapCleanup* tc = CTrapCleanup::New();
   234     CTrapCleanup* tc = CTrapCleanup::New();
   252     TheTest(tc != NULL);
   235     TheTest(tc != NULL);
   253     
   236     
   254     __UHEAP_MARK;
   237     __UHEAP_MARK;
   255     
   238     
       
   239     CreateTestEnv();
   256     TRAPD(err, DoTestsL());
   240     TRAPD(err, DoTestsL());
   257     DestroyTestEnv();
   241     DestroyTestEnv();
   258     TEST2(err, KErrNone);
   242     TEST2(err, KErrNone);
   259 
   243 
   260     __UHEAP_MARKEND;
   244     __UHEAP_MARKEND;