author | John Imhofe <john.imhofe@nokia.com> |
Mon, 21 Dec 2009 16:14:42 +0000 | |
changeset 15 | 4122176ea935 |
parent 0 | a41df078684a |
permissions | -rw-r--r-- |
0 | 1 |
/* |
15
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
0
diff
changeset
|
2 |
* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). |
0 | 3 |
* All rights reserved. |
4 |
* This component and the accompanying materials are made available |
|
15
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
0
diff
changeset
|
5 |
* under the terms of "Eclipse Public License v1.0" |
0 | 6 |
* which accompanies this distribution, and is available |
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 |
* |
|
9 |
* Initial Contributors: |
|
10 |
* Nokia Corporation - initial contribution. |
|
11 |
* |
|
12 |
* Contributors: |
|
13 |
* |
|
15
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
0
diff
changeset
|
14 |
* Description: |
0 | 15 |
* |
16 |
*/ |
|
17 |
||
18 |
||
19 |
||
15
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
0
diff
changeset
|
20 |
|
0 | 21 |
#include "t_fat32clusterbound.h" |
22 |
||
23 |
/** |
|
24 |
Class Constructor |
|
25 |
*/ |
|
26 |
CBaseTestFat32ClusterBound::CBaseTestFat32ClusterBound() |
|
27 |
{ |
|
28 |
SetTestStepName(KTestStepClusterBound); |
|
29 |
} |
|
30 |
||
31 |
/** |
|
32 |
Class Destructor |
|
33 |
*/ |
|
34 |
CBaseTestFat32ClusterBound::~CBaseTestFat32ClusterBound() |
|
35 |
{ |
|
36 |
} |
|
37 |
||
38 |
||
39 |
/** |
|
40 |
This test should be performed once the disk has been filled to its max capacity. |
|
41 |
Obtains the cluster bounds action from the configuration file and calls the function |
|
42 |
that is required to be carried out |
|
43 |
||
44 |
@return EPass if test passes and EFail if test fails |
|
45 |
*/ |
|
46 |
TVerdict CBaseTestFat32ClusterBound::doTestStepL() |
|
47 |
{ |
|
48 |
SetTestStepResult(EFail); |
|
49 |
TInt r; |
|
50 |
TBufC<20> clusterAction; |
|
51 |
TPtrC16 clusteraction = clusterAction; |
|
52 |
_LIT(KClusterAction,"ClusterAction"); |
|
53 |
TBool alright = GetStringFromConfig(ConfigSection(), KClusterAction, clusteraction); |
|
54 |
if (alright) |
|
55 |
{ |
|
56 |
if (clusteraction == _L("WriteToFile")) |
|
57 |
{ |
|
58 |
r = TestClusterBoundsWriteFile(); |
|
59 |
if (r != KErrNone) |
|
60 |
{ |
|
61 |
INFO_PRINTF1(_L("ClusterAction:WriteToFile failed")); |
|
62 |
SetTestStepResult(EFail); |
|
63 |
} |
|
64 |
else |
|
65 |
{ |
|
66 |
INFO_PRINTF1(_L("ClusterAction:WriteToFile passed")); |
|
67 |
SetTestStepResult(EPass); |
|
68 |
} |
|
69 |
} |
|
70 |
if (clusteraction == _L("CreateFiles")) |
|
71 |
{ |
|
72 |
r = TestClusterBoundsCreateFiles(); |
|
73 |
if (r != KErrNone) |
|
74 |
{ |
|
75 |
INFO_PRINTF1(_L("ClusterAction:CreateFiles failed")); |
|
76 |
SetTestStepResult(EFail); |
|
77 |
} |
|
78 |
else |
|
79 |
{ |
|
80 |
INFO_PRINTF1(_L("ClusterAction:CreateFiles passed")); |
|
81 |
SetTestStepResult(EPass); |
|
82 |
} |
|
83 |
} |
|
84 |
} |
|
85 |
else |
|
86 |
{ |
|
87 |
INFO_PRINTF1(_L("No ClusterAction specified in ini file")); |
|
88 |
SetTestStepResult(EFail); |
|
89 |
} |
|
90 |
return TestStepResult(); |
|
91 |
} |
|
92 |
||
93 |
/** |
|
94 |
Attepts to access out of bounds clusters by creating another file and |
|
95 |
attempting to write to it. |
|
96 |
||
97 |
@return KErrNone if successfull, otherwise one of the other system-wide |
|
98 |
error codes. |
|
99 |
*/ |
|
100 |
TInt CBaseTestFat32ClusterBound::TestClusterBoundsWriteFile() |
|
101 |
{ |
|
102 |
TInt r; |
|
103 |
TVolumeInfo iInfo; |
|
104 |
||
105 |
TInt freeSpace; |
|
106 |
RFile rFile; |
|
107 |
||
108 |
r = iTheFs.Volume(iInfo, CurrentDrive()); |
|
109 |
if(r != KErrNone) |
|
110 |
{ |
|
111 |
INFO_PRINTF2(_L("Unable to obtain the volume information, error = %d"), r); |
|
112 |
return r; |
|
113 |
} |
|
114 |
freeSpace = iInfo.iFree; |
|
115 |
TBuf8<100> buffer3(freeSpace + 1); |
|
116 |
r = rFile.Replace(iTheFs, _L("TESTClusterBound.txt"), EFileWrite); |
|
117 |
if(r != KErrNone) |
|
118 |
{ |
|
119 |
INFO_PRINTF2(_L("Unable to create the file, error = %d"), r); |
|
120 |
return r; |
|
121 |
} |
|
122 |
r = rFile.Write(buffer3,freeSpace + 1); |
|
123 |
if (r == KErrDiskFull) |
|
124 |
{ |
|
125 |
INFO_PRINTF1(_L("Disk is Full - Attempting to access out of bounds clusters returns the correct error value")); |
|
126 |
rFile.Close(); |
|
127 |
return KErrNone; |
|
128 |
} |
|
129 |
else |
|
130 |
{ |
|
131 |
INFO_PRINTF2(_L("Attempting to access out of bounds clusters returns the incorrect error value %d"), r); |
|
132 |
rFile.Close(); |
|
133 |
return r; |
|
134 |
} |
|
135 |
||
136 |
} |
|
137 |
||
138 |
/** |
|
139 |
Attepts to access out of bounds clusters by creating empty files to fill |
|
140 |
the root directory and following this, attempting to create another empty file |
|
141 |
||
142 |
@return KErrNone if successfull, otherwise one of the other system-wide |
|
143 |
error codes. |
|
144 |
*/ |
|
145 |
TInt CBaseTestFat32ClusterBound::TestClusterBoundsCreateFiles() |
|
146 |
{ |
|
147 |
RFile rFile; |
|
148 |
_LIT(KFileName, "File%d.txt"); |
|
149 |
||
150 |
TInt sizeOfShortDir = 16 * 4; //Short dir is 64 bytes long |
|
151 |
TInt bytesPerSector = iBPB_BytsPerSec; |
|
152 |
TInt sizeOfCluster = iBPB_SecPerClus * bytesPerSector; |
|
153 |
TInt filesToCreate = sizeOfCluster / sizeOfShortDir; |
|
154 |
filesToCreate = filesToCreate - 1; |
|
155 |
||
156 |
TInt r; |
|
157 |
TInt i; |
|
158 |
for (i = 0; i < filesToCreate; i++) |
|
159 |
{ |
|
160 |
TBuf<20> fileName; |
|
161 |
TInt fileNumber = i + 1; |
|
162 |
fileName.Format(KFileName, fileNumber); |
|
163 |
r= rFile.Replace(iTheFs,fileName , EFileWrite); |
|
164 |
if (r == KErrDiskFull) |
|
165 |
break; |
|
166 |
rFile.Close(); |
|
167 |
} |
|
168 |
||
169 |
||
170 |
r = rFile.Replace(iTheFs, _L("TFile.txt") , EFileWrite); |
|
171 |
if (r == KErrDiskFull) |
|
172 |
{ |
|
173 |
INFO_PRINTF1(_L("Attempting to access out of bounds clusters returns the correct error value")); |
|
174 |
return KErrNone; |
|
175 |
} |
|
176 |
else |
|
177 |
{ |
|
178 |
INFO_PRINTF2(_L("Attempting to access out of bounds clusters returns the incorrect error value %d"), r); |
|
179 |
return r; |
|
180 |
} |
|
181 |
} |