2 * Copyright (C) 2012 David Goulet <dgoulet@efficios.com>
4 * SPDX-License-Identifier: LGPL-2.1-only
9 #include "signal-helper.hpp"
12 #include <arpa/inet.h>
20 #include <sys/types.h>
23 #define TRACEPOINT_DEFINE
26 static struct option long_options
[] = {
27 /* These options set a flag. */
28 { "iter", required_argument
, nullptr, 'i' },
29 { "wait", required_argument
, nullptr, 'w' },
30 { "create-in-main", required_argument
, nullptr, 'm' },
31 { "wait-before-first-event", required_argument
, nullptr, 'b' },
32 { nullptr, 0, nullptr, 0 }
35 int main(int argc
, char **argv
)
37 int i
, netint
, ret
= 0, option_index
, option
;
38 long values
[] = { 1, 2, 3 };
39 char text
[10] = "test";
42 unsigned int nr_iter
= 100;
43 useconds_t nr_usec
= 0;
44 char *wait_before_first_event_file_path
= nullptr;
45 char *create_in_main_file_path
= nullptr;
47 while ((option
= getopt_long(argc
, argv
, "i:w:b:m:", long_options
, &option_index
)) != -1) {
50 wait_before_first_event_file_path
= strdup(optarg
);
53 create_in_main_file_path
= strdup(optarg
);
56 nr_iter
= atoi(optarg
);
59 nr_usec
= atoi(optarg
);
62 /* getopt_long already printed an error message. */
69 if (set_signal_handler()) {
75 * The two following sync points allow for tests to do work after the
76 * app has started BUT before it generates any events.
78 if (create_in_main_file_path
) {
79 ret
= create_file(create_in_main_file_path
);
85 if (wait_before_first_event_file_path
) {
86 ret
= wait_on_file(wait_before_first_event_file_path
);
92 for (i
= 0; i
< nr_iter
; i
++) {
94 tracepoint(tp
, tptest1
, i
, netint
, values
, text
, strlen(text
), dbl
, flt
);
95 tracepoint(tp
, tptest2
, i
, netint
, values
, text
, strlen(text
), dbl
, flt
);
96 tracepoint(tp
, tptest3
, i
, netint
, values
, text
, strlen(text
), dbl
, flt
);
97 tracepoint(tp
, tptest4
, i
, netint
, values
, text
, strlen(text
), dbl
, flt
);
98 tracepoint(tp
, tptest5
, i
, netint
, values
, text
, strlen(text
), dbl
, flt
);
100 if (usleep_safe(nr_usec
)) {
111 free(create_in_main_file_path
);
112 free(wait_before_first_event_file_path
);
113 exit(!ret
? EXIT_SUCCESS
: EXIT_FAILURE
);