34 //-- Thus it needs to be thrown away by preprocessing in such a case. |
34 //-- Thus it needs to be thrown away by preprocessing in such a case. |
35 |
35 |
36 static CConsoleBase* pConsole = NULL; //-- pointer to the text console for printing out data |
36 static CConsoleBase* pConsole = NULL; //-- pointer to the text console for printing out data |
37 static TBool bPrintOutEnabled = ETrue; //-- global flag, if EFalse, all printing out is disabled |
37 static TBool bPrintOutEnabled = ETrue; //-- global flag, if EFalse, all printing out is disabled |
38 |
38 |
39 |
|
40 |
|
41 //------------------------------------------------------------------------------------------------------------------- |
|
42 |
|
43 /** |
|
44 Prints out a hex dump of a descriptor contents |
|
45 @param aBuf data descriptor to dump |
|
46 */ |
|
47 void F32_Test_Utils::HexDump(const TDesC8& aBuf) |
|
48 { |
|
49 HexDump(aBuf.Ptr(), aBuf.Size()); |
|
50 } |
|
51 |
|
52 //------------------------------------------------------------------------------------------------------------------- |
|
53 /** |
|
54 Prints out a hex dump of a buffer |
|
55 @param apBuf pointer to the data to dump |
|
56 @param aBufLen buffer length |
|
57 */ |
|
58 void F32_Test_Utils::HexDump(const TAny* apBuf, TUint aBufLen) |
|
59 { |
|
60 DoPrintf(_L("~ F32_Test_Utils::HexDump() size:%u\n"), aBufLen); |
|
61 |
|
62 ASSERT(apBuf); |
|
63 |
|
64 if(!aBufLen) |
|
65 return; |
|
66 |
|
67 const TUint colDmpWidth = 16; |
|
68 const TUint8* pBuf = (const TUint8*)apBuf; |
|
69 TBuf<256> buf1; |
|
70 TBuf<64> buf2; |
|
71 |
|
72 TUint dumpPos; |
|
73 |
|
74 for(dumpPos=0; dumpPos < aBufLen-1; ) |
|
75 { |
|
76 buf1.Format(_L("%06X: "), dumpPos); |
|
77 buf2.Zero(); |
|
78 |
|
79 for(TUint i=0; i<colDmpWidth; ++i) |
|
80 { |
|
81 buf1.AppendFormat(_L("%02x "), pBuf[dumpPos+i]); |
|
82 |
|
83 const TChar ch = pBuf[dumpPos+i]; |
|
84 if(ch.IsPrint()) |
|
85 buf2.Append(ch); |
|
86 else |
|
87 buf2.Append(_L(".")); |
|
88 |
|
89 |
|
90 if(++dumpPos >= aBufLen) |
|
91 { |
|
92 while(++i < colDmpWidth) |
|
93 { |
|
94 buf1.Append(_L(" ")); |
|
95 buf2.Append(_L(" ")); |
|
96 } |
|
97 |
|
98 break; |
|
99 } |
|
100 } |
|
101 |
|
102 buf1.Append(buf2); |
|
103 DoPrintf(buf1); |
|
104 |
|
105 } |
|
106 |
|
107 DoPrintf(_L("\n")); |
|
108 |
|
109 } |
|
110 |
|
111 |
|
112 //------------------------------------------------------------------------------------------------------------------- |
|
113 /** |
|
114 Compare 2 buffers and print out the difference if there is any. |
|
115 Buffer sizes must be the same and non-0 |
|
116 |
|
117 @param aBuf1 buffer 1 descriptor |
|
118 @param aBuf2 buffer 2 descriptor |
|
119 |
|
120 @return ETrue if buffers are the same, EFalse otherwise |
|
121 */ |
|
122 TBool F32_Test_Utils::CompareBuffers(const TDesC8& aBuf1, const TDesC8& aBuf2) |
|
123 { |
|
124 return CompareBuffers(aBuf1.Ptr(), aBuf1.Size(), aBuf2.Ptr(), aBuf2.Size()); |
|
125 } |
|
126 |
|
127 //------------------------------------------------------------------------------------------------------------------- |
|
128 /** |
|
129 Compare 2 buffers and print out the difference if there is any. |
|
130 Buffer sizes must be the same and non-0 |
|
131 |
|
132 @param apBuf1 pointer to the buffer 1 |
|
133 @param aBuf1Len buffer1 length |
|
134 @param apBuf2 pointer to the buffer 2 |
|
135 @param aBuf2Len buffer2 length |
|
136 |
|
137 @return ETrue if buffers are the same, EFalse otherwise |
|
138 */ |
|
139 TBool F32_Test_Utils::CompareBuffers(const TAny* apBuf1, TUint aBuf1Len, const TAny* apBuf2, TUint aBuf2Len) |
|
140 { |
|
141 ASSERT(apBuf1 && apBuf2); |
|
142 |
|
143 if(aBuf1Len != aBuf2Len) |
|
144 { |
|
145 DoPrintf(_L("~ F32_Test_Utils::CompareBuffers() different sizes! %u:%u\n"), aBuf1Len, aBuf2Len); |
|
146 ASSERT(0); |
|
147 return EFalse; |
|
148 } |
|
149 |
|
150 if(!aBuf1Len) |
|
151 {//-- empty buffers to compare |
|
152 return ETrue; |
|
153 } |
|
154 |
|
155 |
|
156 const TUint8* pBuf1 = (const TUint8*)apBuf1; |
|
157 const TUint8* pBuf2 = (const TUint8*)apBuf2; |
|
158 |
|
159 if(!Mem::Compare(pBuf1, aBuf1Len, pBuf2, aBuf2Len)) |
|
160 return ETrue; //-- buffers are the same. |
|
161 |
|
162 |
|
163 //-- the buffers' contents are different |
|
164 TUint diffpos; |
|
165 TBuf<256> buf1; |
|
166 TBuf<100> buf2; |
|
167 |
|
168 const TUint colDmpWidth = 16; |
|
169 TBool bBannerPrinted = EFalse; |
|
170 |
|
171 //-- dump chunks of the buffer with differences only |
|
172 for(diffpos=0; diffpos<aBuf1Len-1; ) |
|
173 { |
|
174 if(pBuf1[diffpos] == pBuf2[diffpos]) |
|
175 { |
|
176 ++diffpos; |
|
177 continue; |
|
178 } |
|
179 |
|
180 if(!bBannerPrinted) |
|
181 { |
|
182 bBannerPrinted = ETrue; |
|
183 DoPrintf(_L("~ F32_Test_Utils::CompareBuffers() buffers' contents are different starting at pos:%u (0x%x). Hexdump:\n"), diffpos, diffpos); |
|
184 |
|
185 } |
|
186 |
|
187 //-- difference found, dump chunks of the buffer with differences only |
|
188 TUint dumpPos = (diffpos >> 4) << 4; //-- round down to 16 |
|
189 |
|
190 buf1.Format(_L("%06X: "), dumpPos); |
|
191 buf2.Format(_L("|")); |
|
192 |
|
193 for(TUint i=0; i<colDmpWidth; ++i) |
|
194 { |
|
195 buf1.AppendFormat(_L("%02x"), pBuf1[dumpPos+i]); |
|
196 buf2.AppendFormat(_L("%02x"), pBuf2[dumpPos+i]); |
|
197 |
|
198 if(i < colDmpWidth-1) |
|
199 { |
|
200 buf1.Append(_L(" ")); |
|
201 buf2.Append(_L(" ")); |
|
202 } |
|
203 |
|
204 |
|
205 if(++diffpos >= aBuf1Len) |
|
206 {//-- pad the dump with spaces |
|
207 while(++i < colDmpWidth) |
|
208 { |
|
209 buf1.Append(_L(" ")); |
|
210 buf2.Append(_L(" ")); |
|
211 } |
|
212 |
|
213 break; |
|
214 } |
|
215 |
|
216 } |
|
217 |
|
218 buf1.Append(buf2); |
|
219 DoPrintf(buf1); |
|
220 } |
|
221 |
|
222 DoPrintf(_L("\n")); |
|
223 |
|
224 return EFalse; |
|
225 } |
|
226 |
|
227 |
|
228 //------------------------------------------------------------------------------------------------------------------- |
|
229 /** |
39 /** |
230 Set the console where the ouput will go. |
40 Set the console where the ouput will go. |
231 @param apConsole pointer to the console. if NULL, the print out will be debug port only. |
41 @param apConsole pointer to the console. if NULL, the print out will be debug port only. |
232 */ |
42 */ |
233 void F32_Test_Utils::SetConsole(CConsoleBase* apConsole) |
43 void F32_Test_Utils::SetConsole(CConsoleBase* apConsole) |
436 |
246 |
437 _LIT(KFsName_LFFS, "lffs"); |
247 _LIT(KFsName_LFFS, "lffs"); |
438 _LIT(KFsName_Win32, "Win32"); |
248 _LIT(KFsName_Win32, "Win32"); |
439 _LIT(KFsName_ExFAT, "ExFat"); |
249 _LIT(KFsName_ExFAT, "ExFat"); |
440 _LIT(KFsName_AutoMonuter, "automounter"); |
250 _LIT(KFsName_AutoMonuter, "automounter"); |
441 _LIT(KFsName_HVFS, "HVFS"); |
|
442 |
251 |
443 /** @return ETrue if "Automounter" FS is mounted on this drive */ |
252 /** @return ETrue if "Automounter" FS is mounted on this drive */ |
444 TBool F32_Test_Utils::Is_Automounter(RFs &aFs, TInt aDrive) |
253 TBool F32_Test_Utils::Is_Automounter(RFs &aFs, TInt aDrive) |
445 { |
254 { |
446 ASSERT(aDrive >= EDriveA && aDrive <= EDriveZ); |
255 ASSERT(aDrive >= EDriveA && aDrive <= EDriveZ); |
462 |
271 |
463 return (f.CompareF(KFsName_LFFS) == 0 ); |
272 return (f.CompareF(KFsName_LFFS) == 0 ); |
464 |
273 |
465 } |
274 } |
466 |
275 |
467 /** @return ETrue if "Win32" FS is mounted on this drive (i.e this is emulator's drive C:) */ |
276 /** @return ETrue if "Win32" FS is mounted on this drive (i.e this is emulator's drive c:) */ |
468 TBool F32_Test_Utils::Is_Win32(RFs &aFs, TInt aDrive) |
277 TBool F32_Test_Utils::Is_Win32(RFs &aFs, TInt aDrive) |
469 { |
278 { |
470 ASSERT(aDrive >= EDriveA && aDrive <= EDriveZ); |
279 ASSERT(aDrive >= EDriveA && aDrive <= EDriveZ); |
471 TFSName f; |
280 TFSName f; |
472 TInt r = aFs.FileSystemName(f, aDrive); |
281 TInt r = aFs.FileSystemName(f, aDrive); |
473 __ASSERT_ALWAYS((r==KErrNone) && (f.Length()>0), User::Invariant()); |
282 __ASSERT_ALWAYS((r==KErrNone) && (f.Length()>0), User::Invariant()); |
474 |
283 |
475 return (f.CompareF(KFsName_Win32) == 0 ); |
284 return (f.CompareF(KFsName_Win32) == 0 ); |
476 } |
|
477 |
|
478 /** @return ETrue if "HVFS" is mounted on this drive (i.e PlatSim's drive C:) */ |
|
479 TBool F32_Test_Utils::Is_HVFS(RFs &aFs, TInt aDrive) |
|
480 { |
|
481 ASSERT(aDrive >= EDriveA && aDrive <= EDriveZ); |
|
482 TFSName f; |
|
483 TInt r = aFs.FileSystemName(f, aDrive); |
|
484 __ASSERT_ALWAYS((r==KErrNone) && (f.Length()>0), User::Invariant()); |
|
485 |
|
486 return (f.CompareF(KFsName_HVFS) == 0); |
|
487 } |
|
488 |
|
489 /** @return ETrue if "HVFS" or "Win32" FS is mounted on this drive |
|
490 * (i.e drive C: of PlatSim or the emulator) */ |
|
491 TBool F32_Test_Utils::Is_SimulatedSystemDrive(RFs &aFs, TInt aDrive) |
|
492 { |
|
493 ASSERT(aDrive >= EDriveA && aDrive <= EDriveZ); |
|
494 TFSName f; |
|
495 TInt r = aFs.FileSystemName(f, aDrive); |
|
496 __ASSERT_ALWAYS((r==KErrNone) && (f.Length()>0), User::Invariant()); |
|
497 |
|
498 return (f.CompareF(KFsName_HVFS) == 0 || f.CompareF(KFsName_Win32) == 0); |
|
499 } |
285 } |
500 |
286 |
501 /** @return ETrue if the filesystem if FAT (fat12/16/32) */ |
287 /** @return ETrue if the filesystem if FAT (fat12/16/32) */ |
502 TBool F32_Test_Utils::Is_Fat(RFs &aFs, TInt aDrive) |
288 TBool F32_Test_Utils::Is_Fat(RFs &aFs, TInt aDrive) |
503 { |
289 { |