os/kernelhwsrv/kerneltest/f32test/server/b_mtst.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of the License "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
// f32test\server\b_mtst.cpp
sl@0
    15
// Tests file deleteing
sl@0
    16
// 
sl@0
    17
//
sl@0
    18
sl@0
    19
#include <f32file.h>
sl@0
    20
#include <e32test.h>
sl@0
    21
#include "t_server.h"
sl@0
    22
sl@0
    23
RTest test(_L("B_MTST"));
sl@0
    24
//LOCAL_D	RFs TheFs;
sl@0
    25
sl@0
    26
const TInt nTimes=20;
sl@0
    27
sl@0
    28
GLDEF_D RFile file1;
sl@0
    29
GLDEF_D RFile file2;
sl@0
    30
GLDEF_D RFile file3;
sl@0
    31
GLDEF_D RFile file4;
sl@0
    32
GLDEF_D RFile file5;
sl@0
    33
GLDEF_D TBuf8<0x200> buf;
sl@0
    34
GLDEF_D TBuf8<0x200> buf1;
sl@0
    35
GLDEF_D TBuf8<0x200> buf2;
sl@0
    36
GLDEF_D TBuf8<0x200> buf3;
sl@0
    37
GLDEF_D TBuf8<0x200> buf4;
sl@0
    38
GLDEF_D TBuf8<0x200> buf5;
sl@0
    39
GLDEF_D TFileName nameBuf1=_L("B_MTST File 1");
sl@0
    40
GLDEF_D TFileName nameBuf2=_L("B_MTST File 2");
sl@0
    41
GLDEF_D TFileName nameBuf3=_L("B_MTST File 3");
sl@0
    42
GLDEF_D TFileName nameBuf4=_L("B_MTST File 4");
sl@0
    43
GLDEF_D TFileName nameBuf5=_L("B_MTST File 5");
sl@0
    44
sl@0
    45
const TInt len1=163;
sl@0
    46
const TInt len2=31;
sl@0
    47
const TInt len3=271;
sl@0
    48
const TInt len4=128;
sl@0
    49
const TInt len5=14;
sl@0
    50
sl@0
    51
LOCAL_C void checkPattern()
sl@0
    52
    {
sl@0
    53
    test.Printf(_L("Opening: %S\n"),&nameBuf1);
sl@0
    54
    TInt r=file1.Open(TheFs,nameBuf1,EFileStream);
sl@0
    55
	test(r==KErrNone);
sl@0
    56
    test.Printf(_L("Opening: %S\n"),&nameBuf2);
sl@0
    57
	r=file2.Open(TheFs,nameBuf2,EFileStream);
sl@0
    58
	test(r==KErrNone);
sl@0
    59
    test.Printf(_L("Checking test pattern...\n"));
sl@0
    60
	for (TInt i=0 ; i<nTimes ; i++)
sl@0
    61
        {
sl@0
    62
        r=file1.Read(buf,len1);
sl@0
    63
		test(r==KErrNone);
sl@0
    64
        TInt j;
sl@0
    65
		for (j=0 ; j< len1 ; j++)
sl@0
    66
            test(buf[j]==j);
sl@0
    67
        r=file2.Read(buf,len2);
sl@0
    68
		test(r==KErrNone);
sl@0
    69
        for (j=0 ; j< len2 ; j++)
sl@0
    70
            test(buf[j]=='A');
sl@0
    71
        }
sl@0
    72
    file1.Close();
sl@0
    73
    file2.Close();
sl@0
    74
    }
sl@0
    75
sl@0
    76
sl@0
    77
GLDEF_C void CallTestsL(void)
sl@0
    78
    {
sl@0
    79
	test.Title();
sl@0
    80
    test.Next(_L("Generate test patterns"));
sl@0
    81
	TInt i;
sl@0
    82
    for (i=0 ; i<len1 ; i++)
sl@0
    83
        buf1.Append((TUint8)i); 
sl@0
    84
    for (i=0 ; i<len2 ; i++)
sl@0
    85
        buf2.Append('A');       
sl@0
    86
    for (i=0 ; i<len3 ; i++)
sl@0
    87
        buf3.Append('B');       
sl@0
    88
    for (i=0 ; i<len4 ; i++)
sl@0
    89
        buf4.Append('C');       
sl@0
    90
    for (i=0 ; i<len5 ; i++)
sl@0
    91
        buf5.Append('D');       
sl@0
    92
sl@0
    93
    TInt r=file1.Create(TheFs,nameBuf1,EFileStream|EFileWrite);
sl@0
    94
	test(r==KErrNone);
sl@0
    95
    test.Printf(_L("Created: %S\n"),&nameBuf1);
sl@0
    96
    r=file2.Create(TheFs,nameBuf2,EFileStream|EFileWrite);
sl@0
    97
	test(r==KErrNone);
sl@0
    98
    test.Printf(_L("Created: %S\n"),&nameBuf2);
sl@0
    99
    r=file3.Create(TheFs,nameBuf3,EFileStream|EFileWrite);
sl@0
   100
	test(r==KErrNone);
sl@0
   101
    test.Printf(_L("Created: %S\n"),&nameBuf3);
sl@0
   102
    r=file4.Create(TheFs,nameBuf4,EFileStream|EFileWrite);
sl@0
   103
	test(r==KErrNone);
sl@0
   104
    test.Printf(_L("Created: %S\n"),&nameBuf4);
sl@0
   105
    r=file5.Create(TheFs,nameBuf5,EFileStream|EFileWrite);
sl@0
   106
	test(r==KErrNone);
sl@0
   107
    test.Printf(_L("Created: %S\n"),&nameBuf5);
sl@0
   108
    
sl@0
   109
    test.Next(_L("Writing test pattern..."));
sl@0
   110
    for (i=0 ; i<nTimes ; i++)
sl@0
   111
        {
sl@0
   112
        r=file1.Write(buf1,len1);
sl@0
   113
		test(r==KErrNone);
sl@0
   114
		r=file2.Write(buf2,len2);
sl@0
   115
		test(r==KErrNone);
sl@0
   116
		r=file3.Write(buf3,len3);
sl@0
   117
		test(r==KErrNone);
sl@0
   118
		r=file4.Write(buf4,len4);
sl@0
   119
		test(r==KErrNone);
sl@0
   120
		r=file5.Write(buf5,len5);
sl@0
   121
		test(r==KErrNone);
sl@0
   122
        }
sl@0
   123
    file1.Close();
sl@0
   124
	file2.Close();
sl@0
   125
sl@0
   126
    test.Next(_L("Check pattern"));
sl@0
   127
    checkPattern();
sl@0
   128
sl@0
   129
    test.Next(_L("Delete"));
sl@0
   130
    test.Printf(_L("Deleting: %S\n"),&nameBuf1);
sl@0
   131
    r=TheFs.Delete(nameBuf1);
sl@0
   132
	test(r==KErrNone);
sl@0
   133
    test.Printf(_L("Deleting: %S\n"),&nameBuf2);
sl@0
   134
	r=TheFs.Delete(nameBuf2);
sl@0
   135
	test(r==KErrNone);
sl@0
   136
    
sl@0
   137
    file3.Close();
sl@0
   138
    file4.Close();
sl@0
   139
    file5.Close();
sl@0
   140
    
sl@0
   141
    test.Printf(_L("Deleting: %S\n"),&nameBuf3);
sl@0
   142
    r=TheFs.Delete(nameBuf3);
sl@0
   143
	test(r==KErrNone);
sl@0
   144
    test.Printf(_L("Deleting: %S\n"),&nameBuf4);
sl@0
   145
	r=TheFs.Delete(nameBuf4);
sl@0
   146
	test(r==KErrNone);
sl@0
   147
    test.Printf(_L("Deleting: %S\n"),&nameBuf5);
sl@0
   148
	r=TheFs.Delete(nameBuf5);
sl@0
   149
	test(r==KErrNone);
sl@0
   150
sl@0
   151
//	test.Close();
sl@0
   152
    }
sl@0
   153