Update contrib.
2 * Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
4 * This component and the accompanying materials are made available
5 * under the terms of "Eclipse Public License v1.0"
6 * which accompanies this distribution, and is available
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
16 * Test code for miscellaneous functions implemented via the MSystemInterface
17 * This differs from TMISC in that the functions must be tested twice, once with
18 * the local interface and once with the CPosixServer.
31 #include "CTEST.H" /* includes C interface to EPOC32 threads, and SpawnPosixServer */
35 void env_check(wchar_t* name, wchar_t* correct_value)
37 wchar_t* value = wgetenv(name);
39 test(wcscmp(value,correct_value)==0);
43 @SYMTestCaseID SYSLIB-STDLIB-CT-1097
44 @SYMTestCaseDesc Tests for environment variables
46 @SYMTestActions Tests for getting and setting the environment variables
47 @SYMTestExpectedResults Test must not fail
55 test_Next("Environment variables");
56 value=wgetenv((wchar_t*)L"not_present");
59 ret=wsetenv((wchar_t*)L"TEST1",(wchar_t*)L"value1",0);
61 value=wgetenv((wchar_t*)L"not_present");
63 env_check((wchar_t*)L"TEST1",(wchar_t*)L"value1");
65 ret=wsetenv((wchar_t*)L"TEST2",(wchar_t*)L"value2",0);
67 env_check((wchar_t*)L"TEST2",(wchar_t*)L"value2");
69 wunsetenv((wchar_t*)L"not_present");
70 env_check((wchar_t*)L"TEST1",(wchar_t*)L"value1");
71 env_check((wchar_t*)L"TEST2",(wchar_t*)L"value2");
73 ret=wsetenv((wchar_t*)L"TEST1",(wchar_t*)L"different_value",0); /* no rewrite */
74 test(ret==0); /* apparently this isn't an error */
75 env_check((wchar_t*)L"TEST1",(wchar_t*)L"value1");
76 env_check((wchar_t*)L"TEST2",(wchar_t*)L"value2");
78 ret=wsetenv((wchar_t*)L"TEST1",(wchar_t*)L"different_value",1); /* with rewrite */
80 env_check((wchar_t*)L"TEST1",(wchar_t*)L"different_value");
81 env_check((wchar_t*)L"TEST2",(wchar_t*)L"value2");
83 ret=wsetenv((wchar_t*)L"TEST2",(wchar_t*)L"value2.1",1);
85 env_check((wchar_t*)L"TEST1",(wchar_t*)L"different_value");
86 env_check((wchar_t*)L"TEST2",(wchar_t*)L"value2.1");
88 wunsetenv((wchar_t*)L"TEST1");
89 value=wgetenv((wchar_t*)L"TEST1");
91 env_check((wchar_t*)L"TEST2",(wchar_t*)L"value2.1");
93 ret=wsetenv((wchar_t*)L"TEST1\x20aC",(wchar_t*)L"\x20ac a third value which is a really long one so I can force it to realloc some more memory when it does the conversion",0);
95 env_check((wchar_t*)L"TEST1\x20aC",(wchar_t*)L"\x20ac a third value which is a really long one so I can force it to realloc some more memory when it does the conversion");
96 env_check((wchar_t*)L"TEST2",(wchar_t*)L"value2.1");
119 test_Title("Misc MSystemInterface functions");
123 test_Next("Do it again using the CPosixServer (for them, not me)");
126 start_posix_server(); /* calls SpawnPosixServer from C++ code */
128 client=create_thread(allTests, "TMISC2 tests");
130 start_thread(client);
131 err=wait_for_thread(client);