1
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
7
#include <bonobo-activation/bonobo-activation.h>
8
#include <bonobo-activation/bonobo-activation-private.h>
9
#include "activation-server/server.h"
14
#define TOTAL_TEST_SCORE 17
16
CORBA_Object name_service = CORBA_OBJECT_NIL;
19
bonobo_activation_exception_id (CORBA_Environment *ev)
21
if (ev->_major == CORBA_USER_EXCEPTION) {
22
if (!strcmp (ev->_id, "IDL:Bonobo/GeneralError:1.0")) {
23
Bonobo_GeneralError *err = CORBA_exception_value (ev);
25
if (!err || !err->description) {
26
return "No general exception error message";
28
return err->description;
34
return CORBA_exception_id (ev);
39
test_bonobo_activation_server (CORBA_Environment *ev, const char *type)
43
ns = bonobo_activation_name_service_get (ev);
44
if (ev->_major != CORBA_NO_EXCEPTION) {
45
g_warning ("Exception '%s' (%s) finding bonobo_activation_server %s",
46
bonobo_activation_exception_id (ev), ev->_id, type);
50
if (name_service != CORBA_OBJECT_NIL &&
52
g_warning ("bonobo_activation_server crashed %s", type);
56
if (name_service == CORBA_OBJECT_NIL)
59
CORBA_Object_release (ns, ev);
65
test_object (CORBA_Object obj, CORBA_Environment *ev, const char *type)
67
if (ev->_major != CORBA_NO_EXCEPTION) {
68
g_warning ("Activation %s failed: %s\n", type,
69
bonobo_activation_exception_id (ev));
70
} else if (CORBA_Object_is_nil (obj, ev)) {
71
g_warning ("Activation %s failed (returned NIL but no exception)!", type);
76
if (!test_bonobo_activation_server (ev, type)) {
84
test_plugin (CORBA_Object obj, CORBA_Environment *ev, const char *type)
86
Plugin_doPluginTest (obj, ev);
88
if (ev->_major != CORBA_NO_EXCEPTION) {
89
g_warning ("Call failed: %s\n",
90
bonobo_activation_exception_id (ev));
93
fprintf (stderr, "Test %s succeeded\n", type);
94
CORBA_Object_release (obj, ev);
100
test_empty (CORBA_Object obj, CORBA_Environment *ev, const char *type)
102
Empty_doNothing (obj, ev);
104
if (ev->_major != CORBA_NO_EXCEPTION) {
105
g_warning ("Call failed: %s\n",
106
bonobo_activation_exception_id (ev));
109
fprintf (stderr, "Test %s succeeded\n", type);
110
CORBA_Object_release (obj, ev);
116
idle_base_activation (gpointer user_data)
118
/* This is a facile test, we always activate the
119
* ActivationContext first and then get the OD from it */
120
bonobo_activation_activation_context_get ();
126
race_base_init (void)
128
g_idle_add (idle_base_activation, NULL);
129
/* to race with the activation context get in the same process */
130
bonobo_activation_object_directory_get (NULL, NULL);
138
empty_activation_cb (CORBA_Object obj,
139
const char *error_reason,
142
CORBA_Environment ev;
143
gboolean ret = FALSE;
144
char *repo_id = user_data;
146
CORBA_exception_init (&ev);
149
g_warning ("Async activation error activating '%s' : '%s'", repo_id, error_reason);
151
else if (test_object (obj, &ev, "by async query"))
152
ret = test_empty (obj, &ev, "by async query");
156
fprintf (stderr, "PASSED %d of %d: async activation\n", passed + failed, TOTAL_TEST_SCORE);
159
fprintf (stderr, "FAILED %d of %d: async activation\n", passed + failed, TOTAL_TEST_SCORE);
162
CORBA_exception_free (&ev);
168
race_empty (CORBA_Environment *ev)
170
bonobo_activation_activate_async (
171
"repo_ids.has('IDL:Empty2:1.0')", NULL,
172
0, empty_activation_cb, "IDL:Empty2:1.0", ev);
173
g_assert (ev->_major == CORBA_NO_EXCEPTION);
175
bonobo_activation_activate_async (
176
"repo_ids.has('IDL:Empty:1.0')", NULL,
177
0, empty_activation_cb, "IDL:Empty:1.0", ev);
178
g_assert (ev->_major == CORBA_NO_EXCEPTION);
180
while (async_done < 2)
181
g_main_context_iteration (NULL, TRUE);
185
listener_cb (BonoboListener *listener,
186
const char *event_name,
187
const CORBA_any *any,
188
CORBA_Environment *ev,
191
g_message ("Activation callback successfully called on %s",
192
bonobo_event_subtype (event_name));
197
main (int argc, char *argv[])
200
CORBA_Environment ev;
201
Bonobo_ServerInfoList *info;
206
GTimer *timer = g_timer_new ();
207
Bonobo_EventSource event_source;
210
CORBA_exception_init (&ev);
212
bonobo_activation_object_directory_get (
213
bonobo_activation_username_get (),
214
bonobo_activation_hostname_get ());
216
bonobo_init (&argc, &argv);
217
/* putenv("Bonobo_BARRIER_INIT=1"); */
220
event_source = bonobo_activation_activate_from_id
221
("OAFIID:Bonobo_Activation_EventSource", 0, NULL, &ev);
222
if (event_source != CORBA_OBJECT_NIL) {
224
fprintf (stderr, "PASSED %d of %d: Activation event source okay\n",
225
passed + failed, TOTAL_TEST_SCORE);
226
bonobo_event_source_client_add_listener (event_source, listener_cb,
227
"Bonobo/ObjectDirectory", &ev, NULL);
230
fprintf (stderr, "FAILED %d of %d: Activation event source not found\n",
231
passed + failed, TOTAL_TEST_SCORE);
237
sort_by[0] = "prefer_by_list_order(iid, ["
238
"'OAFIID:nautilus_file_manager_icon_view:42681b21-d5ca-4837-87d2-394d88ecc058',"
239
"'OAFIID:nautilus_file_manager_list_view:521e489d-0662-4ad7-ac3a-832deabe111c',"
240
"'OAFIID:nautilus_music_view:9456b5d2-60a8-407f-a56e-d561e1821391'])";
241
sort_by[1] = "iid != 'OAFIID:nautilus_content_loser:95901458-c68b-43aa-aaca-870ced11062d'";
242
sort_by[2] = "iid != 'OAFIID:nautilus_sample_content_view:45c746bc-7d64-4346-90d5-6410463b43ae'";
245
query = "( (((repo_ids.has_all (['IDL:Bonobo/Control:1.0',"
246
"'IDL:Nautilus/View:1.0']) OR (repo_ids.has_one "
247
"(['IDL:Bonobo/Control:1.0','IDL:Bonobo/Embeddable:1.0']) AND "
248
"repo_ids.has_one (['IDL:Bonobo/PersistStream:1.0', "
249
"'IDL:Bonobo/ProgressiveDataSink:1.0', "
250
"'IDL:Bonobo/PersistFile:1.0']))) AND (bonobo:supported_mime_types.defined () OR "
251
"bonobo:supported_uri_schemes.defined () OR "
252
"bonobo:additional_uri_schemes.defined ()) AND "
253
"(((NOT bonobo:supported_mime_types.defined () OR "
254
"bonobo:supported_mime_types.has ('x-directory/normal') OR "
255
"bonobo:supported_mime_types.has ('x-directory/*') OR "
256
"bonobo:supported_mime_types.has ('*/*')) AND "
257
"(NOT bonobo:supported_uri_schemes.defined () OR "
258
"bonobo:supported_uri_schemes.has ('file') OR "
259
"bonobo:supported_uri_schemes.has ('*'))) OR "
260
"(bonobo:additional_uri_schemes.has ('file') OR "
261
"bonobo:additional_uri_schemes.has ('*'))) AND "
262
"nautilus:view_as_name.defined ()) OR false) AND "
263
"(has (['OAFIID:nautilus_file_manager_icon_view:42681b21-d5ca-4837-87d2-394d88ecc058', "
264
"'OAFIID:nautilus_file_manager_list_view:521e489d-0662-4ad7-ac3a-832deabe111c'], iid)) ) AND "
265
"(NOT test_only.defined() OR NOT test_only)";
267
ac = bonobo_activation_activation_context_get ();
269
g_timer_start (timer);
271
info = bonobo_activation_query (query, sort_by, &ev);
273
for (i = 0; i < 1000; i++) {
274
Bonobo_ServerInfoList *copy;
276
info = bonobo_activation_query (query, sort_by, &ev);
278
if (ev._major == CORBA_NO_EXCEPTION) {
281
fprintf (stderr, "Test of query failed '%s'\n",
282
bonobo_activation_exception_id (&ev));
285
copy = Bonobo_ServerInfoList_duplicate (info);
289
g_timer_stop (timer);
291
fprintf (stderr, "Time to query '%g'\n", g_timer_elapsed (timer, NULL));
292
if (ev._major == CORBA_NO_EXCEPTION) {
294
fprintf (stderr, "PASSED %d of %d: timed query\n", passed + failed, TOTAL_TEST_SCORE);
297
fprintf (stderr, "FAILED %d of %d: timed query\n", passed + failed, TOTAL_TEST_SCORE);
298
CORBA_exception_free (&ev);
302
* We wait to see if the server (sever)
303
* timeout is mis-behaving [ at this stage we
304
* havn't registered anything with the server ]
306
fprintf (stderr, "Waiting to see if the server erroneously quits\n");
307
sleep (SERVER_IDLE_QUIT_TIMEOUT * 2 / 1000);
308
g_assert (ORBit_small_get_connection_status (ac) ==
309
ORBIT_CONNECTION_CONNECTED);
317
obj = bonobo_activation_activate_from_id ("OAFIID:Empty:19991025", 0, NULL, &ev);
318
if (test_object (obj, &ev, "from id") && test_empty (obj, &ev, "from id")) {
320
fprintf (stderr, "PASSED %d of %d: IID activation\n", passed + failed, TOTAL_TEST_SCORE);
323
fprintf (stderr, "FAILED %d of %d: IID activation\n", passed + failed, TOTAL_TEST_SCORE);
326
obj = bonobo_activation_activate_from_id ("OAFAID:[OAFIID:Empty:19991025]", 0, NULL, &ev);
327
if (test_object (obj, &ev, "from aid") && test_empty (obj, &ev, "from aid")) {
329
fprintf (stderr, "PASSED %d of %d: AID activation\n", passed + failed, TOTAL_TEST_SCORE);
332
fprintf (stderr, "FAILED %d of %d: AID activation\n", passed + failed, TOTAL_TEST_SCORE);
335
obj = bonobo_activation_activate_from_id ("OAFAID:[OAFIID:Plugin:20010713]", 0, NULL, &ev);
336
if (test_object (obj, &ev, "from aid") && test_plugin (obj, &ev, "from aid")) {
338
fprintf (stderr, "PASSED %d of %d: plugin activation\n", passed + failed, TOTAL_TEST_SCORE);
341
fprintf (stderr, "FAILED %d of %d: plugin activation\n", passed + failed, TOTAL_TEST_SCORE);
344
obj = bonobo_activation_activate_from_id ("OAFIID:Bogus:20000526", 0, NULL, &ev);
345
if (ev._major != CORBA_NO_EXCEPTION) {
347
fprintf (stderr, "PASSED %d of %d: Broken link test : %s\n",
348
passed + failed, TOTAL_TEST_SCORE, bonobo_activation_exception_id (&ev));
349
CORBA_exception_free (&ev);
352
fprintf (stderr, "FAILED %d of %d: Broken link test\n", passed + failed, TOTAL_TEST_SCORE);
355
if (test_bonobo_activation_server (&ev, "with broken factory link")) {
357
fprintf (stderr, "PASSED %d of %d: activation server okay\n", passed + failed, TOTAL_TEST_SCORE);
360
fprintf (stderr, "FAILED %d of %d: activation server okay\n", passed + failed, TOTAL_TEST_SCORE);
363
fprintf (stderr, "Broken exe test ");
364
obj = bonobo_activation_activate_from_id ("OAFIID:Broken:20000530", 0, NULL, &ev);
365
if (ev._major != CORBA_NO_EXCEPTION) {
367
fprintf (stderr, "PASSED %d of %d: Broken exe test : %s\n",
368
passed + failed, TOTAL_TEST_SCORE, bonobo_activation_exception_id (&ev));
369
CORBA_exception_free (&ev);
372
fprintf (stderr, "FAILED %d of %d: Broken exe test\n", passed + failed, TOTAL_TEST_SCORE);
375
if (test_bonobo_activation_server (&ev, "with broken factory link")) {
377
fprintf (stderr, "PASSED %d of %d: activation server okay\n", passed + failed, TOTAL_TEST_SCORE);
380
fprintf (stderr, "FAILED %d of %d: activation server okay\n", passed + failed, TOTAL_TEST_SCORE);
383
obj = bonobo_activation_activate_from_id ("OAFIID:Circular:20000530", 0, NULL, &ev);
384
if (ev._major != CORBA_NO_EXCEPTION) {
386
fprintf (stderr, "PASSED %d of %d: Circular link test : %s\n",
387
passed + failed, TOTAL_TEST_SCORE, bonobo_activation_exception_id (&ev));
388
CORBA_exception_free (&ev);
391
fprintf (stderr, "FAILED %d of %d: Circular link test\n", passed + failed, TOTAL_TEST_SCORE);
394
if (test_bonobo_activation_server (&ev, "with broken factory link")) {
396
fprintf (stderr, "PASSED %d of %d: activation server okay\n", passed + failed, TOTAL_TEST_SCORE);
399
fprintf (stderr, "FAILED %d of %d: activation server okay\n", passed + failed, TOTAL_TEST_SCORE);
402
obj = bonobo_activation_activate_from_id ("OAFIID:NotInServer:20000717", 0, NULL, &ev);
403
if (ev._major != CORBA_NO_EXCEPTION) {
405
fprintf (stderr, "PASSED %d of %d: Server that doesn't register IID test : %s\n",
406
passed + failed, TOTAL_TEST_SCORE, bonobo_activation_exception_id (&ev));
407
CORBA_exception_free (&ev);
410
fprintf (stderr, "FAILED %d of %d: Server that doesn't register IID test\n",
411
passed + failed, TOTAL_TEST_SCORE);
414
if (test_bonobo_activation_server (&ev, "with non-registering server")) {
416
fprintf (stderr, "PASSED %d of %d: activation server okay\n", passed + failed, TOTAL_TEST_SCORE);
419
fprintf (stderr, "FAILED %d of %d: activation server okay\n", passed + failed, TOTAL_TEST_SCORE);
422
obj = bonobo_activation_activate_from_id ("OAFIID:BrokenNoType:20000808", 0, NULL, &ev);
423
if (ev._major != CORBA_NO_EXCEPTION) {
425
fprintf (stderr, "FAILED %d of %d: Server with IID but no type or location : %s\n",
426
passed + failed, TOTAL_TEST_SCORE, bonobo_activation_exception_id (&ev));
427
CORBA_exception_free (&ev);
430
fprintf (stderr, "FAILED %d of %d: Server with IID but no type or location\n",
431
passed + failed, TOTAL_TEST_SCORE);
434
fprintf (stderr, "PASSED %d of %d: Server with IID but no type or location\n",
435
passed + failed, TOTAL_TEST_SCORE);
438
if (test_bonobo_activation_server (&ev, "with no-type/loc server")) {
440
fprintf (stderr, "PASSED %d of %d: activation server okay\n", passed + failed, TOTAL_TEST_SCORE);
443
fprintf (stderr, "FAILED %d of %d: activation server okay\n", passed + failed, TOTAL_TEST_SCORE);
446
fprintf (stderr, "\n%d of %d tests passed (%s)\n", passed,
448
passed == TOTAL_TEST_SCORE? "All": "some failures");
450
if (passed < (TOTAL_TEST_SCORE * 2 / 3)) {
451
fprintf (stderr, "It looks like you havn't installed broken.server "
452
"into ${prefix}/share/bonobo-activation/, this must be done "
453
"by hand to avoid problems with normal operation.\n");
454
fprintf (stderr, "Another possibility is that you failed to kill "
455
"bonobo_activation_server before running make check; try running bonobo-slay.\n");
458
if (name_service != CORBA_OBJECT_NIL)
459
CORBA_Object_release (name_service, &ev);
461
if (event_source != CORBA_OBJECT_NIL)
462
CORBA_Object_release (event_source, &ev);
464
CORBA_exception_free (&ev);
466
if (passed == TOTAL_TEST_SCORE) {
467
if (bonobo_debug_shutdown ()) {