2 * Copyright (C) 2012 David Goulet <dgoulet@efficios.com>
4 * SPDX-License-Identifier: LGPL-2.1-only
17 #include <sys/types.h>
20 #include "signal-helper.h"
22 #define TRACEPOINT_DEFINE
25 static struct option long_options
[] =
27 /* These options set a flag. */
28 {"iter", required_argument
, 0, 'i'},
29 {"wait", required_argument
, 0, 'w'},
30 {"create-in-main", required_argument
, 0, 'm'},
31 {"wait-before-first-event", required_argument
, 0, 'b'},
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
= NULL
;
45 char *create_in_main_file_path
= NULL
;
47 while ((option
= getopt_long(argc
, argv
, "i:w:b:m:",
48 long_options
, &option_index
)) != -1) {
51 wait_before_first_event_file_path
= strdup(optarg
);
54 create_in_main_file_path
= strdup(optarg
);
57 nr_iter
= atoi(optarg
);
60 nr_usec
= atoi(optarg
);
63 /* getopt_long already printed an error message. */
70 if (set_signal_handler()) {
76 * The two following sync points allow for tests to do work after the
77 * app has started BUT before it generates any events.
79 if (create_in_main_file_path
) {
80 ret
= create_file(create_in_main_file_path
);
86 if (wait_before_first_event_file_path
) {
87 ret
= wait_on_file(wait_before_first_event_file_path
);
93 for (i
= 0; i
< nr_iter
; i
++) {
95 tracepoint(tp
, tptest1
, i
, netint
, values
, text
, strlen(text
),
97 tracepoint(tp
, tptest2
, i
, netint
, values
, text
, strlen(text
),
99 tracepoint(tp
, tptest3
, i
, netint
, values
, text
, strlen(text
),
101 tracepoint(tp
, tptest4
, i
, netint
, values
, text
, strlen(text
),
103 tracepoint(tp
, tptest5
, i
, netint
, values
, text
, strlen(text
),
106 if (usleep_safe(nr_usec
)) {
117 free(create_in_main_file_path
);
118 free(wait_before_first_event_file_path
);
119 exit(!ret
? EXIT_SUCCESS
: EXIT_FAILURE
);