From 46cec820d380796882540bf5a8904949d86e3515 Mon Sep 17 00:00:00 2001 From: Nils Carlson Date: Tue, 17 May 2011 15:16:47 +0200 Subject: [PATCH] New fast-exit test-case 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 Acked-by: Mathieu Desnoyers --- .gitignore | 1 + configure.ac | 1 + tests/Makefile.am | 2 +- tests/exit-fast/Makefile.am | 5 ++++ tests/exit-fast/exit-fast.c | 39 ++++++++++++++++++++++++++++++ tests/exit-fast/exit-fast.sh | 46 ++++++++++++++++++++++++++++++++++++ tests/runtests | 2 ++ 7 files changed, 95 insertions(+), 1 deletion(-) create mode 100644 tests/exit-fast/Makefile.am create mode 100644 tests/exit-fast/exit-fast.c create mode 100755 tests/exit-fast/exit-fast.sh diff --git a/.gitignore b/.gitignore index 4bc3814..5d1d9cd 100644 --- a/.gitignore +++ b/.gitignore @@ -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 diff --git a/configure.ac b/configure.ac index 1f3cb33..00df0c0 100644 --- a/configure.ac +++ b/configure.ac @@ -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 diff --git a/tests/Makefile.am b/tests/Makefile.am index e4e06ce..43fb203 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -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 index 0000000..d34fbc2 --- /dev/null +++ b/tests/exit-fast/Makefile.am @@ -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 index 0000000..84bb0c5 --- /dev/null +++ b/tests/exit-fast/exit-fast.c @@ -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 +#include +#include + +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 index 0000000..d10af57 --- /dev/null +++ b/tests/exit-fast/exit-fast.sh @@ -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 . + +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" diff --git a/tests/runtests b/tests/runtests index f686249..36ad12d 100755 --- a/tests/runtests +++ b/tests/runtests @@ -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" -- 2.34.1