1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/kernelhwsrv/kerneltest/f32test/server/b_mtst.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,153 @@
1.4 +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of the License "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +// f32test\server\b_mtst.cpp
1.18 +// Tests file deleteing
1.19 +//
1.20 +//
1.21 +
1.22 +#include <f32file.h>
1.23 +#include <e32test.h>
1.24 +#include "t_server.h"
1.25 +
1.26 +RTest test(_L("B_MTST"));
1.27 +//LOCAL_D RFs TheFs;
1.28 +
1.29 +const TInt nTimes=20;
1.30 +
1.31 +GLDEF_D RFile file1;
1.32 +GLDEF_D RFile file2;
1.33 +GLDEF_D RFile file3;
1.34 +GLDEF_D RFile file4;
1.35 +GLDEF_D RFile file5;
1.36 +GLDEF_D TBuf8<0x200> buf;
1.37 +GLDEF_D TBuf8<0x200> buf1;
1.38 +GLDEF_D TBuf8<0x200> buf2;
1.39 +GLDEF_D TBuf8<0x200> buf3;
1.40 +GLDEF_D TBuf8<0x200> buf4;
1.41 +GLDEF_D TBuf8<0x200> buf5;
1.42 +GLDEF_D TFileName nameBuf1=_L("B_MTST File 1");
1.43 +GLDEF_D TFileName nameBuf2=_L("B_MTST File 2");
1.44 +GLDEF_D TFileName nameBuf3=_L("B_MTST File 3");
1.45 +GLDEF_D TFileName nameBuf4=_L("B_MTST File 4");
1.46 +GLDEF_D TFileName nameBuf5=_L("B_MTST File 5");
1.47 +
1.48 +const TInt len1=163;
1.49 +const TInt len2=31;
1.50 +const TInt len3=271;
1.51 +const TInt len4=128;
1.52 +const TInt len5=14;
1.53 +
1.54 +LOCAL_C void checkPattern()
1.55 + {
1.56 + test.Printf(_L("Opening: %S\n"),&nameBuf1);
1.57 + TInt r=file1.Open(TheFs,nameBuf1,EFileStream);
1.58 + test(r==KErrNone);
1.59 + test.Printf(_L("Opening: %S\n"),&nameBuf2);
1.60 + r=file2.Open(TheFs,nameBuf2,EFileStream);
1.61 + test(r==KErrNone);
1.62 + test.Printf(_L("Checking test pattern...\n"));
1.63 + for (TInt i=0 ; i<nTimes ; i++)
1.64 + {
1.65 + r=file1.Read(buf,len1);
1.66 + test(r==KErrNone);
1.67 + TInt j;
1.68 + for (j=0 ; j< len1 ; j++)
1.69 + test(buf[j]==j);
1.70 + r=file2.Read(buf,len2);
1.71 + test(r==KErrNone);
1.72 + for (j=0 ; j< len2 ; j++)
1.73 + test(buf[j]=='A');
1.74 + }
1.75 + file1.Close();
1.76 + file2.Close();
1.77 + }
1.78 +
1.79 +
1.80 +GLDEF_C void CallTestsL(void)
1.81 + {
1.82 + test.Title();
1.83 + test.Next(_L("Generate test patterns"));
1.84 + TInt i;
1.85 + for (i=0 ; i<len1 ; i++)
1.86 + buf1.Append((TUint8)i);
1.87 + for (i=0 ; i<len2 ; i++)
1.88 + buf2.Append('A');
1.89 + for (i=0 ; i<len3 ; i++)
1.90 + buf3.Append('B');
1.91 + for (i=0 ; i<len4 ; i++)
1.92 + buf4.Append('C');
1.93 + for (i=0 ; i<len5 ; i++)
1.94 + buf5.Append('D');
1.95 +
1.96 + TInt r=file1.Create(TheFs,nameBuf1,EFileStream|EFileWrite);
1.97 + test(r==KErrNone);
1.98 + test.Printf(_L("Created: %S\n"),&nameBuf1);
1.99 + r=file2.Create(TheFs,nameBuf2,EFileStream|EFileWrite);
1.100 + test(r==KErrNone);
1.101 + test.Printf(_L("Created: %S\n"),&nameBuf2);
1.102 + r=file3.Create(TheFs,nameBuf3,EFileStream|EFileWrite);
1.103 + test(r==KErrNone);
1.104 + test.Printf(_L("Created: %S\n"),&nameBuf3);
1.105 + r=file4.Create(TheFs,nameBuf4,EFileStream|EFileWrite);
1.106 + test(r==KErrNone);
1.107 + test.Printf(_L("Created: %S\n"),&nameBuf4);
1.108 + r=file5.Create(TheFs,nameBuf5,EFileStream|EFileWrite);
1.109 + test(r==KErrNone);
1.110 + test.Printf(_L("Created: %S\n"),&nameBuf5);
1.111 +
1.112 + test.Next(_L("Writing test pattern..."));
1.113 + for (i=0 ; i<nTimes ; i++)
1.114 + {
1.115 + r=file1.Write(buf1,len1);
1.116 + test(r==KErrNone);
1.117 + r=file2.Write(buf2,len2);
1.118 + test(r==KErrNone);
1.119 + r=file3.Write(buf3,len3);
1.120 + test(r==KErrNone);
1.121 + r=file4.Write(buf4,len4);
1.122 + test(r==KErrNone);
1.123 + r=file5.Write(buf5,len5);
1.124 + test(r==KErrNone);
1.125 + }
1.126 + file1.Close();
1.127 + file2.Close();
1.128 +
1.129 + test.Next(_L("Check pattern"));
1.130 + checkPattern();
1.131 +
1.132 + test.Next(_L("Delete"));
1.133 + test.Printf(_L("Deleting: %S\n"),&nameBuf1);
1.134 + r=TheFs.Delete(nameBuf1);
1.135 + test(r==KErrNone);
1.136 + test.Printf(_L("Deleting: %S\n"),&nameBuf2);
1.137 + r=TheFs.Delete(nameBuf2);
1.138 + test(r==KErrNone);
1.139 +
1.140 + file3.Close();
1.141 + file4.Close();
1.142 + file5.Close();
1.143 +
1.144 + test.Printf(_L("Deleting: %S\n"),&nameBuf3);
1.145 + r=TheFs.Delete(nameBuf3);
1.146 + test(r==KErrNone);
1.147 + test.Printf(_L("Deleting: %S\n"),&nameBuf4);
1.148 + r=TheFs.Delete(nameBuf4);
1.149 + test(r==KErrNone);
1.150 + test.Printf(_L("Deleting: %S\n"),&nameBuf5);
1.151 + r=TheFs.Delete(nameBuf5);
1.152 + test(r==KErrNone);
1.153 +
1.154 +// test.Close();
1.155 + }
1.156 +