tests: Move to kernel style SPDX license identifiers
[lttng-tools.git] / tests / utils / testapp / gen-ust-nevents / gen-ust-nevents.c
1 /*
2 * Copyright (C) 2012 David Goulet <dgoulet@efficios.com>
3 *
4 * SPDX-License-Identifier: LGPL-2.1-only
5 *
6 */
7
8 #define _LGPL_SOURCE
9 #include <arpa/inet.h>
10 #include <stdarg.h>
11 #include <stdio.h>
12 #include <stdlib.h>
13 #include <string.h>
14 #include <sys/mman.h>
15 #include <sys/stat.h>
16 #include <sys/types.h>
17 #include <unistd.h>
18 #include "utils.h"
19 #include "signal-helper.h"
20
21 #define TRACEPOINT_DEFINE
22 #include "tp.h"
23
24 int main(int argc, char **argv)
25 {
26 int i, netint, ret = 0;
27 long values[] = { 1, 2, 3 };
28 char text[10] = "test";
29 double dbl = 2.0;
30 float flt = 2222.0;
31 unsigned int nr_iter = 100;
32 useconds_t nr_usec = 0;
33
34 if (set_signal_handler()) {
35 ret = -1;
36 goto end;
37 }
38
39 if (argc >= 2) {
40 nr_iter = atoi(argv[1]);
41 }
42
43 if (argc == 3) {
44 /* By default, don't wait unless user specifies. */
45 nr_usec = atoi(argv[2]);
46 }
47
48 for (i = 0; i < nr_iter; i++) {
49 netint = htonl(i);
50 tracepoint(tp, tptest1, i, netint, values, text, strlen(text),
51 dbl, flt);
52 tracepoint(tp, tptest2, i, netint, values, text, strlen(text),
53 dbl, flt);
54 tracepoint(tp, tptest3, i, netint, values, text, strlen(text),
55 dbl, flt);
56 tracepoint(tp, tptest4, i, netint, values, text, strlen(text),
57 dbl, flt);
58 tracepoint(tp, tptest5, i, netint, values, text, strlen(text),
59 dbl, flt);
60 if (nr_usec) {
61 if (usleep_safe(nr_usec)) {
62 ret = -1;
63 goto end;
64 }
65 }
66 if (should_quit) {
67 break;
68 }
69 }
70
71 end:
72 exit(!ret ? EXIT_SUCCESS : EXIT_FAILURE);
73 }
This page took 0.046033 seconds and 6 git commands to generate.