|
ali@38
|
1 |
/*
|
|
ali@38
|
2 |
* Copyright (C) 2016 J. Ali Harlow <ali@juiblex.co.uk>
|
|
ali@38
|
3 |
*
|
|
ali@38
|
4 |
* This program is free software; you can redistribute it and/or modify
|
|
ali@38
|
5 |
* it under the terms of the GNU General Public License as published by
|
|
ali@38
|
6 |
* the Free Software Foundation; either version 2 of the License, or
|
|
ali@38
|
7 |
* (at your option) any later version.
|
|
ali@38
|
8 |
*
|
|
ali@38
|
9 |
* This program is distributed in the hope that it will be useful,
|
|
ali@38
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
ali@38
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
ali@38
|
12 |
* GNU General Public License for more details.
|
|
ali@38
|
13 |
*
|
|
ali@38
|
14 |
* You should have received a copy of the GNU General Public License along
|
|
ali@38
|
15 |
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
ali@38
|
16 |
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
ali@38
|
17 |
*/
|
|
ali@38
|
18 |
|
|
ali@38
|
19 |
#include <stdlib.h>
|
|
ali@38
|
20 |
#include <string.h>
|
|
ali@38
|
21 |
#include <locale.h>
|
|
ali@38
|
22 |
#include <sys/stat.h>
|
|
ali@38
|
23 |
#include <glib.h>
|
|
ali@38
|
24 |
#include <gdk/gdk.h>
|
|
ali@38
|
25 |
#include <gtk/gtk.h>
|
|
ali@38
|
26 |
#include <plover/plover.h>
|
|
ali@38
|
27 |
#include <plover-gtk/transactionhelper.h>
|
|
ali@38
|
28 |
|
|
ali@38
|
29 |
GtkBuilder *ui;
|
|
ali@38
|
30 |
gboolean manual_mode=FALSE;
|
|
ali@38
|
31 |
|
|
ali@38
|
32 |
PloverTransactionHelper *get_transaction_helper(void)
|
|
ali@38
|
33 |
{
|
|
ali@38
|
34 |
const char *dir;
|
|
ali@38
|
35 |
gchar *s;
|
|
ali@38
|
36 |
GError *err=NULL;
|
|
ali@38
|
37 |
PloverTransactionHelper *helper;
|
|
ali@38
|
38 |
dir=g_getenv("gtk_srcdir");
|
|
ali@38
|
39 |
s=g_build_filename(dir,"software-installation.ui",NULL);
|
|
ali@38
|
40 |
ui=gtk_builder_new();
|
|
ali@38
|
41 |
if (!gtk_builder_add_from_file(ui,s,&err))
|
|
ali@38
|
42 |
g_error("%s: %s",s,err->message);
|
|
ali@38
|
43 |
g_free(s);
|
|
ali@38
|
44 |
helper=plover_transaction_helper_new(ui);
|
|
ali@38
|
45 |
g_object_unref(ui);
|
|
ali@38
|
46 |
return helper;
|
|
ali@38
|
47 |
}
|
|
ali@38
|
48 |
|
|
ali@38
|
49 |
static void test_init(void)
|
|
ali@38
|
50 |
{
|
|
ali@38
|
51 |
PloverTransactionHelper *helper;
|
|
ali@38
|
52 |
helper=get_transaction_helper();
|
|
ali@38
|
53 |
g_object_unref(helper);
|
|
ali@38
|
54 |
}
|
|
ali@38
|
55 |
|
|
ali@38
|
56 |
static void test_basic_properties(void)
|
|
ali@38
|
57 |
{
|
|
ali@38
|
58 |
const char *prefix;
|
|
ali@38
|
59 |
GError *err=NULL;
|
|
ali@38
|
60 |
struct comps *comps;
|
|
ali@38
|
61 |
PloverTransactionHelper *helper;
|
|
ali@38
|
62 |
PloverPackageSet *installed;
|
|
ali@38
|
63 |
PloverRepository *upstream;
|
|
ali@38
|
64 |
upstream=plover_repository_new_from_yum("../yum-repo-test-dir",&err);
|
|
ali@38
|
65 |
if (!upstream)
|
|
ali@38
|
66 |
g_error("../yum-repo-test-dir: %s",err->message);
|
|
ali@38
|
67 |
installed=plover_package_set_new_from_installed("../razor-test-dir",&err);
|
|
ali@38
|
68 |
if (!installed)
|
|
ali@38
|
69 |
g_error("../razor-test-dir: %s",err->message);
|
|
ali@38
|
70 |
helper=get_transaction_helper();
|
|
ali@38
|
71 |
g_assert(!plover_transaction_helper_get_visible(helper));
|
|
ali@38
|
72 |
plover_transaction_helper_set_installed(helper,installed);
|
|
ali@38
|
73 |
g_assert(plover_transaction_helper_get_installed(helper)==installed);
|
|
ali@38
|
74 |
plover_transaction_helper_set_upstream(helper,upstream);
|
|
ali@38
|
75 |
g_assert(plover_transaction_helper_get_upstream(helper,&err)==upstream);
|
|
ali@38
|
76 |
g_assert(!err);
|
|
ali@38
|
77 |
plover_transaction_helper_set_base(helper,"../yum-repo-test-dir");
|
|
ali@38
|
78 |
g_assert_cmpstr(plover_transaction_helper_get_base(helper),==,"../yum-repo-test-dir");
|
|
ali@38
|
79 |
comps=plover_transaction_helper_get_comps(helper,&err);
|
|
ali@38
|
80 |
g_assert(!err);
|
|
ali@38
|
81 |
g_assert(plover_comps_lookup_group(comps,"base"));
|
|
ali@38
|
82 |
prefix=plover_transaction_helper_get_prefix(helper,&err);
|
|
ali@38
|
83 |
g_assert(!err);
|
|
ali@38
|
84 |
g_assert_cmpstr(prefix,==,plover_default_prefix_for_vendor("Acme Corporation"));
|
|
ali@38
|
85 |
g_assert(!plover_transaction_helper_get_visible(helper));
|
|
ali@38
|
86 |
g_assert(!plover_transaction_helper_get_error(helper,NULL));
|
|
ali@38
|
87 |
g_object_unref(upstream);
|
|
ali@38
|
88 |
g_object_unref(installed);
|
|
ali@38
|
89 |
g_object_unref(helper);
|
|
ali@38
|
90 |
}
|
|
ali@38
|
91 |
|
|
ali@38
|
92 |
static void test_install_group(void)
|
|
ali@38
|
93 |
{
|
|
ali@38
|
94 |
gchar *root;
|
|
ali@38
|
95 |
GError *err=NULL;
|
|
ali@38
|
96 |
PloverPackageSet *installed;
|
|
ali@38
|
97 |
PloverTransactionHelper *helper;
|
|
ali@38
|
98 |
root=g_strdup("razor-test-dir-XXXXXX");
|
|
ali@38
|
99 |
g_assert(mkdtemp(root));
|
|
ali@38
|
100 |
g_setenv("RAZOR_ROOT",root,TRUE);
|
|
ali@38
|
101 |
g_free(root);
|
|
ali@38
|
102 |
helper=get_transaction_helper();
|
|
ali@38
|
103 |
installed=plover_package_set_new_from_installed("../razor-test-dir",&err);
|
|
ali@38
|
104 |
if (!installed)
|
|
ali@38
|
105 |
g_error("../razor-test-dir: %s",err->message);
|
|
ali@38
|
106 |
plover_transaction_helper_set_installed(helper,installed);
|
|
ali@38
|
107 |
g_object_unref(installed);
|
|
ali@38
|
108 |
plover_transaction_helper_set_base(helper,"../yum-repo-test-dir");
|
|
ali@38
|
109 |
if (!plover_transaction_helper_install_group(helper,"base",&err))
|
|
ali@38
|
110 |
g_error("base: %s",err->message);
|
|
ali@38
|
111 |
g_assert(!err);
|
|
ali@38
|
112 |
g_object_unref(helper);
|
|
ali@38
|
113 |
g_unsetenv("RAZOR_ROOT");
|
|
ali@38
|
114 |
}
|
|
ali@38
|
115 |
|
|
ali@38
|
116 |
static void test_remove_group(void)
|
|
ali@38
|
117 |
{
|
|
ali@38
|
118 |
gchar *root;
|
|
ali@38
|
119 |
GError *err=NULL;
|
|
ali@38
|
120 |
PloverPackageSet *installed;
|
|
ali@38
|
121 |
PloverTransactionHelper *helper;
|
|
ali@38
|
122 |
struct plover_vector *packages;
|
|
ali@38
|
123 |
char *pkgs[]={"zip",NULL};
|
|
ali@38
|
124 |
root=g_strdup("razor-test-dir-XXXXXX");
|
|
ali@38
|
125 |
g_assert(mkdtemp(root));
|
|
ali@38
|
126 |
g_setenv("RAZOR_ROOT",root,TRUE);
|
|
ali@38
|
127 |
helper=get_transaction_helper();
|
|
ali@38
|
128 |
plover_transaction_helper_set_base(helper,"../yum-repo-test-dir");
|
|
ali@38
|
129 |
packages=plover_transaction_helper_group_get_default_packages(helper,
|
|
ali@38
|
130 |
"zappy",&err);
|
|
ali@38
|
131 |
if (!packages)
|
|
ali@38
|
132 |
g_error("zappy: %s",err->message);
|
|
ali@38
|
133 |
if (!plover_install("../yum-repo-test-dir",NULL,packages->strings,&err))
|
|
ali@38
|
134 |
g_error("plover_install: %s",err->message);
|
|
ali@38
|
135 |
plover_vector_free(packages);
|
|
ali@38
|
136 |
installed=plover_package_set_new_from_installed(root,&err);
|
|
ali@38
|
137 |
if (!installed)
|
|
ali@38
|
138 |
g_error("%s: %s",root,err->message);
|
|
ali@38
|
139 |
plover_transaction_helper_set_installed(helper,installed);
|
|
ali@38
|
140 |
g_object_unref(installed);
|
|
ali@38
|
141 |
if (!plover_transaction_helper_remove_group(helper,"zappy",&err))
|
|
ali@38
|
142 |
g_error("zappy: %s",err->message);
|
|
ali@38
|
143 |
g_assert(!err);
|
|
ali@38
|
144 |
g_object_unref(helper);
|
|
ali@38
|
145 |
g_unsetenv("RAZOR_ROOT");
|
|
ali@38
|
146 |
g_free(root);
|
|
ali@38
|
147 |
}
|
|
ali@38
|
148 |
|
|
ali@38
|
149 |
static void test_update(void)
|
|
ali@38
|
150 |
{
|
|
ali@38
|
151 |
gchar *root;
|
|
ali@38
|
152 |
GError *err=NULL;
|
|
ali@38
|
153 |
PloverPackageSet *installed;
|
|
ali@38
|
154 |
PloverTransactionHelper *helper;
|
|
ali@38
|
155 |
root=g_strdup("razor-test-dir-XXXXXX");
|
|
ali@38
|
156 |
g_assert(mkdtemp(root));
|
|
ali@38
|
157 |
g_setenv("RAZOR_ROOT",root,TRUE);
|
|
ali@38
|
158 |
g_free(root);
|
|
ali@38
|
159 |
helper=get_transaction_helper();
|
|
ali@38
|
160 |
installed=plover_package_set_new_from_installed("../razor-test-dir",&err);
|
|
ali@38
|
161 |
if (!installed)
|
|
ali@38
|
162 |
g_error("../razor-test-dir: %s",err->message);
|
|
ali@38
|
163 |
plover_transaction_helper_set_installed(helper,installed);
|
|
ali@38
|
164 |
g_object_unref(installed);
|
|
ali@38
|
165 |
plover_transaction_helper_set_base(helper,"../yum-repo-test-dir");
|
|
ali@38
|
166 |
if (plover_transaction_helper_update(helper,&err))
|
|
ali@38
|
167 |
g_error("plover_transaction_helper_update reports work to be done");
|
|
ali@38
|
168 |
g_assert_error(err,PLOVER_GENERAL_ERROR,PLOVER_GENERAL_ERROR_NO_WORK);
|
|
ali@38
|
169 |
g_object_unref(helper);
|
|
ali@38
|
170 |
g_unsetenv("RAZOR_ROOT");
|
|
ali@38
|
171 |
}
|
|
ali@38
|
172 |
|
|
ali@38
|
173 |
struct run_install_baton {
|
|
ali@38
|
174 |
enum {
|
|
ali@38
|
175 |
RI_STATE_INIT = 0,
|
|
ali@38
|
176 |
RI_STATE_SUMMARY,
|
|
ali@38
|
177 |
RI_STATE_PROGRESS,
|
|
ali@38
|
178 |
RI_STATE_PROGRESS_DELAY,
|
|
ali@38
|
179 |
RI_STATE_DONE,
|
|
ali@38
|
180 |
RI_STATE_FINISH
|
|
ali@38
|
181 |
} state;
|
|
ali@38
|
182 |
guint eid; /* event ID (or 0) */
|
|
ali@38
|
183 |
PloverTransactionHelper *helper;
|
|
ali@38
|
184 |
};
|
|
ali@38
|
185 |
|
|
ali@38
|
186 |
gboolean run_install_tick(gpointer data)
|
|
ali@38
|
187 |
{
|
|
ali@38
|
188 |
gboolean retval=TRUE;
|
|
ali@38
|
189 |
struct run_install_baton *baton=data;
|
|
ali@38
|
190 |
GtkWidget *page;
|
|
ali@38
|
191 |
GtkAssistant *assistant=baton->helper->assistant;
|
|
ali@38
|
192 |
switch(baton->state)
|
|
ali@38
|
193 |
{
|
|
ali@38
|
194 |
case RI_STATE_INIT:
|
|
ali@38
|
195 |
if (!assistant || !gtk_widget_get_visible(GTK_WIDGET(assistant)))
|
|
ali@38
|
196 |
return TRUE;
|
|
ali@38
|
197 |
if (!manual_mode)
|
|
ali@38
|
198 |
gtk_button_clicked(GTK_BUTTON(assistant->forward));
|
|
ali@38
|
199 |
break;
|
|
ali@38
|
200 |
case RI_STATE_SUMMARY:
|
|
ali@38
|
201 |
if (gtk_assistant_get_current_page(assistant)<1)
|
|
ali@38
|
202 |
return TRUE;
|
|
ali@38
|
203 |
if (!manual_mode)
|
|
ali@38
|
204 |
gtk_button_clicked(GTK_BUTTON(assistant->apply));
|
|
ali@38
|
205 |
break;
|
|
ali@38
|
206 |
case RI_STATE_PROGRESS:
|
|
ali@38
|
207 |
if (gtk_assistant_get_current_page(assistant)<2)
|
|
ali@38
|
208 |
return TRUE;
|
|
ali@38
|
209 |
page=gtk_assistant_get_nth_page(assistant,2);
|
|
ali@38
|
210 |
baton->eid=g_timeout_add_seconds(1,run_install_tick,baton);
|
|
ali@38
|
211 |
if (!gtk_assistant_get_page_complete(assistant,page))
|
|
ali@38
|
212 |
return FALSE;
|
|
ali@38
|
213 |
else
|
|
ali@38
|
214 |
retval=FALSE;
|
|
ali@38
|
215 |
break;
|
|
ali@38
|
216 |
case RI_STATE_PROGRESS_DELAY:
|
|
ali@38
|
217 |
retval=FALSE;
|
|
ali@38
|
218 |
baton->eid=g_idle_add_full(G_PRIORITY_LOW,run_install_tick,baton,
|
|
ali@38
|
219 |
NULL);
|
|
ali@38
|
220 |
if (!manual_mode)
|
|
ali@38
|
221 |
gtk_button_clicked(GTK_BUTTON(assistant->forward));
|
|
ali@38
|
222 |
break;
|
|
ali@38
|
223 |
case RI_STATE_DONE:
|
|
ali@38
|
224 |
if (gtk_assistant_get_current_page(assistant)<3)
|
|
ali@38
|
225 |
return TRUE;
|
|
ali@38
|
226 |
if (!manual_mode)
|
|
ali@38
|
227 |
gtk_button_clicked(GTK_BUTTON(assistant->close));
|
|
ali@38
|
228 |
break;
|
|
ali@38
|
229 |
case RI_STATE_FINISH:
|
|
ali@38
|
230 |
if (assistant && gtk_widget_get_visible(GTK_WIDGET(assistant)))
|
|
ali@38
|
231 |
return TRUE;
|
|
ali@38
|
232 |
gtk_main_quit();
|
|
ali@38
|
233 |
baton->eid=0;
|
|
ali@38
|
234 |
return FALSE;
|
|
ali@38
|
235 |
}
|
|
ali@38
|
236 |
baton->state++;
|
|
ali@38
|
237 |
return retval;
|
|
ali@38
|
238 |
}
|
|
ali@38
|
239 |
|
|
ali@38
|
240 |
static void test_run_install(void)
|
|
ali@38
|
241 |
{
|
|
ali@38
|
242 |
gchar *root;
|
|
ali@38
|
243 |
GError *err=NULL;
|
|
ali@38
|
244 |
struct plover_vector *packages;
|
|
ali@38
|
245 |
PloverPackageSet *installed;
|
|
ali@38
|
246 |
PloverTransactionHelper *helper;
|
|
ali@38
|
247 |
struct run_install_baton baton={0,};
|
|
ali@38
|
248 |
root=g_strdup("razor-test-dir-XXXXXX");
|
|
ali@38
|
249 |
g_assert(mkdtemp(root));
|
|
ali@38
|
250 |
g_setenv("RAZOR_ROOT",root,TRUE);
|
|
ali@38
|
251 |
helper=get_transaction_helper();
|
|
ali@38
|
252 |
installed=plover_package_set_new();
|
|
ali@38
|
253 |
if (!plover_package_set_open(installed,root,TRUE,&err))
|
|
ali@38
|
254 |
g_error("%s: %s",root,err->message);
|
|
ali@38
|
255 |
plover_transaction_helper_set_installed(helper,installed);
|
|
ali@38
|
256 |
g_object_unref(installed);
|
|
ali@38
|
257 |
plover_transaction_helper_set_base(helper,"../yum-repo-test-dir");
|
|
ali@38
|
258 |
packages=plover_vector_new();
|
|
ali@38
|
259 |
plover_vector_append(packages,"zappy-tools");
|
|
ali@38
|
260 |
if (!plover_transaction_helper_install_packages(helper,packages,&err))
|
|
ali@38
|
261 |
g_error("zappy-tools: %s",err->message);
|
|
ali@38
|
262 |
g_assert(!err);
|
|
ali@38
|
263 |
plover_vector_free(packages);
|
|
ali@38
|
264 |
plover_transaction_helper_present(helper);
|
|
ali@38
|
265 |
baton.helper=helper;
|
|
ali@38
|
266 |
baton.eid=g_idle_add_full(G_PRIORITY_LOW,run_install_tick,&baton,NULL);
|
|
ali@38
|
267 |
gtk_main();
|
|
ali@38
|
268 |
g_object_unref(helper);
|
|
ali@38
|
269 |
g_unsetenv("RAZOR_ROOT");
|
|
ali@38
|
270 |
g_free(root);
|
|
ali@38
|
271 |
}
|
|
ali@38
|
272 |
|
|
ali@38
|
273 |
struct run_remove_baton {
|
|
ali@38
|
274 |
enum {
|
|
ali@38
|
275 |
RR_STATE_INIT = 0,
|
|
ali@38
|
276 |
RR_STATE_SUMMARY,
|
|
ali@38
|
277 |
RR_STATE_PROGRESS,
|
|
ali@38
|
278 |
RR_STATE_PROGRESS_DELAY,
|
|
ali@38
|
279 |
RR_STATE_DONE,
|
|
ali@38
|
280 |
RR_STATE_FINISH
|
|
ali@38
|
281 |
} state;
|
|
ali@38
|
282 |
guint eid; /* event ID (or 0) */
|
|
ali@38
|
283 |
PloverTransactionHelper *helper;
|
|
ali@38
|
284 |
};
|
|
ali@38
|
285 |
|
|
ali@38
|
286 |
gboolean run_remove_tick(gpointer data)
|
|
ali@38
|
287 |
{
|
|
ali@38
|
288 |
gboolean retval=TRUE;
|
|
ali@38
|
289 |
struct run_remove_baton *baton=data;
|
|
ali@38
|
290 |
GtkWidget *page;
|
|
ali@38
|
291 |
GtkAssistant *assistant=baton->helper->assistant;
|
|
ali@38
|
292 |
switch(baton->state)
|
|
ali@38
|
293 |
{
|
|
ali@38
|
294 |
case RR_STATE_INIT:
|
|
ali@38
|
295 |
if (!assistant || !gtk_widget_get_visible(GTK_WIDGET(assistant)))
|
|
ali@38
|
296 |
return TRUE;
|
|
ali@38
|
297 |
if (!manual_mode)
|
|
ali@38
|
298 |
gtk_button_clicked(GTK_BUTTON(assistant->forward));
|
|
ali@38
|
299 |
break;
|
|
ali@38
|
300 |
case RR_STATE_SUMMARY:
|
|
ali@38
|
301 |
if (gtk_assistant_get_current_page(assistant)<1)
|
|
ali@38
|
302 |
return TRUE;
|
|
ali@38
|
303 |
if (!manual_mode)
|
|
ali@38
|
304 |
gtk_button_clicked(GTK_BUTTON(assistant->apply));
|
|
ali@38
|
305 |
break;
|
|
ali@38
|
306 |
case RR_STATE_PROGRESS:
|
|
ali@38
|
307 |
if (gtk_assistant_get_current_page(assistant)<2)
|
|
ali@38
|
308 |
return TRUE;
|
|
ali@38
|
309 |
page=gtk_assistant_get_nth_page(assistant,2);
|
|
ali@38
|
310 |
baton->eid=g_timeout_add_seconds(1,run_remove_tick,baton);
|
|
ali@38
|
311 |
if (!gtk_assistant_get_page_complete(assistant,page))
|
|
ali@38
|
312 |
return FALSE;
|
|
ali@38
|
313 |
else
|
|
ali@38
|
314 |
retval=FALSE;
|
|
ali@38
|
315 |
break;
|
|
ali@38
|
316 |
case RR_STATE_PROGRESS_DELAY:
|
|
ali@38
|
317 |
retval=FALSE;
|
|
ali@38
|
318 |
baton->eid=g_idle_add_full(G_PRIORITY_LOW,run_remove_tick,baton,
|
|
ali@38
|
319 |
NULL);
|
|
ali@38
|
320 |
if (!manual_mode)
|
|
ali@38
|
321 |
gtk_button_clicked(GTK_BUTTON(assistant->forward));
|
|
ali@38
|
322 |
break;
|
|
ali@38
|
323 |
case RR_STATE_DONE:
|
|
ali@38
|
324 |
if (gtk_assistant_get_current_page(assistant)<3)
|
|
ali@38
|
325 |
return TRUE;
|
|
ali@38
|
326 |
if (!manual_mode)
|
|
ali@38
|
327 |
gtk_button_clicked(GTK_BUTTON(assistant->close));
|
|
ali@38
|
328 |
break;
|
|
ali@38
|
329 |
case RR_STATE_FINISH:
|
|
ali@38
|
330 |
if (assistant && gtk_widget_get_visible(GTK_WIDGET(assistant)))
|
|
ali@38
|
331 |
return TRUE;
|
|
ali@38
|
332 |
gtk_main_quit();
|
|
ali@38
|
333 |
baton->eid=0;
|
|
ali@38
|
334 |
return FALSE;
|
|
ali@38
|
335 |
}
|
|
ali@38
|
336 |
baton->state++;
|
|
ali@38
|
337 |
return retval;
|
|
ali@38
|
338 |
}
|
|
ali@38
|
339 |
|
|
ali@38
|
340 |
static void test_run_remove(void)
|
|
ali@38
|
341 |
{
|
|
ali@38
|
342 |
gchar *root;
|
|
ali@38
|
343 |
GError *err=NULL;
|
|
ali@38
|
344 |
struct plover_vector *packages;
|
|
ali@38
|
345 |
PloverPackageSet *installed;
|
|
ali@38
|
346 |
PloverTransactionHelper *helper;
|
|
ali@38
|
347 |
struct run_remove_baton baton={0,};
|
|
ali@38
|
348 |
root=g_strdup("razor-test-dir-XXXXXX");
|
|
ali@38
|
349 |
g_assert(mkdtemp(root));
|
|
ali@38
|
350 |
g_setenv("RAZOR_ROOT",root,TRUE);
|
|
ali@38
|
351 |
helper=get_transaction_helper();
|
|
ali@38
|
352 |
plover_transaction_helper_set_base(helper,"../yum-repo-test-dir");
|
|
ali@38
|
353 |
packages=
|
|
ali@38
|
354 |
plover_transaction_helper_group_get_default_packages(helper,"zappy",&err);
|
|
ali@38
|
355 |
if (!packages)
|
|
ali@38
|
356 |
g_error("zappy: %s",err->message);
|
|
ali@38
|
357 |
if (!plover_install("../yum-repo-test-dir",NULL,packages->strings,&err))
|
|
ali@38
|
358 |
g_error("plover_install: %s",err->message);
|
|
ali@38
|
359 |
plover_vector_free(packages);
|
|
ali@38
|
360 |
installed=plover_package_set_new();
|
|
ali@38
|
361 |
if (!plover_package_set_open(installed,root,TRUE,&err))
|
|
ali@38
|
362 |
g_error("%s: %s",root,err->message);
|
|
ali@38
|
363 |
plover_transaction_helper_set_installed(helper,installed);
|
|
ali@38
|
364 |
g_object_unref(installed);
|
|
ali@38
|
365 |
if (!plover_transaction_helper_remove_group(helper,"zappy",&err))
|
|
ali@38
|
366 |
g_error("zappy: %s",err->message);
|
|
ali@38
|
367 |
g_assert(!err);
|
|
ali@38
|
368 |
plover_transaction_helper_present(helper);
|
|
ali@38
|
369 |
baton.helper=helper;
|
|
ali@38
|
370 |
baton.eid=g_idle_add_full(G_PRIORITY_LOW,run_remove_tick,&baton,NULL);
|
|
ali@38
|
371 |
gtk_main();
|
|
ali@38
|
372 |
g_object_unref(helper);
|
|
ali@38
|
373 |
g_unsetenv("RAZOR_ROOT");
|
|
ali@38
|
374 |
g_free(root);
|
|
ali@38
|
375 |
}
|
|
ali@38
|
376 |
|
|
ali@38
|
377 |
struct run_update_baton {
|
|
ali@38
|
378 |
enum {
|
|
ali@38
|
379 |
RU_STATE_INIT = 0,
|
|
ali@38
|
380 |
RU_STATE_SUMMARY,
|
|
ali@38
|
381 |
RU_STATE_PROGRESS,
|
|
ali@38
|
382 |
RU_STATE_PROGRESS_DELAY,
|
|
ali@38
|
383 |
RU_STATE_DONE,
|
|
ali@38
|
384 |
RU_STATE_FINISH
|
|
ali@38
|
385 |
} state;
|
|
ali@38
|
386 |
guint eid; /* event ID (or 0) */
|
|
ali@38
|
387 |
PloverTransactionHelper *helper;
|
|
ali@38
|
388 |
};
|
|
ali@38
|
389 |
|
|
ali@38
|
390 |
gboolean run_update_tick(gpointer data)
|
|
ali@38
|
391 |
{
|
|
ali@38
|
392 |
gboolean retval=TRUE;
|
|
ali@38
|
393 |
struct run_update_baton *baton=data;
|
|
ali@38
|
394 |
GtkWidget *page;
|
|
ali@38
|
395 |
GtkAssistant *assistant=baton->helper->assistant;
|
|
ali@38
|
396 |
switch(baton->state)
|
|
ali@38
|
397 |
{
|
|
ali@38
|
398 |
case RU_STATE_INIT:
|
|
ali@38
|
399 |
if (!assistant || !gtk_widget_get_visible(GTK_WIDGET(assistant)))
|
|
ali@38
|
400 |
return TRUE;
|
|
ali@38
|
401 |
if (!manual_mode)
|
|
ali@38
|
402 |
gtk_button_clicked(GTK_BUTTON(assistant->forward));
|
|
ali@38
|
403 |
break;
|
|
ali@38
|
404 |
case RU_STATE_SUMMARY:
|
|
ali@38
|
405 |
if (gtk_assistant_get_current_page(assistant)<1)
|
|
ali@38
|
406 |
return TRUE;
|
|
ali@38
|
407 |
if (!manual_mode)
|
|
ali@38
|
408 |
gtk_button_clicked(GTK_BUTTON(assistant->apply));
|
|
ali@38
|
409 |
break;
|
|
ali@38
|
410 |
case RU_STATE_PROGRESS:
|
|
ali@38
|
411 |
if (gtk_assistant_get_current_page(assistant)<2)
|
|
ali@38
|
412 |
return TRUE;
|
|
ali@38
|
413 |
page=gtk_assistant_get_nth_page(assistant,2);
|
|
ali@38
|
414 |
baton->eid=g_timeout_add_seconds(1,run_update_tick,baton);
|
|
ali@38
|
415 |
if (!gtk_assistant_get_page_complete(assistant,page))
|
|
ali@38
|
416 |
return FALSE;
|
|
ali@38
|
417 |
else
|
|
ali@38
|
418 |
retval=FALSE;
|
|
ali@38
|
419 |
break;
|
|
ali@38
|
420 |
case RU_STATE_PROGRESS_DELAY:
|
|
ali@38
|
421 |
retval=FALSE;
|
|
ali@38
|
422 |
baton->eid=g_idle_add_full(G_PRIORITY_LOW,run_update_tick,baton,
|
|
ali@38
|
423 |
NULL);
|
|
ali@38
|
424 |
if (!manual_mode)
|
|
ali@38
|
425 |
gtk_button_clicked(GTK_BUTTON(assistant->forward));
|
|
ali@38
|
426 |
break;
|
|
ali@38
|
427 |
case RU_STATE_DONE:
|
|
ali@38
|
428 |
if (gtk_assistant_get_current_page(assistant)<3)
|
|
ali@38
|
429 |
return TRUE;
|
|
ali@38
|
430 |
if (!manual_mode)
|
|
ali@38
|
431 |
gtk_button_clicked(GTK_BUTTON(assistant->close));
|
|
ali@38
|
432 |
break;
|
|
ali@38
|
433 |
case RU_STATE_FINISH:
|
|
ali@38
|
434 |
if (assistant && gtk_widget_get_visible(GTK_WIDGET(assistant)))
|
|
ali@38
|
435 |
return TRUE;
|
|
ali@38
|
436 |
gtk_main_quit();
|
|
ali@38
|
437 |
baton->eid=0;
|
|
ali@38
|
438 |
return FALSE;
|
|
ali@38
|
439 |
}
|
|
ali@38
|
440 |
baton->state++;
|
|
ali@38
|
441 |
return retval;
|
|
ali@38
|
442 |
}
|
|
ali@38
|
443 |
|
|
ali@38
|
444 |
static void test_run_update(void)
|
|
ali@38
|
445 |
{
|
|
ali@38
|
446 |
gchar *root;
|
|
ali@38
|
447 |
GError *err=NULL;
|
|
ali@38
|
448 |
struct razor_importer *importer;
|
|
ali@38
|
449 |
struct razor_set *downgraded;
|
|
ali@38
|
450 |
struct razor_atomic *atomic;
|
|
ali@38
|
451 |
struct plover_vector *packages;
|
|
ali@38
|
452 |
PloverPackageSet *installed;
|
|
ali@38
|
453 |
PloverTransactionHelper *helper;
|
|
ali@38
|
454 |
struct run_update_baton baton={0,};
|
|
ali@38
|
455 |
root=g_strdup("razor-test-dir-XXXXXX");
|
|
ali@38
|
456 |
g_assert(mkdtemp(root));
|
|
ali@38
|
457 |
g_setenv("RAZOR_ROOT",root,TRUE);
|
|
ali@38
|
458 |
helper=get_transaction_helper();
|
|
ali@38
|
459 |
plover_transaction_helper_set_base(helper,"../yum-repo-test-dir");
|
|
ali@38
|
460 |
installed=plover_package_set_new();
|
|
ali@38
|
461 |
if (!plover_package_set_open(installed,root,TRUE,&err))
|
|
ali@38
|
462 |
g_error("%s: %s",root,err->message);
|
|
ali@38
|
463 |
importer=razor_importer_create();
|
|
ali@38
|
464 |
razor_importer_begin_package(importer,"zappy","0-1","noarch");
|
|
ali@38
|
465 |
razor_importer_add_details(importer,"","","","");
|
|
ali@38
|
466 |
razor_importer_add_property(importer,"zappy",RAZOR_PROPERTY_PROVIDES,"0-1");
|
|
ali@38
|
467 |
razor_importer_finish_package(importer);
|
|
ali@38
|
468 |
downgraded=razor_importer_finish(importer);
|
|
ali@38
|
469 |
atomic=razor_atomic_open("Add downgraded packages");
|
|
ali@38
|
470 |
if (!plover_package_set_update(installed,downgraded,atomic) ||
|
|
ali@38
|
471 |
razor_atomic_commit(atomic))
|
|
ali@38
|
472 |
g_error("%s: %s",root,razor_atomic_get_error_msg(atomic));
|
|
ali@38
|
473 |
razor_atomic_destroy(atomic);
|
|
ali@38
|
474 |
razor_set_unref(downgraded);
|
|
ali@38
|
475 |
plover_transaction_helper_set_installed(helper,installed);
|
|
ali@38
|
476 |
g_object_unref(installed);
|
|
ali@38
|
477 |
if (!plover_transaction_helper_update(helper,&err))
|
|
ali@38
|
478 |
g_error("update: %s",err->message);
|
|
ali@38
|
479 |
g_assert(!err);
|
|
ali@38
|
480 |
plover_transaction_helper_present(helper);
|
|
ali@38
|
481 |
baton.helper=helper;
|
|
ali@38
|
482 |
baton.eid=g_idle_add_full(G_PRIORITY_LOW,run_update_tick,&baton,NULL);
|
|
ali@38
|
483 |
gtk_main();
|
|
ali@38
|
484 |
g_object_unref(helper);
|
|
ali@38
|
485 |
g_unsetenv("RAZOR_ROOT");
|
|
ali@38
|
486 |
g_free(root);
|
|
ali@38
|
487 |
}
|
|
ali@38
|
488 |
|
|
ali@38
|
489 |
struct check_vendor_baton {
|
|
ali@38
|
490 |
enum {
|
|
ali@38
|
491 |
CV_STATE_INIT = 0,
|
|
ali@38
|
492 |
CV_STATE_SUMMARY,
|
|
ali@38
|
493 |
CV_STATE_PROGRESS,
|
|
ali@38
|
494 |
CV_STATE_PROGRESS_DELAY,
|
|
ali@38
|
495 |
CV_STATE_DONE,
|
|
ali@38
|
496 |
CV_STATE_FINISH
|
|
ali@38
|
497 |
} state;
|
|
ali@38
|
498 |
guint eid; /* event ID (or 0) */
|
|
ali@38
|
499 |
PloverTransactionHelper *helper;
|
|
ali@38
|
500 |
};
|
|
ali@38
|
501 |
|
|
ali@38
|
502 |
gboolean check_vendor_tick(gpointer data)
|
|
ali@38
|
503 |
{
|
|
ali@38
|
504 |
gboolean retval=TRUE;
|
|
ali@38
|
505 |
struct check_vendor_baton *baton=data;
|
|
ali@38
|
506 |
GtkWidget *page,*w;
|
|
ali@38
|
507 |
GtkAssistant *assistant=baton->helper->assistant;
|
|
ali@38
|
508 |
switch(baton->state)
|
|
ali@38
|
509 |
{
|
|
ali@38
|
510 |
case CV_STATE_INIT:
|
|
ali@38
|
511 |
if (!assistant || !gtk_widget_get_visible(GTK_WIDGET(assistant)))
|
|
ali@38
|
512 |
return TRUE;
|
|
ali@38
|
513 |
if (!manual_mode)
|
|
ali@38
|
514 |
gtk_button_clicked(GTK_BUTTON(assistant->forward));
|
|
ali@38
|
515 |
break;
|
|
ali@38
|
516 |
case CV_STATE_SUMMARY:
|
|
ali@38
|
517 |
if (gtk_assistant_get_current_page(assistant)<1)
|
|
ali@38
|
518 |
return TRUE;
|
|
ali@38
|
519 |
g_assert(!gtk_widget_is_sensitive(assistant->apply));
|
|
ali@38
|
520 |
w=GTK_WIDGET(gtk_builder_get_object(ui,"SIRemoveExisting"));
|
|
ali@38
|
521 |
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w),TRUE);
|
|
ali@38
|
522 |
g_assert(gtk_widget_is_sensitive(assistant->apply));
|
|
ali@38
|
523 |
if (!manual_mode)
|
|
ali@38
|
524 |
gtk_button_clicked(GTK_BUTTON(assistant->apply));
|
|
ali@38
|
525 |
break;
|
|
ali@38
|
526 |
case CV_STATE_PROGRESS:
|
|
ali@38
|
527 |
if (gtk_assistant_get_current_page(assistant)<2)
|
|
ali@38
|
528 |
return TRUE;
|
|
ali@38
|
529 |
page=gtk_assistant_get_nth_page(assistant,2);
|
|
ali@38
|
530 |
baton->eid=g_timeout_add_seconds(1,check_vendor_tick,baton);
|
|
ali@38
|
531 |
if (!gtk_assistant_get_page_complete(assistant,page))
|
|
ali@38
|
532 |
return FALSE;
|
|
ali@38
|
533 |
else
|
|
ali@38
|
534 |
retval=FALSE;
|
|
ali@38
|
535 |
break;
|
|
ali@38
|
536 |
case CV_STATE_PROGRESS_DELAY:
|
|
ali@38
|
537 |
retval=FALSE;
|
|
ali@38
|
538 |
baton->eid=g_idle_add_full(G_PRIORITY_LOW,check_vendor_tick,baton,
|
|
ali@38
|
539 |
NULL);
|
|
ali@38
|
540 |
if (!manual_mode)
|
|
ali@38
|
541 |
gtk_button_clicked(GTK_BUTTON(assistant->forward));
|
|
ali@38
|
542 |
break;
|
|
ali@38
|
543 |
case CV_STATE_DONE:
|
|
ali@38
|
544 |
if (gtk_assistant_get_current_page(assistant)<3)
|
|
ali@38
|
545 |
return TRUE;
|
|
ali@38
|
546 |
if (!manual_mode)
|
|
ali@38
|
547 |
gtk_button_clicked(GTK_BUTTON(assistant->close));
|
|
ali@38
|
548 |
break;
|
|
ali@38
|
549 |
case CV_STATE_FINISH:
|
|
ali@38
|
550 |
if (assistant && gtk_widget_get_visible(GTK_WIDGET(assistant)))
|
|
ali@38
|
551 |
return TRUE;
|
|
ali@38
|
552 |
gtk_main_quit();
|
|
ali@38
|
553 |
baton->eid=0;
|
|
ali@38
|
554 |
return FALSE;
|
|
ali@38
|
555 |
}
|
|
ali@38
|
556 |
baton->state++;
|
|
ali@38
|
557 |
return retval;
|
|
ali@38
|
558 |
}
|
|
ali@38
|
559 |
|
|
ali@38
|
560 |
static void test_check_vendor(void)
|
|
ali@38
|
561 |
{
|
|
ali@38
|
562 |
int fh;
|
|
ali@38
|
563 |
gchar *root,*s;
|
|
ali@38
|
564 |
GError *err=NULL;
|
|
ali@38
|
565 |
struct razor_importer *importer;
|
|
ali@38
|
566 |
struct razor_set *downgraded;
|
|
ali@38
|
567 |
struct razor_atomic *atomic;
|
|
ali@38
|
568 |
struct plover_vector *packages;
|
|
ali@38
|
569 |
PloverPackageSet *installed;
|
|
ali@38
|
570 |
PloverTransactionHelper *helper;
|
|
ali@38
|
571 |
struct run_update_baton baton={0,};
|
|
ali@38
|
572 |
g_setenv("PLOVER_VENDOR_PREFIX","/srv",TRUE);
|
|
ali@38
|
573 |
root=g_strdup("razor-test-dir-XXXXXX");
|
|
ali@38
|
574 |
g_assert(mkdtemp(root));
|
|
ali@38
|
575 |
g_setenv("RAZOR_ROOT",root,TRUE);
|
|
ali@38
|
576 |
helper=get_transaction_helper();
|
|
ali@38
|
577 |
plover_transaction_helper_set_check_vendor(helper,TRUE);
|
|
ali@38
|
578 |
plover_transaction_helper_set_base(helper,"../yum-repo-test-dir");
|
|
ali@38
|
579 |
installed=plover_package_set_new();
|
|
ali@38
|
580 |
if (!plover_package_set_open(installed,root,TRUE,&err))
|
|
ali@38
|
581 |
g_error("%s: %s",root,err->message);
|
|
ali@38
|
582 |
importer=razor_importer_create();
|
|
ali@38
|
583 |
razor_importer_begin_package(importer,"zappy","0-1","noarch");
|
|
ali@38
|
584 |
razor_importer_add_details(importer,"","","","");
|
|
ali@38
|
585 |
razor_importer_add_property(importer,"zappy",RAZOR_PROPERTY_PROVIDES,"0-1");
|
|
ali@38
|
586 |
razor_importer_add_install_prefix(importer,"/test");
|
|
ali@38
|
587 |
razor_importer_add_file(importer,"/test/bin/zappy");
|
|
ali@38
|
588 |
razor_importer_finish_package(importer);
|
|
ali@38
|
589 |
downgraded=razor_importer_finish(importer);
|
|
ali@38
|
590 |
atomic=razor_atomic_open("Add downgraded packages");
|
|
ali@38
|
591 |
razor_atomic_make_dirs(atomic,root,"/test/bin/zappy");
|
|
ali@38
|
592 |
s=g_build_filename(root,"test/bin/zappy",NULL);
|
|
ali@38
|
593 |
fh=razor_atomic_create_file(atomic,s,S_IRWXU|S_IRWXG|S_IRWXO);
|
|
ali@38
|
594 |
g_free(s);
|
|
ali@38
|
595 |
razor_atomic_close(atomic,fh);
|
|
ali@38
|
596 |
if (!plover_package_set_update(installed,downgraded,atomic) ||
|
|
ali@38
|
597 |
razor_atomic_commit(atomic))
|
|
ali@38
|
598 |
g_error("%s: %s",root,razor_atomic_get_error_msg(atomic));
|
|
ali@38
|
599 |
razor_atomic_destroy(atomic);
|
|
ali@38
|
600 |
razor_set_unref(downgraded);
|
|
ali@38
|
601 |
plover_transaction_helper_set_installed(helper,installed);
|
|
ali@38
|
602 |
g_object_unref(installed);
|
|
ali@38
|
603 |
if (!plover_transaction_helper_update(helper,&err))
|
|
ali@38
|
604 |
g_error("update: %s",err->message);
|
|
ali@38
|
605 |
g_assert(!err);
|
|
ali@38
|
606 |
plover_transaction_helper_present(helper);
|
|
ali@38
|
607 |
baton.helper=helper;
|
|
ali@38
|
608 |
baton.eid=g_idle_add_full(G_PRIORITY_LOW,check_vendor_tick,&baton,NULL);
|
|
ali@38
|
609 |
gtk_main();
|
|
ali@38
|
610 |
g_object_unref(helper);
|
|
ali@38
|
611 |
g_unsetenv("RAZOR_ROOT");
|
|
ali@38
|
612 |
g_free(root);
|
|
ali@38
|
613 |
g_unsetenv("PLOVER_VENDOR_PREFIX");
|
|
ali@38
|
614 |
}
|
|
ali@38
|
615 |
|
|
ali@38
|
616 |
struct set_error_baton {
|
|
ali@38
|
617 |
enum {
|
|
ali@38
|
618 |
SE_STATE_INIT = 0,
|
|
ali@38
|
619 |
SE_STATE_FINISH
|
|
ali@38
|
620 |
} state;
|
|
ali@38
|
621 |
PloverTransactionHelper *helper;
|
|
ali@38
|
622 |
};
|
|
ali@38
|
623 |
|
|
ali@38
|
624 |
/*
|
|
ali@38
|
625 |
* This handler may be called as either an event (ie., idle or timeout)
|
|
ali@38
|
626 |
* or as a (swapped) signal. In the latter case, the return is ignored.
|
|
ali@38
|
627 |
*/
|
|
ali@38
|
628 |
gboolean set_error_tick(gpointer data)
|
|
ali@38
|
629 |
{
|
|
ali@38
|
630 |
struct set_error_baton *baton=data;
|
|
ali@38
|
631 |
GtkDialog *dlg;
|
|
ali@38
|
632 |
GtkWidget *button;
|
|
ali@38
|
633 |
dlg=GTK_DIALOG(baton->helper->error_dialog);
|
|
ali@38
|
634 |
switch(baton->state)
|
|
ali@38
|
635 |
{
|
|
ali@38
|
636 |
case SE_STATE_INIT:
|
|
ali@38
|
637 |
if (!dlg || !gtk_widget_get_visible(GTK_WIDGET(dlg)))
|
|
ali@38
|
638 |
return TRUE;
|
|
ali@38
|
639 |
button=gtk_dialog_get_widget_for_response(dlg,GTK_RESPONSE_CLOSE);
|
|
ali@38
|
640 |
if (!manual_mode)
|
|
ali@38
|
641 |
gtk_button_clicked(GTK_BUTTON(button));
|
|
ali@38
|
642 |
break;
|
|
ali@38
|
643 |
case SE_STATE_FINISH:
|
|
ali@38
|
644 |
if (dlg && gtk_widget_get_visible(GTK_WIDGET(dlg)))
|
|
ali@38
|
645 |
return TRUE;
|
|
ali@38
|
646 |
gtk_main_quit();
|
|
ali@38
|
647 |
return FALSE;
|
|
ali@38
|
648 |
}
|
|
ali@38
|
649 |
baton->state++;
|
|
ali@38
|
650 |
return TRUE;
|
|
ali@38
|
651 |
}
|
|
ali@38
|
652 |
|
|
ali@38
|
653 |
static void test_set_error(void)
|
|
ali@38
|
654 |
{
|
|
ali@38
|
655 |
gchar *root;
|
|
ali@38
|
656 |
const char *errmsg;
|
|
ali@38
|
657 |
GError *err=NULL;
|
|
ali@38
|
658 |
const GError *err2=NULL;
|
|
ali@38
|
659 |
PloverPackageSet *installed;
|
|
ali@38
|
660 |
PloverTransactionHelper *helper;
|
|
ali@38
|
661 |
struct set_error_baton baton={0,};
|
|
ali@38
|
662 |
root=g_strdup("razor-test-dir-XXXXXX");
|
|
ali@38
|
663 |
g_assert(mkdtemp(root));
|
|
ali@38
|
664 |
g_setenv("RAZOR_ROOT",root,TRUE);
|
|
ali@38
|
665 |
g_free(root);
|
|
ali@38
|
666 |
helper=get_transaction_helper();
|
|
ali@38
|
667 |
installed=plover_package_set_new_from_installed("../razor-test-dir",&err);
|
|
ali@38
|
668 |
if (!installed)
|
|
ali@38
|
669 |
g_error("../razor-test-dir: %s",err->message);
|
|
ali@38
|
670 |
plover_transaction_helper_set_installed(helper,installed);
|
|
ali@38
|
671 |
g_object_unref(installed);
|
|
ali@38
|
672 |
plover_transaction_helper_set_base(helper,"../yum-repo-test-dir");
|
|
ali@38
|
673 |
if (!plover_transaction_helper_update(helper,&err))
|
|
ali@38
|
674 |
plover_transaction_helper_set_error(helper,err,"Expected error");
|
|
ali@38
|
675 |
g_assert(plover_transaction_helper_get_visible(helper));
|
|
ali@38
|
676 |
errmsg=plover_transaction_helper_get_error(helper,&err2);
|
|
ali@38
|
677 |
g_assert_cmpstr(errmsg,==,"Expected error");
|
|
ali@38
|
678 |
g_assert_error(err2,err->domain,err->code);
|
|
ali@38
|
679 |
plover_transaction_helper_present(helper);
|
|
ali@38
|
680 |
baton.helper=helper;
|
|
ali@38
|
681 |
g_idle_add_full(G_PRIORITY_LOW,set_error_tick,&baton,NULL);
|
|
ali@38
|
682 |
g_error_free(err);
|
|
ali@38
|
683 |
gtk_main();
|
|
ali@38
|
684 |
g_object_unref(helper);
|
|
ali@38
|
685 |
g_unsetenv("RAZOR_ROOT");
|
|
ali@38
|
686 |
}
|
|
ali@38
|
687 |
|
|
ali@38
|
688 |
int main(int argc,char **argv)
|
|
ali@38
|
689 |
{
|
|
ali@38
|
690 |
int retval;
|
|
ali@38
|
691 |
GError *err=NULL;
|
|
ali@38
|
692 |
/*
|
|
ali@38
|
693 |
* Note that because g_test_init() handles --help,
|
|
ali@38
|
694 |
* these options will not appear in the output.
|
|
ali@38
|
695 |
*/
|
|
ali@38
|
696 |
GOptionEntry options[]={
|
|
ali@38
|
697 |
{"manual",0,0,G_OPTION_ARG_NONE,&manual_mode,
|
|
ali@38
|
698 |
"Disable automatic mode",NULL},
|
|
ali@38
|
699 |
{NULL}
|
|
ali@38
|
700 |
};
|
|
ali@38
|
701 |
g_test_init(&argc,&argv,NULL);
|
|
ali@38
|
702 |
g_setenv("GTK_MODULES","",TRUE);
|
|
ali@38
|
703 |
g_setenv("GTK2_RC_FILES","/dev/null",TRUE);
|
|
ali@38
|
704 |
gtk_disable_setlocale();
|
|
ali@38
|
705 |
setlocale(LC_ALL,"C");
|
|
ali@38
|
706 |
g_test_bug_base("mailto:ali@juiblex.co.uk");
|
|
ali@38
|
707 |
if (!gtk_init_with_args(&argc,&argv,NULL,options,NULL,&err))
|
|
ali@38
|
708 |
{
|
|
ali@38
|
709 |
g_printf("%s\n",err->message);
|
|
ali@38
|
710 |
exit(0);
|
|
ali@38
|
711 |
}
|
|
ali@38
|
712 |
g_test_add_func("/transactionhelper/init",test_init);
|
|
ali@38
|
713 |
g_test_add_func("/transactionhelper/basic-properties",
|
|
ali@38
|
714 |
test_basic_properties);
|
|
ali@38
|
715 |
g_test_add_func("/transactionhelper/install-group",test_install_group);
|
|
ali@38
|
716 |
g_test_add_func("/transactionhelper/remove-group",test_remove_group);
|
|
ali@38
|
717 |
g_test_add_func("/transactionhelper/update",test_update);
|
|
ali@38
|
718 |
g_test_add_func("/transactionhelper/run-install",test_run_install);
|
|
ali@38
|
719 |
g_test_add_func("/transactionhelper/run-remove",test_run_remove);
|
|
ali@38
|
720 |
g_test_add_func("/transactionhelper/run-update",test_run_update);
|
|
ali@38
|
721 |
g_test_add_func("/transactionhelper/check-vendor",test_check_vendor);
|
|
ali@38
|
722 |
g_test_add_func("/transactionhelper/set-error",test_set_error);
|
|
ali@38
|
723 |
retval=g_test_run();
|
|
ali@38
|
724 |
return retval;
|
|
ali@38
|
725 |
}
|