test: setup logging during nmtst_init_assert_logging()

Before, when having a test with nmtst_init_assert_logging(),
the caller was expected to setup logging separately according
to the log level that the test asserts against.

Since 5e74891b58, the logging
level can be reset via NMTST_DEBUG also for tests that
assert logging. In this case, it would be useful, if the test
would not overwrite the logging level that is set externally
via NMTST_DEBUG.

Instead, let the test pass the logging configuration to
nmtst_init_assert_logging(), and nmtst will setup logging
-- either according to NMTST_DEBUG or as passed in.

This way, setting the log level works also for no-expect-message
tests:

  NMTST_DEBUG="debug,no-expect-message,log-level=TRACE" $TEST
This commit is contained in:
Thomas Haller
2015-03-26 13:03:58 +01:00
parent 07f95c371c
commit b6d3b98655
9 changed files with 29 additions and 17 deletions

View File

@@ -694,8 +694,7 @@ NMTST_DEFINE ();
int main (int argc, char **argv)
{
nmtst_init_assert_logging (&argc, &argv);
nm_logging_setup ("WARN", "DEFAULT", NULL, NULL);
nmtst_init_assert_logging (&argc, &argv, "WARN", "DEFAULT");
g_test_add_func ("/dhcp/generic-options", test_generic_options);
g_test_add_func ("/dhcp/wins-options", test_wins_options);

View File

@@ -276,7 +276,7 @@ NMTST_DEFINE ();
int main (int argc, char **argv)
{
nmtst_init_assert_logging (&argc, &argv);
nmtst_init_assert_logging (&argc, &argv, "INFO", "DEFAULT");
g_test_add_func (TPATH "ibft/dhcp", test_read_ibft_dhcp);
g_test_add_func (TPATH "ibft/static", test_read_ibft_static);

View File

@@ -121,7 +121,7 @@ int main (int argc, char **argv)
{
char *base;
nmtst_init_assert_logging (&argc, &argv);
nmtst_init_assert_logging (&argc, &argv, "INFO", "DEFAULT");
/* The tests */
test_get_ifcfg_name ("get-ifcfg-name-bad", "/foo/bar/adfasdfadf", FALSE, NULL);

View File

@@ -12443,7 +12443,7 @@ NMTST_DEFINE ();
int main (int argc, char **argv)
{
nmtst_init_assert_logging (&argc, &argv);
nmtst_init_assert_logging (&argc, &argv, "INFO", "DEFAULT");
g_test_add_func (TPATH "svUnescape", test_svUnescape);
g_test_add_func (TPATH "vlan-trailing-spaces", test_read_vlan_trailing_spaces);

View File

@@ -448,8 +448,7 @@ main (int argc, char **argv)
nm_linux_platform_setup ();
nmtst_init_assert_logging (&argc, &argv);
nm_logging_setup ("WARN", "DEFAULT", NULL, NULL);
nmtst_init_assert_logging (&argc, &argv, "WARN", "DEFAULT");
f = g_build_filename (argv[1], "net", NULL);
ifnet_init (f);

View File

@@ -3632,7 +3632,7 @@ NMTST_DEFINE ();
int main (int argc, char **argv)
{
nmtst_init_assert_logging (&argc, &argv);
nmtst_init_assert_logging (&argc, &argv, "INFO", "DEFAULT");
/* The tests */
g_test_add_func ("/keyfile/test_read_valid_wired_connection ", test_read_valid_wired_connection);

View File

@@ -292,7 +292,7 @@ NMTST_DEFINE ();
int
main (int argc, char **argv)
{
nmtst_init_assert_logging (&argc, &argv);
nmtst_init_assert_logging (&argc, &argv, "INFO", "DEFAULT");
/* Initialize the DBus manager singleton explicitly, because it is accessed by
* the class initializer of NMDevice (used by the NMTestDevice stub).

View File

@@ -338,9 +338,7 @@ NMTST_DEFINE ();
int
main (int argc, char **argv)
{
nmtst_init_assert_logging (&argc, &argv);
nm_logging_setup ("DEBUG", "DEFAULT", NULL, NULL);
nmtst_init_assert_logging (&argc, &argv, "DEBUG", "DEFAULT");
g_test_add_func ("/general/nm_utils_kill_child", test_nm_utils_kill_child);