Add low-throughput test
[lttng-tools.git] / tests / ust / low-throughput / main.c
... / ...
CommitLineData
1/*
2 * Copyright (C) 2012 - David Goulet <dgoulet@efficios.com>
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; version 2.1 of
7 * the License.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
19#include <poll.h>
20#include <pthread.h>
21#include <stdio.h>
22#include <stdlib.h>
23
24#define TRACEPOINT_DEFINE
25#include "tp.h"
26
27/*
28 * Thread recording a tracepoint every minute for 20 minutes.
29 */
30static void *th_event_minute(void *data)
31{
32 int i;
33
34 /* Loop for 20 minutes */
35 for (i = 1; i < 21; i++) {
36 /* Sleep 60 seconds */
37 poll(NULL, 0, 60000);
38
39 /* 20 minutes tracepoint */
40 if ((i % 20) == 0) {
41 tracepoint(tp, slow, i, "twenty");
42 printf("Twenty: %d\n", i);
43 }
44
45 /* 10 minutes tracepoint */
46 if ((i % 10) == 0) {
47 tracepoint(tp, slow, i, "ten");
48 printf("Ten: %d\n", i);
49 }
50
51 /* 1 minute tracepoint */
52 tracepoint(tp, slow, i, "one");
53 printf("One: %d\n", i);
54 }
55
56 return NULL;
57}
58
59/*
60 * main
61 */
62int main(int argc, char **argv)
63{
64 int ret;
65 void *status;
66 pthread_t thread;
67
68 ret = pthread_create(&thread, NULL, th_event_minute, NULL);
69 if (ret != 0) {
70 perror("pthread_create event minute");
71 goto error;
72 }
73
74 ret = pthread_join(thread, &status);
75 if (ret != 0) {
76 perror("pthread_join");
77 goto error;
78 }
79
80 return 0;
81
82error:
83 return 1;
84}
This page took 0.022459 seconds and 4 git commands to generate.