kerneltest/e32test/misc/t_kill.cpp
changeset 0 a41df078684a
equal deleted inserted replaced
-1:000000000000 0:a41df078684a
       
     1 // Copyright (c) 1996-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 // e32test\misc\t_kill.cpp
       
    15 // 
       
    16 //
       
    17 
       
    18 #include <e32test.h>
       
    19 #include <f32file.h>
       
    20 #include "u32std.h"
       
    21 #include "../misc/prbs.h"
       
    22 
       
    23 RTest test(_L("T_KILL"));
       
    24 
       
    25 _LIT(KFileName1,"D:\\File1");
       
    26 _LIT(KFileName2,"D:\\File2");
       
    27 
       
    28 LOCAL_D TBuf8<1024> Cluster;
       
    29 LOCAL_D TBuf8<2048> WriteBuf;
       
    30 
       
    31 GLDEF_C TInt E32Main()
       
    32 	{
       
    33 	test.Title();
       
    34 	test.Start(_L("Connect to file server"));
       
    35 	RFs fs;
       
    36 	TInt r=fs.Connect();
       
    37 	test(r==KErrNone);
       
    38 
       
    39 	test.Next(_L("Delete old files"));
       
    40 	r=fs.Delete(KFileName1);
       
    41 	test(r==KErrNone || r==KErrNotFound);
       
    42 	r=fs.Delete(KFileName2);
       
    43 	test(r==KErrNone || r==KErrNotFound);
       
    44 
       
    45 	test.Next(_L("Create file 1"));
       
    46 	RFile file1;
       
    47 	r=file1.Create(fs,KFileName1,EFileWrite);
       
    48 	test(r==KErrNone);
       
    49 
       
    50 	test.Next(_L("Create file 2"));
       
    51 	RFile file2;
       
    52 	r=file2.Create(fs,KFileName2,EFileWrite);
       
    53 	test(r==KErrNone);
       
    54 
       
    55 	Cluster.SetLength(512);
       
    56 	test.Next(_L("Write 1024 bytes to file 1"));
       
    57 	r=file1.Write(Cluster);
       
    58 	test(r==KErrNone);
       
    59 
       
    60 	test.Next(_L("Write 1024 bytes to file 2"));
       
    61 	r=file2.Write(Cluster);
       
    62 	test(r==KErrNone);
       
    63 
       
    64 	test.Next(_L("Write 1024 bytes to file 1"));
       
    65 	r=file1.Write(Cluster);
       
    66 	test(r==KErrNone);
       
    67 
       
    68 	TUint seed[2];
       
    69 	seed[0]=0xb504f334;
       
    70 	seed[1]=0;
       
    71 	TInt p=0;
       
    72 	test.Next(_L("Rewind file 1"));
       
    73 	r=file1.Seek(ESeekStart,p);
       
    74 	test(r==KErrNone);
       
    75 	TInt size=WriteBuf.MaxLength();
       
    76 	WriteBuf.SetLength(size);
       
    77 	test.Next(_L("Get 2K of random data"));
       
    78 	TInt i;
       
    79 	for (i=0; i<size; i++)
       
    80 		WriteBuf[i]=static_cast<TUint8>(Random(seed));
       
    81 	test.Next(_L("Press a key to write to file 1"));
       
    82 	test.Getch();
       
    83 	TRequestStatus stat;
       
    84 	file1.Write(WriteBuf,stat);
       
    85 
       
    86 	return 0;
       
    87 	}
       
    88