[PATCH 4/4] test: Make warnings fatal

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Since standard output is hidden by default while we run make check, it's
very easy to miss test cases emitting new warnings. This commit uses
g_log_set_fatal_mask() to ensure that the test cases will abort if a
warning is emitted while they run. This matches the behaviour of the
GTest  framework.
---
 test/test-db.c             | 3 +++
 test/test-device.c         | 3 +++
 test/test-devicelist.c     | 3 +++
 test/test-entity.c         | 3 +++
 test/test-filter.c         | 3 +++
 test/test-install-script.c | 3 +++
 test/test-isodetect.c      | 3 +++
 test/test-list.c           | 3 +++
 test/test-loader.c         | 3 +++
 test/test-mediauris.c      | 3 +++
 test/test-os.c             | 3 +++
 test/test-oslist.c         | 3 +++
 test/test-platform.c       | 3 +++
 test/test-platformlist.c   | 3 +++
 test/test-product.c        | 3 +++
 test/test-productfilter.c  | 3 +++
 test/test-treeuris.c       | 3 +++
 17 files changed, 51 insertions(+)

diff --git a/test/test-db.c b/test/test-db.c
index efb9fd4..31e80d1 100644
--- a/test/test-db.c
+++ b/test/test-db.c
@@ -422,6 +422,9 @@ int main(void)
     Suite *s = list_suite();
     SRunner *sr = srunner_create(s);
 
+    /* Make sure we catch unexpected g_warning() */
+    g_log_set_always_fatal(G_LOG_LEVEL_ERROR | G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING);
+
     /* Upfront so we don't confuse valgrind */
     osinfo_entity_get_type();
     osinfo_db_get_type();
diff --git a/test/test-device.c b/test/test-device.c
index a410e37..c7b2a82 100644
--- a/test/test-device.c
+++ b/test/test-device.c
@@ -55,6 +55,9 @@ int main(void)
     Suite *s = device_suite();
     SRunner *sr = srunner_create(s);
 
+    /* Make sure we catch unexpected g_warning() */
+    g_log_set_always_fatal(G_LOG_LEVEL_ERROR | G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING);
+
     /* Upfront so we don't confuse valgrind */
     osinfo_device_get_type();
 
diff --git a/test/test-devicelist.c b/test/test-devicelist.c
index f06efcd..b83d6ca 100644
--- a/test/test-devicelist.c
+++ b/test/test-devicelist.c
@@ -224,6 +224,9 @@ int main(void)
     Suite *s = list_suite();
     SRunner *sr = srunner_create(s);
 
+    /* Make sure we catch unexpected g_warning() */
+    g_log_set_always_fatal(G_LOG_LEVEL_ERROR | G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING);
+
     /* Upfront so we don't confuse valgrind */
     osinfo_device_get_type();
     osinfo_devicelist_get_type();
diff --git a/test/test-entity.c b/test/test-entity.c
index 3629e5b..68ecd95 100644
--- a/test/test-entity.c
+++ b/test/test-entity.c
@@ -335,6 +335,9 @@ int main(void)
     Suite *s = entity_suite();
     SRunner *sr = srunner_create(s);
 
+    /* Make sure we catch unexpected g_warning() */
+    g_log_set_always_fatal(G_LOG_LEVEL_ERROR | G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING);
+
     /* Upfront so we don't confuse valgrind */
     osinfo_dummy_get_type();
 
diff --git a/test/test-filter.c b/test/test-filter.c
index fc50357..7813325 100644
--- a/test/test-filter.c
+++ b/test/test-filter.c
@@ -172,6 +172,9 @@ int main(void)
     Suite *s = filter_suite();
     SRunner *sr = srunner_create(s);
 
+    /* Make sure we catch unexpected g_warning() */
+    g_log_set_always_fatal(G_LOG_LEVEL_ERROR | G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING);
+
     /* Upfront so we don't confuse valgrind */
     osinfo_device_get_type();
     osinfo_filter_get_type();
diff --git a/test/test-install-script.c b/test/test-install-script.c
index 08d7f76..338fc3b 100644
--- a/test/test-install-script.c
+++ b/test/test-install-script.c
@@ -327,6 +327,9 @@ int main(void)
     Suite *s = list_suite();
     SRunner *sr = srunner_create(s);
 
+    /* Make sure we catch unexpected g_warning() */
+    g_log_set_always_fatal(G_LOG_LEVEL_ERROR | G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING);
+
     /* Upfront so we don't confuse valgrind */
     osinfo_entity_get_type();
     osinfo_db_get_type();
diff --git a/test/test-isodetect.c b/test/test-isodetect.c
index 0ca00f9..a1d3ccc 100644
--- a/test/test-isodetect.c
+++ b/test/test-isodetect.c
@@ -481,6 +481,9 @@ int main(void)
     Suite *s = list_suite();
     SRunner *sr = srunner_create(s);
 
+    /* Make sure we catch unexpected g_warning() */
+    g_log_set_always_fatal(G_LOG_LEVEL_ERROR | G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING);
+
     /* Upfront so we don't confuse valgrind */
     osinfo_entity_get_type();
     osinfo_db_get_type();
diff --git a/test/test-list.c b/test/test-list.c
index 007c362..5480482 100644
--- a/test/test-list.c
+++ b/test/test-list.c
@@ -414,6 +414,9 @@ int main(void)
     Suite *s = list_suite();
     SRunner *sr = srunner_create(s);
 
+    /* Make sure we catch unexpected g_warning() */
+    g_log_set_always_fatal(G_LOG_LEVEL_ERROR | G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING);
+
     /* Upfront so we don't confuse valgrind */
     osinfo_dummy_get_type();
     osinfo_dummy_list_get_type();
diff --git a/test/test-loader.c b/test/test-loader.c
index 8f796d8..0b2a7da 100644
--- a/test/test-loader.c
+++ b/test/test-loader.c
@@ -55,6 +55,9 @@ int main(void)
     Suite *s = loader_suite();
     SRunner *sr = srunner_create(s);
 
+    /* Make sure we catch unexpected g_warning() */
+    g_log_set_always_fatal(G_LOG_LEVEL_ERROR | G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING);
+
     /* Upfront so we don't confuse valgrind */
     osinfo_entity_get_type();
     osinfo_db_get_type();
diff --git a/test/test-mediauris.c b/test/test-mediauris.c
index b73dcbc..ce7841c 100644
--- a/test/test-mediauris.c
+++ b/test/test-mediauris.c
@@ -125,6 +125,9 @@ int main(void)
     Suite *s = list_suite();
     SRunner *sr = srunner_create(s);
 
+    /* Make sure we catch unexpected g_warning() */
+    g_log_set_always_fatal(G_LOG_LEVEL_ERROR | G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING);
+
     if (!g_getenv("LIBOSINFO_NETWORK_TESTS"))
         return 77; /* Skip */
 
diff --git a/test/test-os.c b/test/test-os.c
index ad926cb..bae7f7e 100644
--- a/test/test-os.c
+++ b/test/test-os.c
@@ -216,6 +216,9 @@ int main(void)
     Suite *s = os_suite();
     SRunner *sr = srunner_create(s);
 
+    /* Make sure we catch unexpected g_warning() */
+    g_log_set_always_fatal(G_LOG_LEVEL_ERROR | G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING);
+
     /* Upfront so we don't confuse valgrind */
     osinfo_platform_get_type();
     osinfo_device_get_type();
diff --git a/test/test-oslist.c b/test/test-oslist.c
index 71d55a4..22ff83b 100644
--- a/test/test-oslist.c
+++ b/test/test-oslist.c
@@ -224,6 +224,9 @@ int main(void)
     Suite *s = list_suite();
     SRunner *sr = srunner_create(s);
 
+    /* Make sure we catch unexpected g_warning() */
+    g_log_set_always_fatal(G_LOG_LEVEL_ERROR | G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING);
+
     /* Upfront so we don't confuse valgrind */
     osinfo_os_get_type();
     osinfo_oslist_get_type();
diff --git a/test/test-platform.c b/test/test-platform.c
index 80b28db..8a49983 100644
--- a/test/test-platform.c
+++ b/test/test-platform.c
@@ -131,6 +131,9 @@ int main(void)
     Suite *s = platform_suite();
     SRunner *sr = srunner_create(s);
 
+    /* Make sure we catch unexpected g_warning() */
+    g_log_set_always_fatal(G_LOG_LEVEL_ERROR | G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING);
+
     /* Upfront so we don't confuse valgrind */
     osinfo_platform_get_type();
     osinfo_device_get_type();
diff --git a/test/test-platformlist.c b/test/test-platformlist.c
index ec53549..0310050 100644
--- a/test/test-platformlist.c
+++ b/test/test-platformlist.c
@@ -224,6 +224,9 @@ int main(void)
     Suite *s = list_suite();
     SRunner *sr = srunner_create(s);
 
+    /* Make sure we catch unexpected g_warning() */
+    g_log_set_always_fatal(G_LOG_LEVEL_ERROR | G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING);
+
     /* Upfront so we don't confuse valgrind */
     osinfo_platform_get_type();
     osinfo_platformlist_get_type();
diff --git a/test/test-product.c b/test/test-product.c
index 1e4e2d6..b03eac2 100644
--- a/test/test-product.c
+++ b/test/test-product.c
@@ -205,6 +205,9 @@ int main(void)
     Suite *s = product_suite();
     SRunner *sr = srunner_create(s);
 
+    /* Make sure we catch unexpected g_warning() */
+    g_log_set_always_fatal(G_LOG_LEVEL_ERROR | G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING);
+
     /* Upfront so we don't confuse valgrind */
     osinfo_platform_get_type();
     osinfo_device_get_type();
diff --git a/test/test-productfilter.c b/test/test-productfilter.c
index 8e1fed8..239e1a4 100644
--- a/test/test-productfilter.c
+++ b/test/test-productfilter.c
@@ -243,6 +243,9 @@ int main(void)
     Suite *s = productfilter_suite();
     SRunner *sr = srunner_create(s);
 
+    /* Make sure we catch unexpected g_warning() */
+    g_log_set_always_fatal(G_LOG_LEVEL_ERROR | G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING);
+
     /* Upfront so we don't confuse valgrind */
     osinfo_entity_get_type();
     osinfo_filter_get_type();
diff --git a/test/test-treeuris.c b/test/test-treeuris.c
index 0ddfe4f..3fe8b77 100644
--- a/test/test-treeuris.c
+++ b/test/test-treeuris.c
@@ -125,6 +125,9 @@ int main(void)
     Suite *s = list_suite();
     SRunner *sr = srunner_create(s);
 
+    /* Make sure we catch unexpected g_warning() */
+    g_log_set_always_fatal(G_LOG_LEVEL_ERROR | G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING);
+
     if (!g_getenv("LIBOSINFO_NETWORK_TESTS"))
         return 77; /* Skip */
 
-- 
2.7.4

_______________________________________________
Libosinfo mailing list
Libosinfo@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libosinfo



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Fedora Users]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]

  Powered by Linux