os/ossrv/genericopenlibs/cstdlib/TSTLIB/T_UCRT0P2.CPP
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/ossrv/genericopenlibs/cstdlib/TSTLIB/T_UCRT0P2.CPP	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,111 @@
     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 +// *IMPORTANT*: This should only be run when called from T_UCRT0P1.
    1.18 +// See TestCase SYSLIB-0001 in T_UCRT0P1.CPP for more information.
    1.19 +// 
    1.20 +//
    1.21 +
    1.22 +#include <stdlib.h>
    1.23 +#include <e32debug.h>
    1.24 +#include <e32test.h>
    1.25 +#include <estlib.h>
    1.26 +
    1.27 +
    1.28 +RTest TheTest(_L("T_UCRT0P2"));
    1.29 +
    1.30 +
    1.31 +//Test macros and functions
    1.32 +LOCAL_C void Check(TInt aValue, TInt aLine)
    1.33 +	{
    1.34 +	if(!aValue)
    1.35 +		TheTest(EFalse, aLine);
    1.36 +	}
    1.37 +
    1.38 +LOCAL_C void Check(TInt aValue, TInt aExpected, TInt aLine)
    1.39 +	{
    1.40 +	if(aValue != aExpected)
    1.41 +		{
    1.42 +		RDebug::Print(_L("*** Expected error: %d, got: %d\r\n"), aExpected, aValue);
    1.43 +		TheTest(EFalse, aLine);
    1.44 +		}
    1.45 +	}
    1.46 +
    1.47 +#define TEST(arg) ::Check((arg), __LINE__)
    1.48 +#define TEST2(aValue, aExpected) ::Check(aValue, aExpected, __LINE__)
    1.49 +
    1.50 +
    1.51 +
    1.52 +//DEF074278: Java VM requires more command line testArguments.
    1.53 +void Defect_DEF074278_Part2()
    1.54 +	{
    1.55 +   	TBuf<180> testArguments(_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.56 +	TBuf<210> inputArguments;
    1.57 +
    1.58 +	TUint testArgNo = 25;
    1.59 +
    1.60 +	int argc=0;
    1.61 +	char** argv=0;
    1.62 +	char** envp=0;
    1.63 +
    1.64 +	TheTest.Printf(_L("Retrieving the arguments passed in from T_UCRT0P1\n"));
    1.65 +	__crt0(argc,argv,envp);			// get args & environment from somewhere
    1.66 +
    1.67 +	//Get all the arguments into a descriptor, beginning at pos 1, as pos 0 contains
    1.68 +	//the T_UCRT0P2 exe path and name.
    1.69 +	for (TInt i=1; i < argc; i++)
    1.70 +		{
    1.71 +		char *str=argv[i];
    1.72 +		while(*str)
    1.73 +			inputArguments.Append((TChar)*str++);
    1.74 +		inputArguments.Append(' ');
    1.75 +		}
    1.76 +
    1.77 +	//tests all the arguments were passed to the new process correctly.
    1.78 +	TheTest.Printf(_L("Checking all arguements were passed to the new process correctly... "));
    1.79 +	TEST(testArguments == inputArguments );
    1.80 +	TEST2(testArgNo, argc);
    1.81 +
    1.82 +	exit(0);
    1.83 +	}
    1.84 +
    1.85 +/**
    1.86 +Invoke the tests
    1.87 +*/
    1.88 +LOCAL_C void RunTestsL ()
    1.89 +    {
    1.90 +	Defect_DEF074278_Part2();
    1.91 +	}
    1.92 +
    1.93 +/**
    1.94 +/This should only be called from T_UCRT0P1, as it is part of the same test.
    1.95 +*/
    1.96 +GLDEF_C TInt E32Main()
    1.97 +	{
    1.98 +	CTrapCleanup* tc = CTrapCleanup::New();
    1.99 +	TheTest(tc != NULL);
   1.100 +	__UHEAP_MARK;
   1.101 +
   1.102 +	TheTest.Title();
   1.103 +	TheTest.Printf(_L("Starting the tests in the child process T_UCRT0P2 ...\n"));
   1.104 +	TheTest.Start(_L(" @SYMTestCaseID:SYSLIB-STDLIB-LEGACY-T_UCRT0P2-0001 "));
   1.105 +	TRAPD(error,RunTestsL());
   1.106 +	TEST2(error,KErrNone);
   1.107 +
   1.108 +	TheTest.End();
   1.109 +	TheTest.Close();
   1.110 +	__UHEAP_MARKEND;
   1.111 +	delete tc;
   1.112 +	return 0;
   1.113 +	}
   1.114 +