equal
deleted
inserted
replaced
14 // |
14 // |
15 |
15 |
16 #undef G_DISABLE_ASSERT |
16 #undef G_DISABLE_ASSERT |
17 #undef G_LOG_DOMAIN |
17 #undef G_LOG_DOMAIN |
18 |
18 |
|
19 #include <sys/stat.h> |
19 #include <glib.h> |
20 #include <glib.h> |
20 #include <errno.h> |
21 #include <errno.h> |
21 #define LOG_FILE "c:\\logs\\list_env_log.txt" |
22 #include <glib/gprintf.h> |
22 #include "std_log_result.h" |
23 #ifdef __SYMBIAN32__ |
23 #define LOG_FILENAME_LINE __FILE__, __LINE__ |
24 #include "mrt2_glib2_test.h" |
24 |
25 #endif /*__SYMBIAN32__*/ |
25 void create_xml(int result) |
|
26 { |
|
27 if(result) |
|
28 assert_failed = 1; |
|
29 |
|
30 testResultXml("list_env_log"); |
|
31 close_log_file(); |
|
32 } |
|
33 |
26 |
34 int main (int argc, char *argv[]) |
27 int main (int argc, char *argv[]) |
35 { |
28 { |
36 const gchar *variable1 = "TEST_VAR1"; |
29 const gchar *variable1 = "TEST_VAR1"; |
37 gchar *value1 = "testvalue1"; |
30 gchar *value1 = "testvalue1"; |
39 gchar *value2 = "testvalue2"; |
32 gchar *value2 = "testvalue2"; |
40 gchar **env_list; |
33 gchar **env_list; |
41 gint i, found = 0; |
34 gint i, found = 0; |
42 guint no_of_variables =0; |
35 guint no_of_variables =0; |
43 gboolean found_var1 = 0, found_var2 = 0; |
36 gboolean found_var1 = 0, found_var2 = 0; |
44 |
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"); |
45 if(g_setenv (variable1, value1, TRUE) && g_setenv (variable2, value2, TRUE)) |
43 if(g_setenv (variable1, value1, TRUE) && g_setenv (variable2, value2, TRUE)) |
46 { |
44 { |
47 env_list = g_listenv(); |
45 env_list = g_listenv(); |
48 |
46 |
49 if(env_list) |
47 if(env_list) |
62 found_var2 = 1; |
60 found_var2 = 1; |
63 } |
61 } |
64 |
62 |
65 if(!(found_var1 && found_var2)) |
63 if(!(found_var1 && found_var2)) |
66 { |
64 { |
67 std_log(LOG_FILENAME_LINE, "g_listenv failed"); |
65 g_print( "g_listenv failed"); |
68 assert_failed = 1; |
66 assert_failed = 1; |
69 } |
67 } |
70 } |
68 } |
71 else |
69 else |
72 { |
70 { |
73 std_log(LOG_FILENAME_LINE, "g_listenv returned list is of length 0"); |
71 g_print( "g_listenv returned list is of length 0"); |
74 assert_failed = 1; |
72 assert_failed = 1; |
75 } |
73 } |
76 |
74 |
77 g_strfreev(env_list); |
75 g_strfreev(env_list); |
78 } |
76 } |
79 else |
77 else |
80 { |
78 { |
81 std_log(LOG_FILENAME_LINE, "g_listenv returned NULL"); |
79 g_print( "g_listenv returned NULL"); |
82 assert_failed = 1; |
80 assert_failed = 1; |
83 } |
81 } |
84 } |
82 } |
85 else |
83 else |
86 { |
84 { |
87 std_log(LOG_FILENAME_LINE, "setting env variable failed. errno = %d", errno); |
85 g_print( "setting env variable failed. errno = %d", errno); |
88 } |
86 } |
89 |
87 |
90 if(assert_failed) |
88 if(assert_failed) |
91 std_log(LOG_FILENAME_LINE,"Test Failed"); |
89 g_print("Test list-env Failed"); |
92 else |
90 else |
93 std_log(LOG_FILENAME_LINE,"Test Successful"); |
91 g_print("Test list-env Successful"); |
94 |
92 |
95 create_xml(0); |
93 #if __SYMBIAN32__ |
|
94 testResultXml("list-env"); |
|
95 #endif /* EMULATOR */ |
96 |
96 |
97 return 0; |
97 return 0; |
98 } |
98 } |