]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
test: log error on failure
authorChristian Brauner <christian.brauner@ubuntu.com>
Wed, 17 Jan 2018 10:50:54 +0000 (11:50 +0100)
committerChristian Brauner <christian.brauner@ubuntu.com>
Fri, 19 Jan 2018 14:09:57 +0000 (15:09 +0100)
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/tests/lxc-test-utils.c

index 4c3c17a783419b1d3b01ba00704002d2ee44c21d..6f56ae675fad204b70a6e41e5ebffa7422222ee7 100644 (file)
@@ -386,38 +386,60 @@ void test_parse_byte_size_string(void)
        int64_t n;
 
        ret = parse_byte_size_string("0", &n);
-       if (ret < 0)
+       if (ret < 0) {
+               lxc_error("%s\n", "Failed to parse \"0\"");
                exit(EXIT_FAILURE);
-       if (n != 0)
+       }
+       if (n != 0) {
+               lxc_error("%s\n", "Failed to parse \"0\"");
                exit(EXIT_FAILURE);
+       }
 
        ret = parse_byte_size_string("1", &n);
-       if (ret < 0)
+       if (ret < 0) {
+               lxc_error("%s\n", "Failed to parse \"1\"");
                exit(EXIT_FAILURE);
-       if (n != 1)
+       }
+       if (n != 1) {
+               lxc_error("%s\n", "Failed to parse \"1\"");
                exit(EXIT_FAILURE);
+       }
 
        ret = parse_byte_size_string("1 ", &n);
-       if (ret == 0)
+       if (ret == 0) {
+               lxc_error("%s\n", "Failed to parse \"1 \"");
                exit(EXIT_FAILURE);
+       }
 
        ret = parse_byte_size_string("1B", &n);
-       if (ret < 0)
+       if (ret < 0) {
+               lxc_error("%s\n", "Failed to parse \"1B\"");
                exit(EXIT_FAILURE);
-       if (n != 1)
+       }
+       if (n != 1) {
+               lxc_error("%s\n", "Failed to parse \"1B\"");
                exit(EXIT_FAILURE);
+       }
 
        ret = parse_byte_size_string("1kB", &n);
-       if (ret < 0)
+       if (ret < 0) {
+               lxc_error("%s\n", "Failed to parse \"1kB\"");
                exit(EXIT_FAILURE);
-       if (n != 1024)
+       }
+       if (n != 1024) {
+               lxc_error("%s\n", "Failed to parse \"1kB\"");
                exit(EXIT_FAILURE);
+       }
 
        ret = parse_byte_size_string("1MB", &n);
-       if (ret < 0)
+       if (ret < 0) {
+               lxc_error("%s\n", "Failed to parse \"1MB\"");
                exit(EXIT_FAILURE);
-       if (n != 1048576)
+       }
+       if (n != 1048576) {
+               lxc_error("%s\n", "Failed to parse \"1MB\"");
                exit(EXIT_FAILURE);
+       }
 
        ret = parse_byte_size_string("1GB", &n);
        if (ret < 0)
@@ -426,26 +448,40 @@ void test_parse_byte_size_string(void)
                exit(EXIT_FAILURE);
 
        ret = parse_byte_size_string("1TB", &n);
-       if (ret == 0)
+       if (ret == 0) {
+               lxc_error("%s\n", "Failed to parse \"1TB\"");
                exit(EXIT_FAILURE);
+       }
 
        ret = parse_byte_size_string("1 B", &n);
-       if (ret < 0)
+       if (ret < 0) {
+               lxc_error("%s\n", "Failed to parse \"1 B\"");
                exit(EXIT_FAILURE);
-       if (n != 1)
+       }
+       if (n != 1) {
+               lxc_error("%s\n", "Failed to parse \"1 B\"");
                exit(EXIT_FAILURE);
+       }
 
        ret = parse_byte_size_string("1 kB", &n);
-       if (ret < 0)
+       if (ret < 0) {
+               lxc_error("%s\n", "Failed to parse \"1 kB\"");
                exit(EXIT_FAILURE);
-       if (n != 1024)
+       }
+       if (n != 1024) {
+               lxc_error("%s\n", "Failed to parse \"1 kB\"");
                exit(EXIT_FAILURE);
+       }
 
        ret = parse_byte_size_string("1 MB", &n);
-       if (ret < 0)
+       if (ret < 0) {
+               lxc_error("%s\n", "Failed to parse \"1 MB\"");
                exit(EXIT_FAILURE);
-       if (n != 1048576)
+       }
+       if (n != 1048576) {
+               lxc_error("%s\n", "Failed to parse \"1 MB\"");
                exit(EXIT_FAILURE);
+       }
 
        ret = parse_byte_size_string("1 GB", &n);
        if (ret < 0)
@@ -454,12 +490,16 @@ void test_parse_byte_size_string(void)
                exit(EXIT_FAILURE);
 
        ret = parse_byte_size_string("1 TB", &n);
-       if (ret == 0)
+       if (ret == 0) {
+               lxc_error("%s\n", "Failed to parse \"1 TB\"");
                exit(EXIT_FAILURE);
+       }
 
        ret = parse_byte_size_string("asdf", &n);
-       if (ret == 0)
+       if (ret == 0) {
+               lxc_error("%s\n", "Failed to parse \"asdf\"");
                exit(EXIT_FAILURE);
+       }
 }
 
 int main(int argc, char *argv[])