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