os/kernelhwsrv/kerneltest/f32test/manager/t_proc.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/kernelhwsrv/kerneltest/f32test/manager/t_proc.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,144 @@
     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\manager\t_proc.cpp
    1.18 +// 
    1.19 +//
    1.20 +
    1.21 +#include <f32file.h>
    1.22 +#include <e32test.h>
    1.23 +#include <e32svr.h>
    1.24 +#include <hal.h>
    1.25 +#include "t_server.h"
    1.26 +#include "t_chlffs.h"
    1.27 +
    1.28 +GLDEF_D RTest test(_L("T_PROC"));
    1.29 +
    1.30 +LOCAL_C TInt ThreadMain(TAny* /*aPtr*/)
    1.31 +//
    1.32 +// Startup function for thread
    1.33 +//
    1.34 +	{
    1.35 +
    1.36 +	RFs localFs;
    1.37 +	TInt r=localFs.Connect();
    1.38 +	if (r != KErrNone)
    1.39 +		User::Panic(_L("tm0"), r);
    1.40 +	
    1.41 +	r=localFs.SetSessionPath(gSessionPath);
    1.42 +	if (r != KErrNone)
    1.43 +		User::Panic(_L("tm1"), r);
    1.44 +
    1.45 +	TInt count;
    1.46 +	RFormat f;
    1.47 +#if defined(__MARM__)
    1.48 +	TBuf<4> dirBuf=_L("?:\\");
    1.49 +	dirBuf[0] = (TText)gDriveToTest;
    1.50 +	r=f.Open(localFs,dirBuf,EQuickFormat,count);
    1.51 +#else	
    1.52 +	r=f.Open(localFs,_L("Y:\\"),EQuickFormat,count);
    1.53 +#endif
    1.54 +	if (r != KErrNone)
    1.55 +		User::Panic(_L("tm2"), r);
    1.56 +	f.Close();
    1.57 +
    1.58 +	TInt drv;
    1.59 +	r = RFs::CharToDrive(gSessionPath[0], drv);
    1.60 +	if (r != KErrNone)
    1.61 +		User::Panic(_L("tm3"), r);
    1.62 +
    1.63 +
    1.64 +	RRawDisk raw;
    1.65 +	r=raw.Open(localFs,drv);
    1.66 +	if (r != KErrNone)
    1.67 +		User::Panic(_L("tm4"), r);
    1.68 +
    1.69 +	raw.Close();
    1.70 +	return(KErrNone);
    1.71 +	}
    1.72 +
    1.73 +LOCAL_C void testThreads()
    1.74 +//
    1.75 +//	Run a process that opens a file, format, directory and check that when 
    1.76 +//	the process closes they are all still accessible.
    1.77 +//
    1.78 +	{
    1.79 +
    1.80 +	RThread thread;
    1.81 +	TInt r=thread.Create(_L("Thread1"),ThreadMain,KDefaultStackSize,KMinHeapSize,0x10000,NULL);
    1.82 +	test(r==KErrNone);
    1.83 +	TRequestStatus reqStat;
    1.84 +	thread.Logon(reqStat);
    1.85 +	thread.Resume();
    1.86 +	thread.Close();
    1.87 +	User::WaitForRequest(reqStat);
    1.88 +//
    1.89 +#if defined(__MARM__)
    1.90 +	TBuf<13> dirBuf=_L("?:\\F32-TST\\");
    1.91 +	dirBuf[0] = (TText)gDriveToTest;
    1.92 +	r=TheFs.MkDir(dirBuf);
    1.93 +#else
    1.94 +	r=TheFs.MkDir(_L("Y:\\F32-TST\\"));
    1.95 +#endif
    1.96 +	test(r==KErrNone || r==KErrAlreadyExists);
    1.97 +	RFile f;	
    1.98 +
    1.99 +	r=f.Open(TheFs,_L("THREADFILE.TEST"),EFileRead);
   1.100 +	test(r==KErrNotFound || r==KErrPathNotFound || r==KErrNone);
   1.101 +	f.Close();
   1.102 +
   1.103 +	r=f.Replace(TheFs,_L("THREADFILE.TEST"),EFileRead|EFileWrite);
   1.104 +	test(r==KErrNone);
   1.105 +	f.Close();
   1.106 +	}
   1.107 +
   1.108 +LOCAL_C void DoTests()
   1.109 +//
   1.110 +// Run tests
   1.111 +//	
   1.112 +	{
   1.113 +//	TInt r=TheFs.SessionPath(gSessionPath);
   1.114 +//	test(r==KErrNone);
   1.115 +	testThreads();
   1.116 +	}
   1.117 +
   1.118 +
   1.119 +GLDEF_C void CallTestsL(void)
   1.120 +//
   1.121 +// Test the file server.
   1.122 +//
   1.123 +    {
   1.124 +	
   1.125 +	test.Title();
   1.126 +
   1.127 +	TChar driveLetter;
   1.128 +	if (IsSessionDriveLFFS(TheFs,driveLetter))
   1.129 +		{
   1.130 +		test.Printf(_L("Skipped: test does not run on LFFS.\n"));
   1.131 +		return;
   1.132 +		}
   1.133 +	test.Start(_L("Starting T_PROC test"));
   1.134 +	TInt uid;
   1.135 +	test(HAL::Get(HAL::EMachineUid,uid)==KErrNone);
   1.136 +	
   1.137 +	if(uid==HAL::EMachineUid_Cogent || uid==HAL::EMachineUid_IQ80310 || uid==HAL::EMachineUid_Integrator || uid==HAL::EMachineUid_X86PC)
   1.138 +		{
   1.139 +		test.Printf(_L("WARNING: d: not tested on cogent or IQ80310 or Integrator\n"));
   1.140 +		goto End;
   1.141 +		}
   1.142 +	DoTests();
   1.143 +End:
   1.144 +	test.End();
   1.145 +	return;
   1.146 +    }
   1.147 +