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