sysstatemgmt/systemstarter/test/testprocslowlog/testprocslowlog.cpp
changeset 0 4e1aa6a622a0
equal deleted inserted replaced
-1:000000000000 0:4e1aa6a622a0
       
     1 // Copyright (c) 2007-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 "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 // This process waits 1 second then writes the content of the command line to   *
       
    15 // the log file.                                                                *
       
    16 // In this way, if the process is launched multiple times in sequence, with     *
       
    17 // the command line consisting of an incrementing integer, you can discover     *
       
    18 // how far along the list successful executions have gone. The wait of one      *
       
    19 // second is there so that a list can be constructed which takes a non-trivial  *
       
    20 // amount of time to run from beginning to end without having to populate it    *
       
    21 // with an extrememly large number of processes to launch.                      *
       
    22 // 
       
    23 //
       
    24 
       
    25 /**
       
    26  @file
       
    27  @test
       
    28  @internalComponent - Internal Symbian test code
       
    29 */
       
    30 
       
    31 #include <e32base.h>
       
    32 #include <f32file.h>
       
    33 #include <s32file.h>
       
    34 #include <startupproperties.h>
       
    35 #include "testapps.h"
       
    36 
       
    37 _LIT(KLogFileName, "C:\\testprocslow.log");
       
    38 
       
    39 static void RunL()
       
    40 	{
       
    41 	User::After(1000000); //Microseconds = 1s
       
    42 
       
    43 	const TInt KMaxCommandLength = 256;
       
    44 	TBuf<KMaxCommandLength> commandLine;
       
    45 	if(User::CommandLineLength() > commandLine.MaxLength())
       
    46 		{
       
    47 		User::Leave(KErrTooBig);
       
    48 		}
       
    49 	User::CommandLine(commandLine);
       
    50 	
       
    51 	RFs fs;
       
    52 	User::LeaveIfError(fs.Connect());
       
    53 	CleanupClosePushL(fs);
       
    54 	RFileWriteStream ws;
       
    55 	User::LeaveIfError(ws.Replace(fs, KLogFileName, EFileShareExclusive|EFileWrite));
       
    56 	ws.PushL();
       
    57 	ws.WriteL(commandLine);
       
    58 	ws.CommitL();
       
    59 	CleanupStack::PopAndDestroy(2);// fs, ws
       
    60 
       
    61 	RProcess::Rendezvous(KErrNone);
       
    62 	
       
    63 	}
       
    64 
       
    65 TInt E32Main()
       
    66 	{
       
    67 	__UHEAP_MARK;
       
    68 
       
    69 	CTrapCleanup* cleanup=CTrapCleanup::New();
       
    70 	TInt r=KErrNoMemory;
       
    71 	if (cleanup)
       
    72 		{
       
    73 		TRAP(r,RunL());
       
    74 		delete cleanup;
       
    75 		}
       
    76 
       
    77 	__UHEAP_MARKEND;
       
    78 	return r;
       
    79 	}