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\scndrv\t_scn32dr2.cpp
|
sl@0
|
15 |
//
|
sl@0
|
16 |
//
|
sl@0
|
17 |
|
sl@0
|
18 |
#include <f32file.h>
|
sl@0
|
19 |
#include <e32test.h>
|
sl@0
|
20 |
#include "t_server.h"
|
sl@0
|
21 |
|
sl@0
|
22 |
#include "fat_utils.h"
|
sl@0
|
23 |
using namespace Fat_Test_Utils;
|
sl@0
|
24 |
|
sl@0
|
25 |
|
sl@0
|
26 |
|
sl@0
|
27 |
/* Tests rugged fat file system. Power failure is simulated by failure of write
|
sl@0
|
28 |
operation in TDriver class. See t_tscan.cpp for fuller description.
|
sl@0
|
29 |
Tests drive set in the default path for epoc platforms and x: for WINS.*/
|
sl@0
|
30 |
|
sl@0
|
31 |
GLDEF_D RTest test(_L("T_SCN32DR2"));
|
sl@0
|
32 |
GLDEF_D TFileName TheDrive=_L("?:\\");
|
sl@0
|
33 |
|
sl@0
|
34 |
GLREF_D TInt TheFunctionNumber;
|
sl@0
|
35 |
GLREF_D TInt TheOpNumber;
|
sl@0
|
36 |
GLREF_D TInt TheFailCount;
|
sl@0
|
37 |
GLREF_D TBool IsReset;
|
sl@0
|
38 |
GLREF_D RFs TheFs;
|
sl@0
|
39 |
GLREF_D TFileName TestExeName;
|
sl@0
|
40 |
GLREF_D TFileName StartupExeName;
|
sl@0
|
41 |
GLREF_D TFileName LogFileName;
|
sl@0
|
42 |
|
sl@0
|
43 |
#ifdef _DEBUG
|
sl@0
|
44 |
const TInt KControlIoRuggedOn=2;
|
sl@0
|
45 |
const TInt KControlIoRuggedOff=3;
|
sl@0
|
46 |
const TInt KControlIoIsRugged=4;
|
sl@0
|
47 |
#endif
|
sl@0
|
48 |
GLREF_D TInt WriteFailValue;
|
sl@0
|
49 |
|
sl@0
|
50 |
GLREF_C void ReadLogFile();
|
sl@0
|
51 |
GLREF_C void DoTests();
|
sl@0
|
52 |
|
sl@0
|
53 |
GLDEF_C void CallTestsL()
|
sl@0
|
54 |
//
|
sl@0
|
55 |
// Do all tests
|
sl@0
|
56 |
//
|
sl@0
|
57 |
{
|
sl@0
|
58 |
if(PlatSec::ConfigSetting(PlatSec::EPlatSecEnforceSysBin))
|
sl@0
|
59 |
StartupExeName=_L("?:\\SYS\\BIN\\ESHELL.EXE");
|
sl@0
|
60 |
else
|
sl@0
|
61 |
StartupExeName=_L("?:\\SYSTEM\\BIN\\ESHELL.EXE");
|
sl@0
|
62 |
|
sl@0
|
63 |
|
sl@0
|
64 |
#ifndef _DEBUG
|
sl@0
|
65 |
test.Printf(_L("Error: Only debug builds supported\n"));
|
sl@0
|
66 |
return;
|
sl@0
|
67 |
#else
|
sl@0
|
68 |
|
sl@0
|
69 |
const TInt KWriteFailStd=-100; // error -100 returned from write fail
|
sl@0
|
70 |
|
sl@0
|
71 |
TInt gDriveNumber;
|
sl@0
|
72 |
|
sl@0
|
73 |
TInt r = TheFs.CharToDrive( gSessionPath[0], gDriveNumber );
|
sl@0
|
74 |
test( KErrNone == r );
|
sl@0
|
75 |
|
sl@0
|
76 |
//-- set up console output
|
sl@0
|
77 |
Fat_Test_Utils::SetConsole(test.Console());
|
sl@0
|
78 |
|
sl@0
|
79 |
//-- print drive information
|
sl@0
|
80 |
PrintDrvInfo(TheFs, gDriveNumber);
|
sl@0
|
81 |
|
sl@0
|
82 |
if (!Is_Fat(TheFs, gDriveNumber))
|
sl@0
|
83 |
{
|
sl@0
|
84 |
test.Printf(_L("CallTestsL: Skipped: test requires FAT filesystem\n"));
|
sl@0
|
85 |
return;
|
sl@0
|
86 |
}
|
sl@0
|
87 |
|
sl@0
|
88 |
TheFunctionNumber=0;
|
sl@0
|
89 |
TheOpNumber=0;
|
sl@0
|
90 |
TheFailCount=0;
|
sl@0
|
91 |
IsReset=EFalse;
|
sl@0
|
92 |
WriteFailValue=KWriteFailStd;
|
sl@0
|
93 |
|
sl@0
|
94 |
// ensure that fat filing system is rugged
|
sl@0
|
95 |
TUint8 oldFsys;
|
sl@0
|
96 |
TPtr8 pRugged(&oldFsys,1,1);
|
sl@0
|
97 |
r=TheFs.ControlIo(gDriveNumber,KControlIoIsRugged,pRugged);
|
sl@0
|
98 |
test(r==KErrNone);
|
sl@0
|
99 |
if(oldFsys==0)
|
sl@0
|
100 |
{
|
sl@0
|
101 |
r=TheFs.ControlIo(gDriveNumber,KControlIoRuggedOn);
|
sl@0
|
102 |
test(r==KErrNone);
|
sl@0
|
103 |
}
|
sl@0
|
104 |
DoTests();
|
sl@0
|
105 |
// if nec, set filing system back to !rugged
|
sl@0
|
106 |
if(oldFsys==0)
|
sl@0
|
107 |
{
|
sl@0
|
108 |
r=TheFs.ControlIo(gDriveNumber,KControlIoRuggedOff);
|
sl@0
|
109 |
test(r==KErrNone);
|
sl@0
|
110 |
}
|
sl@0
|
111 |
|
sl@0
|
112 |
return;
|
sl@0
|
113 |
#endif
|
sl@0
|
114 |
}
|
sl@0
|
115 |
|
sl@0
|
116 |
|
sl@0
|
117 |
|