Update contrib.
1 // Copyright (c) 2008-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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // *IMPORTANT*: This should only be run when called from T_UCRT0P1.
15 // See TestCase SYSLIB-STDLIB-UT-4003 in T_UCRT0P1.CPP for more information.
25 RTest TheTest(_L("T_UCRT0P3"));
28 //Test macros and functions
29 LOCAL_C void Check(TInt aValue, TInt aLine)
32 TheTest(EFalse, aLine);
35 LOCAL_C void Check(TInt aValue, TInt aExpected, TInt aLine)
37 if(aValue != aExpected)
39 RDebug::Print(_L("*** Expected error: %d, got: %d\r\n"), aExpected, aValue);
40 TheTest(EFalse, aLine);
44 #define TEST(arg) ::Check((arg), __LINE__)
45 #define TEST2(aValue, aExpected) ::Check(aValue, aExpected, __LINE__)
49 //DEF124477: [coverity] RESOURCE_LEAK - stdlib.
50 void Defect_DEF124477_Part2()
56 TheTest.Printf(_L("Retrieving the arguments passed in from T_UCRT0P1\n"));
58 // Set heap memory allocation failure for 'char_argv'.
59 TheTest.Printf(_L("Set RHeap::EFailNext on the 4th memory allocation event.\n"));
60 __UHEAP_SETFAIL(RHeap::EFailNext, 4);
62 TheTest.Printf(_L("Try to get args and environment.\n"));
63 __crt0(argc,char_argv,char_envp); // get args & environment from somewhere
65 // Memory allocation failure should result in the following variables being NULL.
66 TheTest.Printf(_L("Check argc is NULL.\n"));
68 TheTest.Printf(_L("Check char_argv is NULL.\n"));
70 TheTest.Printf(_L("Check char_envp is NULL.\n"));
79 // Set heap memory allocation failure for 'cmdbuf' in __crt0 to fail, resulting in routine
80 // returning early, so 'char_argc' and 'char_envp' should still be NULL.
81 TheTest.Printf(_L("Set RHeap::EFailNext on the 1st memory allocation event.\n"));
82 __UHEAP_SETFAIL(RHeap::EFailNext, 1);
84 TheTest.Printf(_L("Try to get args and environment.\n"));
85 __crt0(argc,char_argv,char_envp); // get args & environment from somewhere
87 // Memory allocation failure should result in the following variables being NULL.
88 TheTest.Printf(_L("Check argc is NULL.\n"));
90 TheTest.Printf(_L("Check char_envp is NULL.\n"));
94 wchar_t** wchar_t_argv=0;
95 wchar_t** wchar_t_envp=0;
97 TheTest.Printf(_L("Retrieving the arguments passed in from T_UCRT0P1\n"));
99 // Will set the memory allocation for wargv in __crt0 to fail.
100 TheTest.Printf(_L("Set RHeap::EFailNext on the 3rd memory allocation event.\n"));
101 __UHEAP_SETFAIL(RHeap::EFailNext, 3);
103 TheTest.Printf(_L("Now try to get args and environment.\n"));
104 __crt0(argc,wchar_t_argv,wchar_t_envp); // get args & environment from somewhere
106 // The arguements passed into __crt0 should still be NULL.
107 TheTest.Printf(_L("Check argc is NULL.\n"));
109 TheTest.Printf(_L("Check wchar_t_argv is NULL.\n"));
110 TEST(wchar_t_argv==0);
111 TheTest.Printf(_L("Check wchar_t_envp is NULL.\n"));
112 TEST(wchar_t_envp==0);
120 LOCAL_C void RunTestsL ()
122 Defect_DEF124477_Part2();
126 /This should only be called from T_UCRT0P1, as it is part of the same test.
128 GLDEF_C TInt E32Main()
130 CTrapCleanup* tc = CTrapCleanup::New();
135 TheTest.Printf(_L("** Starting the tests in the child process T_UCRT0P3 ...\n"));
136 TheTest.Start(_L(" @SYMTestCaseID: "));
137 TRAPD(error,RunTestsL());
138 TEST2(error,KErrNone);