~jamesodhunt/upstart/foo

« back to all changes in this revision

Viewing changes to init/tests/test_job_process.c

Merge of lp:~jamesodhunt/upstart/upstream-session-support.

Show diffs side-by-side

added added

removed removed

Lines of Context:
147
147
        TEST_FEATURE ("with simple command");
148
148
        TEST_ALLOC_FAIL {
149
149
                TEST_ALLOC_SAFE {
150
 
                        class = job_class_new (NULL, "test");
 
150
                        class = job_class_new (NULL, "test", NULL);
151
151
                        class->process[PROCESS_MAIN] = process_new (class);
152
152
                        class->process[PROCESS_MAIN]->command = nih_sprintf (
153
153
                                class->process[PROCESS_MAIN],
179
179
        TEST_FEATURE ("with shell command");
180
180
        TEST_ALLOC_FAIL {
181
181
                TEST_ALLOC_SAFE {
182
 
                        class = job_class_new (NULL, "test");
 
182
                        class = job_class_new (NULL, "test", NULL);
183
183
                        class->process[PROCESS_MAIN] = process_new (class);
184
184
                        class->process[PROCESS_MAIN]->command = nih_sprintf (
185
185
                                class->process[PROCESS_MAIN],
216
216
        TEST_FEATURE ("with small script");
217
217
        TEST_ALLOC_FAIL {
218
218
                TEST_ALLOC_SAFE {
219
 
                        class = job_class_new (NULL, "test");
 
219
                        class = job_class_new (NULL, "test", NULL);
220
220
                        class->process[PROCESS_MAIN] = process_new (class);
221
221
                        class->process[PROCESS_MAIN]->script = TRUE;
222
222
                        class->process[PROCESS_MAIN]->command = nih_sprintf (
253
253
        TEST_FEATURE ("with small script and trailing newlines");
254
254
        TEST_ALLOC_FAIL {
255
255
                TEST_ALLOC_SAFE {
256
 
                        class = job_class_new (NULL, "test");
 
256
                        class = job_class_new (NULL, "test", NULL);
257
257
                        class->process[PROCESS_MAIN] = process_new (class);
258
258
                        class->process[PROCESS_MAIN]->script = TRUE;
259
259
                        class->process[PROCESS_MAIN]->command = nih_sprintf (
290
290
        TEST_FEATURE ("with script that will fail");
291
291
        TEST_ALLOC_FAIL {
292
292
                TEST_ALLOC_SAFE {
293
 
                        class = job_class_new (NULL, "test");
 
293
                        class = job_class_new (NULL, "test", NULL);
294
294
                        class->process[PROCESS_MAIN] = process_new (class);
295
295
                        class->process[PROCESS_MAIN]->script = TRUE;
296
296
                        class->process[PROCESS_MAIN]->command = nih_sprintf (
327
327
        TEST_FEATURE ("with environment of unnamed instance");
328
328
        TEST_ALLOC_FAIL {
329
329
                TEST_ALLOC_SAFE {
330
 
                        class = job_class_new (NULL, "test");
 
330
                        class = job_class_new (NULL, "test", NULL);
331
331
                        class->process[PROCESS_MAIN] = process_new (class);
332
332
                        class->process[PROCESS_MAIN]->command = nih_sprintf (
333
333
                                class->process[PROCESS_MAIN],
376
376
        TEST_FEATURE ("with environment of named instance");
377
377
        TEST_ALLOC_FAIL {
378
378
                TEST_ALLOC_SAFE {
379
 
                        class = job_class_new (NULL, "test");
 
379
                        class = job_class_new (NULL, "test", NULL);
380
380
                        class->process[PROCESS_MAIN] = process_new (class);
381
381
                        class->process[PROCESS_MAIN]->command = nih_sprintf (
382
382
                                class->process[PROCESS_MAIN],
426
426
        TEST_FEATURE ("with environment for pre-stop");
427
427
        TEST_ALLOC_FAIL {
428
428
                TEST_ALLOC_SAFE {
429
 
                        class = job_class_new (NULL, "test");
 
429
                        class = job_class_new (NULL, "test", NULL);
430
430
                        class->process[PROCESS_PRE_STOP] = process_new (class);
431
431
                        class->process[PROCESS_PRE_STOP]->command = nih_sprintf (
432
432
                                class->process[PROCESS_PRE_STOP],
477
477
        TEST_FEATURE ("with environment for post-stop");
478
478
        TEST_ALLOC_FAIL {
479
479
                TEST_ALLOC_SAFE {
480
 
                        class = job_class_new (NULL, "test");
 
480
                        class = job_class_new (NULL, "test", NULL);
481
481
                        class->process[PROCESS_POST_STOP] = process_new (class);
482
482
                        class->process[PROCESS_POST_STOP]->command = nih_sprintf (
483
483
                                class->process[PROCESS_POST_STOP],
528
528
        TEST_FEATURE ("with long script");
529
529
        TEST_ALLOC_FAIL {
530
530
                TEST_ALLOC_SAFE {
531
 
                        class = job_class_new (NULL, "test");
 
531
                        class = job_class_new (NULL, "test", NULL);
532
532
                        class->process[PROCESS_MAIN] = process_new (class);
533
533
                        class->process[PROCESS_MAIN]->script = TRUE;
534
534
                        class->process[PROCESS_MAIN]->command = nih_alloc (
593
593
        TEST_FEATURE ("with non-daemon job");
594
594
        TEST_ALLOC_FAIL {
595
595
                TEST_ALLOC_SAFE {
596
 
                        class = job_class_new (NULL, "test");
 
596
                        class = job_class_new (NULL, "test", NULL);
597
597
                        class->process[PROCESS_MAIN] = process_new (class);
598
598
                        class->process[PROCESS_MAIN]->command = "true";
599
599
 
629
629
        TEST_FEATURE ("with script for daemon job");
630
630
        TEST_ALLOC_FAIL {
631
631
                TEST_ALLOC_SAFE {
632
 
                        class = job_class_new (NULL, "test");
 
632
                        class = job_class_new (NULL, "test", NULL);
633
633
                        class->process[PROCESS_PRE_START] = process_new (class);
634
634
                        class->process[PROCESS_PRE_START]->command = "true";
635
635
 
666
666
        TEST_FEATURE ("with daemon job");
667
667
        TEST_ALLOC_FAIL {
668
668
                TEST_ALLOC_SAFE {
669
 
                        class = job_class_new (NULL, "test");
 
669
                        class = job_class_new (NULL, "test", NULL);
670
670
                        class->expect = EXPECT_DAEMON;
671
671
                        class->process[PROCESS_MAIN] = process_new (class);
672
672
                        class->process[PROCESS_MAIN]->command = "true";
713
713
        TEST_FEATURE ("with forking job");
714
714
        TEST_ALLOC_FAIL {
715
715
                TEST_ALLOC_SAFE {
716
 
                        class = job_class_new (NULL, "test");
 
716
                        class = job_class_new (NULL, "test", NULL);
717
717
                        class->expect = EXPECT_FORK;
718
718
                        class->process[PROCESS_MAIN] = process_new (class);
719
719
                        class->process[PROCESS_MAIN]->command = "true";
762
762
 
763
763
        TEST_ALLOC_FAIL {
764
764
                TEST_ALLOC_SAFE {
765
 
                        class = job_class_new (NULL, "test");
 
765
                        class = job_class_new (NULL, "test", NULL);
766
766
                        class->process[PROCESS_MAIN] = process_new (class);
767
767
                        class->process[PROCESS_MAIN]->command = filename;
768
768
 
819
819
        TEST_FEATURE ("with simple job");
820
820
        sprintf (function, "%d", TEST_PIDS);
821
821
 
822
 
        class = job_class_new (NULL, "test");
 
822
        class = job_class_new (NULL, "test", NULL);
823
823
 
824
824
        pid = job_process_spawn (class, args, NULL, FALSE, -1);
825
825
        TEST_GT (pid, 0);
856
856
        TEST_FEATURE ("with no console");
857
857
        sprintf (function, "%d", TEST_CONSOLE);
858
858
 
859
 
        class = job_class_new (NULL, "test");
 
859
        class = job_class_new (NULL, "test", NULL);
860
860
        class->console = CONSOLE_NONE;
861
861
 
862
862
        pid = job_process_spawn (class, args, NULL, FALSE, -1);
882
882
        TEST_FEATURE ("with working directory");
883
883
        sprintf (function, "%d", TEST_PWD);
884
884
 
885
 
        class = job_class_new (NULL, "test");
 
885
        class = job_class_new (NULL, "test", NULL);
886
886
        class->chdir = "/tmp";
887
887
 
888
888
        pid = job_process_spawn (class, args, NULL, FALSE, -1);
911
911
        env[1] = "FOO=bar";
912
912
        env[2] = NULL;
913
913
 
914
 
        class = job_class_new (NULL, "test");
 
914
        class = job_class_new (NULL, "test", NULL);
915
915
 
916
916
        pid = job_process_spawn (class, args, env, FALSE, -1);
917
917
        TEST_GT (pid, 0);
936
936
        TEST_FEATURE ("with non-daemon job");
937
937
        sprintf (function, "%d", TEST_SIMPLE);
938
938
 
939
 
        class = job_class_new (NULL, "test");
 
939
        class = job_class_new (NULL, "test", NULL);
940
940
 
941
941
        pid = job_process_spawn (class, args, NULL, FALSE, -1);
942
942
        TEST_GT (pid, 0);
956
956
        TEST_FEATURE ("with daemon job");
957
957
        sprintf (function, "%d", TEST_SIMPLE);
958
958
 
959
 
        class = job_class_new (NULL, "test");
 
959
        class = job_class_new (NULL, "test", NULL);
960
960
 
961
961
        pid = job_process_spawn (class, args, NULL, TRUE, -1);
962
962
        TEST_GT (pid, 0);
985
985
        args[1] = filename;
986
986
        args[2] = NULL;
987
987
 
988
 
        class = job_class_new (NULL, "test");
 
988
        class = job_class_new (NULL, "test", NULL);
989
989
 
990
990
        pid = job_process_spawn (class, args, NULL, FALSE, -1);
991
991
        TEST_LT (pid, 0);
1004
1004
         */
1005
1005
        TEST_FEATURE ("with debug enabled");
1006
1006
 
1007
 
        class = job_class_new (NULL, "test");
 
1007
        class = job_class_new (NULL, "test", NULL);
1008
1008
        class->debug = TRUE;
1009
1009
 
1010
1010
        sprintf (function, "%s", "/bin/true");
1050
1050
        nih_timer_init ();
1051
1051
        event_init ();
1052
1052
 
1053
 
        class = job_class_new (NULL, "test");
 
1053
        class = job_class_new (NULL, "test", NULL);
1054
1054
        class->kill_timeout = 1000;
1055
1055
 
1056
1056
        class->process[PROCESS_MAIN] = process_new (class);
1204
1204
 
1205
1205
        source = conf_source_new (NULL, "/tmp", CONF_JOB_DIR);
1206
1206
        file = conf_file_new (source, "/tmp/test");
1207
 
        file->job = class = job_class_new (NULL, "test");
 
1207
        file->job = class = job_class_new (NULL, "test", NULL);
1208
1208
        class->process[PROCESS_MAIN] = process_new (class);
1209
1209
        class->process[PROCESS_MAIN]->command = "echo";
1210
1210
 
4364
4364
        ProcessType  process;
4365
4365
 
4366
4366
        TEST_FUNCTION ("job_process_find");
4367
 
        class1 = job_class_new (NULL, "foo");
 
4367
        class1 = job_class_new (NULL, "foo", NULL);
4368
4368
        class1->process[PROCESS_MAIN] = process_new (class1);
4369
4369
        class1->process[PROCESS_POST_START] = process_new (class1);
4370
4370
        class1->instance = "$FOO";
4371
4371
        nih_hash_add (job_classes, &class1->entry);
4372
4372
 
4373
 
        class2 = job_class_new (NULL, "bar");
 
4373
        class2 = job_class_new (NULL, "bar", NULL);
4374
4374
        class2->process[PROCESS_PRE_START] = process_new (class2);
4375
4375
        class2->process[PROCESS_MAIN] = process_new (class2);
4376
4376
        class2->process[PROCESS_PRE_STOP] = process_new (class2);
4377
4377
        class2->instance = "$FOO";
4378
4378
        nih_hash_add (job_classes, &class2->entry);
4379
4379
 
4380
 
        class3 = job_class_new (NULL, "baz");
 
4380
        class3 = job_class_new (NULL, "baz", NULL);
4381
4381
        class3->process[PROCESS_POST_STOP] = process_new (class3);
4382
4382
        nih_hash_add (job_classes, &class3->entry);
4383
4383
 
4502
4502
        TEST_FUNCTION ("job_process_handler");
4503
4503
        program_name = "test";
4504
4504
 
4505
 
        class = job_class_new (NULL, "test");
 
4505
        class = job_class_new (NULL, "test", NULL);
4506
4506
        class->process[PROCESS_MAIN] = process_new (class);
4507
4507
        class->process[PROCESS_MAIN]->command = "echo";
4508
4508
 
4727
4727
main (int   argc,
4728
4728
      char *argv[])
4729
4729
{
 
4730
        /* Note we do not set the UPSTART_NO_SESSIONS variable since this
 
4731
         * would cause these tests to fail (as they scrutinize the job
 
4732
         * environment).
 
4733
         */
 
4734
 
4730
4735
        /* We re-exec this binary to test various children features.  To
4731
4736
         * do that, we need to know the full path to the program.
4732
4737
         */