From 402912e0306eee275bdcb7945f71bc7e98979565 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Wed, 20 Jan 2021 16:40:30 +0000 Subject: [PATCH] Make `make check` work again Our CI isn't running the C unit tests because it goes via RPM, and while we could potentially add `%check` there...I don't quite want to do that right now since it also runs the Rust tests which means we rebuild all the Rust code again in debug mode etc. Change the C unit tests to compile in C++ mode, which is enough for local testing. Longer term I think the C unit tests will go away in favor of Rust tests. --- Makefile-tests.am | 18 +++++++++++------- tests/check/{jsonutil.c => jsonutil.cxx} | 0 tests/check/{postprocess.c => postprocess.cxx} | 0 .../{test-sysusers.c => test-sysusers.cxx} | 2 +- tests/check/{test-utils.c => test-utils.cxx} | 2 +- tests/common/{libtest.c => libtest.cxx} | 6 +++--- 6 files changed, 16 insertions(+), 12 deletions(-) rename tests/check/{jsonutil.c => jsonutil.cxx} (100%) rename tests/check/{postprocess.c => postprocess.cxx} (100%) rename tests/check/{test-sysusers.c => test-sysusers.cxx} (98%) rename tests/check/{test-utils.c => test-utils.cxx} (99%) rename tests/common/{libtest.c => libtest.cxx} (93%) diff --git a/Makefile-tests.am b/Makefile-tests.am index da77a529..b8b468ee 100644 --- a/Makefile-tests.am +++ b/Makefile-tests.am @@ -21,29 +21,33 @@ endif GITIGNOREFILES += ssh-config ansible-inventory.yml vmcheck-logs/ test-compose-logs/ tests/vmcheck/image.qcow2 testbin_cppflags = $(AM_CPPFLAGS) -I $(srcdir)/src/lib -I $(srcdir)/src/libpriv -I $(srcdir)/libglnx -I $(srcdir)/tests/common -testbin_cflags = $(AM_CFLAGS) $(rpmostree_bin_common_cflags) +testbin_cflags = $(AM_CXXFLAGS) $(rpmostree_bin_common_cflags) testbin_ldadd = librpmostreeinternals.la $(rpmostree_bin_common_libs) noinst_LTLIBRARIES += libtest.la -libtest_la_SOURCES = tests/common/libtest.c +libtest_la_SOURCES = tests/common/libtest.cxx libtest_la_CPPFLAGS = $(testbin_cppflags) -libtest_la_CFLAGS = $(testbin_cflags) +libtest_la_CXXFLAGS = $(testbin_cflags) libtest_la_LIBADD = $(testbin_ldadd) +tests_check_jsonutil_SOURCES = tests/check/jsonutil.cxx tests_check_jsonutil_CPPFLAGS = $(testbin_cppflags) -tests_check_jsonutil_CFLAGS = $(testbin_cflags) +tests_check_jsonutil_CXXFLAGS = $(testbin_cflags) tests_check_jsonutil_LDADD = $(testbin_ldadd) libtest.la +tests_check_postprocess_SOURCES = tests/check/postprocess.cxx tests_check_postprocess_CPPFLAGS = $(testbin_cppflags) -tests_check_postprocess_CFLAGS = $(testbin_cflags) +tests_check_postprocess_CXXFLAGS = $(testbin_cflags) tests_check_postprocess_LDADD = $(testbin_ldadd) libtest.la +tests_check_test_utils_SOURCES = tests/check/test-utils.cxx tests_check_test_utils_CPPFLAGS = $(testbin_cppflags) -tests_check_test_utils_CFLAGS = $(testbin_cflags) +tests_check_test_utils_CXXFLAGS = $(testbin_cflags) tests_check_test_utils_LDADD = $(testbin_ldadd) libtest.la +tests_check_test_sysusers_SOURCES = tests/check/test-sysusers.cxx tests_check_test_sysusers_CPPFLAGS = $(testbin_cppflags) -tests_check_test_sysusers_CFLAGS = $(testbin_cflags) +tests_check_test_sysusers_CXXFLAGS = $(testbin_cflags) tests_check_test_sysusers_LDADD = $(testbin_ldadd) libtest.la uninstalled_test_programs = \ diff --git a/tests/check/jsonutil.c b/tests/check/jsonutil.cxx similarity index 100% rename from tests/check/jsonutil.c rename to tests/check/jsonutil.cxx diff --git a/tests/check/postprocess.c b/tests/check/postprocess.cxx similarity index 100% rename from tests/check/postprocess.c rename to tests/check/postprocess.cxx diff --git a/tests/check/test-sysusers.c b/tests/check/test-sysusers.cxx similarity index 98% rename from tests/check/test-sysusers.c rename to tests/check/test-sysusers.cxx index b29137a3..a2edae26 100644 --- a/tests/check/test-sysusers.c +++ b/tests/check/test-sysusers.cxx @@ -60,7 +60,7 @@ verify_sysuser_ent_content (GPtrArray *sysusers_entries, for (int counter = 0; counter < sysusers_entries->len; counter++) { g_autofree gchar** sysent_list = g_strsplit (expected_content[counter], " ", -1); - struct sysuser_ent *sysuser_ent = sysusers_entries->pdata[counter]; + auto sysuser_ent = (struct sysuser_ent *)sysusers_entries->pdata[counter]; const char *shell = sysuser_ent->shell ?: "-"; const char *gecos = sysuser_ent->gecos ?: "-"; const char *dir = sysuser_ent->dir ?: "-"; diff --git a/tests/check/test-utils.c b/tests/check/test-utils.cxx similarity index 99% rename from tests/check/test-utils.c rename to tests/check/test-utils.cxx index d6ece897..322411c0 100644 --- a/tests/check/test-utils.c +++ b/tests/check/test-utils.cxx @@ -137,7 +137,7 @@ test_variant_to_nevra(void) glnx_autofd int foo_fd = -1; glnx_openat_rdonly (AT_FDCWD, foo_rpm, TRUE, &foo_fd, &error); g_assert_no_error (error); - importer = rpmostree_importer_new_take_fd (&foo_fd, repo, NULL, 0, NULL, &error); + importer = rpmostree_importer_new_take_fd (&foo_fd, repo, NULL, (RpmOstreeImporterFlags)0, NULL, &error); g_assert_no_error (error); g_assert (importer); diff --git a/tests/common/libtest.c b/tests/common/libtest.cxx similarity index 93% rename from tests/common/libtest.c rename to tests/common/libtest.cxx index 1c294157..1a0e25af 100644 --- a/tests/common/libtest.c +++ b/tests/common/libtest.cxx @@ -36,15 +36,15 @@ rot_test_run_libtest (const char *cmd, GError **error) g_autoptr(GPtrArray) argv = g_ptr_array_new (); g_autoptr(GString) cmdstr = g_string_new (""); - g_ptr_array_add (argv, "bash"); - g_ptr_array_add (argv, "-c"); + g_ptr_array_add (argv, (char*)"bash"); + g_ptr_array_add (argv, (char*)"-c"); g_string_append (cmdstr, "set -xeuo pipefail; . "); g_string_append (cmdstr, srcdir); g_string_append (cmdstr, "/tests/common/libtest.sh; "); g_string_append (cmdstr, cmd); - g_ptr_array_add (argv, cmdstr->str); + g_ptr_array_add (argv, (char*)cmdstr->str); g_ptr_array_add (argv, NULL); if (!g_spawn_sync (NULL, (char**)argv->pdata, NULL, G_SPAWN_SEARCH_PATH,