104 // fetchs the number of corrupt file trap records that exist |
105 // fetchs the number of corrupt file trap records that exist |
105 // there is a separate record for every attempted access to a nominated file |
106 // there is a separate record for every attempted access to a nominated file |
106 // Note that C: is used in the IoControl call, which requires a valid drive, but has no other relevance |
107 // Note that C: is used in the IoControl call, which requires a valid drive, but has no other relevance |
107 TInt numberOfRecords; |
108 TInt numberOfRecords; |
108 TInt r=controlIo(TheFs, EDriveC, KControlIoGetNumberOfCorruptLogRecords, numberOfRecords); |
109 TInt r=controlIo(TheFs, EDriveC, KControlIoGetNumberOfCorruptLogRecords, numberOfRecords); |
109 test(r==KErrNone); |
110 test_KErrNone(r); |
110 return numberOfRecords; |
111 return numberOfRecords; |
111 } |
112 } |
112 |
113 |
113 TInt GetTrapLogRecord(TFsDebugCorruptLogRecordBuf &alogRec, TInt aRecordNumber) |
114 TInt GetTrapLogRecord(TFsDebugCorruptLogRecordBuf &alogRec, TInt aRecordNumber) |
114 { |
115 { |
115 // fetchs a trap record |
116 // fetchs a trap record |
116 // Note that C: is used in the IoControl call, which requires a valid drive, but has no other relevance |
117 // Note that C: is used in the IoControl call, which requires a valid drive, but has no other relevance |
117 TInt r=controlIo(TheFs, EDriveC, KControlIoGetCorruptLogRecord, alogRec, aRecordNumber); |
118 TInt r=controlIo(TheFs, EDriveC, KControlIoGetCorruptLogRecord, alogRec, aRecordNumber); |
118 test(r==KErrNone); |
119 test_KErrNone(r); |
119 return r; |
120 return r; |
120 } |
121 } |
121 |
122 |
122 TInt GetCorruptFileListFile(TDes& aFileName) |
123 TInt GetCorruptFileListFile(TDes& aFileName) |
123 { |
124 { |
124 // Retrieves the name of the file containing the list of files, nominated as corrupt, used to generate |
125 // Retrieves the name of the file containing the list of files, nominated as corrupt, used to generate |
125 // the corrupt files list. |
126 // the corrupt files list. |
126 // Note that C: is used in the IoControl call, which requires a valid drive, but has no other relevance |
127 // Note that C: is used in the IoControl call, which requires a valid drive, but has no other relevance |
127 TInt r=controlIo(TheFs, EDriveC, KControlIoGetCorruptListFile, aFileName); |
128 TInt r=controlIo(TheFs, EDriveC, KControlIoGetCorruptListFile, aFileName); |
128 test(r==KErrNone); |
129 test_KErrNone(r); |
129 return r; |
130 return r; |
130 } |
131 } |
131 |
132 |
132 void AccessFiles() |
133 void AccessFiles() |
133 { |
134 { |
134 test.Next(_L("Access corrupt files")); |
135 test.Next(_L("Access corrupt files")); |
135 RFile f; |
136 RFile f; |
136 const TInt attribs=EFileShareExclusive|EFileStreamText|EFileRead; |
137 const TInt attribs=EFileShareExclusive|EFileStreamText|EFileRead; |
137 // File1 |
138 // File1 |
138 TInt r=f.Open(TheFs,KTestFile1,attribs); |
139 TInt r=f.Open(TheFs,KTestFile1,attribs); |
139 test(r==KTestFile1Error1); |
140 test_Value(r, r == KTestFile1Error1); |
140 f.Close(); |
141 f.Close(); |
141 numberOfTraps+=(r==KErrNone?0:1); |
142 numberOfTraps+=(r==KErrNone?0:1); |
142 // try again |
143 // try again |
143 r=f.Open(TheFs,KTestFile1,attribs); |
144 r=f.Open(TheFs,KTestFile1,attribs); |
144 test(r==KTestFile1Error2); |
145 test_Value(r, r == KTestFile1Error2); |
145 f.Close(); |
146 f.Close(); |
146 numberOfTraps+=(r==KErrNone?0:1); |
147 numberOfTraps+=(r==KErrNone?0:1); |
147 // File2 |
148 // File2 |
148 r=f.Open(TheFs,KTestFile2,attribs); |
149 r=f.Open(TheFs,KTestFile2,attribs); |
149 test(r==KTestFile2Error1); |
150 test_Value(r, r == KTestFile2Error1); |
150 f.Close(); |
151 f.Close(); |
151 numberOfTraps+=(r==KErrNone?0:1); |
152 numberOfTraps+=(r==KErrNone?0:1); |
152 // try again |
153 // try again |
153 r=f.Open(TheFs,KTestFile2,attribs); |
154 r=f.Open(TheFs,KTestFile2,attribs); |
154 test(r==KTestFile2Error2); |
155 test_Value(r, r == KTestFile2Error2); |
155 f.Close(); |
156 f.Close(); |
156 numberOfTraps+=(r==KErrNone?0:1); |
157 numberOfTraps+=(r==KErrNone?0:1); |
157 } |
158 } |
158 |
159 |
159 void DoTests() |
160 void DoTests() |
160 { |
161 { |
161 TFileName corruptFileNamesList; |
162 TFileName corruptFileNamesList; |
162 test.Next(_L("Get name of file with list of nominated files")); |
163 test.Next(_L("Get name of file with list of nominated files")); |
163 TInt r=GetCorruptFileListFile(corruptFileNamesList); |
164 TInt r=GetCorruptFileListFile(corruptFileNamesList); |
164 test(r==KErrNone); |
165 test_KErrNone(r); |
165 test.Printf(_L("Using %S\n"),&corruptFileNamesList); |
166 test.Printf(_L("Using %S\n"),&corruptFileNamesList); |
166 |
167 |
167 AccessFiles(); |
168 AccessFiles(); |
168 test.Next(_L("Get Number of traps")); |
169 test.Next(_L("Get Number of traps")); |
169 TInt nRecs=GetNumberOfTraps(); |
170 TInt nRecs=GetNumberOfTraps(); |