Changeset dba056b in mainline for uspace/srv/sysman/test


Ignore:
Timestamp:
2019-08-06T19:23:56Z (6 years ago)
Author:
Matthieu Riolo <matthieu.riolo@…>
Children:
c6d87c10
Parents:
3f05ef7
git-author:
Michal Koutný <xm.koutny+hos@…> (2015-06-20 01:04:31)
git-committer:
Matthieu Riolo <matthieu.riolo@…> (2019-08-06 19:23:56)
Message:

sysman: Using exposees to detect asynchronous start

  • also fixed bug with reference counting of merged jobs
  • add test for the faulty behavior
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/sysman/test/job_queue.c

    r3f05ef7 rdba056b  
    152152}
    153153
     154PCUT_TEST(merge_jobs_with_callback) {
     155        /* Setup mock behavior */
     156        unit_type_vmts[UNIT_SERVICE]->start = &mock_unit_vmt_start_async;
     157        unit_type_vmts[UNIT_SERVICE]->exposee_created =
     158            &mock_unit_vmt_exposee_created;
     159
     160        /* Define mock units */
     161        unit_t *s0 = mock_units[UNIT_SERVICE][0];
     162
     163        /* Create and start first job */
     164        job_t *j0 = NULL;
     165        int rc = sysman_run_job(s0, STATE_STARTED, &job_finished_cb, &j0);
     166        PCUT_ASSERT_INT_EQUALS(EOK, rc);
     167
     168        sysman_process_queue();
     169        /* Job not finished */
     170        PCUT_ASSERT_NULL(j0);
     171
     172
     173        /*
     174         * While s0 is starting in j0, create second job that should be merged
     175         * into the existing one.
     176         */
     177        job_t *j1 = NULL;
     178        rc = sysman_run_job(s0, STATE_STARTED, &job_finished_cb, &j1);
     179        PCUT_ASSERT_INT_EQUALS(EOK, rc);
     180
     181        sysman_process_queue();
     182        /* Job not finished */
     183        PCUT_ASSERT_NULL(j1);
     184
     185        sysman_raise_event(&sysman_event_unit_exposee_created, s0);
     186        sysman_process_queue();
     187
     188        PCUT_ASSERT_NOT_NULL(j0);
     189        PCUT_ASSERT_NOT_NULL(j1);
     190       
     191        /*
     192         * Jobs were, merged so both callbacks should have been called with the
     193         * same job
     194         */
     195        PCUT_ASSERT_EQUALS(j0, j1);
     196
     197        /* And there should be exactly two references (per each callback) */
     198        job_del_ref(&j0);
     199        job_del_ref(&j0);
     200
     201        PCUT_ASSERT_NULL(j0);
     202}
     203
    154204
    155205PCUT_EXPORT(job_queue);
Note: See TracChangeset for help on using the changeset viewer.