Changeset 72c8f77 in mainline for uspace/srv/sysman/test/job_queue.c


Ignore:
Timestamp:
2019-08-06T18:30:29Z (5 years ago)
Author:
Matthieu Riolo <matthieu.riolo@…>
Children:
63a3276
Parents:
c2d50c8
git-author:
Michal Koutný <xm.koutny+hos@…> (2015-05-26 16:15:58)
git-committer:
Matthieu Riolo <matthieu.riolo@…> (2019-08-06 18:30:29)
Message:

sysman: Separate job closure creation and its enqueuing

  • added merge job operation
  • created test that failed with previous implementation of job closure
File:
1 edited

Legend:

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

    rc2d50c8 r72c8f77  
    4242static fid_t fibril_event_loop;
    4343
    44 #if 0
    45 static bool async_finished;
    46 static fibril_condvar_t async_finished_cv;
    47 static fibril_mutex_t async_finished_mtx;
    48 #endif
    49 
    50 static void async_finished_callback(void *object, void *arg)
     44static void job_finished_cb(void *object, void *arg)
    5145{
    5246        job_t *job = object;
     
    5650        *job_ptr = job;
    5751}
    58 
    59 #if 0
    60 static void reset_wait(void)
    61 {
    62         fibril_mutex_lock(&async_finished_mtx);
    63         async_finished = false;
    64         fibril_mutex_unlock(&async_finished_mtx);
    65 }
    66 
    67 static void async_wait()
    68 {
    69         fibril_mutex_lock(&async_finished_mtx);
    70         while (!async_finished) {
    71                 fibril_condvar_wait(&async_finished_cv, &async_finished_mtx);
    72         }
    73         fibril_mutex_unlock(&async_finished_mtx);
    74 }
    75 #endif
    7652
    7753PCUT_TEST_SUITE(job_queue);
     
    10783        job_t *job = NULL;
    10884
    109         int rc = sysman_run_job(u, STATE_STARTED, &async_finished_callback,
     85        int rc = sysman_run_job(u, STATE_STARTED, &job_finished_cb,
    11086            &job);
    11187        PCUT_ASSERT_INT_EQUALS(EOK, rc);
     
    126102        job_t *job = NULL;
    127103
    128         int rc = sysman_run_job(u, STATE_STARTED, &async_finished_callback,
    129             &job);
     104        int rc = sysman_run_job(u, STATE_STARTED, &job_finished_cb, &job);
    130105        PCUT_ASSERT_INT_EQUALS(EOK, rc);
    131106
     
    142117}
    143118
     119PCUT_TEST(multipath_to_started_unit) {
     120        /* Setup mock behavior */
     121        unit_type_vmts[UNIT_SERVICE]->start = &mock_unit_vmt_start_sync;
     122
     123        unit_type_vmts[UNIT_MOUNT]->start = &mock_unit_vmt_start_async;
     124        unit_type_vmts[UNIT_MOUNT]->exposee_created =
     125            &mock_unit_vmt_exposee_created;
     126
     127        /* Define mock units */
     128        unit_t *s0 = mock_units[UNIT_SERVICE][0];
     129        unit_t *s1 = mock_units[UNIT_SERVICE][1];
     130        unit_t *m0 = mock_units[UNIT_MOUNT][0];
     131
     132        /* All services require root fs */
     133        mock_add_dependency(s0, m0);
     134        mock_add_dependency(s1, m0);
     135       
     136        /* S1 requires another mount and S0 */
     137        mock_add_dependency(s1, s0);
     138
     139        /* Enforce initial state */
     140        m0->state = STATE_STARTED;
     141
     142        /* Run test */
     143        job_t *job = NULL;
     144        int rc = sysman_run_job(s1, STATE_STARTED, &job_finished_cb, &job);
     145        PCUT_ASSERT_INT_EQUALS(EOK, rc);
     146
     147        sysman_process_queue();
     148
     149        PCUT_ASSERT_NOT_NULL(job);
     150        PCUT_ASSERT_EQUALS(STATE_STARTED, s0->state);
     151        PCUT_ASSERT_EQUALS(STATE_STARTED, s1->state);
     152}
     153
    144154
    145155PCUT_EXPORT(job_queue);
Note: See TracChangeset for help on using the changeset viewer.