1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/ossrv/genericopenlibs/cstdlib/TSTLIB/T_UCRT0P1.CPP Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,127 @@
1.4 +// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +//
1.18 +
1.19 +#include <e32cons.h>
1.20 +#include <e32test.h>
1.21 +
1.22 +
1.23 +LOCAL_D RTest test(_L("T_UCRT0P1"));
1.24 +LOCAL_D RProcess me;
1.25 +
1.26 +
1.27 +/**
1.28 +@SYMTestCaseID SYSLIB-STDLIB-UT-1669
1.29 +@SYMTestCaseDesc Testing whether increasing KMaxArgC from 20 to 25 results in the extra arguments
1.30 + passed in to a new process to be handled correctly.
1.31 +@SYMTestPriority High
1.32 +@SYMTestActions Starts a new process (T_UCRT0P2) passing in a set of arguments and this new process
1.33 + checks all the arguements were handled correctly.
1.34 +@SYMTestExpectedResults The test should not fail.
1.35 +@SYMDEF DEF074278
1.36 +*/
1.37 +void Defect_DEF074278()
1.38 + {
1.39 + test.Next(_L(" @SYMTestCaseID:SYSLIB-STDLIB-UT-1669 - Defect_DEF074278... "));
1.40 +
1.41 + 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 "));
1.42 +
1.43 + test.Printf(_L("Create a new process passing in a large number of arguements\n"));
1.44 + //Creating another process to run T_UCRT0P2 passing in 24 arguments (25th will be the
1.45 + //path and name of the exe). T_UCRT0P2 should only be run via this test and not on it's own.
1.46 + TInt err=me.Create(_L("T_UCRT0P2"),arguments);
1.47 + if (err==KErrNotFound)
1.48 + err=me.Create(_L("z:\\test\\T_UCRT0P2"),arguments);
1.49 + if (err==KErrNotFound)
1.50 + err=me.Create(_L("c:\\test\\T_UCRT0P2"),arguments);
1.51 + if (err==KErrNotFound)
1.52 + err=me.Create(_L("z:\\sys\\bin\\T_UCRT0P2"),arguments);
1.53 + test(err==KErrNone);
1.54 +
1.55 + //Checking that the child proces T_UCRT0P2 executes properly with no panic
1.56 + TRequestStatus status;
1.57 + me.Logon(status);
1.58 + me.Resume();
1.59 + User::WaitForRequest(status);
1.60 + //Test to make sure the child process ended correctly
1.61 + test(status==KErrNone);
1.62 + test(me.ExitReason()==KErrNone);
1.63 + me.Close();
1.64 + }
1.65 +
1.66 +
1.67 +/**
1.68 +@SYMTestCaseID SYSLIB-STDLIB-UT-4003
1.69 +@SYMTestCaseDesc When there are heap memory allocation failures in __crt0, any locally allocated
1.70 + heap memory should be cleaned up before the pointers go out of scope, preventing a memory leak.
1.71 +@SYMTestPriority Medium
1.72 +@SYMTestActions Start new process (T_UCRT0P3) passing arguments. Set heap allocation to fail at certain
1.73 + points in __crt0. Clean up any locally allocated before routine returns. Check pointers
1.74 + are set to NULL and there are no memory leaks.
1.75 +@SYMTestExpectedResults No memory is leaked and pointer are NULL.
1.76 +@SYMDEF DEF124477
1.77 +*/
1.78 +void Defect_DEF124477()
1.79 + {
1.80 + test.Next(_L("@SYMTestCaseID:SYSLIB-STDLIB-UT-4003 - Defect_DEF124477..."));
1.81 +
1.82 + TBuf<20> arguments(_L("random arguements"));
1.83 +
1.84 + test.Printf(_L("Create a new process passing in the arguements\n"));
1.85 + //Creating another process to run T_UCRT0P3 passing in the arguments.
1.86 + // T_UCRT0P3 should only be run via this test and not on it's own.
1.87 + TInt err=me.Create(_L("T_UCRT0P3"),arguments);
1.88 + if (err==KErrNotFound)
1.89 + err=me.Create(_L("z:\\test\\T_UCRT0P3"),arguments);
1.90 + test(err==KErrNone);
1.91 +
1.92 + //Checking that the child proces T_UCRT0P3 executes properly with no panic
1.93 + TRequestStatus status;
1.94 + me.Logon(status);
1.95 + me.Resume();
1.96 + User::WaitForRequest(status);
1.97 + //Test to make sure the child process ended correctly
1.98 + test(status==KErrNone);
1.99 + test(me.ExitReason()==KErrNone);
1.100 + me.Close();
1.101 + }
1.102 +
1.103 +/**
1.104 +Invoke the tests
1.105 +*/
1.106 +LOCAL_C void RunTestsL()
1.107 + {
1.108 + Defect_DEF074278();
1.109 + #ifdef _DEBUG
1.110 + Defect_DEF124477(); // OOM related test.
1.111 + #endif
1.112 + }
1.113 +
1.114 +
1.115 +GLDEF_C TInt E32Main()
1.116 + {
1.117 + test.Title();
1.118 + test.Start(_L(" Running T_UCRT0P1 tests..."));
1.119 + __UHEAP_MARK;
1.120 + CTrapCleanup* cleanup=CTrapCleanup::New();
1.121 + test(cleanup != NULL);
1.122 + TRAPD(error,RunTestsL());
1.123 + test(error==KErrNone);
1.124 + test.End();
1.125 + test.Close();
1.126 + delete cleanup;
1.127 + __UHEAP_MARKEND;
1.128 + return 0;
1.129 + }
1.130 +