os/ossrv/genericopenlibs/cstdlib/TSTLIB/T_UCRT0P1.CPP
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     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     if (err==KErrNotFound)
    47         err=me.Create(_L("c:\\test\\T_UCRT0P2"),arguments);
    48     if (err==KErrNotFound)
    49         err=me.Create(_L("z:\\sys\\bin\\T_UCRT0P2"),arguments);
    50 	test(err==KErrNone);
    51 
    52 	//Checking that the child proces T_UCRT0P2 executes properly with no panic
    53 	TRequestStatus status;
    54 	me.Logon(status);
    55 	me.Resume();
    56 	User::WaitForRequest(status);
    57 	//Test to make sure the child process ended correctly
    58 	test(status==KErrNone);
    59 	test(me.ExitReason()==KErrNone);
    60 	me.Close();
    61 	}
    62 
    63 
    64 /**
    65 @SYMTestCaseID           SYSLIB-STDLIB-UT-4003
    66 @SYMTestCaseDesc	     When there are heap memory allocation failures in __crt0, any locally allocated
    67                          heap memory should be cleaned up before the pointers go out of scope, preventing a memory leak.
    68 @SYMTestPriority         Medium
    69 @SYMTestActions  	     Start new process (T_UCRT0P3) passing arguments. Set heap allocation to fail at certain
    70                          points in __crt0. Clean up any locally allocated before routine returns. Check pointers
    71                          are set to NULL and there are no memory leaks. 
    72 @SYMTestExpectedResults  No memory is leaked and pointer are NULL.
    73 @SYMDEF                  DEF124477
    74 */
    75 void Defect_DEF124477()
    76 	{
    77 	test.Next(_L("@SYMTestCaseID:SYSLIB-STDLIB-UT-4003 - Defect_DEF124477..."));
    78 	
    79 	TBuf<20> arguments(_L("random arguements"));
    80 
    81 	test.Printf(_L("Create a new process passing in the arguements\n"));
    82 	//Creating another process to run T_UCRT0P3 passing in the arguments. 
    83 	// T_UCRT0P3 should only be run via this test and not on it's own.
    84 	TInt err=me.Create(_L("T_UCRT0P3"),arguments);
    85 	if (err==KErrNotFound)
    86 		err=me.Create(_L("z:\\test\\T_UCRT0P3"),arguments);
    87 	test(err==KErrNone);
    88 
    89 	//Checking that the child proces T_UCRT0P3 executes properly with no panic
    90 	TRequestStatus status;
    91 	me.Logon(status);
    92 	me.Resume();
    93 	User::WaitForRequest(status);
    94 	//Test to make sure the child process ended correctly
    95 	test(status==KErrNone);
    96 	test(me.ExitReason()==KErrNone);
    97 	me.Close();
    98 	}
    99 
   100 /**
   101 Invoke the tests
   102 */
   103 LOCAL_C void RunTestsL()
   104     {
   105 	Defect_DEF074278();
   106 	#ifdef _DEBUG	
   107 		Defect_DEF124477();  // OOM related test.
   108 	#endif
   109 	}
   110 
   111 
   112 GLDEF_C TInt E32Main()
   113     {
   114 	test.Title();
   115 	test.Start(_L(" Running T_UCRT0P1 tests..."));
   116 	__UHEAP_MARK;
   117 	CTrapCleanup* cleanup=CTrapCleanup::New();
   118 	test(cleanup != NULL);
   119 	TRAPD(error,RunTestsL());
   120 	test(error==KErrNone);
   121 	test.End();
   122 	test.Close();
   123 	delete cleanup;
   124 	__UHEAP_MARKEND;
   125 	return 0;
   126     }
   127