New fast-exit test-case
authorNils Carlson <nils.carlson@ericsson.com>
Tue, 17 May 2011 13:16:47 +0000 (15:16 +0200)
committerNils Carlson <nils.carlson@ericsson.com>
Tue, 17 May 2011 14:35:40 +0000 (16:35 +0200)
A fast-exit test-case that just writes one marker and exits,
tests that the consumer daemon maps the buffers before the
program exits. Exiting is tested both by normal return
and by commiting suicide (SIGKILL to self).

Signed-off-by: Nils Carlson <nils.carlson@ericsson.com>
Acked-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
.gitignore
configure.ac
tests/Makefile.am
tests/exit-fast/Makefile.am [new file with mode: 0644]
tests/exit-fast/exit-fast.c [new file with mode: 0644]
tests/exit-fast/exit-fast.sh [new file with mode: 0755]
tests/runtests

index 4bc3814b0e54f1a064df9b59bf0fcef1e2502e5b..5d1d9cd458875bf3756aaa3ff7d81f1c390fad43 100644 (file)
@@ -40,3 +40,4 @@ tests/test-nevents/prog
 tests/trace_event/trace_event_test
 tests/tracepoint/benchmark/tracepoint_benchmark
 tests/tracepoint/tracepoint_test
+tests/exit-fast/exit-fast
index 1f3cb33f8279720e6e35c5d53d85b583c1029aee..00df0c06d26bd83fda46fee99b9acc70f43ffbe3 100644 (file)
@@ -165,6 +165,7 @@ AC_CONFIG_FILES([
        tests/tracepoint/benchmark/Makefile
        tests/register_test/Makefile
        tests/libustctl_function_tests/Makefile
+       tests/exit-fast/Makefile
        libustinstr-malloc/Makefile
        libustfork/Makefile
        libustconsumer/Makefile
index e4e06cebb8fd985aa41aa98e86a95409e8205c42..43fb2036f3c080406527327c4051e019efa325a3 100644 (file)
@@ -1,4 +1,4 @@
-SUBDIRS = . hello hello2 basic basic_long fork simple_include snprintf test-nevents test-libustinstr-malloc dlopen same_line_marker trace_event register_test tracepoint libustctl_function_tests
+SUBDIRS = . hello hello2 basic basic_long fork 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
 
diff --git a/tests/exit-fast/Makefile.am b/tests/exit-fast/Makefile.am
new file mode 100644 (file)
index 0000000..d34fbc2
--- /dev/null
@@ -0,0 +1,5 @@
+AM_CPPFLAGS = -I$(top_srcdir)/include
+
+noinst_PROGRAMS = exit-fast
+exit_fast_SOURCES = exit-fast.c
+exit_fast_LDADD = $(top_builddir)/libust/libust.la $(top_builddir)/libust-initializer.o
diff --git a/tests/exit-fast/exit-fast.c b/tests/exit-fast/exit-fast.c
new file mode 100644 (file)
index 0000000..84bb0c5
--- /dev/null
@@ -0,0 +1,39 @@
+/* Copyright (C) 2011 Nils Carlson
+ *
+ * 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; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * 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
+ */
+
+/* This test generates a single event and exits.
+ */
+
+#include <signal.h>
+#include <string.h>
+#include <ust/ust.h>
+
+int main(int argc, char *argv[])
+{
+       int suicide = 0;
+
+       if (argc > 1 && !strcmp(argv[1], "suicide")) {
+               suicide = 1;
+       }
+
+       ust_marker(fast, "%d", 0xf330);
+
+       if (suicide) {
+               kill(getpid(), SIGKILL);
+       }
+       return 0;
+}
diff --git a/tests/exit-fast/exit-fast.sh b/tests/exit-fast/exit-fast.sh
new file mode 100755 (executable)
index 0000000..d10af57
--- /dev/null
@@ -0,0 +1,46 @@
+#!/bin/bash
+#
+# Copyright 2011 Ericsson AB
+#
+#    This file is part of the UST test-suite.
+#
+#    The UST test-suite is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation, either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    The UST test-suite 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 General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License
+#    along with the UST test-suite.  If not, see <http://www.gnu.org/licenses/>.
+
+TESTDIR=$(dirname $0)/..
+
+source $TESTDIR/test_functions.sh
+source $TESTDIR/tap.sh
+
+starttest "Exit-Fast"
+
+plan_tests 6
+USTTRACE="$TESTDIR/../usttrace"
+
+diag "#"
+diag "First run, normal exit"
+diag "#"
+
+okx $USTTRACE -L $TESTDIR/exit-fast/exit-fast
+trace_loc=$($USTTRACE -W)
+trace_matches -N "fast" -n 1 "^ust.fast:" $trace_loc
+check_trace_logs "$trace_loc"
+
+diag "#"
+diag "Re-running, killing process"
+diag "#"
+
+okx $USTTRACE -L $TESTDIR/exit-fast/exit-fast suicide
+trace_loc=$($USTTRACE -W)
+trace_matches -N "fast" -n 1 "^ust.fast:" $trace_loc
+check_trace_logs "$trace_loc"
index f6862498ab1803b058462b74601e32bf49ae1c6e..36ad12d27ad27fd5a4d1bf8d879e2e207c127cd5 100755 (executable)
@@ -48,6 +48,8 @@ simple_harness_run same_line_marker/same_line_marker.sh
 
 simple_harness_run libustctl_function_tests/libustctl_function_tests
 
+simple_harness_run exit-fast/exit-fast.sh
+
 echo "************************************"
 if [[ $tests_failed -eq 0 ]]; then
     echo "$0: All passed"
This page took 0.026672 seconds and 4 git commands to generate.