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.
This commit is contained in:
Colin Walters 2021-01-20 16:40:30 +00:00 committed by OpenShift Merge Robot
parent 70cfb765f6
commit 402912e030
6 changed files with 16 additions and 12 deletions

View File

@ -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 = \

View File

@ -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 ?: "-";

View File

@ -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);

View File

@ -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,