~vorlon/ubuntu/raring/upstart/lp.1199778

« back to all changes in this revision

Viewing changes to init/tests/test_process.c

  • Committer: Scott James Remnant
  • Date: 2008-03-01 17:58:15 UTC
  • Revision ID: scott@netsplit.com-20080301175815-9ghzdfpn913uivtl
* init/job.c (job_new): Increment the number of instances.
(job_instance): Simplify the function, it now only returns the
existing instance or NULL.  This makes it easier to extend when
we have env-limited instances later on.
(job_handle_event): If job_instance returns NULL, create
a new instance with job_new() and always reset the operator afterwards.
* init/tests/test_job.c (test_new): Check that the instances variable
is incremented when a new job is created.
(test_instance): Change to check that it returns NULL when there is
no active instance, or for multi-instance jobs, instead of creating
a new one itself.
(test_config_replace, test_find_by_pid)
(test_find_by_id, test_change_goal, test_change_state)
(test_next_state, test_run_process, test_kill_process)
(test_child_handler, test_handle_event)
(test_handle_event_finished): Call job_new to create a new instance
from a config, instead of job_instance.

* init/tests/test_conf.c (test_source_reload_job_dir)
(test_file_destroy): Call job_new to create a new instance from a
config, instead of job_instance.
* init/tests/test_event.c (test_poll): Call job_new to create a new
instance from a config, instead of job_instance.
* init/tests/test_process.c (test_spawn, test_environment): Call
job_new to create a new instance from a config, instead of job_instance

Show diffs side-by-side

added added

removed removed

Lines of Context:
131
131
 
132
132
        config = job_config_new (NULL, "test");
133
133
 
134
 
        job = job_instance (config);
 
134
        job = job_new (config);
135
135
        pid = process_spawn (job, args, FALSE);
136
136
        TEST_GT (pid, 0);
137
137
 
170
170
        config = job_config_new (NULL, "test");
171
171
        config->console = CONSOLE_NONE;
172
172
 
173
 
        job = job_instance (config);
 
173
        job = job_new (config);
174
174
        pid = process_spawn (job, args, FALSE);
175
175
        TEST_GT (pid, 0);
176
176
 
197
197
        config = job_config_new (NULL, "test");
198
198
        config->chdir = "/tmp";
199
199
 
200
 
        job = job_instance (config);
 
200
        job = job_new (config);
201
201
        pid = process_spawn (job, args, FALSE);
202
202
        TEST_GT (pid, 0);
203
203
 
225
225
        env[0] = "FOO=bar";
226
226
        env[1] = NULL;
227
227
 
228
 
        job = job_instance (config);
 
228
        job = job_new (config);
229
229
        job->id = 1000;
230
230
        pid = process_spawn (job, args, FALSE);
231
231
        TEST_GT (pid, 0);
260
260
        env[0] = "FOO=bar";
261
261
        env[1] = NULL;
262
262
 
263
 
        job = job_instance (config);
 
263
        job = job_new (config);
264
264
        job->id = 1000;
265
265
 
266
266
        job->start_on = event_operator_new (job, EVENT_AND, NULL, NULL);
321
321
 
322
322
        config = job_config_new (NULL, "test");
323
323
 
324
 
        job = job_instance (config);
 
324
        job = job_new (config);
325
325
        pid = process_spawn (job, args, FALSE);
326
326
        TEST_GT (pid, 0);
327
327
 
343
343
        config = job_config_new (NULL, "test");
344
344
        config->wait_for = JOB_WAIT_DAEMON;
345
345
 
346
 
        job = job_instance (config);
 
346
        job = job_new (config);
347
347
        pid = process_spawn (job, args, TRUE);
348
348
        TEST_GT (pid, 0);
349
349
 
373
373
 
374
374
        config = job_config_new (NULL, "test");
375
375
 
376
 
        job = job_instance (config);
 
376
        job = job_new (config);
377
377
        pid = process_spawn (job, args, FALSE);
378
378
        TEST_LT (pid, 0);
379
379
 
478
478
        TEST_FEATURE ("with empty environment");
479
479
        config = job_config_new (NULL, "test");
480
480
 
481
 
        job = job_instance (config);
 
481
        job = job_new (config);
482
482
        job->id = 99;
483
483
 
484
484
        TEST_ALLOC_FAIL {
518
518
        assert (nih_str_array_add (&(config->env), config, NULL, "FOO=BAR"));
519
519
        assert (nih_str_array_add (&(config->env), config, NULL, "BAR=BAZ"));
520
520
 
521
 
        job = job_instance (config);
 
521
        job = job_new (config);
522
522
        job->id = 99;
523
523
 
524
524
        TEST_ALLOC_FAIL {
559
559
        TEST_FEATURE ("with environment from start events");
560
560
        config = job_config_new (NULL, "test");
561
561
 
562
 
        job = job_instance (config);
 
562
        job = job_new (config);
563
563
        job->id = 99;
564
564
 
565
565
        job->start_on = event_operator_new (job, EVENT_AND, NULL, NULL);
638
638
        assert (nih_str_array_add (&(config->env), config, NULL,
639
639
                                   "UPSTART_JOB=evil"));
640
640
 
641
 
        job = job_instance (config);
 
641
        job = job_new (config);
642
642
        job->id = 99;
643
643
 
644
644
        job->start_on = event_operator_new (job, EVENT_AND, NULL, NULL);