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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // f32test\fsstress\t_sess.cpp
23 GLDEF_D RTest test(_L("T_SESS"));
24 GLDEF_D TFileName gTestSessionPath;
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];
33 LOCAL_C void SetSessionPath(RFs aFs,TChar aDriveLetter)
35 // Set the session path for a RFs connection to aDrive
38 gTestSessionPath=(_L("?:\\SESSION_TEST\\"));
39 gTestSessionPath[0]=(TText)aDriveLetter;
40 TInt r=aFs.SetSessionPath(gTestSessionPath);
42 r=aFs.MkDirAll(gTestSessionPath);
43 test(r==KErrNone || r==KErrAlreadyExists);
47 GLDEF_C void CallTestsL()
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
59 if (IsSessionDriveLFFS(TheFs,driveLetter))
61 test.Printf(_L("CallTestsL: Skipped: test does not run on LFFS.\n"));
65 test.Start(_L("Starting T_SESSION tests..."));
67 // Create an array of fileserver sessions
68 // Create an array of TSessionTest objects
73 for (; i<KMaxNumberSessions; i++)
75 r=gSession[i].Connect();
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
85 for (i=0; i<(KMaxNumberSessions-1); i++)
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();
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();
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();
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();
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();
143 if (i==KMaxNumberSessions-1) // Tidy up by closing remaining open session
145 gSession[i].ResourceCountMarkEnd();
146 gSession[i+1].Close();
150 // Set up the arrays again and open sessions ready for more testing
152 for (i=0; i<KMaxNumberSessions; i++)
154 r=gSession[i].Connect();
156 SetSessionPath(gSession[i],driveLetter);
157 gSession[i].ResourceCountMarkStart();
158 gTestObject[i].Initialise(gSession[i]);
162 for (i=0; i<KMaxNumberSessions-1; i++)
164 gTestObject[i].testInitialisation();
165 gTestObject[i+1].testSubst();
166 gTestObject[i].testDriveList();
167 gSession[i].ResourceCountMarkEnd();
169 gTestObject[i+1].testInitialisation();
170 gTestObject[i+1].testSetVolume();
171 if (i==KMaxNumberSessions-1) // Tidy up by closing remaining open session
173 gSession[i+1].ResourceCountMarkEnd();
174 gSession[i+1].Close();