os/kernelhwsrv/kerneltest/f32test/fsstress/t_sess.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     1 // Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     4 // under the terms of the License "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 // f32test\fsstress\t_sess.cpp
    15 //
    16 //
    17 
    18 #include "t_sess.h"
    19 
    20 #include "t_server.h"
    21 #include "t_chlffs.h"
    22 
    23 GLDEF_D RTest test(_L("T_SESS"));
    24 GLDEF_D TFileName gTestSessionPath;
    25 
    26 // These objects are too large to be placed on the stack - ~15 sessions is enough
    27 // to cause a stack overflow on ARM4.
    28 const TInt KMaxNumberSessions=25;
    29 RFs gSession[KMaxNumberSessions];
    30 TSessionTest gTestObject[KMaxNumberSessions];
    31 
    32 
    33 LOCAL_C void SetSessionPath(RFs aFs,TChar aDriveLetter)
    34 //
    35 //	Set the session path for a RFs connection to aDrive
    36 //
    37 	{
    38 	gTestSessionPath=(_L("?:\\SESSION_TEST\\"));
    39 	gTestSessionPath[0]=(TText)aDriveLetter;
    40 	TInt r=aFs.SetSessionPath(gTestSessionPath);
    41 	test(r==KErrNone);
    42 	r=aFs.MkDirAll(gTestSessionPath);
    43 	test(r==KErrNone || r==KErrAlreadyExists);
    44 	}
    45 
    46 
    47 GLDEF_C void CallTestsL()
    48 //
    49 //	This test makes a number of fileserver connections (sessions)
    50 //	The fileserver is stressed by running these sessions concurrently, swapping
    51 //	between them whilst testing various fileserver API functions
    52 //	Further testing of the fileserver is performed by closing connections one by
    53 //	one whilst ensuring their closure does not affect the other connected sessions
    54 //
    55     {
    56 	test.Title();
    57 
    58 	TChar driveLetter;
    59 	if (IsSessionDriveLFFS(TheFs,driveLetter))
    60 		{
    61 		test.Printf(_L("CallTestsL: Skipped: test does not run on LFFS.\n"));
    62 		return;
    63 		}
    64 
    65 	test.Start(_L("Starting T_SESSION tests..."));
    66 
    67 //	Create an array of fileserver sessions
    68 //	Create an array of TSessionTest objects
    69 
    70 	TInt i=0;
    71 
    72 	TInt r;
    73 	for (; i<KMaxNumberSessions; i++)
    74 		{
    75 		r=gSession[i].Connect();
    76 		test(r==KErrNone);
    77 
    78 		SetSessionPath(gSession[i],driveLetter);
    79 		gSession[i].ResourceCountMarkStart();
    80 		gTestObject[i].Initialise(gSession[i]);
    81 		gTestObject[i].RunTests();	//	Run the set of tests for each session
    82 		}							//	Leave each session open
    83 
    84 
    85 	for (i=0; i<(KMaxNumberSessions-1); i++)
    86 		{
    87 	//	Alternate tests between open sessions
    88 		gTestObject[i].testSetVolume();
    89 		gTestObject[i+1].testInitialisation();
    90 		gTestObject[i].testSubst();
    91 		gTestObject[i+1].testInitialisation();
    92 		gTestObject[i].testInitialisation();
    93 		gTestObject[i].testDriveList();
    94 		gTestObject[i+1].CopyFileToTestDirectory();
    95 		gTestObject[i].MakeAndDeleteFiles();
    96 	//	Close gSession[i] and check that session[i+1] is OK
    97 		gSession[i].ResourceCountMarkEnd();
    98 		gSession[i].Close();
    99 		gTestObject[i+1].testInitialisation();
   100 		gTestObject[i+1].testSetVolume();
   101 		gTestObject[i+1].testInitialisation();
   102 		gTestObject[i+1].testSubst();
   103 		gTestObject[i+1].testDriveList();
   104 	//	Reconnect gSession[i]
   105 		r=gSession[i].Connect();
   106 		test(r==KErrNone);
   107 		SetSessionPath(gSession[i],driveLetter);
   108 		gSession[i].ResourceCountMarkStart();
   109 		gTestObject[i].Initialise(gSession[i]);
   110 		gTestObject[i].testSetVolume();
   111 		gTestObject[i+1].testInitialisation();
   112 		gTestObject[i].testSubst();
   113 		gTestObject[i+1].testInitialisation();
   114 		gTestObject[i].testInitialisation();
   115 		gTestObject[i].testDriveList();
   116 	//	Close gSession[i+1] and check that session[i] is OK
   117 		gSession[i+1].ResourceCountMarkEnd();
   118 		gSession[i+1].Close();
   119 		gTestObject[i].testInitialisation();
   120 		gTestObject[i].testSetVolume();
   121 		gTestObject[i].testInitialisation();
   122 		gTestObject[i].testSubst();
   123 		gTestObject[i].testDriveList();
   124 	//	Reconnect gSession[i+1]
   125 		r=gSession[i+1].Connect();
   126 		test(r==KErrNone);
   127 		SetSessionPath(gSession[i+1],driveLetter);
   128 		gSession[i].ResourceCountMarkStart();
   129 		gTestObject[i+1].Initialise(gSession[i+1]);
   130 		gTestObject[i].testSetVolume();
   131 		gTestObject[i+1].testInitialisation();
   132 		gTestObject[i].testSubst();
   133 		gTestObject[i+1].testInitialisation();
   134 	//	Close session[i] and check that session[i+1] is OK
   135 		gSession[i].ResourceCountMarkEnd();
   136 		gSession[i].Close();
   137 		gTestObject[i+1].testInitialisation();
   138 		gTestObject[i+1].testSetVolume();
   139 		gTestObject[i+1].testInitialisation();
   140 		gTestObject[i+1].testSubst();
   141 		gTestObject[i+1].testDriveList();
   142 
   143 		if (i==KMaxNumberSessions-1)	//	Tidy up by closing remaining open session
   144 			{
   145 			gSession[i].ResourceCountMarkEnd();
   146 			gSession[i+1].Close();
   147 			}
   148 		}
   149 
   150 //	Set up the arrays again and open sessions ready for more testing
   151 
   152 	for (i=0; i<KMaxNumberSessions; i++)
   153 		{
   154 		r=gSession[i].Connect();
   155 		test(r==KErrNone);
   156 		SetSessionPath(gSession[i],driveLetter);
   157 		gSession[i].ResourceCountMarkStart();
   158 		gTestObject[i].Initialise(gSession[i]);
   159 		}
   160 
   161 
   162 	for (i=0; i<KMaxNumberSessions-1; i++)
   163 		{
   164 		gTestObject[i].testInitialisation();
   165 		gTestObject[i+1].testSubst();
   166 		gTestObject[i].testDriveList();
   167 		gSession[i].ResourceCountMarkEnd();
   168 		gSession[i].Close();
   169 		gTestObject[i+1].testInitialisation();
   170 		gTestObject[i+1].testSetVolume();
   171 		if (i==KMaxNumberSessions-1)	//	Tidy up by closing remaining open session
   172 			{
   173 			gSession[i+1].ResourceCountMarkEnd();
   174 			gSession[i+1].Close();
   175 			}
   176 		}
   177 
   178 
   179 	test.End();
   180 	test.Close();
   181 	return;
   182     }