sl@0: // Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of the License "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // f32test\manager\t_proc.cpp sl@0: // sl@0: // sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include "t_server.h" sl@0: #include "t_chlffs.h" sl@0: sl@0: GLDEF_D RTest test(_L("T_PROC")); sl@0: sl@0: LOCAL_C TInt ThreadMain(TAny* /*aPtr*/) sl@0: // sl@0: // Startup function for thread sl@0: // sl@0: { sl@0: sl@0: RFs localFs; sl@0: TInt r=localFs.Connect(); sl@0: if (r != KErrNone) sl@0: User::Panic(_L("tm0"), r); sl@0: sl@0: r=localFs.SetSessionPath(gSessionPath); sl@0: if (r != KErrNone) sl@0: User::Panic(_L("tm1"), r); sl@0: sl@0: TInt count; sl@0: RFormat f; sl@0: #if defined(__MARM__) sl@0: TBuf<4> dirBuf=_L("?:\\"); sl@0: dirBuf[0] = (TText)gDriveToTest; sl@0: r=f.Open(localFs,dirBuf,EQuickFormat,count); sl@0: #else sl@0: r=f.Open(localFs,_L("Y:\\"),EQuickFormat,count); sl@0: #endif sl@0: if (r != KErrNone) sl@0: User::Panic(_L("tm2"), r); sl@0: f.Close(); sl@0: sl@0: TInt drv; sl@0: r = RFs::CharToDrive(gSessionPath[0], drv); sl@0: if (r != KErrNone) sl@0: User::Panic(_L("tm3"), r); sl@0: sl@0: sl@0: RRawDisk raw; sl@0: r=raw.Open(localFs,drv); sl@0: if (r != KErrNone) sl@0: User::Panic(_L("tm4"), r); sl@0: sl@0: raw.Close(); sl@0: return(KErrNone); sl@0: } sl@0: sl@0: LOCAL_C void testThreads() sl@0: // sl@0: // Run a process that opens a file, format, directory and check that when sl@0: // the process closes they are all still accessible. sl@0: // sl@0: { sl@0: sl@0: RThread thread; sl@0: TInt r=thread.Create(_L("Thread1"),ThreadMain,KDefaultStackSize,KMinHeapSize,0x10000,NULL); sl@0: test(r==KErrNone); sl@0: TRequestStatus reqStat; sl@0: thread.Logon(reqStat); sl@0: thread.Resume(); sl@0: thread.Close(); sl@0: User::WaitForRequest(reqStat); sl@0: // sl@0: #if defined(__MARM__) sl@0: TBuf<13> dirBuf=_L("?:\\F32-TST\\"); sl@0: dirBuf[0] = (TText)gDriveToTest; sl@0: r=TheFs.MkDir(dirBuf); sl@0: #else sl@0: r=TheFs.MkDir(_L("Y:\\F32-TST\\")); sl@0: #endif sl@0: test(r==KErrNone || r==KErrAlreadyExists); sl@0: RFile f; sl@0: sl@0: r=f.Open(TheFs,_L("THREADFILE.TEST"),EFileRead); sl@0: test(r==KErrNotFound || r==KErrPathNotFound || r==KErrNone); sl@0: f.Close(); sl@0: sl@0: r=f.Replace(TheFs,_L("THREADFILE.TEST"),EFileRead|EFileWrite); sl@0: test(r==KErrNone); sl@0: f.Close(); sl@0: } sl@0: sl@0: LOCAL_C void DoTests() sl@0: // sl@0: // Run tests sl@0: // sl@0: { sl@0: // TInt r=TheFs.SessionPath(gSessionPath); sl@0: // test(r==KErrNone); sl@0: testThreads(); sl@0: } sl@0: sl@0: sl@0: GLDEF_C void CallTestsL(void) sl@0: // sl@0: // Test the file server. sl@0: // sl@0: { sl@0: sl@0: test.Title(); sl@0: sl@0: TChar driveLetter; sl@0: if (IsSessionDriveLFFS(TheFs,driveLetter)) sl@0: { sl@0: test.Printf(_L("Skipped: test does not run on LFFS.\n")); sl@0: return; sl@0: } sl@0: test.Start(_L("Starting T_PROC test")); sl@0: TInt uid; sl@0: test(HAL::Get(HAL::EMachineUid,uid)==KErrNone); sl@0: sl@0: if(uid==HAL::EMachineUid_Cogent || uid==HAL::EMachineUid_IQ80310 || uid==HAL::EMachineUid_Integrator || uid==HAL::EMachineUid_X86PC) sl@0: { sl@0: test.Printf(_L("WARNING: d: not tested on cogent or IQ80310 or Integrator\n")); sl@0: goto End; sl@0: } sl@0: DoTests(); sl@0: End: sl@0: test.End(); sl@0: return; sl@0: } sl@0: