enum event_filter_node_op op, bool use_strcmp)
{
const struct event_field *field;
-
- /* wanted_field has the value in all available formats */
- field = event_find_field_recursive(event, wanted_field->key);
+ struct event_field duration;
+
+ if (strcmp(wanted_field->key, "duration") == 0) {
+ uintmax_t duration_value;
+ i_zero(&duration);
+ duration.key = "duration";
+ duration.value_type = EVENT_FIELD_VALUE_TYPE_INTMAX;
+ event_get_last_duration(event, &duration_value);
+ duration.value.intmax = (intmax_t)duration_value;
+ field = &duration;
+ } else {
+ /* wanted_field has the value in all available formats */
+ field = event_find_field_recursive(event, wanted_field->key);
+ }
if (field == NULL) {
/* field="" matches nonexistent field */
return wanted_field->value.str[0] == '\0';
test_end();
}
+static void test_event_filter_duration(void)
+{
+ struct event_filter *filter;
+ const char *error;
+ const struct failure_context failure_ctx = {
+ .type = LOG_TYPE_DEBUG
+ };
+
+ test_begin("event filter: event duration");
+
+ /* we check that we can actually match duration field */
+ filter = event_filter_create();
+ test_assert(event_filter_parse("duration < 1000", filter, &error) == 0);
+
+ struct event *e = event_create(NULL);
+ test_assert(event_filter_match(filter, e, &failure_ctx));
+
+ event_filter_unref(&filter);
+ event_unref(&e);
+ test_end();
+}
+
void test_event_filter(void)
{
test_event_filter_override_parent_fields();
test_event_filter_named_and_str();
test_event_filter_named_or_str();
test_event_filter_named_separate_from_str();
+ test_event_filter_duration();
}