author | mikek |
Wed, 16 Jun 2010 12:59:18 +0100 | |
branch | GCC_SURGE |
changeset 160 | 30e086416910 |
parent 109 | b3a1d9898418 |
child 257 | 3e88ff8f41d5 |
permissions | -rw-r--r-- |
0 | 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". |
|
7 |
// |
|
8 |
// Initial Contributors: |
|
9 |
// Nokia Corporation - initial contribution. |
|
10 |
// |
|
11 |
// Contributors: |
|
12 |
// |
|
13 |
// Description: |
|
14 |
// f32test\scndrv\t_scn32dr3.cpp |
|
15 |
// |
|
16 |
// |
|
17 |
||
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
18 |
#define __E32TEST_EXTENSION__ |
0 | 19 |
#include <f32file.h> |
20 |
#include <e32test.h> |
|
33
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
21 |
#include <e32svr.h> |
0 | 22 |
#include "t_server.h" |
23 |
||
24 |
#include "fat_utils.h" |
|
25 |
using namespace Fat_Test_Utils; |
|
26 |
||
27 |
||
28 |
/* Tests rugged fat filing system for epoc platforms. Copies \t_scn32dr3.exe to |
|
29 |
\sys\bin\eshell.exe to enable the test to carry on after a reset. |
|
30 |
See t_tscan for a fuller description of the tests carried out. Good idea to |
|
31 |
disable crash debugger via \e32\inc\m32std.h. Drive to be tested is selected at |
|
32 |
the command line. Also useful to disable beep in \e32\kpepoc\kp_ini.cpp to |
|
33 |
avoid excessive noise.*/ |
|
34 |
||
35 |
GLDEF_D RTest test(_L("T_SCN32DR3")); |
|
36 |
||
37 |
GLREF_D TInt TheFunctionNumber; |
|
38 |
GLREF_D TInt TheOpNumber; |
|
39 |
GLREF_D TInt TheFailCount; |
|
40 |
GLREF_D TBool IsReset; |
|
41 |
GLREF_D RFs TheFs; |
|
42 |
GLREF_D TFileName TestExeName; |
|
43 |
GLREF_D TFileName StartupExeName; |
|
44 |
GLREF_D TFileName LogFileName; |
|
45 |
||
46 |
#if defined( _DEBUG) && !defined(__WINS__) |
|
47 |
const TInt KControlIoRuggedOn=2; |
|
48 |
const TInt KControlIoRuggedOff=3; |
|
49 |
const TInt KControlIoIsRugged=4; |
|
50 |
#endif |
|
51 |
GLREF_D TInt WriteFailValue; |
|
52 |
GLREF_C void ReadLogFile(); |
|
53 |
GLREF_C void DoTests(); |
|
54 |
||
55 |
#if defined(_DEBUG) |
|
56 |
LOCAL_C void OverrideEShell(void) |
|
57 |
// |
|
58 |
// Copies the executable file as the eshell so that it is automatically run |
|
59 |
// |
|
60 |
{ |
|
61 |
test.Next(_L("OverideEShell")); |
|
62 |
RProcess myProc; |
|
63 |
if (myProc.FileName().CompareF(StartupExeName) == 0) |
|
64 |
test.Printf(_L("OverrideEShell: running as eshell\n")); |
|
65 |
else |
|
66 |
{ |
|
67 |
RFile logFile; |
|
68 |
TInt r; |
|
69 |
TFileName tempDirName=_L(""); |
|
70 |
// Copy over this executable and create a progress file. |
|
71 |
test.Printf(_L("Copying %S to %S\n"), &TestExeName, &StartupExeName); |
|
72 |
if(PlatSec::ConfigSetting(PlatSec::EPlatSecEnforceSysBin)) |
|
73 |
tempDirName = _L("?:\\SYS\\BIN\\"); |
|
74 |
else |
|
75 |
tempDirName = _L("?:\\SYSTEM\\BIN\\"); |
|
76 |
tempDirName[0] = gSessionPath[0]; |
|
77 |
r=TheFs.MkDirAll(tempDirName); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
78 |
test_Value(r, r == KErrNone||r==KErrAlreadyExists); |
0 | 79 |
CFileMan* fileMan=NULL; |
80 |
TRAP(r,fileMan = CFileMan::NewL(TheFs)); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
81 |
test_KErrNone(r); |
0 | 82 |
//Copy the test from Z drive. |
83 |
TFileName temp=_L("Z:\\SYS\\BIN\\T_SCN32DR3.EXE"); |
|
84 |
r = fileMan->Copy(temp, TestExeName, CFileMan::EOverWrite); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
85 |
test_KErrNone(r); |
0 | 86 |
r = fileMan->Copy(TestExeName, StartupExeName, CFileMan::EOverWrite); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
87 |
test_KErrNone(r); |
0 | 88 |
//Mask read attribute. Fix for DEF081323 |
89 |
r = fileMan->Attribs(StartupExeName, 0, KEntryAttReadOnly, 0); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
90 |
test_KErrNone(r); |
0 | 91 |
r = fileMan->Attribs(TestExeName, 0, KEntryAttReadOnly, 0); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
92 |
test_KErrNone(r); |
0 | 93 |
r = logFile.Replace(TheFs,LogFileName,EFileShareExclusive|EFileWrite); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
94 |
test_KErrNone(r); |
0 | 95 |
logFile.Close(); |
96 |
delete fileMan; |
|
97 |
} |
|
98 |
} |
|
99 |
#endif |
|
100 |
||
101 |
GLDEF_C void CallTestsL() |
|
102 |
// |
|
103 |
// |
|
104 |
// |
|
105 |
{ |
|
106 |
if(PlatSec::ConfigSetting(PlatSec::EPlatSecEnforceSysBin)) |
|
107 |
StartupExeName=_L("?:\\SYS\\BIN\\ESHELL.EXE"); |
|
108 |
else |
|
109 |
StartupExeName=_L("?:\\SYSTEM\\BIN\\ESHELL.EXE"); |
|
110 |
//RFs::ControlIo only supported in debug build |
|
111 |
#ifndef _DEBUG |
|
112 |
test.Printf(_L("Error: Supported only debug testing\n")); |
|
113 |
return; |
|
114 |
#else |
|
115 |
#if defined(__WINS__) |
|
116 |
test.Printf(_L("WINS not tested\n")); |
|
117 |
return; |
|
118 |
#else |
|
119 |
const TInt KWriteFailReset=-99; // soft reset after write fail |
|
120 |
||
121 |
TInt r; |
|
122 |
TestExeName[0]=StartupExeName[0]=LogFileName[0]=gSessionPath[0]; |
|
123 |
// ensure file system is rugged |
|
124 |
TUint8 oldFsys; |
|
125 |
TPtr8 pRugged(&oldFsys,1,1); |
|
126 |
r=TheFs.ControlIo(gSessionPath[0]-'A',KControlIoIsRugged,pRugged); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
127 |
test_KErrNone(r); |
0 | 128 |
if(oldFsys==0) |
129 |
{ |
|
130 |
r=TheFs.ControlIo(gSessionPath[0]-'A',KControlIoRuggedOn); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
131 |
test_KErrNone(r); |
0 | 132 |
} |
133 |
TheFunctionNumber=0; |
|
134 |
TheOpNumber=0; |
|
135 |
TheFailCount=0; |
|
136 |
IsReset=ETrue; |
|
137 |
WriteFailValue=KWriteFailReset; |
|
138 |
test.Printf(_L("IsReset=%d\n"),IsReset); |
|
139 |
OverrideEShell(); |
|
140 |
ReadLogFile(); |
|
141 |
r=TheFs.ScanDrive(gSessionPath); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
142 |
test_KErrNone(r); |
0 | 143 |
r=TheFs.CheckDisk(gSessionPath); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
144 |
test_KErrNone(r); |
0 | 145 |
DoTests(); |
146 |
r=TheFs.Delete(LogFileName); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
147 |
test_KErrNone(r); |
0 | 148 |
r=TheFs.Delete(StartupExeName); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
149 |
test_KErrNone(r); |
0 | 150 |
// return file system to original state |
151 |
if(oldFsys==0) |
|
152 |
r=TheFs.ControlIo(gSessionPath[0]-'A',KControlIoRuggedOff); |
|
153 |
UserSvr::ResetMachine(EStartupWarmReset); |
|
154 |
return; |
|
155 |
#endif |
|
156 |
#endif |
|
157 |
} |
|
158 |
||
159 |