ret = stat(path, &buf);
if (ret == -1 && errno == ENOENT) {
if (file_exist) {
- (void) poll(NULL, 0, 10); /* 10 ms delay */
- continue; /* retry */
+ /*
+ * The file does not exist. wait a bit and
+ * continue looping until it does.
+ */
+ (void) poll(NULL, 0, 10);
+ continue;
}
- break; /* File does not exist */
+
+ /*
+ * File does not exist and the exit condition we want.
+ * Break from the loop and return.
+ */
+ break;
}
if (ret) {
perror("stat");
exit(EXIT_FAILURE);
}
- break; /* found */
+ /*
+ * stat() returned 0, so the file exists. break now only if
+ * that's the exit condition we want.
+ */
+ if (file_exist) {
+ break;
+ }
}
}
+static
int write_pipe(const char *path, uint8_t data)
{
int ret = 0;
return ret;
}
+static
int stop_consumer(const char **argv)
{
int ret = 0, i;
return ret;
}
+static
int resume_consumer(const char **argv)
{
int ret = 0, i;
return ret;
}
-int suspend_application()
+static
+int suspend_application(void)
{
int ret;
struct stat buf;
}
+static
int resume_application()
{
int ret;
}
+static
void test_triggers_buffer_usage_condition(const char *session_name,
const char *channel_name,
enum lttng_domain_type domain_type,
assert("Logic error for test vector generation");
}
- loop_ret = asprintf(&test_tuple_string, "session name %s, channel name %s, threshold ratio %s, threshold byte %s, domain type %s",
+ loop_ret = asprintf(&test_tuple_string, "session name %s, channel name %s, threshold ratio %s, threshold byte %s, domain type %s",
session_name_set ? "set" : "unset",
channel_name_set ? "set" : "unset",
threshold_ratio_set ? "set" : "unset",
* registered trigger fail.
*/
loop_ret = lttng_unregister_trigger(trigger);
- ok(loop_ret == -LTTNG_ERR_TRIGGER_NOT_FOUND, "Unregister of a non-registerd trigger fails as expected: %s", test_tuple_string);
+ ok(loop_ret == -LTTNG_ERR_TRIGGER_NOT_FOUND, "Unregister of a non-registered trigger fails as expected: %s", test_tuple_string);
} else {
ok(loop_ret == -LTTNG_ERR_INVALID_TRIGGER, "Trigger is invalid as expected and cannot be registered: %s", test_tuple_string);
}
} while (ret != 0);
}
+static
void test_notification_channel(const char *session_name, const char *channel_name, const enum lttng_domain_type domain_type, const char **argv)
{
int ret = 0;
lttng_start_tracing(session_name);
/* Wait for high notification */
- nc_status = lttng_notification_channel_get_next_notification(notification_channel, ¬ification);
+ do {
+ nc_status = lttng_notification_channel_get_next_notification(notification_channel, ¬ification);
+ } while (nc_status == LTTNG_NOTIFICATION_CHANNEL_STATUS_INTERRUPTED);
ok(nc_status == LTTNG_NOTIFICATION_CHANNEL_STATUS_OK
&& notification
&& lttng_condition_get_type(lttng_notification_get_condition(notification)) == LTTNG_CONDITION_TYPE_BUFFER_USAGE_HIGH,
nc_status = lttng_notification_channel_subscribe(notification_channel, low_condition);
ok(nc_status == LTTNG_NOTIFICATION_CHANNEL_STATUS_OK, "subscribe with pending notification");
- nc_status = lttng_notification_channel_get_next_notification(notification_channel, ¬ification);
+ do {
+ nc_status = lttng_notification_channel_get_next_notification(notification_channel, ¬ification);
+ } while (nc_status == LTTNG_NOTIFICATION_CHANNEL_STATUS_INTERRUPTED);
ok(nc_status == LTTNG_NOTIFICATION_CHANNEL_STATUS_OK
&& notification
&& lttng_condition_get_type(lttng_notification_get_condition(notification)) == LTTNG_CONDITION_TYPE_BUFFER_USAGE_LOW,
resume_application();
lttng_start_tracing(session_name);
- nc_status = lttng_notification_channel_get_next_notification(notification_channel, ¬ification);
+ do {
+ nc_status = lttng_notification_channel_get_next_notification(notification_channel, ¬ification);
+ } while (nc_status == LTTNG_NOTIFICATION_CHANNEL_STATUS_INTERRUPTED);
ok(nc_status == LTTNG_NOTIFICATION_CHANNEL_STATUS_OK && notification &&
lttng_condition_get_type(lttng_notification_get_condition(notification)) == LTTNG_CONDITION_TYPE_BUFFER_USAGE_HIGH,
"High notification received after intermediary communication");
resume_consumer(argv);
wait_data_pending(session_name);
- nc_status = lttng_notification_channel_get_next_notification(notification_channel, ¬ification);
+ do {
+ nc_status = lttng_notification_channel_get_next_notification(notification_channel, ¬ification);
+ } while (nc_status == LTTNG_NOTIFICATION_CHANNEL_STATUS_INTERRUPTED);
ok(nc_status == LTTNG_NOTIFICATION_CHANNEL_STATUS_OK && notification &&
lttng_condition_get_type(lttng_notification_get_condition(notification)) == LTTNG_CONDITION_TYPE_BUFFER_USAGE_LOW,
"Low notification received after re-subscription");
/* Stop consumer to force a high notification */
lttng_start_tracing(session_name);
- nc_status = lttng_notification_channel_get_next_notification(notification_channel, ¬ification);
+ do {
+ nc_status = lttng_notification_channel_get_next_notification(notification_channel, ¬ification);
+ } while (nc_status == LTTNG_NOTIFICATION_CHANNEL_STATUS_INTERRUPTED);
ok(nc_status == LTTNG_NOTIFICATION_CHANNEL_STATUS_OK && notification &&
lttng_condition_get_type(lttng_notification_get_condition(notification)) == LTTNG_CONDITION_TYPE_BUFFER_USAGE_HIGH,
"High notification");