50
|
1 |
// Copyright (c) 2010 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".
|
|
7 |
//
|
|
8 |
// Initial Contributors:
|
|
9 |
// Nokia Corporation - initial contribution.
|
|
10 |
//
|
|
11 |
// Contributors:
|
|
12 |
//
|
|
13 |
// Description:
|
|
14 |
//
|
|
15 |
|
|
16 |
#undef G_DISABLE_ASSERT
|
|
17 |
#undef G_LOG_DOMAIN
|
|
18 |
|
72
|
19 |
#include <sys/stat.h>
|
50
|
20 |
#include <glib.h>
|
|
21 |
#include <errno.h>
|
72
|
22 |
#include <glib/gprintf.h>
|
|
23 |
#ifdef __SYMBIAN32__
|
|
24 |
#include "mrt2_glib2_test.h"
|
|
25 |
#endif /*__SYMBIAN32__*/
|
50
|
26 |
|
|
27 |
int main (int argc, char *argv[])
|
|
28 |
{
|
|
29 |
const gchar *variable1 = "TEST_VAR1";
|
|
30 |
gchar *value1 = "testvalue1";
|
|
31 |
const gchar *variable2 = "TEST_VAR2";
|
|
32 |
gchar *value2 = "testvalue2";
|
|
33 |
gchar **env_list;
|
|
34 |
gint i, found = 0;
|
|
35 |
guint no_of_variables =0;
|
|
36 |
gboolean found_var1 = 0, found_var2 = 0;
|
72
|
37 |
#ifdef __SYMBIAN32__
|
|
38 |
g_log_set_handler (NULL, G_LOG_FLAG_FATAL| G_LOG_FLAG_RECURSION | G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING | G_LOG_LEVEL_MESSAGE | G_LOG_LEVEL_INFO | G_LOG_LEVEL_DEBUG, &mrtLogHandler, NULL);
|
|
39 |
g_set_print_handler(mrtPrintHandler);
|
|
40 |
#endif /*__SYMBIAN32__*/
|
|
41 |
|
|
42 |
g_print("Test list-env Start");
|
50
|
43 |
if(g_setenv (variable1, value1, TRUE) && g_setenv (variable2, value2, TRUE))
|
|
44 |
{
|
|
45 |
env_list = g_listenv();
|
|
46 |
|
|
47 |
if(env_list)
|
|
48 |
{
|
|
49 |
no_of_variables = g_strv_length(env_list);
|
|
50 |
|
|
51 |
if(no_of_variables)
|
|
52 |
{
|
|
53 |
for(i = 0; i<no_of_variables; i++)
|
|
54 |
{
|
|
55 |
gchar *data = env_list[i];
|
|
56 |
|
|
57 |
if(g_strcmp0(data, variable1) == 0)
|
|
58 |
found_var1 = 1;
|
|
59 |
else if(g_strcmp0(data, variable2) == 0)
|
|
60 |
found_var2 = 1;
|
|
61 |
}
|
|
62 |
|
|
63 |
if(!(found_var1 && found_var2))
|
|
64 |
{
|
72
|
65 |
g_print( "g_listenv failed");
|
50
|
66 |
assert_failed = 1;
|
|
67 |
}
|
|
68 |
}
|
|
69 |
else
|
|
70 |
{
|
72
|
71 |
g_print( "g_listenv returned list is of length 0");
|
50
|
72 |
assert_failed = 1;
|
|
73 |
}
|
|
74 |
|
|
75 |
g_strfreev(env_list);
|
|
76 |
}
|
|
77 |
else
|
|
78 |
{
|
72
|
79 |
g_print( "g_listenv returned NULL");
|
50
|
80 |
assert_failed = 1;
|
|
81 |
}
|
|
82 |
}
|
|
83 |
else
|
|
84 |
{
|
72
|
85 |
g_print( "setting env variable failed. errno = %d", errno);
|
50
|
86 |
}
|
|
87 |
|
|
88 |
if(assert_failed)
|
72
|
89 |
g_print("Test list-env Failed");
|
50
|
90 |
else
|
72
|
91 |
g_print("Test list-env Successful");
|
50
|
92 |
|
72
|
93 |
#if __SYMBIAN32__
|
|
94 |
testResultXml("list-env");
|
|
95 |
#endif /* EMULATOR */
|
50
|
96 |
|
|
97 |
return 0;
|
|
98 |
}
|