241
241
last_id = event->id;
243
243
TEST_EQ (event->progress, EVENT_PENDING);
244
TEST_EQ (event->jobs, 0);
245
244
TEST_EQ (event->failed, FALSE);
246
TEST_EQ (event->refs, 0);
247
TEST_EQ (event->blockers, 0);
247
249
TEST_EQ_STR (event->info.name, "test");
248
250
TEST_ALLOC_PARENT (event->info.name, event);
286
288
TEST_EQ_P (ret, NULL);
290
test_emit_finished (void)
294
TEST_FUNCTION ("event_emit_finished");
295
event = event_new (NULL, "test", NULL, NULL);
296
event->progress = EVENT_HANDLING;
298
/* Check that if an event has jobs remaining, the progress isn't
301
TEST_FEATURE ("with remaining jobs");
303
event_emit_finished (event);
305
TEST_EQ (event->progress, EVENT_HANDLING);
308
/* Check that if an event has no jobs remaining, the progress is
309
* changed to finished.
311
TEST_FEATURE ("with no remaining jobs");
313
event_emit_finished (event);
315
TEST_EQ (event->progress, EVENT_FINISHED);
297
/* Check that calling event_ref increments the number of references
298
* that the event has, while leaving the blockers at zero.
300
TEST_FUNCTION ("event_ref");
301
event = event_new (NULL, "test", NULL, NULL);
306
TEST_EQ (event->refs, 5);
307
TEST_EQ (event->blockers, 0);
309
nih_list_free (&event->entry);
317
/* Check that calling event_unref decrements the number of references
318
* that the event has, while leaving the blockers at zero.
320
TEST_FUNCTION ("event_unref");
321
event = event_new (NULL, "test", NULL, NULL);
326
TEST_EQ (event->refs, 3);
327
TEST_EQ (event->blockers, 0);
329
nih_list_free (&event->entry);
337
/* Check that calling event_block increments the number of blockers
338
* that the event has, while leaving the references at zero.
340
TEST_FUNCTION ("event_block");
341
event = event_new (NULL, "test", NULL, NULL);
346
TEST_EQ (event->blockers, 5);
347
TEST_EQ (event->refs, 0);
349
nih_list_free (&event->entry);
357
/* Check that calling event_unblock increments the number of blockers
358
* that the event has, while leaving the references at zero.
360
TEST_FUNCTION ("event_unblock");
361
event = event_new (NULL, "test", NULL, NULL);
364
event_unblock (event);
366
TEST_EQ (event->blockers, 3);
367
TEST_EQ (event->refs, 0);
318
369
nih_list_free (&event->entry);
435
487
TEST_EQ (WEXITSTATUS (status), 0);
437
489
TEST_EQ (event->progress, EVENT_HANDLING);
438
TEST_EQ (event->jobs, 1);
490
TEST_EQ (event->refs, 1);
491
TEST_EQ (event->blockers, 1);
440
493
TEST_EQ (job->goal, JOB_START);
441
494
TEST_EQ (job->state, JOB_RUNNING);
449
502
nih_list_free (&event->entry);
452
/* Check that having a handling event in the queue doesn't cause
505
/* Check that having a handling event in the queue which has blockers
506
* doesn't cause any problem.
455
TEST_FEATURE ("with handling event");
508
TEST_FEATURE ("with blocked handling event");
456
509
TEST_ALLOC_FAIL {
457
510
event = event_new (NULL, "test", NULL, NULL);
458
511
event->progress = EVENT_HANDLING;
467
/* Check that events in the finished state are consumed, leaving
468
* the list empty. Subscribed processes should be notified, blocked
469
* jobs should be releaed and the event should be freed.
521
/* Check that we finish unblocked handling events, leaving the list
522
* empty. Subscribed processes should be notified, blocked jobs
523
* should be releaed and the event should be freed.
471
525
TEST_FEATURE ("with finished event");
531
586
TEST_LIST_EMPTY (subscriptions);
589
/* Check that a finished event with remaining references is held
590
* in the done state, and not freed immediately.
592
TEST_FEATURE ("with referenced event");
594
event = event_new (NULL, "test", NULL, NULL);
595
event->progress = EVENT_DONE;
600
TEST_LIST_NOT_EMPTY (&event->entry);
601
nih_list_free (&event->entry);
534
605
/* Check that a pending event which doesn't cause any jobs to be
535
* changed goes straight into the finished state, thus getting
606
* changed goes straight into the done state, thus getting
538
609
TEST_FEATURE ("with no-op pending event");