svn commit: trunk/busybox: debianutils include testsuite

vda at busybox.net vda at busybox.net
Tue Jul 1 03:00:46 PDT 2008


Author: vda
Date: 2008-07-01 03:00:46 -0700 (Tue, 01 Jul 2008)
New Revision: 22580

Log:
ssd: do not stat -x EXECUTABLE, it is not needed anymore
ssd: use PATH
ssd: fix -a without -x case
ssd: fix help text
ssd: CLOSE_EXTRA_FDS in MMU case too
ssd: add testsuite



Added:
   trunk/busybox/testsuite/start-stop-daemon.tests

Modified:
   trunk/busybox/debianutils/start_stop_daemon.c
   trunk/busybox/include/usage.h


Changeset:
Modified: trunk/busybox/debianutils/start_stop_daemon.c
===================================================================
--- trunk/busybox/debianutils/start_stop_daemon.c	2008-07-01 08:51:25 UTC (rev 22579)
+++ trunk/busybox/debianutils/start_stop_daemon.c	2008-07-01 10:00:46 UTC (rev 22580)
@@ -326,7 +326,9 @@
 	char *signame;
 	char *startas;
 	char *chuid;
+#ifdef OLDER_VERSION_OF_X
 	struct stat execstat;
+#endif
 #if ENABLE_FEATURE_START_STOP_DAEMON_FANCY
 //	char *retry_arg = NULL;
 //	int retries = -1;
@@ -361,6 +363,8 @@
 
 	if (!(opt & OPT_a))
 		startas = execname;
+	if (!execname) /* in case -a is given and -x is not */
+		execname = startas;
 
 //	USE_FEATURE_START_STOP_DAEMON_FANCY(
 //		if (retry_arg)
@@ -374,7 +378,8 @@
 		if (errno)
 			user_id = xuname2uid(userspec);
 	}
-	do_procinit(); /* Both start and stop needs to know current processes */
+	/* Both start and stop need to know current processes */
+	do_procinit();
 
 	if (opt & CTX_STOP) {
 		int i = do_stop();
@@ -383,17 +388,21 @@
 
 	if (found) {
 		if (!QUIET)
-			printf("%s already running\n%d\n", execname, found->pid);
+			printf("%s is already running\n%u\n", execname, (unsigned)found->pid);
 		return !(opt & OPT_OKNODO);
 	}
 
+#ifdef OLDER_VERSION_OF_X
 	if (execname)
 		xstat(execname, &execstat);
+#endif
 
 	*--argv = startas;
 	if (opt & OPT_BACKGROUND) {
 #if BB_MMU
-		bb_daemonize(0);
+		bb_daemonize(DAEMON_DEVNULL_STDIO + DAEMON_CLOSE_EXTRA_FDS);
+		/* DAEMON_DEVNULL_STDIO is superfluous -
+		 * it's always done by bb_daemonize() */
 #else
 		pid_t pid = vfork();
 		if (pid < 0) /* error */
@@ -404,19 +413,18 @@
 			 * so "return 0" may do bad things */
 			_exit(EXIT_SUCCESS);
 		}
-		/* child */
+		/* Child */
 		setsid(); /* detach from controlling tty */
 		/* Redirect stdio to /dev/null, close extra FDs.
 		 * We do not actually daemonize because of DAEMON_ONLY_SANITIZE */
-		bb_daemonize_or_rexec(
-			DAEMON_DEVNULL_STDIO
-			+ DAEMON_CLOSE_EXTRA_FDS
+		bb_daemonize_or_rexec(DAEMON_DEVNULL_STDIO
+			DAEMON_CLOSE_EXTRA_FDS
 			+ DAEMON_ONLY_SANITIZE,
 			NULL /* argv, unused */ );
 #endif
 	}
 	if (opt & OPT_MAKEPID) {
-		/* user wants _us_ to make the pidfile */
+		/* User wants _us_ to make the pidfile */
 		write_pidfile(pidfile);
 	}
 	if (opt & OPT_c) {
@@ -434,6 +442,6 @@
 		}
 	}
 #endif
-	execv(startas, argv);
+	execvp(startas, argv);
 	bb_perror_msg_and_die("cannot start %s", startas);
 }

Modified: trunk/busybox/include/usage.h
===================================================================
--- trunk/busybox/include/usage.h	2008-07-01 08:51:25 UTC (rev 22579)
+++ trunk/busybox/include/usage.h	2008-07-01 10:00:46 UTC (rev 22580)
@@ -3638,9 +3638,7 @@
        "$ cat TODO | split -a 2 -l 2 TODO_\n"
 
 #define start_stop_daemon_trivial_usage \
-       "[OPTIONS] [" \
-	USE_GETOPT_LONG("--start|--stop") SKIP_GETOPT_LONG("-S|-K") \
-       "] ... [-- arguments...]"
+       "[OPTIONS] [-S|-K] ... [-- arguments...]"
 #define start_stop_daemon_full_usage "\n\n" \
        "Search for matching processes, and then\n" \
        "-S: stop all matching processes.\n" \

Added: trunk/busybox/testsuite/start-stop-daemon.tests
===================================================================
--- trunk/busybox/testsuite/start-stop-daemon.tests	                        (rev 0)
+++ trunk/busybox/testsuite/start-stop-daemon.tests	2008-07-01 10:00:46 UTC (rev 22580)
@@ -0,0 +1,19 @@
+#!/bin/sh
+# Copyright 2008 by Denys Vlasenko
+# Licensed under GPL v2, see file LICENSE for details.
+
+. testing.sh
+
+# testing "test name" "cmd" "expected result" "file input" "stdin"
+
+testing "start-stop-daemon -x without -a" \
+	'start-stop-daemon -S -x true 2>&1; echo $?' \
+	"0\n" \
+	"" ""
+
+testing "start-stop-daemon -a without -x" \
+	'start-stop-daemon -S -a false 2>&1; echo $?' \
+	"1\n" \
+	"" ""
+
+exit $FAILCOUNT


Property changes on: trunk/busybox/testsuite/start-stop-daemon.tests
___________________________________________________________________
Name: svn:executable
   + *



More information about the busybox-cvs mailing list