kerneltest/f32test/filesystem/fat/t_nonrugged.cpp
author hgs
Thu, 10 Jun 2010 11:48:01 +0100
changeset 149 d9f1e5bfe28c
permissions -rw-r--r--
201021_18
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
149
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
     1
// Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
     2
// All rights reserved.
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
     3
// This component and the accompanying materials are made available
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
     4
// under the terms of the License "Eclipse Public License v1.0"
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
     5
// which accompanies this distribution, and is available
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
     7
//
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
     8
// Initial Contributors:
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
     9
// Nokia Corporation - initial contribution.
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
    10
//
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
    11
// Contributors:
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
    12
//
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
    13
// Description:
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
    14
// f32test\filesystem\fat\t_nonrugged.cpp
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
    15
// Functional tests for the non-Rugged file mode (also called the File Sequential mode)
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
    16
// Only perform tests on the Rugged FAT file system
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
    17
//
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
    18
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
    19
#define __E32TEST_EXTENSION__
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
    20
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
    21
#include <f32file.h>
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
    22
#include <e32test.h>
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
    23
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
    24
#include "t_server.h"
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
    25
#include "fat_utils.h"
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
    26
using namespace Fat_Test_Utils;
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
    27
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
    28
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
    29
RTest test(_L("T_NONRUGGED"));
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
    30
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
    31
TInt gDriveNum;
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
    32
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
    33
_LIT(KTestPath, ":\\F32-TST\\T_NONRUGGED\\");	// 22
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
    34
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
    35
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
    36
enum TNonRuggedFileMode
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
    37
	{
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
    38
	ENormalFileMode,	// File is in normal (Rugged) mode
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
    39
	ENonRuggedFileMode	// File is in non-Rugged file mode (EFileSequential)
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
    40
	};
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
    41
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
    42
enum TNonRuggedControlIO
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
    43
/*
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
    44
 * ControlIo enum values
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
    45
 */
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
    46
    {
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
    47
    EControlIOIsRuggedFSys		= 4,			// Defined as EIsRuggedFSys in \fileserver\sfat32\common_constants.h
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
    48
    EControlIOIsFileSequential	= KMaxTInt-23	// Defined as KControlIoIsFileSequential in \fileserver\inc\f32dbg.h
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
    49
    };
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
    50
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
    51
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
    52
void CreateFile(RFile& aFile, const TDesC& aPath, TUint aFileMode)
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
    53
/*
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
    54
 * Creates/opens a file in Rugged/non-Rugged mode after emptying the trace buffer
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
    55
 */
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
    56
	{
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
    57
	TInt r = TheFs.MkDirAll(aPath);
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
    58
	test_Value(r, r == KErrNone || r == KErrAlreadyExists);
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
    59
	r = aFile.Replace(TheFs, aPath, aFileMode);
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
    60
	test_KErrNone(r);
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
    61
	}
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
    62
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
    63
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
    64
void DeleteFileAndDir(const TDesC& aPath)
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
    65
/*
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
    66
 * Deletes a single file and the directory containing it
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
    67
 */
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
    68
	{
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
    69
	TInt r = TheFs.Delete(aPath);
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
    70
	test_KErrNone(r);
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
    71
	r = TheFs.RmDir(aPath);
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
    72
	test_KErrNone(r);
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
    73
	}
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
    74
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
    75
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
    76
void SingleClientTest()
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
    77
/*
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
    78
 * Unit test for Non-Rugged File mode with a single client
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
    79
	 ***********************************************************************************
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
    80
	 * 1. Create a file in non-Rugged file mode and then close the file.
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
    81
	 * 2. Open the file in normal Rugged file mode and then close it.
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
    82
	 * 3. Open the file in non-Rugged file mode again and then close it.
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
    83
	 * Expected Results:
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
    84
	 * 1. File is in non-Rugged file mode.
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
    85
	 * 2. File is in normal Rugged file mode.
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
    86
	 * 3. File is in non-Rugged file mode.
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
    87
	 ***********************************************************************************
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
    88
 */
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
    89
	{
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
    90
	test.Next(_L("Test single client"));
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
    91
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
    92
	TBuf<34> singleFile;
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
    93
	singleFile.Append(gDriveToTest);		//  1
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
    94
	singleFile.Append(KTestPath);			// 22
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
    95
	singleFile.Append(_L("file.single"));	// 11
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
    96
	TInt r = TheFs.Delete(singleFile);
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
    97
	test_Value(r, r == KErrNone || r == KErrNotFound || r == KErrPathNotFound);
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
    98
	TBuf8<KMaxPath> singleFilePkg;
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
    99
	singleFilePkg.Copy(singleFile.Mid(2));
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   100
	TUint8 fileMode = 0;
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   101
	TPtr8 fileModePkg(&fileMode, 1, 1);
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   102
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   103
	test.Printf(_L("Create file in non-Rugged file mode\n"));
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   104
	RFile file;
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   105
	CreateFile(file, singleFile, (EFileWrite | EFileSequential));
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   106
	r = TheFs.ControlIo(gDriveNum, EControlIOIsFileSequential, singleFilePkg, fileModePkg);
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   107
	test_KErrNone(r);
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   108
	test_Equal(ENonRuggedFileMode, fileMode);
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   109
	file.Close();
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   110
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   111
	test.Printf(_L("Open file in normal mode\n"));
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   112
	CreateFile(file, singleFile, EFileWrite);
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   113
	r = TheFs.ControlIo(gDriveNum, EControlIOIsFileSequential, singleFilePkg, fileModePkg);
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   114
	test_KErrNone(r);
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   115
	test_Equal(ENormalFileMode, fileMode);
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   116
	file.Close();
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   117
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   118
	test.Printf(_L("Open file in non-Rugged file mode again\n"));
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   119
	CreateFile(file, singleFile, (EFileWrite | EFileSequential));
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   120
	r = TheFs.ControlIo(gDriveNum, EControlIOIsFileSequential, singleFilePkg, fileModePkg);
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   121
	test_KErrNone(r);
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   122
	test_Equal(ENonRuggedFileMode, fileMode);
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   123
	file.Close();
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   124
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   125
	DeleteFileAndDir(singleFile);
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   126
	}
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   127
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   128
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   129
void MultipleClientsTest()
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   130
/*
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   131
 * Unit tests for Non-Rugged File mode with multiple clients accessing the same file
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   132
 */
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   133
	{
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   134
	/***********************************************************************************
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   135
	 * Use Case 1:
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   136
	 * 1. Client1 opens a file in non-Rugged file mode.
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   137
	 * 2. Client2 then opens the same file in normal Rugged file mode.
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   138
	 * Expected Results:
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   139
	 * 1. File is in non-Rugged file mode.
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   140
	 * 2. File changed to normal Rugged file mode.
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   141
	 ***********************************************************************************
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   142
	 */
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   143
	test.Next(_L("Test multiple clients - Use case 1"));
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   144
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   145
	TBuf<33> fileName1;
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   146
	fileName1.Append(gDriveToTest);		//  1
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   147
	fileName1.Append(KTestPath);		// 22
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   148
	fileName1.Append(_L("file1.mult"));	// 10
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   149
	TInt r = TheFs.Delete(fileName1);
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   150
	test_Value(r, r == KErrNone || r == KErrNotFound || r == KErrPathNotFound);
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   151
	TBuf8<31> fileName1Pkg;
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   152
	fileName1Pkg.Copy(fileName1.Mid(2));
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   153
	TUint8 fileMode = 0;
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   154
	TPtr8 fileModePkg(&fileMode, 1, 1);
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   155
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   156
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   157
	// Use Case 1.1, Client 1 (Non-Rugged Client) ------------------------------------
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   158
	test.Printf(_L("Client1 create file in non-Rugged file mode\n"));
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   159
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   160
	RFile file1;
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   161
	CreateFile(file1, fileName1, (EFileWrite | EFileSequential | EFileShareAny));
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   162
	r = TheFs.ControlIo(gDriveNum, EControlIOIsFileSequential, fileName1Pkg, fileModePkg);
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   163
	test_KErrNone(r);
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   164
	test_Equal(ENonRuggedFileMode, fileMode);
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   165
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   166
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   167
	// Use Case 1.2, Client 2 (Rugged Client) ----------------------------------------
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   168
	test.Printf(_L("Client2 open file in 'normal' Rugged file mode\n"));
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   169
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   170
	RFile file2;
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   171
	CreateFile(file2, fileName1, (EFileWrite | EFileShareAny));
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   172
	r = TheFs.ControlIo(gDriveNum, EControlIOIsFileSequential, fileName1Pkg, fileModePkg);
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   173
	test_KErrNone(r);
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   174
	test_Equal(ENormalFileMode, fileMode);
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   175
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   176
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   177
	file1.Close();
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   178
	file2.Close();
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   179
	r = TheFs.Delete(fileName1);
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   180
	test_KErrNone(r);
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   181
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   182
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   183
	/***********************************************************************************
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   184
	 * Use Case 2:
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   185
	 * 1. Client1 opens a file in normal Rugged file mode.
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   186
	 * 2. Client2 then opens the same file in non-Rugged file mode.
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   187
	 * Expected Results:
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   188
	 * 1. File is in normal Rugged file mode.
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   189
	 * 2. File does not change to non-Rugged file mode.
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   190
	 ***********************************************************************************
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   191
	 */
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   192
	test.Next(_L("Test multiple clients - Use case 2"));
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   193
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   194
	TBuf<34> fileName2;
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   195
	fileName2.Append(gDriveToTest);		//  1
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   196
	fileName2.Append(KTestPath);		// 22
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   197
	fileName2.Append(_L("file2.mult"));	// 10
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   198
	r = TheFs.Delete(fileName2);
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   199
	test_Value(r, r == KErrNone || r == KErrNotFound || r == KErrPathNotFound);
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   200
	TBuf8<KMaxPath> fileName2Pkg;
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   201
	fileName2Pkg.Copy(fileName2.Mid(2));
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   202
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   203
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   204
	// Use Case 2.1, Client 1 (Rugged Client) ----------------------------------------
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   205
	test.Printf(_L("Client1 create file in 'normal' Rugged file mode\n"));
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   206
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   207
	CreateFile(file1, fileName2, (EFileWrite | EFileShareAny));
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   208
	r = TheFs.ControlIo(gDriveNum, EControlIOIsFileSequential, fileName2Pkg, fileModePkg);
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   209
	test_KErrNone(r);
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   210
	test_Equal(ENormalFileMode, fileMode);
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   211
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   212
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   213
	// Use Case 2.2, Client 2 (Non-Rugged Client) ------------------------------------
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   214
	test.Printf(_L("Client2 open file in non-Rugged file mode\n"));
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   215
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   216
	CreateFile(file2, fileName2, (EFileWrite | EFileSequential | EFileShareAny));
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   217
	r = TheFs.ControlIo(gDriveNum, EControlIOIsFileSequential, fileName2Pkg, fileModePkg);
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   218
	test_KErrNone(r);
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   219
	test_Equal(ENormalFileMode, fileMode);
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   220
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   221
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   222
	file1.Close();
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   223
	file2.Close();
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   224
	DeleteFileAndDir(fileName2);
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   225
	}
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   226
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   227
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   228
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   229
void CallTestsL()
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   230
/*
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   231
 * Start point of T_NONRUGGED
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   232
 */
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   233
	{
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   234
#ifndef _DEBUG
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   235
    test.Printf(_L("T_NONRUGGED skipped. To run only on debug builds.\n"));
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   236
    return;
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   237
#else
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   238
    
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   239
	TInt r = TheFs.CharToDrive(gDriveToTest, gDriveNum);
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   240
	test_KErrNone(r);
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   241
	
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   242
	// Currently only FAT file system supports Rugged drive
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   243
    if (!Is_Fat(TheFs, gDriveNum))
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   244
		{
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   245
		test.Printf(_L("T_NONRUGGED skipped. Requires FAT filesystem to run.\n"));
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   246
		return;
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   247
		}
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   248
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   249
// Use this to set filesystem to Rugged if it is not set as such
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   250
#if(0)
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   251
	{
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   252
	// Ensure that the FAT filesystem is Rugged
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   253
	TUint8 ruggedVal = 0;
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   254
	TPtr8 ruggedPkg(&ruggedVal, 1, 1);
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   255
	r = TheFs.ControlIo(gDriveNum, EControlIOIsRuggedFSys, ruggedPkg);
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   256
	test_KErrNone(r);
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   257
	if (!ruggedVal)
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   258
		{
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   259
		r = TheFs.ControlIo(gDriveNumber, KControlIoRuggedOn);
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   260
		test_KErrNone(r);
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   261
		}
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   262
	}
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   263
#endif
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   264
	
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   265
    // Test to run only on a rugged FAT drive
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   266
    TUint8 ruggedVal = 0;
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   267
    TPtr8 ruggedPkg(&ruggedVal, 1, 1);
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   268
    r = TheFs.ControlIo(gDriveNum, EControlIOIsRuggedFSys, ruggedPkg);
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   269
    test_KErrNone(r);
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   270
    if (!ruggedVal)
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   271
    	{
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   272
		test.Printf(_L("T_NONRUGGED skipped. Requires Rugged FAT to run.\n"));
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   273
		return;
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   274
    	}
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   275
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   276
	test.Start(_L("T_NONRUGGED Test Start"));
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   277
	
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   278
	// Run tests
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   279
	SingleClientTest();
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   280
	MultipleClientsTest();
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   281
	
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   282
// Use this to unset filesystem to non-Rugged if it has been set above
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   283
#if(0)
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   284
	// Set filesystem back to non-Rugged
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   285
	if (!ruggedVal)
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   286
		{
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   287
		r = TheFs.ControlIo(gDriveNumber, KControlIoRuggedOff);
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   288
		test_KErrNone(r);
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   289
		}
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   290
#endif
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   291
	
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   292
	test.End();
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   293
	test.Close();
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   294
#endif
d9f1e5bfe28c 201021_18
hgs
parents:
diff changeset
   295
	}