X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=tests%2Fregression%2Fust%2Flow-throughput%2Fmain.c;fp=tests%2Fregression%2Fust%2Flow-throughput%2Fmain.c;h=06ab9ef825ae20c6c73c08ae7d9091aa0dfceabe;hp=0000000000000000000000000000000000000000;hb=9ac429ef32142eaecfec2d1a44569464c4f8f721;hpb=785d2d0dc3aec3a4e44fcf677155dd07e8e4cc1f diff --git a/tests/regression/ust/low-throughput/main.c b/tests/regression/ust/low-throughput/main.c new file mode 100644 index 000000000..06ab9ef82 --- /dev/null +++ b/tests/regression/ust/low-throughput/main.c @@ -0,0 +1,81 @@ +/* + * Copyright (C) 2012 - David Goulet + * + * 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 +#include +#include +#include + +#define TRACEPOINT_DEFINE +#include "tp.h" + +/* + * Thread recording a tracepoint every minute for 20 minutes. + */ +static void *th_event_minute(void *data) +{ + int i; + + /* Loop for 20 minutes */ + for (i = 1; i < 21; i++) { + /* Sleep 60 seconds */ + poll(NULL, 0, 60000); + + /* 20 minutes tracepoint */ + if ((i % 20) == 0) { + tracepoint(tp, slow, i, "twenty"); + } + + /* 10 minutes tracepoint */ + if ((i % 10) == 0) { + tracepoint(tp, slow, i, "ten"); + } + + /* 1 minute tracepoint */ + tracepoint(tp, slow, i, "one"); + } + + return NULL; +} + +/* + * main + */ +int main(int argc, char **argv) +{ + int ret; + void *status; + pthread_t thread; + + ret = pthread_create(&thread, NULL, th_event_minute, NULL); + if (ret != 0) { + perror("pthread_create event minute"); + goto error; + } + + ret = pthread_join(thread, &status); + if (ret != 0) { + perror("pthread_join"); + goto error; + } + + return 0; + +error: + return 1; +}