X-Git-Url: https://git.octo.it/?p=collectd.git;a=blobdiff_plain;f=src%2Futils_mount_test.c;h=e8f3009423706622988853b351932d730941d463;hp=c084debe46381d54e6ffb95cff612e392930ced6;hb=d486225f89ea52d8ed2b4242eba2ad94c409f837;hpb=5236399c4c5483b1a9c21233e34b2b4357800d58 diff --git a/src/utils_mount_test.c b/src/utils_mount_test.c index c084debe..e8f30094 100644 --- a/src/utils_mount_test.c +++ b/src/utils_mount_test.c @@ -30,87 +30,86 @@ #include "testing.h" #include "utils_mount.h" +#if HAVE_KSTAT_H +#include +#endif + #if HAVE_LIBKSTAT kstat_ctl_t *kc; #endif /* HAVE_LIBKSTAT */ -DEF_TEST(cu_mount_checkoption) -{ +DEF_TEST(cu_mount_checkoption) { char line_opts[] = "foo=one,bar=two,qux=three"; - char *foo = strstr (line_opts, "foo"); - char *bar = strstr (line_opts, "bar"); - char *qux = strstr (line_opts, "qux"); + char *foo = strstr(line_opts, "foo"); + char *bar = strstr(line_opts, "bar"); + char *qux = strstr(line_opts, "qux"); char line_bool[] = "one,two,three"; - char *one = strstr (line_bool, "one"); - char *two = strstr (line_bool, "two"); - char *three = strstr (line_bool, "three"); + char *one = strstr(line_bool, "one"); + char *two = strstr(line_bool, "two"); + char *three = strstr(line_bool, "three"); /* Normal operation */ - OK (foo == cu_mount_checkoption (line_opts, "foo", 0)); - OK (bar == cu_mount_checkoption (line_opts, "bar", 0)); - OK (qux == cu_mount_checkoption (line_opts, "qux", 0)); - OK (NULL == cu_mount_checkoption (line_opts, "unknown", 0)); + OK(foo == cu_mount_checkoption(line_opts, "foo", 0)); + OK(bar == cu_mount_checkoption(line_opts, "bar", 0)); + OK(qux == cu_mount_checkoption(line_opts, "qux", 0)); + OK(NULL == cu_mount_checkoption(line_opts, "unknown", 0)); - OK (one == cu_mount_checkoption (line_bool, "one", 0)); - OK (two == cu_mount_checkoption (line_bool, "two", 0)); - OK (three == cu_mount_checkoption (line_bool, "three", 0)); - OK (NULL == cu_mount_checkoption (line_bool, "four", 0)); + OK(one == cu_mount_checkoption(line_bool, "one", 0)); + OK(two == cu_mount_checkoption(line_bool, "two", 0)); + OK(three == cu_mount_checkoption(line_bool, "three", 0)); + OK(NULL == cu_mount_checkoption(line_bool, "four", 0)); /* Shorter and longer parts */ - OK (foo == cu_mount_checkoption (line_opts, "fo", 0)); - OK (bar == cu_mount_checkoption (line_opts, "bar=", 0)); - OK (qux == cu_mount_checkoption (line_opts, "qux=thr", 0)); + OK(foo == cu_mount_checkoption(line_opts, "fo", 0)); + OK(bar == cu_mount_checkoption(line_opts, "bar=", 0)); + OK(qux == cu_mount_checkoption(line_opts, "qux=thr", 0)); - OK (one == cu_mount_checkoption (line_bool, "o", 0)); - OK (two == cu_mount_checkoption (line_bool, "tw", 0)); - OK (three == cu_mount_checkoption (line_bool, "thr", 0)); + OK(one == cu_mount_checkoption(line_bool, "o", 0)); + OK(two == cu_mount_checkoption(line_bool, "tw", 0)); + OK(three == cu_mount_checkoption(line_bool, "thr", 0)); /* "full" flag */ - OK (one == cu_mount_checkoption (line_bool, "one", 1)); - OK (two == cu_mount_checkoption (line_bool, "two", 1)); - OK (three == cu_mount_checkoption (line_bool, "three", 1)); - OK (NULL == cu_mount_checkoption (line_bool, "four", 1)); + OK(one == cu_mount_checkoption(line_bool, "one", 1)); + OK(two == cu_mount_checkoption(line_bool, "two", 1)); + OK(three == cu_mount_checkoption(line_bool, "three", 1)); + OK(NULL == cu_mount_checkoption(line_bool, "four", 1)); - OK (NULL == cu_mount_checkoption (line_bool, "o", 1)); - OK (NULL == cu_mount_checkoption (line_bool, "tw", 1)); - OK (NULL == cu_mount_checkoption (line_bool, "thr", 1)); + OK(NULL == cu_mount_checkoption(line_bool, "o", 1)); + OK(NULL == cu_mount_checkoption(line_bool, "tw", 1)); + OK(NULL == cu_mount_checkoption(line_bool, "thr", 1)); - return (0); + return 0; } -DEF_TEST(cu_mount_getoptionvalue) -{ +DEF_TEST(cu_mount_getoptionvalue) { char line_opts[] = "foo=one,bar=two,qux=three"; char line_bool[] = "one,two,three"; char *v; - EXPECT_EQ_STR ("one", v = cu_mount_getoptionvalue (line_opts, "foo=")); - sfree (v); - EXPECT_EQ_STR ("two", v = cu_mount_getoptionvalue (line_opts, "bar=")); - sfree (v); - EXPECT_EQ_STR ("three", v = cu_mount_getoptionvalue (line_opts, "qux=")); - sfree (v); - OK (NULL == (v = cu_mount_getoptionvalue (line_opts, "unknown="))); - sfree (v); - - EXPECT_EQ_STR ("", v = cu_mount_getoptionvalue (line_bool, "one")); - sfree (v); - EXPECT_EQ_STR ("", v = cu_mount_getoptionvalue (line_bool, "two")); - sfree (v); - EXPECT_EQ_STR ("", v = cu_mount_getoptionvalue (line_bool, "three")); - sfree (v); - OK (NULL == (v = cu_mount_getoptionvalue (line_bool, "four"))); - sfree (v); - - return (0); + EXPECT_EQ_STR("one", v = cu_mount_getoptionvalue(line_opts, "foo=")); + sfree(v); + EXPECT_EQ_STR("two", v = cu_mount_getoptionvalue(line_opts, "bar=")); + sfree(v); + EXPECT_EQ_STR("three", v = cu_mount_getoptionvalue(line_opts, "qux=")); + sfree(v); + OK(NULL == (v = cu_mount_getoptionvalue(line_opts, "unknown="))); + sfree(v); + + EXPECT_EQ_STR("", v = cu_mount_getoptionvalue(line_bool, "one")); + sfree(v); + EXPECT_EQ_STR("", v = cu_mount_getoptionvalue(line_bool, "two")); + sfree(v); + EXPECT_EQ_STR("", v = cu_mount_getoptionvalue(line_bool, "three")); + sfree(v); + OK(NULL == (v = cu_mount_getoptionvalue(line_bool, "four"))); + sfree(v); + + return 0; } -int main (void) -{ +int main(void) { RUN_TEST(cu_mount_checkoption); RUN_TEST(cu_mount_getoptionvalue); END_TEST; } - -/* vim: set sw=2 sts=2 et : */