X-Git-Url: http://git.efficios.com/?p=lttng-tools.git;a=blobdiff_plain;f=tests%2Fregression%2Fust%2Fgetcpu-override%2Flttng-ust-getcpu-override-test.c;h=c387063110e9f586be5b9d452dbecd24a3daf84c;hp=a5272e12b020e1ae5b403483c3922a1b5ab728c2;hb=refs%2Fheads%2Fsow-2019-0002-rev1;hpb=885fe3784604c1224637e803852c6a1e5a0993c6 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 index a5272e12b..c38706311 100644 --- a/tests/regression/ust/getcpu-override/lttng-ust-getcpu-override-test.c +++ b/tests/regression/ust/getcpu-override/lttng-ust-getcpu-override-test.c @@ -2,36 +2,23 @@ * lttng-ust-getcpu-override-test.c * Based on lttng-getcpu-override-example.c from LTTng-ust exemple * - * Copyright (c) 2014 Mathieu Desnoyers - * Copyright (c) 2015 Jonathan Rajotte + * Copyright (C) 2014 Mathieu Desnoyers + * Copyright (C) 2015 Jonathan Rajotte * - * 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: + * SPDX-License-Identifier: MIT * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. */ #include -#include +#include #include #include #include #include -int plugin_getcpu(void) +static long nprocessors; + +static int plugin_getcpu(void) { /* Generate a sequence based on the number of configurated processor * by using sequence[i] % nb_configured_processors. Where sequence @@ -63,16 +50,24 @@ int plugin_getcpu(void) 98, 5, 50, 99, 4, 89, 13, 63, 6, 136, 153, 23, 16, 47, 130, 75, 62 }; int ret; - ret = seq_seed[i] % sysconf(_SC_NPROCESSORS_CONF); + + ret = seq_seed[i] % nprocessors; i++; i = i % 256; return ret; } +void lttng_ust_getcpu_plugin_init(void); void lttng_ust_getcpu_plugin_init(void) { int ret; + nprocessors = sysconf(_SC_NPROCESSORS_CONF); + if (nprocessors < 0) { + perror("Failed to get _SC_NPROCESSORS_CONF"); + goto error; + } + ret = lttng_ust_getcpu_override(plugin_getcpu); if (ret) { fprintf(stderr, "Error enabling getcpu override: %s\n",