index bbb3a67fbe24d640029bef0f02cd7823f7bc2eac..6a2676a89e1d8ccee1cddc6735d2f5e7d9335ff7 100644 (file)
/**
/**
- * collectd - src/utils_vl_lookup_test.c
- * Copyright (C) 2012 Florian Forster
+ * collectd - src/tests/test_utils_vl_lookup.c
+ * Copyright (C) 2012 Florian Forster
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* Florian Forster <octo at collectd.org>
**/
* Florian Forster <octo at collectd.org>
**/
+#include "testing.h"
#include "collectd.h"
#include "utils_vl_lookup.h"
#include "collectd.h"
#include "utils_vl_lookup.h"
identifier_t *class = user_class;
identifier_t *obj = user_obj;
identifier_t *class = user_class;
identifier_t *obj = user_obj;
- assert (expect_new_obj == have_new_obj);
+ OK1(expect_new_obj == have_new_obj,
+ (expect_new_obj ? "New obj is created." : "Updating existing obj."));
memcpy (&last_class_ident, class, sizeof (last_class_ident));
memcpy (&last_obj_ident, obj, sizeof (last_obj_ident));
memcpy (&last_class_ident, class, sizeof (last_class_ident));
memcpy (&last_obj_ident, obj, sizeof (last_obj_ident));
identifier_t *class = user_class;
identifier_t *obj;
identifier_t *class = user_class;
identifier_t *obj;
- assert (expect_new_obj);
+ OK(expect_new_obj);
memcpy (&last_class_ident, class, sizeof (last_class_ident));
memcpy (&last_class_ident, class, sizeof (last_class_ident));
{
identifier_t ident;
void *user_class;
{
identifier_t ident;
void *user_class;
- int status;
memset (&ident, 0, sizeof (ident));
strncpy (ident.host, host, sizeof (ident.host));
memset (&ident, 0, sizeof (ident));
strncpy (ident.host, host, sizeof (ident.host));
user_class = malloc (sizeof (ident));
memmove (user_class, &ident, sizeof (ident));
user_class = malloc (sizeof (ident));
memmove (user_class, &ident, sizeof (ident));
- status = lookup_add (obj, &ident, group_by, user_class);
- assert (status == 0);
+ OK(lookup_add (obj, &ident, group_by, user_class) == 0);
} /* }}} void test_add */
static int checked_lookup_search (lookup_t *obj,
} /* }}} void test_add */
static int checked_lookup_search (lookup_t *obj,
lookup_obj_callback,
(void *) free,
(void *) free);
lookup_obj_callback,
(void *) free,
(void *) free);
- assert (obj != NULL);
+ OK(obj != NULL);
return (obj);
}
return (obj);
}
-static void testcase0 (void)
+DEF_TEST(group_by_specific_host)
{
lookup_t *obj = checked_lookup_create ();
{
lookup_t *obj = checked_lookup_create ();
/* expect new = */ 0);
lookup_destroy (obj);
/* expect new = */ 0);
lookup_destroy (obj);
+ return (0);
}
}
-static void testcase1 (void)
+DEF_TEST(group_by_any_host)
{
lookup_t *obj = checked_lookup_create ();
{
lookup_t *obj = checked_lookup_create ();
/* expect new = */ 0);
lookup_destroy (obj);
/* expect new = */ 0);
lookup_destroy (obj);
+ return (0);
}
}
-static void testcase2 (void)
+DEF_TEST(multiple_lookups)
{
lookup_t *obj = checked_lookup_create ();
int status;
{
lookup_t *obj = checked_lookup_create ();
int status;
assert (status == 2);
lookup_destroy (obj);
assert (status == 2);
lookup_destroy (obj);
+ return (0);
}
}
-static void testcase3 (void)
+DEF_TEST(regex)
{
lookup_t *obj = checked_lookup_create ();
{
lookup_t *obj = checked_lookup_create ();
/* expect new = */ 1);
lookup_destroy (obj);
/* expect new = */ 1);
lookup_destroy (obj);
+ return (0);
}
int main (int argc, char **argv) /* {{{ */
{
}
int main (int argc, char **argv) /* {{{ */
{
- testcase0 ();
- testcase1 ();
- testcase2 ();
- testcase3 ();
- return (EXIT_SUCCESS);
+ RUN_TEST(group_by_specific_host);
+ RUN_TEST(group_by_any_host);
+ RUN_TEST(multiple_lookups);
+ RUN_TEST(regex);
+
+ END_TEST;
} /* }}} int main */
} /* }}} int main */