diff options
author | Benjamin Dauvergne <bdauvergne@entrouvert.com> | 2011-12-10 12:56:34 +0100 |
---|---|---|
committer | Benjamin Dauvergne <bdauvergne@entrouvert.com> | 2011-12-16 11:39:18 +0100 |
commit | 65b94cc1f5b3d169647703950a707b4efc7c1f81 (patch) | |
tree | 77af95cb23fccc88bc8488925a1d13264ae0d3f5 /tests/basic_tests.c | |
parent | c3467ed48c979a0f2029207a79f8f4e4c78ea513 (diff) | |
download | lasso-65b94cc1f5b3d169647703950a707b4efc7c1f81.tar.gz lasso-65b94cc1f5b3d169647703950a707b4efc7c1f81.tar.xz lasso-65b94cc1f5b3d169647703950a707b4efc7c1f81.zip |
[tests] improve checking for log output
- now any non expected log output is considered an error, by setting a
g_log default handler.
- block_lasso_logs()/unblock_lasso_logs() will block logging output at
the DEBUG level
- begin_check_do_log(level, message, endswith)/end_check_do_log() with
check that the only message emitted between the two macros is one
equals to "message" at the level "level", or ending (to work around
variable parts in a log message) with "message" if "endswith" is True.
Diffstat (limited to 'tests/basic_tests.c')
-rw-r--r-- | tests/basic_tests.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/tests/basic_tests.c b/tests/basic_tests.c index cb96a3c4..406e93b4 100644 --- a/tests/basic_tests.c +++ b/tests/basic_tests.c @@ -51,7 +51,9 @@ END_TEST START_TEST(test02_server_load_dump_random_string) { LassoServer *serverContext; + begin_check_do_log(G_LOG_LEVEL_CRITICAL, "libxml2: Start tag expected, '<' not found\\n", FALSE); serverContext = lasso_server_new_from_dump("foo"); + end_check_do_log(); fail_unless(serverContext == NULL, "serverContext was created from a fake dump"); } @@ -60,7 +62,9 @@ END_TEST START_TEST(test03_server_load_dump_random_xml) { LassoServer *serverContext; + begin_check_do_log(G_LOG_LEVEL_CRITICAL, "(xml.c/:2307) Unable to build a LassoNode from a xmlNode", TRUE); serverContext = lasso_server_new_from_dump("<?xml version=\"1.0\"?><foo/>"); + end_check_do_log(); fail_unless(serverContext == NULL, "serverContext was created from fake (but valid XML) dump"); } @@ -156,7 +160,9 @@ START_TEST(test08_test_new_from_xmlNode) "LassoTest", &this_info, 0); r = lasso_registry_default_add_direct_mapping("http://example.com", "Test1", LASSO_LASSO_HREF, "LassoTest"); fail_unless(r == 0, "no mapping for http://example.com:Test1 should exist"); + begin_check_do_log(G_LOG_LEVEL_WARNING, " Class LassoTest has no node_data so no initialization is possible", TRUE); node = lasso_node_new_from_dump("<Test1 xmlns=\"http://example.com\"></Test1>"); + end_check_do_log(); fail_unless(node != NULL, "parsing <Test1/> should return an object"); fail_unless(strcmp(G_OBJECT_TYPE_NAME(node), "LassoTest") == 0, "node classname should be LassoTest"); g_object_unref(node); @@ -1960,11 +1966,13 @@ START_TEST(test13_test_lasso_server_load_metadata) TESTSDATADIR "/idp5-saml2/private-key.pem", NULL, /* Secret key to unlock private key */ NULL)); + block_lasso_logs; check_good_rc(lasso_server_load_metadata(server, LASSO_PROVIDER_ROLE_IDP, TESTSDATADIR "/metadata/renater-metadata.xml", TESTSDATADIR "/metadata/metadata-federation-renater.crt", &blacklisted_1, &loaded_entity_ids, LASSO_SERVER_LOAD_METADATA_FLAG_DEFAULT)); + unblock_lasso_logs; check_equals(g_hash_table_size(server->providers), 110); check_equals(g_list_length(loaded_entity_ids), 110); |