projects
/
lttng-tools.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
tests: Make test_per_application_leaks more robust
[lttng-tools.git]
/
tests
/
regression
/
tools
/
notification
/
base_client.c
diff --git
a/tests/regression/tools/notification/base_client.c
b/tests/regression/tools/notification/base_client.c
index bb12410e81f7ed971572e2dd3be1400826a9df72..1f7158aea34457782fb6a7e34005e88795f3b672 100644
(file)
--- a/
tests/regression/tools/notification/base_client.c
+++ b/
tests/regression/tools/notification/base_client.c
@@
-9,13
+9,6
@@
*
*/
*
*/
-#include <stdio.h>
-#include <stdbool.h>
-#include <string.h>
-#include <unistd.h>
-#include <inttypes.h>
-#include <assert.h>
-
#include <lttng/action/action.h>
#include <lttng/action/list.h>
#include <lttng/action/notify.h>
#include <lttng/action/action.h>
#include <lttng/action/list.h>
#include <lttng/action/notify.h>
@@
-24,10
+17,16
@@
#include <lttng/condition/evaluation.h>
#include <lttng/domain.h>
#include <lttng/endpoint.h>
#include <lttng/condition/evaluation.h>
#include <lttng/domain.h>
#include <lttng/endpoint.h>
+#include <lttng/lttng-error.h>
#include <lttng/notification/channel.h>
#include <lttng/notification/notification.h>
#include <lttng/trigger/trigger.h>
#include <lttng/notification/channel.h>
#include <lttng/notification/notification.h>
#include <lttng/trigger/trigger.h>
-#include <lttng/lttng-error.h>
+
+#include <inttypes.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
static unsigned int nr_notifications = 0;
static unsigned int nr_expected_notifications = 0;
static unsigned int nr_notifications = 0;
static unsigned int nr_expected_notifications = 0;
@@
-40,12
+39,10
@@
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;
static enum lttng_condition_type buffer_usage_type = LTTNG_CONDITION_TYPE_UNKNOWN;
static enum lttng_domain_type domain_type = LTTNG_DOMAIN_NONE;
-int handle_condition(
- const struct lttng_condition *condition,
- const struct lttng_evaluation *condition_evaluation);
+int handle_condition(const struct lttng_condition *condition,
+ const struct lttng_evaluation *condition_evaluation);
-static
-int parse_arguments(char **argv)
+static int parse_arguments(char **argv)
{
int sscanf_ret;
const char *domain_type_string = NULL;
{
int sscanf_ret;
const char *domain_type_string = NULL;
@@
-92,20
+89,29
@@
int parse_arguments(char **argv)
/* Ratio or bytes ? */
if (!strcasecmp("bytes", buffer_usage_threshold_type)) {
is_threshold_ratio = false;
/* Ratio or bytes ? */
if (!strcasecmp("bytes", buffer_usage_threshold_type)) {
is_threshold_ratio = false;
- sscanf(buffer_usage_threshold_value, "%" SCNu64, &threshold_bytes);
+ sscanf_ret = sscanf(buffer_usage_threshold_value, "%" SCNu64, &threshold_bytes);
+ if (sscanf_ret != 1) {
+ printf("error: Invalid buffer usage threshold value bytes (integer), sscanf returned %d\n",
+ sscanf_ret);
+ goto error;
+ }
}
if (!strcasecmp("ratio", buffer_usage_threshold_type)) {
is_threshold_ratio = true;
}
if (!strcasecmp("ratio", buffer_usage_threshold_type)) {
is_threshold_ratio = true;
- sscanf(buffer_usage_threshold_value, "%lf", &threshold_ratio);
+ sscanf_ret = sscanf(buffer_usage_threshold_value, "%lf", &threshold_ratio);
+ if (sscanf_ret != 1) {
+ printf("error: Invalid buffer usage threshold value ratio (float), sscanf returned %d\n",
+ sscanf_ret);
+ goto error;
+ }
}
/* Number of notification to expect */
}
/* Number of notification to expect */
- sscanf_ret = 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",
if (sscanf_ret != 1) {
printf("error: Invalid nr_expected_notifications, sscanf returned %d\n",
-
sscanf_ret);
+ sscanf_ret);
goto error;
}
goto error;
}
@@
-129,6
+135,7
@@
int main(int argc, char **argv)
struct lttng_condition *condition = NULL;
struct lttng_action *action = NULL;
struct lttng_trigger *trigger = NULL;
struct lttng_condition *condition = NULL;
struct lttng_action *action = NULL;
struct lttng_trigger *trigger = NULL;
+ enum lttng_error_code ret_code;
/*
* Disable buffering on stdout.
/*
* Disable buffering on stdout.
@@
-150,8
+157,8
@@
int main(int argc, char **argv)
}
/* Setup */
}
/* Setup */
- notification_channel =
lttng_notification_channel_create(
-
lttng_session_daemon_notification_endpoint);
+ notification_channel =
+
lttng_notification_channel_create(
lttng_session_daemon_notification_endpoint);
if (!notification_channel) {
printf("error: Could not create notification channel\n");
ret = 1;
if (!notification_channel) {
printf("error: Could not create notification channel\n");
ret = 1;
@@
-179,10
+186,10
@@
int main(int argc, char **argv)
if (is_threshold_ratio) {
condition_status = lttng_condition_buffer_usage_set_threshold_ratio(
if (is_threshold_ratio) {
condition_status = lttng_condition_buffer_usage_set_threshold_ratio(
-
condition, threshold_ratio);
+ condition, threshold_ratio);
} else {
} else {
- condition_status =
lttng_condition_buffer_usage_set_threshold(
-
condition, threshold_bytes);
+ condition_status =
+
lttng_condition_buffer_usage_set_threshold(
condition, threshold_bytes);
}
if (condition_status != LTTNG_CONDITION_STATUS_OK) {
}
if (condition_status != LTTNG_CONDITION_STATUS_OK) {
@@
-191,22
+198,19
@@
int main(int argc, char **argv)
goto end;
}
goto end;
}
- condition_status = lttng_condition_buffer_usage_set_session_name(
- condition, session_name);
+ condition_status = lttng_condition_buffer_usage_set_session_name(condition, session_name);
if (condition_status != LTTNG_CONDITION_STATUS_OK) {
printf("error: Could not set session name\n");
ret = 1;
goto end;
}
if (condition_status != LTTNG_CONDITION_STATUS_OK) {
printf("error: Could not set session name\n");
ret = 1;
goto end;
}
- condition_status = lttng_condition_buffer_usage_set_channel_name(
- condition, channel_name);
+ condition_status = lttng_condition_buffer_usage_set_channel_name(condition, channel_name);
if (condition_status != LTTNG_CONDITION_STATUS_OK) {
printf("error: Could not set channel name\n");
ret = 1;
goto end;
}
if (condition_status != LTTNG_CONDITION_STATUS_OK) {
printf("error: Could not set channel name\n");
ret = 1;
goto end;
}
- condition_status = lttng_condition_buffer_usage_set_domain_type(
- condition, domain_type);
+ condition_status = lttng_condition_buffer_usage_set_domain_type(condition, domain_type);
if (condition_status != LTTNG_CONDITION_STATUS_OK) {
printf("error: Could not set domain type\n");
ret = 1;
if (condition_status != LTTNG_CONDITION_STATUS_OK) {
printf("error: Could not set domain type\n");
ret = 1;
@@
-257,14
+261,14
@@
int main(int argc, char **argv)
goto end;
}
goto end;
}
- ret
= lttng_register_trigger
(trigger);
+ ret
_code = lttng_register_trigger_with_automatic_name
(trigger);
/*
* An equivalent trigger might already be registered if an other app
* registered an equivalent trigger.
*/
/*
* An equivalent trigger might already be registered if an other app
* registered an equivalent trigger.
*/
- if (ret
< 0 && ret != -
LTTNG_ERR_TRIGGER_EXISTS) {
- printf("error: %s\n", lttng_strerror(
ret
));
+ if (ret
_code != LTTNG_OK && ret_code !=
LTTNG_ERR_TRIGGER_EXISTS) {
+ printf("error: %s\n", lttng_strerror(
-ret_code
));
ret = 1;
goto end;
}
ret = 1;
goto end;
}
@@
-290,9
+294,8
@@
int main(int argc, char **argv)
goto end;
}
/* Receive the next notification. */
goto end;
}
/* Receive the next notification. */
- status = lttng_notification_channel_get_next_notification(
- notification_channel,
- ¬ification);
+ status = lttng_notification_channel_get_next_notification(notification_channel,
+ ¬ification);
switch (status) {
case LTTNG_NOTIFICATION_CHANNEL_STATUS_OK:
switch (status) {
case LTTNG_NOTIFICATION_CHANNEL_STATUS_OK:
@@
-343,9
+346,8
@@
end:
return ret;
}
return ret;
}
-int handle_condition(
- const struct lttng_condition *condition,
- const struct lttng_evaluation *evaluation)
+int handle_condition(const struct lttng_condition *condition,
+ const struct lttng_evaluation *evaluation)
{
int ret = 0;
const char *string_low = "low";
{
int ret = 0;
const char *string_low = "low";
@@
-367,22
+369,19
@@
int handle_condition(
}
/* Fetch info to test */
}
/* Fetch info to test */
- ret = lttng_condition_buffer_usage_get_session_name(condition,
- &condition_session_name);
+ ret = lttng_condition_buffer_usage_get_session_name(condition, &condition_session_name);
if (ret) {
printf("error: session name could not be fetched\n");
ret = 1;
goto end;
}
if (ret) {
printf("error: session name could not be fetched\n");
ret = 1;
goto end;
}
- ret = lttng_condition_buffer_usage_get_channel_name(condition,
- &condition_channel_name);
+ ret = lttng_condition_buffer_usage_get_channel_name(condition, &condition_channel_name);
if (ret) {
printf("error: channel name could not be fetched\n");
ret = 1;
goto end;
}
if (ret) {
printf("error: channel name could not be fetched\n");
ret = 1;
goto end;
}
- ret = lttng_condition_buffer_usage_get_domain_type(condition,
- &condition_domain_type);
+ ret = lttng_condition_buffer_usage_get_domain_type(condition, &condition_domain_type);
if (ret) {
printf("error: domain type could not be fetched\n");
ret = 1;
if (ret) {
printf("error: domain type could not be fetched\n");
ret = 1;
@@
-408,8
+407,7
@@
int handle_condition(
}
if (is_threshold_ratio) {
}
if (is_threshold_ratio) {
- lttng_evaluation_buffer_usage_get_usage_ratio(
- evaluation, &buffer_usage_ratio);
+ lttng_evaluation_buffer_usage_get_usage_ratio(evaluation, &buffer_usage_ratio);
switch (condition_type) {
case LTTNG_CONDITION_TYPE_BUFFER_USAGE_LOW:
if (buffer_usage_ratio > threshold_ratio) {
switch (condition_type) {
case LTTNG_CONDITION_TYPE_BUFFER_USAGE_LOW:
if (buffer_usage_ratio > threshold_ratio) {
@@
-431,8
+429,7
@@
int handle_condition(
goto end;
}
} else {
goto end;
}
} else {
- lttng_evaluation_buffer_usage_get_usage(
- evaluation, &buffer_usage_bytes);
+ lttng_evaluation_buffer_usage_get_usage(evaluation, &buffer_usage_bytes);
switch (condition_type) {
case LTTNG_CONDITION_TYPE_BUFFER_USAGE_LOW:
if (buffer_usage_bytes > threshold_bytes) {
switch (condition_type) {
case LTTNG_CONDITION_TYPE_BUFFER_USAGE_LOW:
if (buffer_usage_bytes > threshold_bytes) {
This page took
0.027566 seconds
and
4
git commands to generate.