sssd/0026-test-Check-ERR_LAST.patch

79 lines
2.6 KiB
Diff
Raw Normal View History

From c82b150d9599e212a71996d3f987f9b236833fe4 Mon Sep 17 00:00:00 2001
From: Michal Zidek <mzidek@redhat.com>
Date: Tue, 10 Mar 2015 18:38:10 +0100
Subject: [PATCH 26/99] test: Check ERR_LAST
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Check if number of error codes and messages is the same.
Reviewed-by: Lukáš Slebodník <lslebodn@redhat.com>
---
src/tests/util-tests.c | 10 ++++++++++
src/util/util_errors.c | 1 +
src/util/util_errors.h | 2 +-
3 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/src/tests/util-tests.c b/src/tests/util-tests.c
index 21eb02f14a7225ae9b9de4aa7f958b73f84a066d..7ee40dbca6b87b18c876caaa2a535b08d708415d 100644
--- a/src/tests/util-tests.c
+++ b/src/tests/util-tests.c
@@ -1050,6 +1050,12 @@ START_TEST(test_convert_time)
}
END_TEST
+START_TEST(test_sss_strerror_err_last)
+{
+ ck_assert_str_eq(sss_strerror(ERR_LAST), "ERR_LAST");
+}
+END_TEST
+
Suite *util_suite(void)
{
Suite *s = suite_create("util");
@@ -1102,11 +1108,15 @@ Suite *util_suite(void)
ck_leak_check_teardown);
tcase_add_test(tc_convert_time, test_convert_time);
+ TCase *tc_sss_strerror = tcase_create("sss_strerror");
+ tcase_add_test(tc_sss_strerror, test_sss_strerror_err_last);
+
suite_add_tcase (s, tc_util);
suite_add_tcase (s, tc_utf8);
suite_add_tcase (s, tc_mh3);
suite_add_tcase (s, tc_atomicio);
suite_add_tcase (s, tc_convert_time);
+ suite_add_tcase (s, tc_sss_strerror);
return s;
}
diff --git a/src/util/util_errors.c b/src/util/util_errors.c
index 180d2e713b3cefdfdaabd9b3acc736c2aeaccbdf..dad988bce2515c3614a19205f038053152916a16 100644
--- a/src/util/util_errors.c
+++ b/src/util/util_errors.c
@@ -69,6 +69,7 @@ struct err_string error_to_str[] = {
{ "Error setting SELinux user context" }, /* ERR_SELINUX_CONTEXT */
{ "Username format not allowed by re_expression" }, /* ERR_REGEX_NOMATCH */
{ "Time specification not supported" }, /* ERR_TIMESPEC_NOT_SUPPORTED */
+ { "ERR_LAST" } /* ERR_LAST */
};
diff --git a/src/util/util_errors.h b/src/util/util_errors.h
index 5ebce631d4520944b387d20028e4f32613c1d3a8..5d657c707dabc74cf5771af2b601500ba2664ee0 100644
--- a/src/util/util_errors.h
+++ b/src/util/util_errors.h
@@ -97,7 +97,7 @@ enum sssd_errors {
#define SSSD_ERR_BASE(err) ((err) & ~ERR_MASK)
#define SSSD_ERR_IDX(err) ((err) & ERR_MASK)
#define IS_SSSD_ERROR(err) \
- ((SSSD_ERR_BASE(err) == ERR_BASE) && ((err) < ERR_LAST))
+ ((SSSD_ERR_BASE(err) == ERR_BASE) && ((err) <= ERR_LAST))
#define ERR_OK 0
/* Backwards compat */
--
2.4.0