70
70
UDisksSpawnedJob *job;
72
job = udisks_spawned_job_new ("/bin/true", NULL, getuid (), geteuid (), NULL);
72
job = udisks_spawned_job_new ("/bin/true", NULL, getuid (), geteuid (), NULL, NULL);
73
73
_g_assert_signal_received (job, "completed", G_CALLBACK (on_completed_expect_success), NULL);
74
74
g_object_unref (job);
82
82
UDisksSpawnedJob *job;
84
job = udisks_spawned_job_new ("/bin/false", NULL, getuid (), geteuid (), NULL);
84
job = udisks_spawned_job_new ("/bin/false", NULL, getuid (), geteuid (), NULL, NULL);
85
85
_g_assert_signal_received (job, "completed", G_CALLBACK (on_completed_expect_failure),
86
"Command-line `/bin/false' exited with non-zero exit status 1: ");
86
(gpointer) "Command-line `/bin/false' exited with non-zero exit status 1: ");
87
87
g_object_unref (job);
95
95
UDisksSpawnedJob *job;
97
job = udisks_spawned_job_new ("/path/to/unknown/file", NULL, getuid (), geteuid (), NULL);
97
job = udisks_spawned_job_new ("/path/to/unknown/file", NULL, getuid (), geteuid (), NULL, NULL);
98
98
_g_assert_signal_received (job, "completed", G_CALLBACK (on_completed_expect_failure),
99
"Error spawning command-line `/path/to/unknown/file': Failed to execute child process \"/path/to/unknown/file\" (No such file or directory) (g-exec-error-quark, 8)");
99
(gpointer) "Error spawning command-line `/path/to/unknown/file': Failed to execute child process \"/path/to/unknown/file\" (No such file or directory) (g-exec-error-quark, 8)");
100
100
g_object_unref (job);
111
111
cancellable = g_cancellable_new ();
112
112
g_cancellable_cancel (cancellable);
113
job = udisks_spawned_job_new ("/bin/true", NULL, getuid (), geteuid (), cancellable);
113
job = udisks_spawned_job_new ("/bin/true", NULL, getuid (), geteuid (), NULL, cancellable);
114
114
_g_assert_signal_received (job, "completed", G_CALLBACK (on_completed_expect_failure),
115
"Operation was cancelled (g-io-error-quark, 19)");
115
(gpointer) "Operation was cancelled (g-io-error-quark, 19)");
116
116
g_object_unref (job);
117
117
g_object_unref (cancellable);
135
135
GCancellable *cancellable;
137
137
cancellable = g_cancellable_new ();
138
job = udisks_spawned_job_new ("/bin/sleep 0.5", NULL, getuid (), geteuid (), cancellable);
138
job = udisks_spawned_job_new ("/bin/sleep 0.5", NULL, getuid (), geteuid (), NULL, cancellable);
139
139
g_timeout_add (10, on_timeout, cancellable); /* 10 msec */
140
140
g_main_loop_run (loop);
141
141
_g_assert_signal_received (job, "completed", G_CALLBACK (on_completed_expect_failure),
142
"Operation was cancelled (g-io-error-quark, 19)");
142
(gpointer) "Operation was cancelled (g-io-error-quark, 19)");
143
143
g_object_unref (job);
144
144
g_object_unref (cancellable);
167
167
UDisksSpawnedJob *job;
168
168
gboolean handler_ran;
170
job = udisks_spawned_job_new ("/path/to/unknown/file", NULL, getuid (), geteuid (), NULL /* GCancellable */);
170
job = udisks_spawned_job_new ("/path/to/unknown/file", NULL, getuid (), geteuid (), NULL, NULL /* GCancellable */);
171
171
handler_ran = FALSE;
172
172
g_signal_connect (job, "spawned-job-completed", G_CALLBACK (on_spawned_job_completed), &handler_ran);
173
173
_g_assert_signal_received (job, "completed", G_CALLBACK (on_completed_expect_failure),
174
"Error spawning command-line `/path/to/unknown/file': Failed to execute child process \"/path/to/unknown/file\" (No such file or directory) (g-exec-error-quark, 8)");
174
(gpointer) "Error spawning command-line `/path/to/unknown/file': Failed to execute child process \"/path/to/unknown/file\" (No such file or directory) (g-exec-error-quark, 8)");
175
175
g_assert (handler_ran);
176
176
g_object_unref (job);
184
184
UDisksSpawnedJob *job;
186
job = udisks_spawned_job_new ("/bin/sleep 1000", NULL, getuid (), geteuid (), NULL /* GCancellable */);
186
job = udisks_spawned_job_new ("/bin/sleep 1000", NULL, getuid (), geteuid (), NULL, NULL /* GCancellable */);
187
187
g_object_unref (job);
216
216
s = g_strdup_printf (UDISKS_TEST_DIR "/udisks-test-helper 0");
217
job = udisks_spawned_job_new (s, NULL, getuid (), geteuid (), NULL);
217
job = udisks_spawned_job_new (s, NULL, getuid (), geteuid (), NULL, NULL);
218
218
_g_assert_signal_received (job, "spawned-job-completed", G_CALLBACK (read_stdout_on_spawned_job_completed), NULL);
219
219
g_object_unref (job);
249
249
s = g_strdup_printf (UDISKS_TEST_DIR "/udisks-test-helper 1");
250
job = udisks_spawned_job_new (s, NULL, getuid (), geteuid (), NULL);
250
job = udisks_spawned_job_new (s, NULL, getuid (), geteuid (), NULL, NULL);
251
251
_g_assert_signal_received (job, "spawned-job-completed", G_CALLBACK (read_stderr_on_spawned_job_completed), NULL);
252
252
g_object_unref (job);
280
280
s = g_strdup_printf (UDISKS_TEST_DIR "/udisks-test-helper 2");
281
job = udisks_spawned_job_new (s, NULL, getuid (), geteuid (), NULL);
281
job = udisks_spawned_job_new (s, NULL, getuid (), geteuid (), NULL, NULL);
282
282
_g_assert_signal_received (job, "spawned-job-completed", G_CALLBACK (exit_status_on_spawned_job_completed),
283
283
GINT_TO_POINTER (1));
284
284
g_object_unref (job);
287
287
s = g_strdup_printf (UDISKS_TEST_DIR "/udisks-test-helper 3");
288
job = udisks_spawned_job_new (s, NULL, getuid (), geteuid (), NULL);
288
job = udisks_spawned_job_new (s, NULL, getuid (), geteuid (), NULL, NULL);
289
289
_g_assert_signal_received (job, "spawned-job-completed", G_CALLBACK (exit_status_on_spawned_job_completed),
290
290
GINT_TO_POINTER (2));
291
291
g_object_unref (job);
303
303
s = g_strdup_printf (UDISKS_TEST_DIR "/udisks-test-helper 4");
304
job = udisks_spawned_job_new (s, NULL, getuid (), geteuid (), NULL);
304
job = udisks_spawned_job_new (s, NULL, getuid (), geteuid (), NULL, NULL);
305
305
_g_assert_signal_received (job, "completed", G_CALLBACK (on_completed_expect_failure),
306
"Command-line `./udisks-test-helper 4' was signaled with signal SIGSEGV (11): "
306
(gpointer) "Command-line `./udisks-test-helper 4' was signaled with signal SIGSEGV (11): "
307
307
"OK, deliberately causing a segfault\n");
308
308
g_object_unref (job);
311
311
s = g_strdup_printf (UDISKS_TEST_DIR "/udisks-test-helper 5");
312
job = udisks_spawned_job_new (s, NULL, getuid (), geteuid (), NULL);
312
job = udisks_spawned_job_new (s, NULL, getuid (), geteuid (), NULL, NULL);
313
313
_g_assert_signal_received (job, "completed", G_CALLBACK (on_completed_expect_failure),
314
"Command-line `./udisks-test-helper 5' was signaled with signal SIGABRT (6): "
314
(gpointer) "Command-line `./udisks-test-helper 5' was signaled with signal SIGABRT (6): "
315
315
"OK, deliberately abort()'ing\n");
316
316
g_object_unref (job);
352
352
s = g_strdup_printf (UDISKS_TEST_DIR "/udisks-test-helper 6");
353
job = udisks_spawned_job_new (s, NULL, getuid (), geteuid (), NULL);
353
job = udisks_spawned_job_new (s, NULL, getuid (), geteuid (), NULL, NULL);
354
354
_g_assert_signal_received (job, "spawned-job-completed", G_CALLBACK (binary_output_on_spawned_job_completed), NULL);
355
355
g_object_unref (job);
383
383
s = g_strdup_printf (UDISKS_TEST_DIR "/udisks-test-helper 7");
384
job = udisks_spawned_job_new (s, "foobar", getuid (), geteuid (), NULL);
384
job = udisks_spawned_job_new (s, "foobar", getuid (), geteuid (), NULL, NULL);
385
385
_g_assert_signal_received (job, "spawned-job-completed", G_CALLBACK (input_string_on_spawned_job_completed), NULL);
386
386
g_object_unref (job);
405
405
UDisksThreadedJob *job;
407
job = udisks_threaded_job_new (threaded_job_successful_func, NULL, NULL, NULL);
407
job = udisks_threaded_job_new (threaded_job_successful_func, NULL, NULL, NULL, NULL);
408
408
_g_assert_signal_received (job, "completed", G_CALLBACK (on_completed_expect_success), NULL);
409
409
g_object_unref (job);
431
431
UDisksThreadedJob *job;
433
job = udisks_threaded_job_new (threaded_job_failure_func, NULL, NULL, NULL);
433
job = udisks_threaded_job_new (threaded_job_failure_func, NULL, NULL, NULL, NULL);
434
434
_g_assert_signal_received (job, "completed", G_CALLBACK (on_completed_expect_failure),
435
"Threaded job failed with error: some error (g-key-file-error-quark, 5)");
435
(gpointer) "Threaded job failed with error: some error (g-key-file-error-quark, 5)");
436
436
g_object_unref (job);
447
447
cancellable = g_cancellable_new ();
448
448
g_cancellable_cancel (cancellable);
449
job = udisks_threaded_job_new (threaded_job_successful_func, NULL, NULL, cancellable);
449
job = udisks_threaded_job_new (threaded_job_successful_func, NULL, NULL, NULL, cancellable);
450
450
_g_assert_signal_received (job, "completed", G_CALLBACK (on_completed_expect_failure),
451
"Threaded job failed with error: Operation was cancelled (g-io-error-quark, 19)");
451
(gpointer) "Threaded job failed with error: Operation was cancelled (g-io-error-quark, 19)");
452
452
g_object_unref (job);
453
453
g_object_unref (cancellable);
486
486
cancellable = g_cancellable_new ();
488
job = udisks_threaded_job_new (threaded_job_sleep_until_cancelled, &count, NULL, cancellable);
488
job = udisks_threaded_job_new (threaded_job_sleep_until_cancelled, &count, NULL, NULL, cancellable);
489
489
g_timeout_add (10, on_timeout, cancellable); /* 10 msec */
490
490
g_main_loop_run (loop);
491
491
_g_assert_signal_received (job, "completed", G_CALLBACK (on_completed_expect_failure),
492
"Threaded job failed with error: Operation was cancelled (g-io-error-quark, 19)");
492
(gpointer) "Threaded job failed with error: Operation was cancelled (g-io-error-quark, 19)");
493
493
g_assert_cmpint (count, >, 0);
494
494
g_object_unref (job);
495
495
g_object_unref (cancellable);
518
518
UDisksThreadedJob *job;
519
519
gboolean handler_ran;
521
job = udisks_threaded_job_new (threaded_job_failure_func, NULL, NULL, NULL);
521
job = udisks_threaded_job_new (threaded_job_failure_func, NULL, NULL, NULL, NULL);
522
522
handler_ran = FALSE;
523
523
g_signal_connect (job, "threaded-job-completed", G_CALLBACK (on_threaded_job_completed), &handler_ran);
524
524
_g_assert_signal_received (job, "completed", G_CALLBACK (on_completed_expect_failure),
525
"Threaded job failed with error: some error (g-key-file-error-quark, 5)");
525
(gpointer) "Threaded job failed with error: some error (g-key-file-error-quark, 5)");
526
526
g_assert (handler_ran);
527
527
g_object_unref (job);