<div dir="ltr">Merged in master, thanks!<div><br></div><div>Jérémie</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jul 14, 2015 at 5:52 PM, Jonathan Rajotte <span dir="ltr"><<a href="mailto:jonathan.rajotte-julien@efficios.com" target="_blank">jonathan.rajotte-julien@efficios.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Signed-off-by: Jonathan Rajotte <<a href="mailto:jonathan.rajotte-julien@efficios.com">jonathan.rajotte-julien@efficios.com</a>><br>
---<br>
<a href="http://configure.ac" rel="noreferrer" target="_blank">configure.ac</a> | 1 +<br>
tests/fast_regression | 1 +<br>
tests/regression/ust/Makefile.am | 3 +-<br>
tests/regression/ust/getcpu-override/Makefile.am | 37 +++++<br>
.../lttng-ust-getcpu-override-test.c | 84 +++++++++++<br>
.../ust/getcpu-override/run-getcpu-override | 13 ++<br>
.../ust/getcpu-override/test_getcpu_override | 166 +++++++++++++++++++++<br>
7 files changed, 304 insertions(+), 1 deletion(-)<br>
create mode 100644 tests/regression/ust/getcpu-override/Makefile.am<br>
create mode 100644 tests/regression/ust/getcpu-override/lttng-ust-getcpu-override-test.c<br>
create mode 100755 tests/regression/ust/getcpu-override/run-getcpu-override<br>
create mode 100755 tests/regression/ust/getcpu-override/test_getcpu_override<br>
<br>
diff --git a/<a href="http://configure.ac" rel="noreferrer" target="_blank">configure.ac</a> b/<a href="http://configure.ac" rel="noreferrer" target="_blank">configure.ac</a><br>
index 1fcac72..287e3d4 100644<br>
--- a/<a href="http://configure.ac" rel="noreferrer" target="_blank">configure.ac</a><br>
+++ b/<a href="http://configure.ac" rel="noreferrer" target="_blank">configure.ac</a><br>
@@ -529,6 +529,7 @@ AC_CONFIG_FILES([<br>
tests/regression/ust/java-jul/Makefile<br>
tests/regression/ust/java-log4j/Makefile<br>
tests/regression/ust/python-logging/Makefile<br>
+ tests/regression/ust/getcpu-override/Makefile<br>
tests/stress/Makefile<br>
tests/unit/Makefile<br>
tests/unit/ini_config/Makefile<br>
diff --git a/tests/fast_regression b/tests/fast_regression<br>
index c14f7f2..037054f 100644<br>
--- a/tests/fast_regression<br>
+++ b/tests/fast_regression<br>
@@ -22,6 +22,7 @@ regression/ust/overlap/test_overlap<br>
regression/ust/java-jul/test_java_jul<br>
regression/ust/java-log4j/test_java_log4j<br>
regression/ust/python-logging/test_python_logging<br>
+regression/ust/getcpu-override/test_getcpu_override<br>
regression/ust/test_event_basic<br>
regression/ust/test_event_tracef<br>
regression/ust/test_event_wildcard<br>
diff --git a/tests/regression/ust/Makefile.am b/tests/regression/ust/Makefile.am<br>
index 0d11f90..e3a04c0 100644<br>
--- a/tests/regression/ust/Makefile.am<br>
+++ b/tests/regression/ust/Makefile.am<br>
@@ -1,7 +1,8 @@<br>
if HAVE_LIBLTTNG_UST_CTL<br>
SUBDIRS = nprocesses high-throughput low-throughput before-after multi-session \<br>
overlap buffers-pid linking daemon exit-fast fork libc-wrapper \<br>
- periodical-metadata-flush java-jul java-log4j python-logging<br>
+ periodical-metadata-flush java-jul java-log4j python-logging \<br>
+ getcpu-override<br>
<br>
EXTRA_DIST = test_event_basic test_event_wildcard test_event_tracef test_event_perf<br>
<br>
diff --git a/tests/regression/ust/getcpu-override/Makefile.am b/tests/regression/ust/getcpu-override/Makefile.am<br>
new file mode 100644<br>
index 0000000..f1026ac<br>
--- /dev/null<br>
+++ b/tests/regression/ust/getcpu-override/Makefile.am<br>
@@ -0,0 +1,37 @@<br>
+AM_CPPFLAGS = -I$(srcdir)<br>
+<br>
+# The rpath is necessary because libtool won't build a shared library<br>
+# if it's noinst_<br>
+GETCPU_LIBTOOL_FLAGS = \<br>
+ -module \<br>
+ -shared \<br>
+ -avoid-version \<br>
+ --no-as-needed \<br>
+ -rpath $(abs_builddir)<br>
+<br>
+noinst_LTLIBRARIES = <a href="http://lttng-ust-getcpu-override-test.la" rel="noreferrer" target="_blank">lttng-ust-getcpu-override-test.la</a><br>
+lttng_ust_getcpu_override_test_la_LDFLAGS = $(GETCPU_LIBTOOL_FLAGS)<br>
+<br>
+if LTTNG_TOOLS_BUILD_WITH_LIBDL<br>
+lttng_ust_getcpu_override_test_la_LIBADD = -ldl<br>
+endif<br>
+if LTTNG_TOOLS_BUILD_WITH_LIBC_DL<br>
+lttng_ust_getcpu_override_test_la_LIBADD = -lc<br>
+endif<br>
+<br>
+noinst_SCRIPTS = test_getcpu_override run-getcpu-override<br>
+EXTRA_DIST = test_getcpu_override run-getcpu-override<br>
+<br>
+all-local:<br>
+ @if [ x"$(srcdir)" != x"$(builddir)" ]; then \<br>
+ for script in $(EXTRA_DIST); do \<br>
+ cp -f $(srcdir)/$$script $(builddir); \<br>
+ done; \<br>
+ fi<br>
+<br>
+clean-local:<br>
+ @if [ x"$(srcdir)" != x"$(builddir)" ]; then \<br>
+ for script in $(EXTRA_DIST); do \<br>
+ rm -f $(builddir)/$$script; \<br>
+ done; \<br>
+ fi<br>
diff --git a/tests/regression/ust/getcpu-override/lttng-ust-getcpu-override-test.c b/tests/regression/ust/getcpu-override/lttng-ust-getcpu-override-test.c<br>
new file mode 100644<br>
index 0000000..f098e2c<br>
--- /dev/null<br>
+++ b/tests/regression/ust/getcpu-override/lttng-ust-getcpu-override-test.c<br>
@@ -0,0 +1,84 @@<br>
+/*<br>
+ * lttng-ust-getcpu-override-test.c<br>
+ * Based on lttng-getcpu-override-example.c from LTTng-ust exemple<br>
+ *<br>
+ * Copyright (c) 2014 Mathieu Desnoyers <<a href="mailto:mathieu.desnoyers@efficios.com">mathieu.desnoyers@efficios.com</a>><br>
+ * Copyright (c) 2015 Jonathan Rajotte <<a href="mailto:jonathan.rajotte-julien@efficios.com">jonathan.rajotte-julien@efficios.com</a>><br>
+ *<br>
+ * Permission is hereby granted, free of charge, to any person obtaining a copy<br>
+ * of this software and associated documentation files (the "Software"), to deal<br>
+ * in the Software without restriction, including without limitation the rights<br>
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell<br>
+ * copies of the Software, and to permit persons to whom the Software is<br>
+ * furnished to do so, subject to the following conditions:<br>
+ *<br>
+ * The above copyright notice and this permission notice shall be included in<br>
+ * all copies or substantial portions of the Software.<br>
+ *<br>
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR<br>
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,<br>
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE<br>
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER<br>
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,<br>
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE<br>
+ * SOFTWARE.<br>
+ */<br>
+<br>
+#include <stdlib.h><br>
+#include <time.h><br>
+#include <string.h><br>
+#include <stdio.h><br>
+#include <unistd.h><br>
+#include <lttng/ust-getcpu.h><br>
+<br>
+int plugin_getcpu(void)<br>
+{<br>
+ /* Generate a sequence based on the number of configurated processor<br>
+ * by using sequence[i] % nb_configured_processors. Where sequence<br>
+ * is a static random sequence.<br>
+ * The expected cpu_id sequence can be regenerated on the test script<br>
+ * side and compared to the extracted cpu sequence for validation.<br>
+ * This does no guarantee in absolute the validity of the getcpu<br>
+ * plugin but provide a strong argument of it's validity.<br>
+ */<br>
+ static int i = 0;<br>
+ static int seq_seed[256] = {100, 57, 232, 236, 42, 193, 224, 184, 216, 150,<br>
+ 92, 91, 108, 118, 55, 243, 65, 101, 209, 0, 147, 36, 29, 34, 49, 188,<br>
+ 174, 105, 253, 245, 227, 238, 112, 20, 222, 201, 102, 175, 119, 19, 132,<br>
+ 41, 78, 90, 114, 64, 138, 14, 48, 18, 162, 85, 204, 124, 133, 73, 172,<br>
+ 106, 241, 126, 28, 104, 111, 21, 127, 219, 9, 244, 237, 189, 59, 214,<br>
+ 52, 141, 107, 26, 25, 199, 3, 157, 117, 234, 33, 44, 46, 84, 69, 155,<br>
+ 122, 250, 231, 86, 239, 76, 190, 120, 1, 94, 206, 8, 148, 159, 167, 215,<br>
+ 164, 31, 217, 61, 71, 125, 68, 109, 195, 177, 95, 82, 142, 182, 129, 87,<br>
+ 37, 140, 134, 186, 173, 39, 116, 143, 254, 229, 131, 67, 121, 192, 240,<br>
+ 15, 221, 30, 242, 185, 80, 170, 135, 51, 187, 194, 246, 12, 225, 181,<br>
+ 137, 211, 228, 88, 218, 27, 233, 161, 77, 252, 123, 93, 220, 248, 205,<br>
+ 223, 144, 128, 196, 70, 247, 210, 178, 203, 154, 24, 169, 149, 163, 35,<br>
+ 7, 151, 103, 197, 139, 165, 158, 207, 72, 113, 145, 45, 183, 11, 198,<br>
+ 43, 81, 230, 97, 96, 2, 66, 213, 146, 179, 22, 58, 54, 38, 160, 200,<br>
+ 235, 226, 156, 56, 208, 249, 32, 176, 168, 110, 191, 79, 152, 115, 10,<br>
+ 74, 60, 251, 17, 83, 180, 171, 202, 40, 166, 255, 53, 212, 98, 5, 50,<br>
+ 99, 4, 89, 13, 63, 6, 136, 153, 23, 16, 47, 130, 75, 62};<br>
+<br>
+ int ret;<br>
+ ret = seq_seed[i] % sysconf(_SC_NPROCESSORS_CONF);<br>
+ i++;<br>
+ i = i % 256;<br>
+ return ret;<br>
+}<br>
+<br>
+void lttng_ust_getcpu_plugin_init(void)<br>
+{<br>
+ int ret;<br>
+<br>
+ ret = lttng_ust_getcpu_override(plugin_getcpu);<br>
+ if (ret) {<br>
+ fprintf(stderr, "Error enabling getcpu override: %s\n",<br>
+ strerror(-ret));<br>
+ goto error;<br>
+ }<br>
+ return;<br>
+<br>
+error:<br>
+ exit(EXIT_FAILURE);<br>
+}<br>
diff --git a/tests/regression/ust/getcpu-override/run-getcpu-override b/tests/regression/ust/getcpu-override/run-getcpu-override<br>
new file mode 100755<br>
index 0000000..2e5d82b<br>
--- /dev/null<br>
+++ b/tests/regression/ust/getcpu-override/run-getcpu-override<br>
@@ -0,0 +1,13 @@<br>
+#!/bin/sh<br>
+<br>
+# launch with: run-getcpu-override progname args<br>
+DIR=$(dirname $0)<br>
+DIR=$(readlink -f $DIR)<br>
+<br>
+if [ -x "$DIR/.libs/lttng-ust-getcpu-override-test.so" ]; then<br>
+ ret=`LTTNG_UST_GETCPU_PLUGIN="$DIR/.libs/lttng-ust-getcpu-override-test.so" $@`<br>
+ exit $ret<br>
+else<br>
+ echo "Getcpu-override missing shared object"<br>
+ exit $1<br>
+fi<br>
diff --git a/tests/regression/ust/getcpu-override/test_getcpu_override b/tests/regression/ust/getcpu-override/test_getcpu_override<br>
new file mode 100755<br>
index 0000000..2492c9c<br>
--- /dev/null<br>
+++ b/tests/regression/ust/getcpu-override/test_getcpu_override<br>
@@ -0,0 +1,166 @@<br>
+#!/bin/bash<br>
+#<br>
+# Copyright (C) - 2015 Jonathan Rajotte <<a href="mailto:jonathan.rajotte-julien@efficios.com">jonathan.rajotte-julien@efficios.com</a>><br>
+#<br>
+# This library is free software; you can redistribute it and/or modify it under<br>
+# the terms of the GNU Lesser General Public License as published by the Free<br>
+# Software Foundation; version 2.1 of the License.<br>
+#<br>
+# This library is distributed in the hope that it will be useful, but WITHOUT<br>
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS<br>
+# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more<br>
+# details.<br>
+#<br>
+# You should have received a copy of the GNU Lesser General Public License<br>
+# along with this library; if not, write to the Free Software Foundation, Inc.,<br>
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA<br>
+TEST_DESC="UST - Getcpu override plugin"<br>
+<br>
+CURDIR=$(dirname $0)/<br>
+TESTDIR=$CURDIR/../../..<br>
+SESSION_NAME="sequence-cpu"<br>
+<br>
+TESTAPP_PATH="$TESTDIR/utils/testapp"<br>
+TESTAPP_NAME="gen-ust-events"<br>
+TESTAPP_BIN="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME"<br>
+TESTAPP_WRAPPER="run-getcpu-override"<br>
+NUM_EVENT=256<br>
+EVENT_NAME="tp:tptest"<br>
+<br>
+NUM_TESTS=20<br>
+<br>
+SEQUENCE_SEED=(<br>
+100 57 232 236 42 193 224 184 216 150 92 91 108 118 55 243 65 101 209 0 147 36<br>
+29 34 49 188 174 105 253 245 227 238 112 20 222 201 102 175 119 19 132 41 78 90<br>
+114 64 138 14 48 18 162 85 204 124 133 73 172 106 241 126 28 104 111 21 127 219<br>
+9 244 237 189 59 214 52 141 107 26 25 199 3 157 117 234 33 44 46 84 69 155 122<br>
+250 231 86 239 76 190 120 1 94 206 8 148 159 167 215 164 31 217 61 71 125 68 109<br>
+195 177 95 82 142 182 129 87 37 140 134 186 173 39 116 143 254 229 131 67 121<br>
+192 240 15 221 30 242 185 80 170 135 51 187 194 246 12 225 181 137 211 228 88<br>
+218 27 233 161 77 252 123 93 220 248 205 223 144 128 196 70 247 210 178 203 154<br>
+24 169 149 163 35 7 151 103 197 139 165 158 207 72 113 145 45 183 11 198 43 81<br>
+230 97 96 2 66 213 146 179 22 58 54 38 160 200 235 226 156 56 208 249 32 176 168<br>
+110 191 79 152 115 10 74 60 251 17 83 180 171 202 40 166 255 53 212 98 5 50 99 4<br>
+89 13 63 6 136 153 23 16 47 130 75 62<br>
+)<br>
+<br>
+# Equivalent to the syconf(_SC_NPROCESSORS_CONF) call.<br>
+NPROC=`nproc --all`<br>
+<br>
+source $TESTDIR/utils/utils.sh<br>
+<br>
+if [ ! -x "$CURDIR/.libs/lttng-ust-getcpu-override-test.so" ]; then<br>
+ BAIL_OUT "No shared object generated"<br>
+fi<br>
+<br>
+# MUST set TESTDIR before calling those functions<br>
+<br>
+run_app()<br>
+{<br>
+ diag "Launching app without getcpu-plugin wrapper"<br>
+ $TESTAPP_BIN $NUM_EVENT<br>
+ ok $? "Application without wrapper done"<br>
+}<br>
+<br>
+run_getcpu_plugin_app()<br>
+{<br>
+ diag "Launching app with getcpu-plugin wrapper"<br>
+ $CURDIR/$TESTAPP_WRAPPER $TESTAPP_BIN $NUM_EVENT<br>
+ ok $? "Application with wrapper done"<br>
+}<br>
+<br>
+compare_ok()<br>
+{<br>
+ compare 0 "$@"<br>
+}<br>
+<br>
+compare_fail()<br>
+{<br>
+ compare 1 "$@"<br>
+}<br>
+<br>
+compare()<br>
+{<br>
+ local expected_to_fail=$1<br>
+ declare -a array_to_compare=("${!2}")<br>
+ local valid=0<br>
+<br>
+ test ${#array_to_compare[*]} -eq ${#SEQUENCE_SEED[*]}<br>
+ ok $? "Sequence seed and cpuid sequence are equal ${#SEQUENCE_SEED[*]}/${#array_to_compare[*]}"<br>
+<br>
+ for (( i = 0; i < ${#SEQUENCE_SEED[*]}; i++ )); do<br>
+ if [ "${array_to_compare[$i]}" -ne "$(( ${SEQUENCE_SEED[$i]} % $NPROC))" ]; then<br>
+ valid=1<br>
+ break<br>
+ fi<br>
+ done<br>
+<br>
+ if [[ $expected_to_fail -eq "1" ]]; then<br>
+ test $valid -ne "0"<br>
+ ok $? "Cpuid extraction and seed sequence comparison fail as expected"<br>
+ else<br>
+ ok $valid "Cpuid extraction and seed sequence comparison"<br>
+ fi<br>
+}<br>
+<br>
+test_getcpu_override()<br>
+{<br>
+ diag "Getcpu plugin"<br>
+<br>
+ create_lttng_session_ok $SESSION_NAME $TRACE_PATH<br>
+ enable_ust_lttng_event_ok $SESSION_NAME "$EVENT_NAME"<br>
+ start_lttng_tracing_ok $SESSION_NAME<br>
+ run_app<br>
+ stop_lttng_tracing_ok $SESSION_NAME<br>
+ destroy_lttng_session_ok $SESSION_NAME<br>
+<br>
+ # Move output to an array by using =($())<br>
+ cpuid_events=($($BABELTRACE_BIN $TRACE_PATH | sed -n 's/.*cpu_id = \([0-9]*\).*/\1/p'))<br>
+ num_events=${#cpuid_events[*]}<br>
+ test $num_events -eq $NUM_EVENT<br>
+ ok $? "Extraction without getcpu plugin have $num_events/$NUM_EVENT"<br>
+ compare_fail cpuid_events[@]<br>
+<br>
+ create_lttng_session_ok $SESSION_NAME $TRACE_PATH<br>
+ enable_ust_lttng_event_ok $SESSION_NAME "$EVENT_NAME"<br>
+ start_lttng_tracing_ok $SESSION_NAME<br>
+ run_getcpu_plugin_app<br>
+ stop_lttng_tracing_ok $SESSION_NAME<br>
+ destroy_lttng_session_ok $SESSION_NAME<br>
+<br>
+ cpuid_events=($($BABELTRACE_BIN $TRACE_PATH | sed -n 's/.*cpu_id = \([0-9]*\).*/\1/p'))<br>
+ num_events=${#cpuid_events[*]}<br>
+ test $num_events -eq $NUM_EVENT<br>
+ ok $? "Extraction without getcpu plugin have $num_events/$NUM_EVENT"<br>
+<br>
+ compare_ok cpuid_events[@]<br>
+<br>
+ return $?<br>
+}<br>
+<br>
+plan_tests $NUM_TESTS<br>
+<br>
+print_test_banner "$TEST_DESC"<br>
+<br>
+TESTS=(<br>
+ "test_getcpu_override"<br>
+)<br>
+<br>
+TEST_COUNT=${#TESTS[@]}<br>
+i=0<br>
+<br>
+start_lttng_sessiond<br>
+<br>
+while [ "$i" -lt "$TEST_COUNT" ]; do<br>
+<br>
+ TRACE_PATH=$(mktemp -d)<br>
+<br>
+ # Execute test<br>
+ ${TESTS[$i]}<br>
+<br>
+ rm -rf $TRACE_PATH<br>
+<br>
+ let "i++"<br>
+done<br>
+<br>
+stop_lttng_sessiond<br>
<span class="HOEnZb"><font color="#888888">--<br>
2.1.4<br>
<br>
</font></span></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature">Jérémie Galarneau<br>EfficiOS Inc.<br><a href="http://www.efficios.com" target="_blank">http://www.efficios.com</a></div>
</div>