summaryrefslogtreecommitdiff
path: root/tests/daemon
diff options
context:
space:
mode:
authorAndreas Baumann <abaumann@yahoo.com>2008-12-21 17:09:49 +0100
committerAndreas Baumann <abaumann@yahoo.com>2008-12-21 17:09:49 +0100
commit07bbb6aa8857a2fbc77d6db6b6d1e7bafb7d0976 (patch)
treed99410ede29d8f09f35351cc1beeb0866082ae57 /tests/daemon
parent01e67d010b9badcf2ffc65d74b0f9285f26d45e5 (diff)
downloadwolfbones-07bbb6aa8857a2fbc77d6db6b6d1e7bafb7d0976.tar.gz
wolfbones-07bbb6aa8857a2fbc77d6db6b6d1e7bafb7d0976.tar.bz2
making log a little bit less leaking Unixisms
Diffstat (limited to 'tests/daemon')
-rw-r--r--tests/daemon/GNUmakefile42
-rw-r--r--tests/daemon/testd.c20
2 files changed, 52 insertions, 10 deletions
diff --git a/tests/daemon/GNUmakefile b/tests/daemon/GNUmakefile
new file mode 100644
index 0000000..c3aa194
--- /dev/null
+++ b/tests/daemon/GNUmakefile
@@ -0,0 +1,42 @@
+TOPDIR = ../..
+
+SUBDIRS =
+
+INCLUDE_DIRS = -I$(TOPDIR)/include -I.
+
+BINS = \
+ testd
+
+OBJS = \
+ testd_cmdline.o
+
+-include $(TOPDIR)/makefiles/sub.mk
+
+# ABa: currently a special rule for cmdline.c as gengetopt is not
+# completly fixed yet
+testd.d : testd_cmdline.h
+testd_cmdline.h : testd.ggo
+ gengetopt --file-name testd_cmdline --include-getopt --conf-parser -i $<
+testd_cmdline.c : testd.ggo
+ gengetopt --file-name testd_cmdline --include-getopt --conf-parser -i $<
+
+testd_cmdline.o : testd_cmdline.c testd_cmdline.h
+ $(CC) -c -o $@ $<
+
+local_all: testd_cmdline.h
+
+local_clean:
+
+local_distclean:
+ -@rm testd_cmdline.c testd_cmdline.h
+
+local_test:
+# TODO:still a little bit unrealiable with fakeroot
+# @fakeroot $(TOPDIR)/src/testd -d --pidfile /tmp/testd.pid && \
+# sleep 3 && \
+# ls -altr /tmp/testd* && \
+# cat /tmp/testd.pid
+# -@ps -alef | grep test | grep -v grep
+# @sleep 1
+# @pkill testd
+# -@ls -altr /tmp/testd*
diff --git a/tests/daemon/testd.c b/tests/daemon/testd.c
index 7d8fafb..f5a70b6 100644
--- a/tests/daemon/testd.c
+++ b/tests/daemon/testd.c
@@ -1,9 +1,9 @@
#include "port/stdbool.h" /* for bool */
-#include "port/string.h" /* for memset */
#include <sys/types.h> /* for pid_t */
#include <unistd.h> /* for exit, unistd, getuid, getppid */
#include <stdlib.h> /* for EXIT_FAILURE */
+#include <string.h> /* for memset */
#include "errors.h" /* global error codes */
#include "log.h" /* logging facility */
@@ -67,18 +67,18 @@ int main( int argc, char *argv[] ) {
args_info.config_file_arg : DEFAULT_CONFIG_FILE ) );
}
- openlogtostderr( LOG_DEBUG - 1 + (int)args_info.debug_given );
+ openlogtostderr( log_DEBUG - 1 + (int)args_info.debug_given );
if( args_info.logfile_given )
openlogtofile( args_info.logfile_arg,
args_info.logfile_level_given ?
- log_str_to_level( args_info.logfile_level_arg ) : LOG_NOTICE );
+ log_str_to_level( args_info.logfile_level_arg ) : log_NOTICE );
if( !args_info.foreground_given ) {
openlogtosyslog( CMDLINE_PARSER_PACKAGE,
args_info.syslog_facility_given ?
- log_str_to_syslog_facility( args_info.syslog_facility_arg ) : LOG_DAEMON,
+ log_str_to_syslog_facility( args_info.syslog_facility_arg ) : log_DAEMON,
args_info.syslog_level_given ?
- log_str_to_level( args_info.syslog_level_arg ) : LOG_NOTICE );
+ log_str_to_level( args_info.syslog_level_arg ) : log_NOTICE );
memset( &daemon_params, 0, sizeof( daemon_params ) );
daemon_params.daemon_name = CMDLINE_PARSER_PACKAGE;
@@ -111,7 +111,7 @@ int main( int argc, char *argv[] ) {
}
}
- LOG( LOG_NOTICE, "Started %s daemon", CMDLINE_PARSER_PACKAGE );
+ LOG( log_NOTICE, "Started %s daemon", CMDLINE_PARSER_PACKAGE );
while( ( sig != SIGTERM ) && ( sig != SIGINT ) && ( sig != -1 ) ) {
sig = signal_suspend( 60, &error );
switch( sig ) {
@@ -122,12 +122,12 @@ int main( int argc, char *argv[] ) {
break;
case SIGHUP:
- LOG( LOG_NOTICE, "Rereading configuration" );
+ LOG( log_NOTICE, "Rereading configuration" );
break;
case SIGTERM:
case SIGINT:
- LOG( LOG_NOTICE, "Got termination signal, shutting down the daemon" );
+ LOG( log_NOTICE, "Got termination signal, shutting down the daemon" );
break;
case SIGUSR1:
@@ -137,13 +137,13 @@ int main( int argc, char *argv[] ) {
break;
default:
- LOG( LOG_ERR, "Unexpected signal '%s' (%s, %d)",
+ LOG( log_ERR, "Unexpected signal '%s' (%s, %d)",
signal_get_long_name( sig ),
signal_get_short_name( sig ),
sig );
}
}
- LOG( LOG_NOTICE, "Stopped %s daemon", CMDLINE_PARSER_PACKAGE );
+ LOG( log_NOTICE, "Stopped %s daemon", CMDLINE_PARSER_PACKAGE );
if( !args_info.foreground_given ) {
cmdline_parser_free( &args_info );