tests/basic/basic
tests/basic_long/basic_long
+tests/daemon/daemon
tests/demo/demo
tests/dlopen/dlopen
tests/exit-fast/exit-fast
tests/hello/Makefile
tests/hello-static-lib/Makefile
tests/hello.cxx/Makefile
+ tests/daemon/Makefile
tests/demo/Makefile
tests/fork/Makefile
tests/ust-basic-tracing/Makefile
-SUBDIRS = . hello hello-static-lib fork ust-basic-tracing ust-multi-test demo hello.cxx
+SUBDIRS = . hello hello-static-lib fork ust-basic-tracing ust-multi-test \
+ demo hello.cxx daemon
#SUBDIRS = . hello2 basic basic_long simple_include snprintf test-nevents test-libustinstr-malloc dlopen same_line_marker trace_event register_test tracepoint libustctl_function_tests exit-fast
dist_noinst_SCRIPTS = test_loop runtests trace_matches
--- /dev/null
+AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_builddir)/include -Wsystem-headers
+
+noinst_PROGRAMS = daemon
+daemon_SOURCES = daemon.c ust_tests_daemon.h
+daemon_LDADD = $(top_builddir)/liblttng-ust/liblttng-ust.la \
+ $(top_builddir)/liblttng-ust-fork/liblttng-ust-fork.la
+
+if LTTNG_UST_BUILD_WITH_LIBDL
+daemon_LDADD += -ldl
+endif
+if LTTNG_UST_BUILD_WITH_LIBC_DL
+daemon_LDADD += -lc
+endif
+
+noinst_SCRIPTS = run
+EXTRA_DIST = run
--- /dev/null
+This test checks if tracing works correctly in a child process created by
+a daemon() call.
--- /dev/null
+/*
+ * Copyright (C) 2009 Pierre-Marc Fournier
+ * Copyright (C) 2011-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; version 2.1 of
+ * the License.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <stdio.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <stdlib.h>
+
+#define TRACEPOINT_DEFINE
+#define TRACEPOINT_CREATE_PROBES
+#include "ust_tests_daemon.h"
+
+int main(int argc, char **argv, char *env[])
+{
+ int result;
+
+ if (argc < 1) {
+ fprintf(stderr, "usage: daemon\n");
+ exit(1);
+ }
+
+ printf("daemon test program, parent pid is %d\n", getpid());
+ tracepoint(ust_tests_daemon, before_daemon);
+
+ result = daemon(0, 1);
+ if (result == 0) {
+ printf("Child pid is %d\n", getpid());
+
+ tracepoint(ust_tests_daemon, after_daemon_child, getpid());
+ } else {
+ tracepoint(ust_tests_daemon, after_daemon_parent);
+ perror("daemon");
+ exit(1);
+ }
+
+ return 0;
+}
--- /dev/null
+#!/bin/sh
+
+./daemon
--- /dev/null
+#undef TRACEPOINT_PROVIDER
+#define TRACEPOINT_PROVIDER ust_tests_daemon
+
+#if !defined(_TRACEPOINT_UST_TESTS_DAEMON_H) || defined(TRACEPOINT_HEADER_MULTI_READ)
+#define _TRACEPOINT_UST_TESTS_DAEMON_H
+
+/*
+ * Copyright (C) 2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ */
+
+#include <lttng/tracepoint.h>
+#include <sys/types.h>
+
+TRACEPOINT_EVENT(ust_tests_daemon, before_daemon,
+ TP_ARGS(),
+ TP_FIELDS()
+)
+
+TRACEPOINT_EVENT(ust_tests_daemon, after_daemon_child,
+ TP_ARGS(pid_t, pid),
+ TP_FIELDS(
+ ctf_integer(pid_t, pid, pid)
+ )
+)
+
+TRACEPOINT_EVENT(ust_tests_daemon, after_daemon_parent,
+ TP_ARGS(),
+ TP_FIELDS()
+)
+
+#endif /* _TRACEPOINT_UST_TESTS_DAEMON_H */
+
+#undef TRACEPOINT_INCLUDE_FILE
+#define TRACEPOINT_INCLUDE_FILE ./ust_tests_daemon.h
+
+/* This part must be outside ifdef protection */
+#include <lttng/tracepoint-event.h>