X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=tests%2Fregression%2Ftools%2Fnotification%2Fbase_client.c;h=bb12410e81f7ed971572e2dd3be1400826a9df72;hb=ad63a966ae7a204528fa77599f92100d7341be7a;hp=fcef66c21a3f062c1a8c1b48c119a25b27ea5c9a;hpb=9d16b343fb9e781fc8d8fa3c448a3f382306dd33;p=lttng-tools.git diff --git a/tests/regression/tools/notification/base_client.c b/tests/regression/tools/notification/base_client.c index fcef66c21..bb12410e8 100644 --- a/tests/regression/tools/notification/base_client.c +++ b/tests/regression/tools/notification/base_client.c @@ -17,6 +17,7 @@ #include #include +#include #include #include #include @@ -35,6 +36,7 @@ static const char *channel_name = NULL; static double threshold_ratio = 0.0; static uint64_t threshold_bytes = 0; static bool is_threshold_ratio = false; +static bool use_action_list = false; static enum lttng_condition_type buffer_usage_type = LTTNG_CONDITION_TYPE_UNKNOWN; static enum lttng_domain_type domain_type = LTTNG_DOMAIN_NONE; @@ -42,12 +44,16 @@ int handle_condition( const struct lttng_condition *condition, const struct lttng_evaluation *condition_evaluation); -int parse_arguments(char **argv) { +static +int parse_arguments(char **argv) +{ + int sscanf_ret; const char *domain_type_string = NULL; const char *buffer_usage_type_string = NULL; const char *buffer_usage_threshold_type = NULL; const char *buffer_usage_threshold_value = NULL; const char *nr_expected_notifications_string = NULL; + const char *use_action_list_value = NULL; session_name = argv[1]; channel_name = argv[2]; @@ -56,6 +62,7 @@ int parse_arguments(char **argv) { buffer_usage_threshold_type = argv[5]; buffer_usage_threshold_value = argv[6]; nr_expected_notifications_string = argv[7]; + use_action_list_value = argv[8]; /* Parse arguments */ /* Domain type */ @@ -94,7 +101,18 @@ int parse_arguments(char **argv) { } /* Number of notification to expect */ - sscanf(nr_expected_notifications_string, "%d", &nr_expected_notifications); + sscanf_ret = sscanf(nr_expected_notifications_string, "%d", + &nr_expected_notifications); + if (sscanf_ret != 1) { + printf("error: Invalid nr_expected_notifications, sscanf returned %d\n", + sscanf_ret); + goto error; + } + + /* Put notify action in a group. */ + if (!strcasecmp("1", use_action_list_value)) { + use_action_list = true; + } return 0; error: @@ -105,6 +123,7 @@ int main(int argc, char **argv) { int ret = 0; enum lttng_condition_status condition_status; + enum lttng_action_status action_status; enum lttng_notification_channel_status nc_status; struct lttng_notification_channel *notification_channel = NULL; struct lttng_condition *condition = NULL; @@ -118,7 +137,7 @@ int main(int argc, char **argv) */ setbuf(stdout, NULL); - if (argc < 8) { + if (argc < 9) { printf("error: Missing arguments for tests\n"); ret = 1; goto end; @@ -194,11 +213,41 @@ int main(int argc, char **argv) goto end; } - action = lttng_action_notify_create(); - if (!action) { - printf("error: Could not create action notify\n"); - ret = 1; - goto end; + if (use_action_list) { + struct lttng_action *notify, *group; + + group = lttng_action_list_create(); + if (!group) { + printf("error: Could not create action list\n"); + ret = 1; + goto end; + } + + notify = lttng_action_notify_create(); + if (!notify) { + lttng_action_destroy(group); + printf("error: Could not create action notify\n"); + ret = 1; + goto end; + } + + action_status = lttng_action_list_add_action(group, notify); + if (action_status != LTTNG_ACTION_STATUS_OK) { + printf("error: Could not add action notify to action list\n"); + lttng_action_destroy(group); + lttng_action_destroy(notify); + ret = 1; + goto end; + } + + action = group; + } else { + action = lttng_action_notify_create(); + if (!action) { + printf("error: Could not create action notify\n"); + ret = 1; + goto end; + } } trigger = lttng_trigger_create(condition, action); @@ -263,7 +312,7 @@ int main(int argc, char **argv) goto end; default: /* Unhandled conditions / errors. */ - printf("error: Unknown notification channel status\n"); + printf("error: Unknown notification channel status (%d) \n", status); ret = 1; goto end; }