251
251
extern int reload_configuration_action (NihCommand *command, char * const *args);
252
252
extern int version_action (NihCommand *command, char * const *args);
253
253
extern int log_priority_action (NihCommand *command, char * const *args);
254
extern int usage_action (NihCommand *command, char * const *args);
256
257
static int my_connect_handler_called = FALSE;
14403
char dirname[PATH_MAX];
14404
nih_local char *cmd;
14405
pid_t upstart_pid = 0;
14406
pid_t dbus_pid = 0;
14411
NihCommand command;
14415
TEST_GROUP ("usage");
14417
TEST_FILENAME (dirname);
14418
TEST_EQ (mkdir (dirname, 0755), 0);
14420
/* Use the "secret" interface */
14421
TEST_EQ (setenv ("UPSTART_CONFDIR", dirname, 1), 0);
14423
TEST_DBUS (dbus_pid);
14424
START_UPSTART (upstart_pid);
14426
TEST_FEATURE ("no usage");
14427
CREATE_FILE (dirname, "foo.conf",
14429
"description \"wibble\"");
14431
cmd = nih_sprintf (NULL, "%s usage foo 2>&1", INITCTL_BINARY);
14432
TEST_NE_P (cmd, NULL);
14433
RUN_COMMAND (NULL, cmd, &output, &lines);
14434
TEST_EQ_STR (output[0], "Usage: ");
14435
TEST_EQ (lines, 1);
14438
DELETE_FILE (dirname, "foo.conf");
14440
/*******************************************************************/
14442
TEST_FEATURE ("with usage");
14444
CREATE_FILE (dirname, "foo.conf",
14445
"usage \"this is usage\"");
14447
cmd = nih_sprintf (NULL, "%s usage foo 2>&1", INITCTL_BINARY);
14448
TEST_NE_P (cmd, NULL);
14449
RUN_COMMAND (NULL, cmd, &output, &lines);
14450
TEST_EQ_STR (output[0], "Usage: this is usage");
14451
TEST_EQ (lines, 1);
14454
DELETE_FILE (dirname, "foo.conf");
14456
/*******************************************************************/
14458
TEST_FEATURE ("failed status with usage");
14460
CREATE_FILE (dirname, "foo.conf",
14462
"usage \"this is usage\"");
14464
memset (&command, 0, sizeof command);
14471
TEST_DIVERT_STDOUT (out) {
14472
TEST_DIVERT_STDERR (err) {
14473
ret = status_action (&command, args);
14481
TEST_FILE_END (out);
14482
TEST_FILE_RESET (out);
14484
TEST_FILE_EQ (err, "test: Unknown parameter: FOO\n");
14485
TEST_FILE_EQ (err, "Usage: this is usage\n");
14486
TEST_FILE_END (err);
14487
TEST_FILE_RESET (err);
14489
DELETE_FILE (dirname, "foo.conf");
14492
STOP_UPSTART (upstart_pid);
14493
TEST_EQ (unsetenv ("UPSTART_CONFDIR"), 0);
14494
TEST_DBUS_END (dbus_pid);