SoW-2019-0002: Dynamic Snapshot
[lttng-tools.git] / tests / utils / testapp / gen-ust-nevents / gen-ust-nevents.c
CommitLineData
ffb08a8c 1/*
9d16b343 2 * Copyright (C) 2012 David Goulet <dgoulet@efficios.com>
ffb08a8c 3 *
9d16b343 4 * SPDX-License-Identifier: LGPL-2.1-only
ffb08a8c 5 *
ffb08a8c
JD
6 */
7
70dac0d7 8#define _LGPL_SOURCE
ffb08a8c 9#include <arpa/inet.h>
1831ae68 10#include <getopt.h>
ffb08a8c
JD
11#include <stdarg.h>
12#include <stdio.h>
13#include <stdlib.h>
14#include <string.h>
15#include <sys/mman.h>
16#include <sys/stat.h>
17#include <sys/types.h>
18#include <unistd.h>
ae941114 19#include "utils.h"
95983a02 20#include "signal-helper.h"
ffb08a8c
JD
21
22#define TRACEPOINT_DEFINE
23#include "tp.h"
24
1831ae68
FD
25static struct option long_options[] =
26{
27 /* These options set a flag. */
28 {"iter", required_argument, 0, 'i'},
29 {"wait", required_argument, 0, 'w'},
30 {0, 0, 0, 0}
31};
32
ffb08a8c
JD
33int main(int argc, char **argv)
34{
1831ae68 35 int i, netint, ret = 0, option_index, option;
ffb08a8c
JD
36 long values[] = { 1, 2, 3 };
37 char text[10] = "test";
38 double dbl = 2.0;
39 float flt = 2222.0;
40 unsigned int nr_iter = 100;
41 useconds_t nr_usec = 0;
42
1831ae68
FD
43 while ((option = getopt_long(argc, argv, "i:w:",
44 long_options, &option_index)) != -1) {
45 switch (option) {
46 case 'i':
47 nr_iter = atoi(optarg);
48 break;
49 case 'w':
50 nr_usec = atoi(optarg);
51 break;
52 case '?':
53 /* getopt_long already printed an error message. */
54 break;
55 default:
56 ret = -1;
57 goto end;
58 }
59 }
60
95983a02
JG
61 if (set_signal_handler()) {
62 ret = -1;
63 goto end;
64 }
65
ffb08a8c
JD
66
67 for (i = 0; i < nr_iter; i++) {
68 netint = htonl(i);
69 tracepoint(tp, tptest1, i, netint, values, text, strlen(text),
70 dbl, flt);
71 tracepoint(tp, tptest2, i, netint, values, text, strlen(text),
72 dbl, flt);
73 tracepoint(tp, tptest3, i, netint, values, text, strlen(text),
74 dbl, flt);
75 tracepoint(tp, tptest4, i, netint, values, text, strlen(text),
76 dbl, flt);
77 tracepoint(tp, tptest5, i, netint, values, text, strlen(text),
78 dbl, flt);
ae941114
JG
79 if (nr_usec) {
80 if (usleep_safe(nr_usec)) {
81 ret = -1;
82 goto end;
83 }
84 }
95983a02
JG
85 if (should_quit) {
86 break;
87 }
ffb08a8c
JD
88 }
89
ae941114
JG
90end:
91 exit(!ret ? EXIT_SUCCESS : EXIT_FAILURE);
ffb08a8c 92}
This page took 0.057105 seconds and 5 git commands to generate.