10730
10924
dbus_shutdown ();
10928
test_show_config (void)
10930
char dirname[PATH_MAX];
10931
nih_local char *cmd;
10932
pid_t upstart_pid = 0;
10933
pid_t dbus_pid = 0;
10936
char expected_output[] = "foo";
10938
TEST_GROUP ("show_config");
10940
TEST_FILENAME (dirname);
10941
TEST_EQ (mkdir (dirname, 0755), 0);
10943
/* Use the "secret" interface */
10944
TEST_EQ (setenv ("UPSTART_CONFDIR", dirname, 1), 0);
10946
TEST_DBUS (dbus_pid);
10947
START_UPSTART (upstart_pid);
10949
TEST_FEATURE ("no emits, no start on, no stop on");
10950
CREATE_FILE (dirname, "foo.conf",
10952
"description \"wibble\"");
10954
cmd = nih_sprintf (NULL, "%s show-config foo 2>&1", INITCTL_BINARY);
10955
TEST_NE_P (cmd, NULL);
10956
RUN_COMMAND (NULL, cmd, &output, &lines);
10957
TEST_EQ_STR (output[0], expected_output);
10958
TEST_EQ (lines, 1);
10961
cmd = nih_sprintf (NULL, "%s show-config -e foo 2>&1", INITCTL_BINARY);
10962
TEST_NE_P (cmd, NULL);
10963
RUN_COMMAND (NULL, cmd, &output, &lines);
10964
TEST_EQ_STR (output[0], expected_output);
10965
TEST_EQ (lines, 1);
10968
DELETE_FILE (dirname, "foo.conf");
10970
/*******************************************************************/
10972
TEST_FEATURE ("1 emits, no start on, no stop on");
10974
CREATE_FILE (dirname, "foo.conf",
10976
"emits \"thing\"\n"
10977
"description \"wibble\"");
10979
cmd = nih_sprintf (NULL, "%s show-config foo 2>&1", INITCTL_BINARY);
10980
TEST_NE_P (cmd, NULL);
10981
RUN_COMMAND (NULL, cmd, &output, &lines);
10982
TEST_EQ_STR (output[0], expected_output);
10983
TEST_EQ_STR (output[1], " emits thing");
10984
TEST_EQ (lines, 2);
10987
cmd = nih_sprintf (NULL, "%s show-config -e foo 2>&1", INITCTL_BINARY);
10988
TEST_NE_P (cmd, NULL);
10989
RUN_COMMAND (NULL, cmd, &output, &lines);
10990
TEST_EQ_STR (output[0], expected_output);
10991
TEST_EQ_STR (output[1], " emits thing");
10992
TEST_EQ (lines, 2);
10995
DELETE_FILE (dirname, "foo.conf");
10997
/*******************************************************************/
10999
TEST_FEATURE ("2 emits, no start on, no stop on");
11001
CREATE_FILE (dirname, "foo.conf",
11003
"emits \"thing\"\n"
11004
"emits \"thong\"\n"
11005
"description \"wibble\"");
11007
cmd = nih_sprintf (NULL, "%s show-config foo 2>&1", INITCTL_BINARY);
11008
TEST_NE_P (cmd, NULL);
11009
RUN_COMMAND (NULL, cmd, &output, &lines);
11010
TEST_EQ_STR (output[0], expected_output);
11011
TEST_EQ_STR (output[1], " emits thing");
11012
TEST_EQ_STR (output[2], " emits thong");
11013
TEST_EQ (lines, 3);
11016
cmd = nih_sprintf (NULL, "%s show-config -e foo 2>&1", INITCTL_BINARY);
11017
TEST_NE_P (cmd, NULL);
11018
RUN_COMMAND (NULL, cmd, &output, &lines);
11019
TEST_EQ_STR (output[0], expected_output);
11020
TEST_EQ_STR (output[1], " emits thing");
11021
TEST_EQ_STR (output[2], " emits thong");
11022
TEST_EQ (lines, 3);
11025
DELETE_FILE (dirname, "foo.conf");
11027
/*******************************************************************/
11029
TEST_FEATURE ("no emits, start on, no stop on");
11031
CREATE_FILE (dirname, "foo.conf",
11033
"start on (A and B)\n"
11034
"description \"wibble\"");
11036
cmd = nih_sprintf (NULL, "%s show-config foo 2>&1", INITCTL_BINARY);
11037
TEST_NE_P (cmd, NULL);
11038
RUN_COMMAND (NULL, cmd, &output, &lines);
11039
TEST_EQ_STR (output[0], expected_output);
11040
TEST_EQ_STR (output[1], " start on (A and B)");
11041
TEST_EQ (lines, 2);
11044
cmd = nih_sprintf (NULL, "%s show-config -e foo 2>&1", INITCTL_BINARY);
11045
TEST_NE_P (cmd, NULL);
11046
RUN_COMMAND (NULL, cmd, &output, &lines);
11047
TEST_EQ_STR (output[0], expected_output);
11048
TEST_EQ_STR (output[1], " start on A (job:, env:)");
11049
TEST_EQ_STR (output[2], " start on B (job:, env:)");
11050
TEST_EQ (lines, 3);
11053
DELETE_FILE (dirname, "foo.conf");
11055
/*******************************************************************/
11057
TEST_FEATURE ("1 emits, start on, no stop on");
11059
CREATE_FILE (dirname, "foo.conf",
11062
"start on (A and B)\n"
11063
"description \"wibble\"");
11065
cmd = nih_sprintf (NULL, "%s show-config foo 2>&1", INITCTL_BINARY);
11066
TEST_NE_P (cmd, NULL);
11067
RUN_COMMAND (NULL, cmd, &output, &lines);
11068
TEST_EQ_STR (output[0], expected_output);
11069
TEST_EQ_STR (output[1], " emits bong");
11070
TEST_EQ_STR (output[2], " start on (A and B)");
11071
TEST_EQ (lines, 3);
11074
cmd = nih_sprintf (NULL, "%s show-config -e foo 2>&1", INITCTL_BINARY);
11075
TEST_NE_P (cmd, NULL);
11076
RUN_COMMAND (NULL, cmd, &output, &lines);
11077
TEST_EQ_STR (output[0], expected_output);
11078
TEST_EQ_STR (output[1], " emits bong");
11079
TEST_EQ_STR (output[2], " start on A (job:, env:)");
11080
TEST_EQ_STR (output[3], " start on B (job:, env:)");
11081
TEST_EQ (lines, 4);
11084
DELETE_FILE (dirname, "foo.conf");
11086
/*******************************************************************/
11088
TEST_FEATURE ("2 emits, start on, no stop on");
11090
CREATE_FILE (dirname, "foo.conf",
11093
"start on (A and B)\n"
11094
"emits \"stime\"\n"
11095
"description \"wibble\"");
11097
cmd = nih_sprintf (NULL, "%s show-config foo 2>&1", INITCTL_BINARY);
11098
TEST_NE_P (cmd, NULL);
11099
RUN_COMMAND (NULL, cmd, &output, &lines);
11100
TEST_EQ_STR (output[0], expected_output);
11101
TEST_EQ_STR (output[1], " emits bong");
11102
TEST_EQ_STR (output[2], " emits stime");
11103
TEST_EQ_STR (output[3], " start on (A and B)");
11104
TEST_EQ (lines, 4);
11107
cmd = nih_sprintf (NULL, "%s show-config -e foo 2>&1", INITCTL_BINARY);
11108
TEST_NE_P (cmd, NULL);
11109
RUN_COMMAND (NULL, cmd, &output, &lines);
11110
TEST_EQ_STR (output[0], expected_output);
11111
TEST_EQ_STR (output[1], " emits bong");
11112
TEST_EQ_STR (output[2], " emits stime");
11113
TEST_EQ_STR (output[3], " start on A (job:, env:)");
11114
TEST_EQ_STR (output[4], " start on B (job:, env:)");
11115
TEST_EQ (lines, 5);
11118
DELETE_FILE (dirname, "foo.conf");
11120
/*******************************************************************/
11122
TEST_FEATURE ("no emits, no start on, stop on");
11124
CREATE_FILE (dirname, "foo.conf",
11126
"stop on (A or B)\n"
11127
"description \"wibble\"");
11129
cmd = nih_sprintf (NULL, "%s show-config foo 2>&1", INITCTL_BINARY);
11130
TEST_NE_P (cmd, NULL);
11131
RUN_COMMAND (NULL, cmd, &output, &lines);
11132
TEST_EQ_STR (output[0], expected_output);
11133
TEST_EQ_STR (output[1], " stop on (A or B)");
11134
TEST_EQ (lines, 2);
11137
cmd = nih_sprintf (NULL, "%s show-config -e foo 2>&1", INITCTL_BINARY);
11138
TEST_NE_P (cmd, NULL);
11139
RUN_COMMAND (NULL, cmd, &output, &lines);
11140
TEST_EQ_STR (output[0], expected_output);
11141
TEST_EQ_STR (output[1], " stop on A (job:, env:)");
11142
TEST_EQ_STR (output[2], " stop on B (job:, env:)");
11143
TEST_EQ (lines, 3);
11146
DELETE_FILE (dirname, "foo.conf");
11148
/*******************************************************************/
11150
TEST_FEATURE ("1 emits, no start on, stop on");
11152
CREATE_FILE (dirname, "foo.conf",
11155
"stop on (A or B)\n"
11156
"description \"wibble\"");
11158
cmd = nih_sprintf (NULL, "%s show-config foo 2>&1", INITCTL_BINARY);
11159
TEST_NE_P (cmd, NULL);
11160
RUN_COMMAND (NULL, cmd, &output, &lines);
11161
TEST_EQ_STR (output[0], expected_output);
11162
TEST_EQ_STR (output[1], " emits bong");
11163
TEST_EQ_STR (output[2], " stop on (A or B)");
11164
TEST_EQ (lines, 3);
11167
cmd = nih_sprintf (NULL, "%s show-config -e foo 2>&1", INITCTL_BINARY);
11168
TEST_NE_P (cmd, NULL);
11169
RUN_COMMAND (NULL, cmd, &output, &lines);
11170
TEST_EQ_STR (output[0], expected_output);
11171
TEST_EQ_STR (output[1], " emits bong");
11172
TEST_EQ_STR (output[2], " stop on A (job:, env:)");
11173
TEST_EQ_STR (output[3], " stop on B (job:, env:)");
11174
TEST_EQ (lines, 4);
11177
DELETE_FILE (dirname, "foo.conf");
11179
/*******************************************************************/
11181
TEST_FEATURE ("2 emits, no start on, stop on");
11183
CREATE_FILE (dirname, "foo.conf",
11186
"stop on (A or B)\n"
11187
"emits \"stime\"\n"
11188
"description \"wibble\"");
11190
cmd = nih_sprintf (NULL, "%s show-config foo 2>&1", INITCTL_BINARY);
11191
TEST_NE_P (cmd, NULL);
11192
RUN_COMMAND (NULL, cmd, &output, &lines);
11193
TEST_EQ_STR (output[0], expected_output);
11194
TEST_EQ_STR (output[1], " emits bong");
11195
TEST_EQ_STR (output[2], " emits stime");
11196
TEST_EQ_STR (output[3], " stop on (A or B)");
11197
TEST_EQ (lines, 4);
11200
cmd = nih_sprintf (NULL, "%s show-config -e foo 2>&1", INITCTL_BINARY);
11201
TEST_NE_P (cmd, NULL);
11202
RUN_COMMAND (NULL, cmd, &output, &lines);
11203
TEST_EQ_STR (output[0], expected_output);
11204
TEST_EQ_STR (output[1], " emits bong");
11205
TEST_EQ_STR (output[2], " emits stime");
11206
TEST_EQ_STR (output[3], " stop on A (job:, env:)");
11207
TEST_EQ_STR (output[4], " stop on B (job:, env:)");
11208
TEST_EQ (lines, 5);
11211
DELETE_FILE (dirname, "foo.conf");
11213
/*******************************************************************/
11215
TEST_FEATURE ("2 emits, start on with only initial JOB, stop on with JOB at end of env");
11217
CREATE_FILE (dirname, "foo.conf",
11220
"stop on (A or stopping c=d e=f g=h JOB=\"bang\")\n"
11221
"emits \"stime\"\n"
11222
"start on (starting JOB=\"boo\" or B x=y)\n"
11223
"description \"wibble\"");
11225
cmd = nih_sprintf (NULL, "%s show-config foo 2>&1", INITCTL_BINARY);
11226
TEST_NE_P (cmd, NULL);
11227
RUN_COMMAND (NULL, cmd, &output, &lines);
11228
TEST_EQ_STR (output[0], expected_output);
11229
TEST_EQ_STR (output[1], " emits bong");
11230
TEST_EQ_STR (output[2], " emits stime");
11231
TEST_EQ_STR (output[3], " start on (starting JOB=boo or B x=y)");
11232
TEST_EQ_STR (output[4], " stop on (A or stopping c=d e=f g=h JOB=bang)");
11233
TEST_EQ (lines, 5);
11236
cmd = nih_sprintf (NULL, "%s show-config -e foo 2>&1", INITCTL_BINARY);
11237
TEST_NE_P (cmd, NULL);
11238
RUN_COMMAND (NULL, cmd, &output, &lines);
11239
TEST_EQ_STR (output[0], expected_output);
11240
TEST_EQ_STR (output[1], " emits bong");
11241
TEST_EQ_STR (output[2], " emits stime");
11242
TEST_EQ_STR (output[3], " start on starting (job: boo, env:)");
11243
TEST_EQ_STR (output[4], " start on B (job:, env: x=y)");
11244
TEST_EQ_STR (output[5], " stop on A (job:, env:)");
11245
TEST_EQ_STR (output[6], " stop on stopping (job: bang, env: c=d e=f g=h)");
11246
TEST_EQ (lines, 7);
11249
DELETE_FILE (dirname, "foo.conf");
11251
/*******************************************************************/
11253
TEST_FEATURE ("2 emits, start on with initial JOB+env, stop on with JOB at end of env");
11255
CREATE_FILE (dirname, "foo.conf",
11258
"stop on (A or stopping c=d e=f g=h JOB=\"bang\")\n"
11259
"emits \"stime\"\n"
11260
"start on (starting JOB=\"boo\" P=Q c=sea or B x=y)\n"
11261
"description \"wibble\"");
11263
cmd = nih_sprintf (NULL, "%s show-config foo 2>&1", INITCTL_BINARY);
11264
TEST_NE_P (cmd, NULL);
11265
RUN_COMMAND (NULL, cmd, &output, &lines);
11266
TEST_EQ_STR (output[0], expected_output);
11267
TEST_EQ_STR (output[1], " emits bong");
11268
TEST_EQ_STR (output[2], " emits stime");
11269
TEST_EQ_STR (output[3], " start on (starting JOB=boo P=Q c=sea or B x=y)");
11270
TEST_EQ_STR (output[4], " stop on (A or stopping c=d e=f g=h JOB=bang)");
11271
TEST_EQ (lines, 5);
11274
cmd = nih_sprintf (NULL, "%s show-config -e foo 2>&1", INITCTL_BINARY);
11275
TEST_NE_P (cmd, NULL);
11276
RUN_COMMAND (NULL, cmd, &output, &lines);
11277
TEST_EQ_STR (output[0], expected_output);
11278
TEST_EQ_STR (output[1], " emits bong");
11279
TEST_EQ_STR (output[2], " emits stime");
11280
TEST_EQ_STR (output[3], " start on starting (job: boo, env: P=Q c=sea)");
11281
TEST_EQ_STR (output[4], " start on B (job:, env: x=y)");
11282
TEST_EQ_STR (output[5], " stop on A (job:, env:)");
11283
TEST_EQ_STR (output[6], " stop on stopping (job: bang, env: c=d e=f g=h)");
11284
TEST_EQ (lines, 7);
11287
DELETE_FILE (dirname, "foo.conf");
11289
/*******************************************************************/
11291
TEST_FEATURE ("3 emits, start on (with env), stop on (with env)");
11293
CREATE_FILE (dirname, "foo.conf",
11295
"stop on starting D and (stopping E or F hello=world)\n"
11298
"emits \"stime\"\n"
11299
"start on A and (B FOO=BAR or starting C x=y)\n"
11300
"description \"wibble\"");
11302
cmd = nih_sprintf (NULL, "%s show-config foo 2>&1", INITCTL_BINARY);
11303
TEST_NE_P (cmd, NULL);
11304
RUN_COMMAND (NULL, cmd, &output, &lines);
11305
TEST_EQ_STR (output[0], expected_output);
11306
TEST_EQ_STR (output[1], " emits bong");
11307
TEST_EQ_STR (output[2], " emits bar");
11308
TEST_EQ_STR (output[3], " emits stime");
11309
/* note the extra brackets! */
11310
TEST_EQ_STR (output[4], " start on (A and (B FOO=BAR or starting C x=y))");
11311
/* note the extra brackets! */
11312
TEST_EQ_STR (output[5], " stop on (starting D and (stopping E or F hello=world))");
11313
TEST_EQ (lines, 6);
11316
cmd = nih_sprintf (NULL, "%s show-config -e foo 2>&1", INITCTL_BINARY);
11317
TEST_NE_P (cmd, NULL);
11318
RUN_COMMAND (NULL, cmd, &output, &lines);
11319
TEST_EQ_STR (output[0], expected_output);
11320
TEST_EQ_STR (output[1], " emits bong");
11321
TEST_EQ_STR (output[2], " emits bar");
11322
TEST_EQ_STR (output[3], " emits stime");
11323
TEST_EQ_STR (output[4], " start on A (job:, env:)");
11324
TEST_EQ_STR (output[5], " start on B (job:, env: FOO=BAR)");
11325
TEST_EQ_STR (output[6], " start on starting (job: C, env: x=y)");
11326
TEST_EQ_STR (output[7], " stop on starting (job: D, env:)");
11327
TEST_EQ_STR (output[8], " stop on stopping (job: E, env:)");
11328
TEST_EQ_STR (output[9], " stop on F (job:, env: hello=world)");
11329
TEST_EQ (lines, 10);
11332
DELETE_FILE (dirname, "foo.conf");
11334
/*******************************************************************/
11336
TEST_FEATURE ("3 emits, complex start on (with env), complex stop on (with env)");
11338
CREATE_FILE (dirname, "foo.conf",
11340
"stop on runlevel [!2345] colour=blue or starting rocket\n"
11343
"emits \"stime\"\n"
11344
"start on (starting mountall or (runlevel [016] and "
11345
"(stopped gdm or stopped kdm or stopped xdm A=B or stopping lxdm)))\n"
11346
"description \"wibble\"");
11348
cmd = nih_sprintf (NULL, "%s show-config foo 2>&1", INITCTL_BINARY);
11349
TEST_NE_P (cmd, NULL);
11350
RUN_COMMAND (NULL, cmd, &output, &lines);
11351
TEST_EQ_STR (output[0], expected_output);
11352
TEST_EQ_STR (output[1], " emits bong");
11353
TEST_EQ_STR (output[2], " emits bar");
11354
TEST_EQ_STR (output[3], " emits stime");
11355
/* note the extra brackets! */
11356
TEST_EQ_STR (output[4], " start on (starting mountall or (runlevel [016] and "
11357
"(((stopped gdm or stopped kdm) or stopped xdm A=B) or stopping lxdm)))");
11358
/* note the extra brackets! */
11359
TEST_EQ_STR (output[5], " stop on (runlevel [!2345] colour=blue or starting rocket)");
11360
TEST_EQ (lines, 6);
11363
cmd = nih_sprintf (NULL, "%s show-config -e foo 2>&1", INITCTL_BINARY);
11364
TEST_NE_P (cmd, NULL);
11365
RUN_COMMAND (NULL, cmd, &output, &lines);
11366
TEST_EQ_STR (output[0], expected_output);
11367
TEST_EQ_STR (output[1], " emits bong");
11368
TEST_EQ_STR (output[2], " emits bar");
11369
TEST_EQ_STR (output[3], " emits stime");
11370
TEST_EQ_STR (output[4], " start on starting (job: mountall, env:)");
11371
TEST_EQ_STR (output[5], " start on runlevel (job:, env: [016])");
11372
TEST_EQ_STR (output[6], " start on stopped (job: gdm, env:)");
11373
TEST_EQ_STR (output[7], " start on stopped (job: kdm, env:)");
11374
TEST_EQ_STR (output[8], " start on stopped (job: xdm, env: A=B)");
11375
TEST_EQ_STR (output[9], " start on stopping (job: lxdm, env:)");
11376
TEST_EQ_STR (output[10], " stop on runlevel (job:, env: [!2345] colour=blue)");
11377
TEST_EQ_STR (output[11], " stop on starting (job: rocket, env:)");
11378
TEST_EQ (lines, 12);
11381
DELETE_FILE (dirname, "foo.conf");
11383
/*******************************************************************/
11385
STOP_UPSTART (upstart_pid);
11386
TEST_EQ (unsetenv ("UPSTART_CONFDIR"), 0);
11387
TEST_DBUS_END (dbus_pid);
11391
test_check_config (void)
11393
char dirname[PATH_MAX];
11394
nih_local char *cmd;
11395
pid_t upstart_pid = 0;
11396
pid_t dbus_pid = 0;
11400
TEST_GROUP ("check_config");
11402
TEST_FILENAME (dirname);
11403
TEST_EQ (mkdir (dirname, 0755), 0);
11405
/* Use the "secret" interface */
11406
TEST_EQ (setenv ("UPSTART_CONFDIR", dirname, 1), 0);
11408
TEST_DBUS (dbus_pid);
11409
START_UPSTART (upstart_pid);
11411
/*******************************************************************/
11413
TEST_FEATURE ("no unreachable jobs/events (satisfied by job or event)");
11415
CREATE_FILE (dirname, "foo.conf",
11416
"start on (starting bar or wibble)");
11418
CREATE_FILE (dirname, "bar.conf",
11422
CREATE_FILE (dirname, "baz.conf",
11425
cmd = nih_sprintf (NULL, "%s check-config 2>&1", INITCTL_BINARY);
11426
TEST_NE_P (cmd, NULL);
11427
RUN_COMMAND (NULL, cmd, &output, &lines);
11428
TEST_EQ (lines, 0);
11430
DELETE_FILE (dirname, "foo.conf");
11431
DELETE_FILE (dirname, "bar.conf");
11432
DELETE_FILE (dirname, "baz.conf");
11434
/*******************************************************************/
11436
TEST_FEATURE ("no unreachable jobs/events (satisfied by job)");
11438
CREATE_FILE (dirname, "foo.conf",
11439
"start on (starting bar or wibble)");
11441
CREATE_FILE (dirname, "bar.conf",
11445
cmd = nih_sprintf (NULL, "%s check-config 2>&1", INITCTL_BINARY);
11446
TEST_NE_P (cmd, NULL);
11447
RUN_COMMAND (NULL, cmd, &output, &lines);
11448
TEST_EQ (lines, 0);
11450
DELETE_FILE (dirname, "foo.conf");
11451
DELETE_FILE (dirname, "bar.conf");
11453
/*******************************************************************/
11455
TEST_FEATURE ("no unreachable jobs/events (satisfied by event)");
11457
CREATE_FILE (dirname, "foo.conf",
11458
"start on (starting bar or wibble)");
11460
CREATE_FILE (dirname, "baz.conf",
11463
cmd = nih_sprintf (NULL, "%s check-config 2>&1", INITCTL_BINARY);
11464
TEST_NE_P (cmd, NULL);
11465
RUN_COMMAND (NULL, cmd, &output, &lines);
11466
TEST_EQ (lines, 0);
11468
DELETE_FILE (dirname, "foo.conf");
11469
DELETE_FILE (dirname, "baz.conf");
11471
/*******************************************************************/
11473
TEST_FEATURE ("unreachable event");
11475
CREATE_FILE (dirname, "foo.conf",
11476
"start on (starting bar and wibble)");
11478
CREATE_FILE (dirname, "bar.conf",
11482
cmd = nih_sprintf (NULL, "%s check-config 2>&1", INITCTL_BINARY);
11483
TEST_NE_P (cmd, NULL);
11484
RUN_COMMAND (NULL, cmd, &output, &lines);
11485
TEST_EQ_STR (output[0], "foo");
11486
TEST_EQ_STR (output[1], " start on: unknown event wibble");
11487
TEST_EQ (lines, 2);
11489
DELETE_FILE (dirname, "foo.conf");
11490
DELETE_FILE (dirname, "bar.conf");
11492
/*******************************************************************/
11494
TEST_FEATURE ("unreachable job");
11496
CREATE_FILE (dirname, "foo.conf",
11497
"start on (starting bar and wibble)");
11499
CREATE_FILE (dirname, "baz.conf",
11502
cmd = nih_sprintf (NULL, "%s check-config 2>&1", INITCTL_BINARY);
11503
TEST_NE_P (cmd, NULL);
11504
RUN_COMMAND (NULL, cmd, &output, &lines);
11505
TEST_EQ_STR (output[0], "foo");
11506
TEST_EQ_STR (output[1], " start on: unknown job bar");
11507
TEST_EQ (lines, 2);
11509
DELETE_FILE (dirname, "foo.conf");
11510
DELETE_FILE (dirname, "baz.conf");
11512
/*******************************************************************/
11514
TEST_FEATURE ("unreachable event with forced ignore");
11516
CREATE_FILE (dirname, "foo.conf",
11517
"start on (starting bar and wibble)");
11519
CREATE_FILE (dirname, "bar.conf",
11523
cmd = nih_sprintf (NULL, "%s check-config --ignore-events=wibble 2>&1",
11525
TEST_NE_P (cmd, NULL);
11526
RUN_COMMAND (NULL, cmd, &output, &lines);
11527
TEST_EQ (lines, 0);
11529
DELETE_FILE (dirname, "bar.conf");
11531
/*******************************************************************/
11533
TEST_FEATURE ("unreachable events with forced ignores");
11535
CREATE_FILE (dirname, "foo.conf",
11536
"start on (fred and wilma)");
11538
cmd = nih_sprintf (NULL, "%s check-config --ignore-events=wilma,foo,fred 2>&1",
11540
TEST_NE_P (cmd, NULL);
11541
RUN_COMMAND (NULL, cmd, &output, &lines);
11542
TEST_EQ (lines, 0);
11544
DELETE_FILE (dirname, "foo.conf");
11546
/*******************************************************************/
11548
TEST_FEATURE ("satisfiable complex start on");
11550
/* Yes folks, it's the classic */
11551
CREATE_FILE (dirname, "plymouth.conf",
11552
"start on (starting mountall\n"
11553
" or (runlevel [016]\n"
11554
" and (stopped gdm\n"
11555
" or stopped kdm\n"
11556
" or stopped xdm\n"
11557
" or stopped lxdm)))");
11559
CREATE_FILE (dirname, "mountall.conf", "exec true");
11560
CREATE_FILE (dirname, "gdm.conf" , "exec true");
11562
cmd = nih_sprintf (NULL, "%s check-config --ignore-events=runlevel 2>&1",
11564
TEST_NE_P (cmd, NULL);
11565
RUN_COMMAND (NULL, cmd, &output, &lines);
11566
TEST_EQ (lines, 0);
11568
DELETE_FILE (dirname, "plymouth.conf");
11569
DELETE_FILE (dirname, "mountall.conf");
11570
DELETE_FILE (dirname, "gdm.conf");
11572
/*******************************************************************/
11574
TEST_FEATURE ("unsatisfiable complex start on");
11576
CREATE_FILE (dirname, "plymouth.conf",
11577
"start on (starting mountall\n"
11578
" or (runlevel [016]\n"
11579
" and (stopped gdm\n"
11580
" or stopped kdm\n"
11581
" or stopped xdm\n"
11582
" or stopped lxdm)))");
11584
CREATE_FILE (dirname, "mountall.conf", "exec true");
11586
cmd = nih_sprintf (NULL, "%s check-config --ignore-events=runlevel 2>&1",
11588
TEST_NE_P (cmd, NULL);
11589
RUN_COMMAND (NULL, cmd, &output, &lines);
11591
TEST_EQ_STR (output[0], "plymouth");
11592
TEST_EQ_STR (output[1], " start on: unknown job lxdm");
11593
TEST_EQ_STR (output[2], " start on: unknown job xdm");
11594
TEST_EQ_STR (output[3], " start on: unknown job kdm");
11595
TEST_EQ_STR (output[4], " start on: unknown job gdm");
11596
TEST_EQ (lines, 5);
11598
DELETE_FILE (dirname, "plymouth.conf");
11599
DELETE_FILE (dirname, "mountall.conf");
11601
/*******************************************************************/
11603
TEST_FEATURE ("satisfiable complex stop on");
11605
/* Yes folks, it's the classic */
11606
CREATE_FILE (dirname, "plymouth.conf",
11607
"stop on (starting mountall\n"
11608
" or (runlevel [016]\n"
11609
" and (stopped gdm\n"
11610
" or stopped kdm\n"
11611
" or stopped xdm\n"
11612
" or stopped lxdm)))");
11614
CREATE_FILE (dirname, "mountall.conf", "exec true");
11615
CREATE_FILE (dirname, "gdm.conf" , "exec true");
11617
cmd = nih_sprintf (NULL, "%s check-config --ignore-events=runlevel 2>&1",
11619
TEST_NE_P (cmd, NULL);
11620
RUN_COMMAND (NULL, cmd, &output, &lines);
11621
TEST_EQ (lines, 0);
11623
DELETE_FILE (dirname, "plymouth.conf");
11624
DELETE_FILE (dirname, "mountall.conf");
11625
DELETE_FILE (dirname, "gdm.conf");
11627
/*******************************************************************/
11629
TEST_FEATURE ("unsatisfiable complex stop on");
11631
CREATE_FILE (dirname, "plymouth.conf",
11632
"stop on (starting mountall\n"
11633
" or (runlevel [016]\n"
11634
" and (stopped gdm\n"
11635
" or stopped kdm\n"
11636
" or stopped xdm\n"
11637
" or stopped lxdm)))");
11639
CREATE_FILE (dirname, "mountall.conf", "exec true");
11641
cmd = nih_sprintf (NULL, "%s check-config --ignore-events=runlevel 2>&1",
11643
TEST_NE_P (cmd, NULL);
11644
RUN_COMMAND (NULL, cmd, &output, &lines);
11646
TEST_EQ_STR (output[0], "plymouth");
11647
TEST_EQ_STR (output[1], " stop on: unknown job lxdm");
11648
TEST_EQ_STR (output[2], " stop on: unknown job xdm");
11649
TEST_EQ_STR (output[3], " stop on: unknown job kdm");
11650
TEST_EQ_STR (output[4], " stop on: unknown job gdm");
11651
TEST_EQ (lines, 5);
11653
DELETE_FILE (dirname, "plymouth.conf");
11654
DELETE_FILE (dirname, "mountall.conf");
11656
/*******************************************************************/
11658
TEST_FEATURE ("unsatisfiable complex stop on, satisfiable complex start on");
11660
CREATE_FILE (dirname, "plymouth.conf",
11661
"stop on (starting mountall\n"
11662
" or (runlevel [016]\n"
11663
" and (stopped gdm\n"
11664
" or stopped kdm\n"
11665
" or stopped xdm\n"
11666
" or stopped lxdm)))\n"
11667
"start on (stopping portmap\n"
11668
" or (runlevel [06] or starting beano))\n");
11670
CREATE_FILE (dirname, "mountall.conf", "exec true");
11671
CREATE_FILE (dirname, "portmap.conf", "exec true");
11672
CREATE_FILE (dirname, "beano.conf", "exec true");
11674
cmd = nih_sprintf (NULL, "%s check-config --ignore-events=runlevel 2>&1",
11676
TEST_NE_P (cmd, NULL);
11677
RUN_COMMAND (NULL, cmd, &output, &lines);
11679
TEST_EQ_STR (output[0], "plymouth");
11680
TEST_EQ_STR (output[1], " stop on: unknown job lxdm");
11681
TEST_EQ_STR (output[2], " stop on: unknown job xdm");
11682
TEST_EQ_STR (output[3], " stop on: unknown job kdm");
11683
TEST_EQ_STR (output[4], " stop on: unknown job gdm");
11684
TEST_EQ (lines, 5);
11686
DELETE_FILE (dirname, "plymouth.conf");
11687
DELETE_FILE (dirname, "mountall.conf");
11688
DELETE_FILE (dirname, "portmap.conf");
11689
DELETE_FILE (dirname, "beano.conf");
11691
/*******************************************************************/
11693
TEST_FEATURE ("satisfiable complex start on, unsatisfiable complex stop on");
11695
CREATE_FILE (dirname, "plymouth.conf",
11696
"start on (starting mountall\n"
11698
" and (stopped gdm\n"
11699
" or stopped kdm\n"
11700
" or stopped xdm\n"
11701
" or stopped lxdm)))\n"
11702
"stop on (stopping portmap\n"
11703
" or (wibble or starting beano))\n");
11705
CREATE_FILE (dirname, "mountall.conf", "exec true");
11706
CREATE_FILE (dirname, "portmap.conf",
11709
CREATE_FILE (dirname, "gdm.conf", "exec true");
11711
cmd = nih_sprintf (NULL, "%s check-config >&1",
11713
TEST_NE_P (cmd, NULL);
11714
RUN_COMMAND (NULL, cmd, &output, &lines);
11716
TEST_EQ_STR (output[0], "plymouth");
11717
TEST_EQ_STR (output[1], " stop on: unknown job beano");
11718
TEST_EQ_STR (output[2], " stop on: unknown event wibble");
11719
TEST_EQ (lines, 3);
11721
DELETE_FILE (dirname, "plymouth.conf");
11722
DELETE_FILE (dirname, "mountall.conf");
11723
DELETE_FILE (dirname, "portmap.conf");
11724
DELETE_FILE (dirname, "gdm.conf");
11726
/*******************************************************************/
11728
TEST_FEATURE ("unsatisfiable complex start on, unsatisfiable complex stop on");
11730
CREATE_FILE (dirname, "plymouth.conf",
11731
"start on (starting mountall\n"
11733
" and (stopped gdm\n"
11734
" or stopped kdm\n"
11735
" or stopped xdm\n"
11736
" or stopped lxdm)))\n"
11737
"stop on (stopping portmap\n"
11738
" or (wibble or starting beano))\n");
11740
CREATE_FILE (dirname, "mountall.conf", "exec true");
11741
CREATE_FILE (dirname, "portmap.conf", "exec true");
11743
cmd = nih_sprintf (NULL, "%s check-config 2>&1",
11745
TEST_NE_P (cmd, NULL);
11746
RUN_COMMAND (NULL, cmd, &output, &lines);
11748
TEST_EQ_STR (output[0], "plymouth");
11749
TEST_EQ_STR (output[1], " start on: unknown job lxdm");
11750
TEST_EQ_STR (output[2], " start on: unknown job xdm");
11751
TEST_EQ_STR (output[3], " start on: unknown job kdm");
11752
TEST_EQ_STR (output[4], " start on: unknown job gdm");
11753
TEST_EQ_STR (output[5], " start on: unknown event hello");
11754
TEST_EQ_STR (output[6], " stop on: unknown job beano");
11755
TEST_EQ_STR (output[7], " stop on: unknown event wibble");
11756
TEST_EQ (lines, 8);
11758
DELETE_FILE (dirname, "plymouth.conf");
11759
DELETE_FILE (dirname, "mountall.conf");
11760
DELETE_FILE (dirname, "portmap.conf");
11762
/*******************************************************************/
11764
TEST_FEATURE ("satisfiable complex start on, satisfiable complex stop on");
11766
CREATE_FILE (dirname, "plymouth.conf",
11767
"start on (starting mountall\n"
11769
" and (stopped gdm\n"
11770
" or (stopped kdm\n"
11771
" or (stopped xdm\n"
11772
" or stopped lxdm)))))\n"
11773
"stop on (stopping portmap\n"
11774
" or (wibble or starting beano))\n");
11776
CREATE_FILE (dirname, "mountall.conf", "exec true\n");
11777
CREATE_FILE (dirname, "portmap.conf",
11780
CREATE_FILE (dirname, "lxdm.conf", "exec true");
11781
CREATE_FILE (dirname, "wibble.conf", "emits wibble");
11782
CREATE_FILE (dirname, "beano.conf", "exec true");
11784
cmd = nih_sprintf (NULL, "%s check-config 2>&1",
11786
TEST_NE_P (cmd, NULL);
11787
RUN_COMMAND (NULL, cmd, &output, &lines);
11789
TEST_EQ (lines, 0);
11791
DELETE_FILE (dirname, "plymouth.conf");
11792
DELETE_FILE (dirname, "mountall.conf");
11793
DELETE_FILE (dirname, "portmap.conf");
11794
DELETE_FILE (dirname, "lxdm.conf");
11795
DELETE_FILE (dirname, "beano.conf");
11796
DELETE_FILE (dirname, "wibble.conf");
11798
/*******************************************************************/
11801
"satisfiable complex start on, satisfiable complex stop on with warnings");
11803
CREATE_FILE (dirname, "plymouth.conf",
11804
"start on (starting mountall\n"
11806
" and (stopped gdm\n"
11807
" or (stopped kdm\n"
11808
" or (stopped xdm\n"
11809
" or stopped lxdm)))))\n"
11810
"stop on (stopping portmap\n"
11811
" or (wibble or starting beano))\n");
11813
CREATE_FILE (dirname, "mountall.conf", "exec true\n");
11814
CREATE_FILE (dirname, "portmap.conf",
11817
CREATE_FILE (dirname, "lxdm.conf", "exec true");
11818
CREATE_FILE (dirname, "wibble.conf", "emits wibble");
11819
CREATE_FILE (dirname, "beano.conf", "exec true");
11821
cmd = nih_sprintf (NULL, "%s check-config --warn 2>&1",
11823
TEST_NE_P (cmd, NULL);
11824
RUN_COMMAND (NULL, cmd, &output, &lines);
11826
TEST_EQ_STR (output[0], "plymouth");
11827
TEST_EQ_STR (output[1], " start on: unknown job xdm");
11828
TEST_EQ_STR (output[2], " start on: unknown job kdm");
11829
TEST_EQ_STR (output[3], " start on: unknown job gdm");
11830
TEST_EQ (lines, 4);
11832
DELETE_FILE (dirname, "plymouth.conf");
11833
DELETE_FILE (dirname, "mountall.conf");
11834
DELETE_FILE (dirname, "portmap.conf");
11835
DELETE_FILE (dirname, "lxdm.conf");
11836
DELETE_FILE (dirname, "beano.conf");
11837
DELETE_FILE (dirname, "wibble.conf");
11839
/*******************************************************************/
11841
STOP_UPSTART (upstart_pid);
11842
TEST_EQ (unsetenv ("UPSTART_CONFDIR"), 0);
11843
TEST_DBUS_END (dbus_pid);
10735
11848
test_list_action (void)