diff --git a/docs/boothd.8.txt b/docs/boothd.8.txt index 70a47496..c0be935e 100644 --- a/docs/boothd.8.txt +++ b/docs/boothd.8.txt @@ -97,12 +97,11 @@ The configuration name also determines the name of the PID file - for the defaul Report version information. *-S*:: - 'systemd' mode: don't fork. This is like '-D' but without the debug output. + 'systemd' mode: don't fork. + Disables daemonizing, the process will remain in the foreground. *-D*:: - Debug output/don't daemonize. - Increases the debug output level; booth daemon remains - in the foreground. + Increases the debug output level. *-l* 'lockfile':: Use another lock file. By default, the lock file name is diff --git a/src/main.c b/src/main.c index ce6c35e7..7ccb7826 100644 --- a/src/main.c +++ b/src/main.c @@ -1116,12 +1116,15 @@ static int read_arguments(int argc, char **argv) strcat(cp, BOOTH_DEFAULT_CONF_EXT); } break; + case 'D': debug_level++; enable_stderr = 1; - /* Fall through */ + break; + case 'S': daemonize = 0; + enable_stderr = 1; break; case 'l': diff --git a/test/boothrunner.py b/test/boothrunner.py index ac56df8b..f9154e7e 100755 --- a/test/boothrunner.py +++ b/test/boothrunner.py @@ -31,6 +31,9 @@ def set_lock_file(self, lock_file): def set_debug(self): self.args += [ '-D' ] + def set_foreground(self): + self.args += [ '-S' ] + def all_args(self): return [ self.boothd_path ] + self.args + self.final_args diff --git a/test/serverenv.py b/test/serverenv.py index 59ae6fad..d0467b97 100755 --- a/test/serverenv.py +++ b/test/serverenv.py @@ -33,7 +33,7 @@ class ServerTestEnvironment(BoothTestEnvironment): def run_booth(self, expected_exitcode, expected_daemon, config_text=None, config_file=None, lock_file=True, - args=[], debug=False): + args=[], debug=False, foreground=False): ''' Runs boothd. Defaults to using a temporary lock file and the standard config file path. There are four possible types of @@ -42,7 +42,7 @@ def run_booth(self, expected_exitcode, expected_daemon, - boothd exits non-zero without launching a daemon (setup phase failed, e.g. due to invalid configuration file) - boothd exits zero after launching a daemon (successful operation) - - boothd does not exit (running in foreground / debug mode) + - boothd does not exit (running in foreground mode) - boothd does not exit (setup phase hangs, e.g. while attempting to connect to peer during ticket_catchup()) @@ -61,13 +61,15 @@ def run_booth(self, expected_exitcode, expected_daemon, an integer, or False if booth is not expected to terminate within the timeout expected_daemon - True iff a daemon is expected to be launched (this includes - running the server in debug / foreground mode via -D; even - though in this case the server's not technically not a daemon, + True iff a daemon is expected to be launched (this means + running the server in foreground mode via -S; + even though in this case the server's not technically not a daemon, we still want to treat it like one by checking the lockfile before and after we kill it) debug True means pass the -D parameter + foreground + True means pass the -S parameter Returns a (pid, return_code, stdout, stderr, runner) tuple, where return_code/stdout/stderr are None iff pid is still running. @@ -97,6 +99,9 @@ def run_booth(self, expected_exitcode, expected_daemon, if debug: runner.set_debug() + if foreground: + runner.set_foreground() + runner.show_args() (pid, return_code, stdout, stderr) = runner.run() self.check_return_code(pid, return_code, expected_exitcode) diff --git a/test/servertests.py b/test/servertests.py index 290bce2e..f574f26a 100755 --- a/test/servertests.py +++ b/test/servertests.py @@ -86,6 +86,16 @@ def test_missing_quotes(self): def test_debug_mode(self): (pid, ret, stdout, stderr, runner) = \ self.run_booth(config_text=self.working_config, debug=True, + expected_exitcode=0, expected_daemon=True) + + def test_foreground_mode(self): + (pid, ret, stdout, stderr, runner) = \ + self.run_booth(config_text=self.working_config, foreground=True, + expected_exitcode=None, expected_daemon=True) + + def test_debug_and_foreground_mode(self): + (pid, ret, stdout, stderr, runner) = \ + self.run_booth(config_text=self.working_config, debug=True, foreground=True, expected_exitcode=None, expected_daemon=True) def test_missing_transport(self):