genericopenlibs/cstdlib/TSTLIB/T_UCRT0P1.CPP
changeset 0 e4d67989cc36
child 67 a1e347446159
equal deleted inserted replaced
-1:000000000000 0:e4d67989cc36
       
     1 // Copyright (c) 2005-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 //
       
    15 
       
    16 #include <e32cons.h>
       
    17 #include <e32test.h>
       
    18 
       
    19 
       
    20 LOCAL_D RTest test(_L("T_UCRT0P1"));
       
    21 LOCAL_D RProcess me;
       
    22 
       
    23 
       
    24 /**
       
    25 @SYMTestCaseID 			SYSLIB-STDLIB-UT-1669
       
    26 @SYMTestCaseDesc	    Testing whether increasing KMaxArgC from 20 to 25 results in the extra arguments
       
    27 						passed in to a new process to be handled correctly.
       
    28 @SYMTestPriority 	    High
       
    29 @SYMTestActions  	    Starts a new process (T_UCRT0P2) passing in a set of arguments and this new process
       
    30 						checks all the arguements were handled correctly.
       
    31 @SYMTestExpectedResults The test should not fail.
       
    32 @SYMDEF 				DEF074278
       
    33 */
       
    34 void Defect_DEF074278()
       
    35 	{
       
    36 	test.Next(_L(" @SYMTestCaseID:SYSLIB-STDLIB-UT-1669 - Defect_DEF074278... "));
       
    37 	
       
    38 	TBuf<180> arguments(_L("one two three four five six seven eight nine ten eleven twelve thirteen fourteen fifteen sixteen seventeen eighteen nineteen twenty twenty-one twenty-two twenty-three twenty-four "));
       
    39 
       
    40 	test.Printf(_L("Create a new process passing in a large number of arguements\n"));
       
    41 	//Creating another process to run T_UCRT0P2 passing in 24 arguments (25th will be the
       
    42 	//path and name of the exe). T_UCRT0P2 should only be run via this test and not on it's own.
       
    43 	TInt err=me.Create(_L("T_UCRT0P2"),arguments);
       
    44 	if (err==KErrNotFound)
       
    45 		err=me.Create(_L("z:\\test\\T_UCRT0P2"),arguments);
       
    46 	test(err==KErrNone);
       
    47 
       
    48 	//Checking that the child proces T_UCRT0P2 executes properly with no panic
       
    49 	TRequestStatus status;
       
    50 	me.Logon(status);
       
    51 	me.Resume();
       
    52 	User::WaitForRequest(status);
       
    53 	//Test to make sure the child process ended correctly
       
    54 	test(status==KErrNone);
       
    55 	test(me.ExitReason()==KErrNone);
       
    56 	me.Close();
       
    57 	}
       
    58 
       
    59 
       
    60 /**
       
    61 @SYMTestCaseID           SYSLIB-STDLIB-UT-4003
       
    62 @SYMTestCaseDesc	     When there are heap memory allocation failures in __crt0, any locally allocated
       
    63                          heap memory should be cleaned up before the pointers go out of scope, preventing a memory leak.
       
    64 @SYMTestPriority         Medium
       
    65 @SYMTestActions  	     Start new process (T_UCRT0P3) passing arguments. Set heap allocation to fail at certain
       
    66                          points in __crt0. Clean up any locally allocated before routine returns. Check pointers
       
    67                          are set to NULL and there are no memory leaks. 
       
    68 @SYMTestExpectedResults  No memory is leaked and pointer are NULL.
       
    69 @SYMDEF                  DEF124477
       
    70 */
       
    71 void Defect_DEF124477()
       
    72 	{
       
    73 	test.Next(_L("@SYMTestCaseID:SYSLIB-STDLIB-UT-4003 - Defect_DEF124477..."));
       
    74 	
       
    75 	TBuf<20> arguments(_L("random arguements"));
       
    76 
       
    77 	test.Printf(_L("Create a new process passing in the arguements\n"));
       
    78 	//Creating another process to run T_UCRT0P3 passing in the arguments. 
       
    79 	// T_UCRT0P3 should only be run via this test and not on it's own.
       
    80 	TInt err=me.Create(_L("T_UCRT0P3"),arguments);
       
    81 	if (err==KErrNotFound)
       
    82 		err=me.Create(_L("z:\\test\\T_UCRT0P3"),arguments);
       
    83 	test(err==KErrNone);
       
    84 
       
    85 	//Checking that the child proces T_UCRT0P3 executes properly with no panic
       
    86 	TRequestStatus status;
       
    87 	me.Logon(status);
       
    88 	me.Resume();
       
    89 	User::WaitForRequest(status);
       
    90 	//Test to make sure the child process ended correctly
       
    91 	test(status==KErrNone);
       
    92 	test(me.ExitReason()==KErrNone);
       
    93 	me.Close();
       
    94 	}
       
    95 
       
    96 /**
       
    97 Invoke the tests
       
    98 */
       
    99 LOCAL_C void RunTestsL()
       
   100     {
       
   101 	Defect_DEF074278();
       
   102 	#ifdef _DEBUG	
       
   103 		Defect_DEF124477();  // OOM related test.
       
   104 	#endif
       
   105 	}
       
   106 
       
   107 
       
   108 GLDEF_C TInt E32Main()
       
   109     {
       
   110 	test.Title();
       
   111 	test.Start(_L(" Running T_UCRT0P1 tests..."));
       
   112 	__UHEAP_MARK;
       
   113 	CTrapCleanup* cleanup=CTrapCleanup::New();
       
   114 	test(cleanup != NULL);
       
   115 	TRAPD(error,RunTestsL());
       
   116 	test(error==KErrNone);
       
   117 	test.End();
       
   118 	test.Close();
       
   119 	delete cleanup;
       
   120 	__UHEAP_MARKEND;
       
   121 	return 0;
       
   122     }
       
   123