os/kernelhwsrv/kerneltest/f32test/manager/t_proc.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
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\manager\t_proc.cpp
sl@0
    15
// 
sl@0
    16
//
sl@0
    17
sl@0
    18
#include <f32file.h>
sl@0
    19
#include <e32test.h>
sl@0
    20
#include <e32svr.h>
sl@0
    21
#include <hal.h>
sl@0
    22
#include "t_server.h"
sl@0
    23
#include "t_chlffs.h"
sl@0
    24
sl@0
    25
GLDEF_D RTest test(_L("T_PROC"));
sl@0
    26
sl@0
    27
LOCAL_C TInt ThreadMain(TAny* /*aPtr*/)
sl@0
    28
//
sl@0
    29
// Startup function for thread
sl@0
    30
//
sl@0
    31
	{
sl@0
    32
sl@0
    33
	RFs localFs;
sl@0
    34
	TInt r=localFs.Connect();
sl@0
    35
	if (r != KErrNone)
sl@0
    36
		User::Panic(_L("tm0"), r);
sl@0
    37
	
sl@0
    38
	r=localFs.SetSessionPath(gSessionPath);
sl@0
    39
	if (r != KErrNone)
sl@0
    40
		User::Panic(_L("tm1"), r);
sl@0
    41
sl@0
    42
	TInt count;
sl@0
    43
	RFormat f;
sl@0
    44
#if defined(__MARM__)
sl@0
    45
	TBuf<4> dirBuf=_L("?:\\");
sl@0
    46
	dirBuf[0] = (TText)gDriveToTest;
sl@0
    47
	r=f.Open(localFs,dirBuf,EQuickFormat,count);
sl@0
    48
#else	
sl@0
    49
	r=f.Open(localFs,_L("Y:\\"),EQuickFormat,count);
sl@0
    50
#endif
sl@0
    51
	if (r != KErrNone)
sl@0
    52
		User::Panic(_L("tm2"), r);
sl@0
    53
	f.Close();
sl@0
    54
sl@0
    55
	TInt drv;
sl@0
    56
	r = RFs::CharToDrive(gSessionPath[0], drv);
sl@0
    57
	if (r != KErrNone)
sl@0
    58
		User::Panic(_L("tm3"), r);
sl@0
    59
sl@0
    60
sl@0
    61
	RRawDisk raw;
sl@0
    62
	r=raw.Open(localFs,drv);
sl@0
    63
	if (r != KErrNone)
sl@0
    64
		User::Panic(_L("tm4"), r);
sl@0
    65
sl@0
    66
	raw.Close();
sl@0
    67
	return(KErrNone);
sl@0
    68
	}
sl@0
    69
sl@0
    70
LOCAL_C void testThreads()
sl@0
    71
//
sl@0
    72
//	Run a process that opens a file, format, directory and check that when 
sl@0
    73
//	the process closes they are all still accessible.
sl@0
    74
//
sl@0
    75
	{
sl@0
    76
sl@0
    77
	RThread thread;
sl@0
    78
	TInt r=thread.Create(_L("Thread1"),ThreadMain,KDefaultStackSize,KMinHeapSize,0x10000,NULL);
sl@0
    79
	test(r==KErrNone);
sl@0
    80
	TRequestStatus reqStat;
sl@0
    81
	thread.Logon(reqStat);
sl@0
    82
	thread.Resume();
sl@0
    83
	thread.Close();
sl@0
    84
	User::WaitForRequest(reqStat);
sl@0
    85
//
sl@0
    86
#if defined(__MARM__)
sl@0
    87
	TBuf<13> dirBuf=_L("?:\\F32-TST\\");
sl@0
    88
	dirBuf[0] = (TText)gDriveToTest;
sl@0
    89
	r=TheFs.MkDir(dirBuf);
sl@0
    90
#else
sl@0
    91
	r=TheFs.MkDir(_L("Y:\\F32-TST\\"));
sl@0
    92
#endif
sl@0
    93
	test(r==KErrNone || r==KErrAlreadyExists);
sl@0
    94
	RFile f;	
sl@0
    95
sl@0
    96
	r=f.Open(TheFs,_L("THREADFILE.TEST"),EFileRead);
sl@0
    97
	test(r==KErrNotFound || r==KErrPathNotFound || r==KErrNone);
sl@0
    98
	f.Close();
sl@0
    99
sl@0
   100
	r=f.Replace(TheFs,_L("THREADFILE.TEST"),EFileRead|EFileWrite);
sl@0
   101
	test(r==KErrNone);
sl@0
   102
	f.Close();
sl@0
   103
	}
sl@0
   104
sl@0
   105
LOCAL_C void DoTests()
sl@0
   106
//
sl@0
   107
// Run tests
sl@0
   108
//	
sl@0
   109
	{
sl@0
   110
//	TInt r=TheFs.SessionPath(gSessionPath);
sl@0
   111
//	test(r==KErrNone);
sl@0
   112
	testThreads();
sl@0
   113
	}
sl@0
   114
sl@0
   115
sl@0
   116
GLDEF_C void CallTestsL(void)
sl@0
   117
//
sl@0
   118
// Test the file server.
sl@0
   119
//
sl@0
   120
    {
sl@0
   121
	
sl@0
   122
	test.Title();
sl@0
   123
sl@0
   124
	TChar driveLetter;
sl@0
   125
	if (IsSessionDriveLFFS(TheFs,driveLetter))
sl@0
   126
		{
sl@0
   127
		test.Printf(_L("Skipped: test does not run on LFFS.\n"));
sl@0
   128
		return;
sl@0
   129
		}
sl@0
   130
	test.Start(_L("Starting T_PROC test"));
sl@0
   131
	TInt uid;
sl@0
   132
	test(HAL::Get(HAL::EMachineUid,uid)==KErrNone);
sl@0
   133
	
sl@0
   134
	if(uid==HAL::EMachineUid_Cogent || uid==HAL::EMachineUid_IQ80310 || uid==HAL::EMachineUid_Integrator || uid==HAL::EMachineUid_X86PC)
sl@0
   135
		{
sl@0
   136
		test.Printf(_L("WARNING: d: not tested on cogent or IQ80310 or Integrator\n"));
sl@0
   137
		goto End;
sl@0
   138
		}
sl@0
   139
	DoTests();
sl@0
   140
End:
sl@0
   141
	test.End();
sl@0
   142
	return;
sl@0
   143
    }
sl@0
   144