diff options
author | Jakub Hrozek <jhrozek@redhat.com> | 2014-04-15 15:29:44 +0200 |
---|---|---|
committer | Jakub Hrozek <jhrozek@redhat.com> | 2014-05-13 21:46:38 +0200 |
commit | 87729e3a6c56383642a8d3a86b2856487f2ee064 (patch) | |
tree | e70448d22bf0a7925736420e57793c654b7dcd3e /src/tests/sbus_tests.c | |
parent | 94f07a6f4375ec25d8fa5c99a0c4f68de7002457 (diff) | |
download | sssd-87729e3a6c56383642a8d3a86b2856487f2ee064.tar.gz sssd-87729e3a6c56383642a8d3a86b2856487f2ee064.tar.xz sssd-87729e3a6c56383642a8d3a86b2856487f2ee064.zip |
SBUS: Add a convenience function sbus_error_new
Adds a convenience function that constructs a DBusError on top of a talloc
context and as such can be used to mark an sbus request as failed without
having to create a DBusError instance by the caller.
Reviewed-by: Pavel Březina <pbrezina@redhat.com>
Reviewed-by: Stef Walter <stefw@redhat.com>
Diffstat (limited to 'src/tests/sbus_tests.c')
-rw-r--r-- | src/tests/sbus_tests.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/tests/sbus_tests.c b/src/tests/sbus_tests.c index 1a6354ab5..30b713530 100644 --- a/src/tests/sbus_tests.c +++ b/src/tests/sbus_tests.c @@ -326,6 +326,37 @@ START_TEST(test_introspection) } END_TEST +START_TEST(test_sbus_new_error) +{ + TALLOC_CTX *ctx; + DBusError *error; + + ctx = talloc_new(NULL); + + error = sbus_error_new(ctx, DBUS_ERROR_IO_ERROR, "Input-output error"); + ck_assert(error != NULL); + ck_assert(dbus_error_is_set(error)); + ck_assert(dbus_error_has_name(error, DBUS_ERROR_IO_ERROR)); + talloc_free(error); + + error = sbus_error_new(ctx, DBUS_ERROR_IO_ERROR, + "The answer should have been %d", 42); + ck_assert(error != NULL); + ck_assert(dbus_error_is_set(error)); + ck_assert(dbus_error_has_name(error, DBUS_ERROR_IO_ERROR)); + talloc_free(error); + + /* NULL message must also work */ + error = sbus_error_new(ctx, DBUS_ERROR_IO_ERROR, NULL); + ck_assert(error != NULL); + ck_assert(dbus_error_is_set(error)); + ck_assert(dbus_error_has_name(error, DBUS_ERROR_IO_ERROR)); + talloc_free(error); + + talloc_free(ctx); +} +END_TEST + TCase *create_sbus_tests(void) { TCase *tc = tcase_create("tests"); @@ -334,6 +365,7 @@ TCase *create_sbus_tests(void) tcase_add_test(tc, test_request_parse_ok); tcase_add_test(tc, test_request_parse_bad_args); tcase_add_test(tc, test_introspection); + tcase_add_test(tc, test_sbus_new_error); return tc; } |