os/ossrv/genericopenlibs/cstdlib/TSTLIB/T_UCRT0P2.CPP
author sl
Tue, 10 Jun 2014 14:32:02 +0200 (2014-06-10)
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
// *IMPORTANT*: This should only be run when called from T_UCRT0P1.
sl@0
    15
// See TestCase SYSLIB-0001 in T_UCRT0P1.CPP for more information.
sl@0
    16
// 
sl@0
    17
//
sl@0
    18
sl@0
    19
#include <stdlib.h>
sl@0
    20
#include <e32debug.h>
sl@0
    21
#include <e32test.h>
sl@0
    22
#include <estlib.h>
sl@0
    23
sl@0
    24
sl@0
    25
RTest TheTest(_L("T_UCRT0P2"));
sl@0
    26
sl@0
    27
sl@0
    28
//Test macros and functions
sl@0
    29
LOCAL_C void Check(TInt aValue, TInt aLine)
sl@0
    30
	{
sl@0
    31
	if(!aValue)
sl@0
    32
		TheTest(EFalse, aLine);
sl@0
    33
	}
sl@0
    34
sl@0
    35
LOCAL_C void Check(TInt aValue, TInt aExpected, TInt aLine)
sl@0
    36
	{
sl@0
    37
	if(aValue != aExpected)
sl@0
    38
		{
sl@0
    39
		RDebug::Print(_L("*** Expected error: %d, got: %d\r\n"), aExpected, aValue);
sl@0
    40
		TheTest(EFalse, aLine);
sl@0
    41
		}
sl@0
    42
	}
sl@0
    43
sl@0
    44
#define TEST(arg) ::Check((arg), __LINE__)
sl@0
    45
#define TEST2(aValue, aExpected) ::Check(aValue, aExpected, __LINE__)
sl@0
    46
sl@0
    47
sl@0
    48
sl@0
    49
//DEF074278: Java VM requires more command line testArguments.
sl@0
    50
void Defect_DEF074278_Part2()
sl@0
    51
	{
sl@0
    52
   	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 "));
sl@0
    53
	TBuf<210> inputArguments;
sl@0
    54
sl@0
    55
	TUint testArgNo = 25;
sl@0
    56
sl@0
    57
	int argc=0;
sl@0
    58
	char** argv=0;
sl@0
    59
	char** envp=0;
sl@0
    60
sl@0
    61
	TheTest.Printf(_L("Retrieving the arguments passed in from T_UCRT0P1\n"));
sl@0
    62
	__crt0(argc,argv,envp);			// get args & environment from somewhere
sl@0
    63
sl@0
    64
	//Get all the arguments into a descriptor, beginning at pos 1, as pos 0 contains
sl@0
    65
	//the T_UCRT0P2 exe path and name.
sl@0
    66
	for (TInt i=1; i < argc; i++)
sl@0
    67
		{
sl@0
    68
		char *str=argv[i];
sl@0
    69
		while(*str)
sl@0
    70
			inputArguments.Append((TChar)*str++);
sl@0
    71
		inputArguments.Append(' ');
sl@0
    72
		}
sl@0
    73
sl@0
    74
	//tests all the arguments were passed to the new process correctly.
sl@0
    75
	TheTest.Printf(_L("Checking all arguements were passed to the new process correctly... "));
sl@0
    76
	TEST(testArguments == inputArguments );
sl@0
    77
	TEST2(testArgNo, argc);
sl@0
    78
sl@0
    79
	exit(0);
sl@0
    80
	}
sl@0
    81
sl@0
    82
/**
sl@0
    83
Invoke the tests
sl@0
    84
*/
sl@0
    85
LOCAL_C void RunTestsL ()
sl@0
    86
    {
sl@0
    87
	Defect_DEF074278_Part2();
sl@0
    88
	}
sl@0
    89
sl@0
    90
/**
sl@0
    91
/This should only be called from T_UCRT0P1, as it is part of the same test.
sl@0
    92
*/
sl@0
    93
GLDEF_C TInt E32Main()
sl@0
    94
	{
sl@0
    95
	CTrapCleanup* tc = CTrapCleanup::New();
sl@0
    96
	TheTest(tc != NULL);
sl@0
    97
	__UHEAP_MARK;
sl@0
    98
sl@0
    99
	TheTest.Title();
sl@0
   100
	TheTest.Printf(_L("Starting the tests in the child process T_UCRT0P2 ...\n"));
sl@0
   101
	TheTest.Start(_L(" @SYMTestCaseID:SYSLIB-STDLIB-LEGACY-T_UCRT0P2-0001 "));
sl@0
   102
	TRAPD(error,RunTestsL());
sl@0
   103
	TEST2(error,KErrNone);
sl@0
   104
sl@0
   105
	TheTest.End();
sl@0
   106
	TheTest.Close();
sl@0
   107
	__UHEAP_MARKEND;
sl@0
   108
	delete tc;
sl@0
   109
	return 0;
sl@0
   110
	}
sl@0
   111