1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/kernelhwsrv/kerneltest/f32test/fsstress/t_sess.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,182 @@
1.4 +// Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of the License "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +// f32test\fsstress\t_sess.cpp
1.18 +//
1.19 +//
1.20 +
1.21 +#include "t_sess.h"
1.22 +
1.23 +#include "t_server.h"
1.24 +#include "t_chlffs.h"
1.25 +
1.26 +GLDEF_D RTest test(_L("T_SESS"));
1.27 +GLDEF_D TFileName gTestSessionPath;
1.28 +
1.29 +// These objects are too large to be placed on the stack - ~15 sessions is enough
1.30 +// to cause a stack overflow on ARM4.
1.31 +const TInt KMaxNumberSessions=25;
1.32 +RFs gSession[KMaxNumberSessions];
1.33 +TSessionTest gTestObject[KMaxNumberSessions];
1.34 +
1.35 +
1.36 +LOCAL_C void SetSessionPath(RFs aFs,TChar aDriveLetter)
1.37 +//
1.38 +// Set the session path for a RFs connection to aDrive
1.39 +//
1.40 + {
1.41 + gTestSessionPath=(_L("?:\\SESSION_TEST\\"));
1.42 + gTestSessionPath[0]=(TText)aDriveLetter;
1.43 + TInt r=aFs.SetSessionPath(gTestSessionPath);
1.44 + test(r==KErrNone);
1.45 + r=aFs.MkDirAll(gTestSessionPath);
1.46 + test(r==KErrNone || r==KErrAlreadyExists);
1.47 + }
1.48 +
1.49 +
1.50 +GLDEF_C void CallTestsL()
1.51 +//
1.52 +// This test makes a number of fileserver connections (sessions)
1.53 +// The fileserver is stressed by running these sessions concurrently, swapping
1.54 +// between them whilst testing various fileserver API functions
1.55 +// Further testing of the fileserver is performed by closing connections one by
1.56 +// one whilst ensuring their closure does not affect the other connected sessions
1.57 +//
1.58 + {
1.59 + test.Title();
1.60 +
1.61 + TChar driveLetter;
1.62 + if (IsSessionDriveLFFS(TheFs,driveLetter))
1.63 + {
1.64 + test.Printf(_L("CallTestsL: Skipped: test does not run on LFFS.\n"));
1.65 + return;
1.66 + }
1.67 +
1.68 + test.Start(_L("Starting T_SESSION tests..."));
1.69 +
1.70 +// Create an array of fileserver sessions
1.71 +// Create an array of TSessionTest objects
1.72 +
1.73 + TInt i=0;
1.74 +
1.75 + TInt r;
1.76 + for (; i<KMaxNumberSessions; i++)
1.77 + {
1.78 + r=gSession[i].Connect();
1.79 + test(r==KErrNone);
1.80 +
1.81 + SetSessionPath(gSession[i],driveLetter);
1.82 + gSession[i].ResourceCountMarkStart();
1.83 + gTestObject[i].Initialise(gSession[i]);
1.84 + gTestObject[i].RunTests(); // Run the set of tests for each session
1.85 + } // Leave each session open
1.86 +
1.87 +
1.88 + for (i=0; i<(KMaxNumberSessions-1); i++)
1.89 + {
1.90 + // Alternate tests between open sessions
1.91 + gTestObject[i].testSetVolume();
1.92 + gTestObject[i+1].testInitialisation();
1.93 + gTestObject[i].testSubst();
1.94 + gTestObject[i+1].testInitialisation();
1.95 + gTestObject[i].testInitialisation();
1.96 + gTestObject[i].testDriveList();
1.97 + gTestObject[i+1].CopyFileToTestDirectory();
1.98 + gTestObject[i].MakeAndDeleteFiles();
1.99 + // Close gSession[i] and check that session[i+1] is OK
1.100 + gSession[i].ResourceCountMarkEnd();
1.101 + gSession[i].Close();
1.102 + gTestObject[i+1].testInitialisation();
1.103 + gTestObject[i+1].testSetVolume();
1.104 + gTestObject[i+1].testInitialisation();
1.105 + gTestObject[i+1].testSubst();
1.106 + gTestObject[i+1].testDriveList();
1.107 + // Reconnect gSession[i]
1.108 + r=gSession[i].Connect();
1.109 + test(r==KErrNone);
1.110 + SetSessionPath(gSession[i],driveLetter);
1.111 + gSession[i].ResourceCountMarkStart();
1.112 + gTestObject[i].Initialise(gSession[i]);
1.113 + gTestObject[i].testSetVolume();
1.114 + gTestObject[i+1].testInitialisation();
1.115 + gTestObject[i].testSubst();
1.116 + gTestObject[i+1].testInitialisation();
1.117 + gTestObject[i].testInitialisation();
1.118 + gTestObject[i].testDriveList();
1.119 + // Close gSession[i+1] and check that session[i] is OK
1.120 + gSession[i+1].ResourceCountMarkEnd();
1.121 + gSession[i+1].Close();
1.122 + gTestObject[i].testInitialisation();
1.123 + gTestObject[i].testSetVolume();
1.124 + gTestObject[i].testInitialisation();
1.125 + gTestObject[i].testSubst();
1.126 + gTestObject[i].testDriveList();
1.127 + // Reconnect gSession[i+1]
1.128 + r=gSession[i+1].Connect();
1.129 + test(r==KErrNone);
1.130 + SetSessionPath(gSession[i+1],driveLetter);
1.131 + gSession[i].ResourceCountMarkStart();
1.132 + gTestObject[i+1].Initialise(gSession[i+1]);
1.133 + gTestObject[i].testSetVolume();
1.134 + gTestObject[i+1].testInitialisation();
1.135 + gTestObject[i].testSubst();
1.136 + gTestObject[i+1].testInitialisation();
1.137 + // Close session[i] and check that session[i+1] is OK
1.138 + gSession[i].ResourceCountMarkEnd();
1.139 + gSession[i].Close();
1.140 + gTestObject[i+1].testInitialisation();
1.141 + gTestObject[i+1].testSetVolume();
1.142 + gTestObject[i+1].testInitialisation();
1.143 + gTestObject[i+1].testSubst();
1.144 + gTestObject[i+1].testDriveList();
1.145 +
1.146 + if (i==KMaxNumberSessions-1) // Tidy up by closing remaining open session
1.147 + {
1.148 + gSession[i].ResourceCountMarkEnd();
1.149 + gSession[i+1].Close();
1.150 + }
1.151 + }
1.152 +
1.153 +// Set up the arrays again and open sessions ready for more testing
1.154 +
1.155 + for (i=0; i<KMaxNumberSessions; i++)
1.156 + {
1.157 + r=gSession[i].Connect();
1.158 + test(r==KErrNone);
1.159 + SetSessionPath(gSession[i],driveLetter);
1.160 + gSession[i].ResourceCountMarkStart();
1.161 + gTestObject[i].Initialise(gSession[i]);
1.162 + }
1.163 +
1.164 +
1.165 + for (i=0; i<KMaxNumberSessions-1; i++)
1.166 + {
1.167 + gTestObject[i].testInitialisation();
1.168 + gTestObject[i+1].testSubst();
1.169 + gTestObject[i].testDriveList();
1.170 + gSession[i].ResourceCountMarkEnd();
1.171 + gSession[i].Close();
1.172 + gTestObject[i+1].testInitialisation();
1.173 + gTestObject[i+1].testSetVolume();
1.174 + if (i==KMaxNumberSessions-1) // Tidy up by closing remaining open session
1.175 + {
1.176 + gSession[i+1].ResourceCountMarkEnd();
1.177 + gSession[i+1].Close();
1.178 + }
1.179 + }
1.180 +
1.181 +
1.182 + test.End();
1.183 + test.Close();
1.184 + return;
1.185 + }