[SSSD] [PATCH 1/2] test_expire: Use right assertion macro for standard functions

Lukas Slebodnik lslebodn at redhat.com
Wed Mar 25 16:09:48 UTC 2015


On (25/03/15 16:29), Pavel Reichl wrote:
>On 03/25/2015 03:21 PM, Lukas Slebodnik wrote:
>>ehlo,
>>
>>Documentation to macro assert_return_code says:
>>Assert that the return_code is greater than or equal to 0.
>>
>>The function prints an error message to standard error and terminates the
>>test by calling fail() if the return code is smaller than 0. If the function
>>you check sets an errno if it fails you can pass it to the function and
>>it will be printed as part of the error message.
>>
>>So in case of error we will see more verbose message.
>>
>>Simple patch is attached.
>>
>>LS
>>
>>0001-test_expire-Use-right-assertion-macro-for-standard-f.patch
>>
>>
>> From b4986e9f923bde9431aaaed24b3606f2ffb5470b Mon Sep 17 00:00:00 2001
>>From: Lukas Slebodnik<lslebodn at redhat.com>
>>Date: Wed, 25 Mar 2015 15:11:45 +0100
>>Subject: [PATCH 1/2] test_expire: Use right assertion macro for standard
>>  functions
>>
>>Documentation to macro assert_return_code says:
>>Assert that the return_code is greater than or equal to 0.
>>
>>The function prints an error message to standard error and terminates the
>>test by calling fail() if the return code is smaller than 0. If the function
>>you check sets an errno if it fails you can pass it to the function and
>>it will be printed as part of the error message.
>>
>>So in case of error we will see more verbose message.
>>---
>>  src/tests/cmocka/test_expire_common.c | 5 +++--
>>  1 file changed, 3 insertions(+), 2 deletions(-)
>>
>>diff --git a/src/tests/cmocka/test_expire_common.c b/src/tests/cmocka/test_expire_common.c
>>index 1698bd80e7c3bb992717906506533bb15e17944e..5d3ea02f3e5f0316cdf812368c361edc52459781 100644
>>--- a/src/tests/cmocka/test_expire_common.c
>>+++ b/src/tests/cmocka/test_expire_common.c
>>@@ -117,7 +117,8 @@ void expire_test_tz(const char* tz,
>>      if (tz) {
>>          ret = setenv("TZ", tz, 1);
>>-        assert_false(ret == -1);
>>+
>Is the new line added on purpose?
no,
Removed in updated patch.

LS
-------------- next part --------------
>From af1ecbe620fca3e6dcab0c9080530ac517864bb9 Mon Sep 17 00:00:00 2001
From: Lukas Slebodnik <lslebodn at redhat.com>
Date: Wed, 25 Mar 2015 15:11:45 +0100
Subject: [PATCH] test_expire: Use right assertion macro for standard functions

Documentation to macro assert_return_code says:
Assert that the return_code is greater than or equal to 0.

The function prints an error message to standard error and terminates the
test by calling fail() if the return code is smaller than 0. If the function
you check sets an errno if it fails you can pass it to the function and
it will be printed as part of the error message.

So in case of error we will see more verbose message.
---
 src/tests/cmocka/test_expire_common.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/tests/cmocka/test_expire_common.c b/src/tests/cmocka/test_expire_common.c
index 1698bd80e7c3bb992717906506533bb15e17944e..ad255a529e764228f128b5084ae2e379bc337cf4 100644
--- a/src/tests/cmocka/test_expire_common.c
+++ b/src/tests/cmocka/test_expire_common.c
@@ -117,7 +117,7 @@ void expire_test_tz(const char* tz,
 
     if (tz) {
         ret = setenv("TZ", tz, 1);
-        assert_false(ret == -1);
+        assert_return_code(ret, errno);
     }
 
     test_func(test_in, _test_out);
@@ -125,6 +125,6 @@ void expire_test_tz(const char* tz,
     /* restore */
     if (orig_tz != NULL) {
         ret = setenv("TZ", orig_tz, 1);
-        assert_false(ret == -1);
+        assert_return_code(ret, errno);
     }
 }
-- 
2.3.3



More information about the sssd-devel mailing list