Fix ordering issue with dependencies
Use glib2 suppression file when running valgrind tests Signed-off-by: Stephen Gallagher <sgallagh@redhat.com>
This commit is contained in:
parent
ac437b4983
commit
fbc6b4e257
230
0002-Always-sort-the-dependencies.patch
Normal file
230
0002-Always-sort-the-dependencies.patch
Normal file
@ -0,0 +1,230 @@
|
||||
From f8fd49a9aefffdaa24f6d4b24268ac3cd5f3d090 Mon Sep 17 00:00:00 2001
|
||||
From: Stephen Gallagher <sgallagh@redhat.com>
|
||||
Date: Mon, 7 Jan 2019 10:22:30 -0500
|
||||
Subject: [PATCH 2/3] Always sort the dependencies
|
||||
|
||||
This will make sure that the output is always consistent. This
|
||||
patch fixes both the ordering of the module names as well as the
|
||||
stream names.
|
||||
|
||||
Signed-off-by: Stephen Gallagher <sgallagh@redhat.com>
|
||||
---
|
||||
.../modulemd-2.0/private/modulemd-yaml.h | 30 ++++---
|
||||
modulemd/v2/modulemd-dependencies.c | 85 ++-----------------
|
||||
.../v2/tests/test-modulemd-modulestream.c | 14 +--
|
||||
3 files changed, 36 insertions(+), 93 deletions(-)
|
||||
|
||||
diff --git a/modulemd/v2/include/modulemd-2.0/private/modulemd-yaml.h b/modulemd/v2/include/modulemd-2.0/private/modulemd-yaml.h
|
||||
index e426fe6f1d9c43c7ad13420edc481eba46ae3fda..cca84590d6b29fe2f7d20fb91e7205fa21a38533 100644
|
||||
--- a/modulemd/v2/include/modulemd-2.0/private/modulemd-yaml.h
|
||||
+++ b/modulemd/v2/include/modulemd-2.0/private/modulemd-yaml.h
|
||||
@@ -655,12 +655,30 @@ skip_unknown_yaml (yaml_parser_t *parser, GError **error);
|
||||
MODULEMD_YAML_ERROR_EMIT, \
|
||||
"String set for key %s was empty on emit", \
|
||||
key); \
|
||||
return FALSE; \
|
||||
} \
|
||||
+ EMIT_STRING_SET_FULL ( \
|
||||
+ emitter, error, key, table, YAML_BLOCK_SEQUENCE_STYLE); \
|
||||
+ } \
|
||||
+ while (0)
|
||||
+
|
||||
+#define EMIT_STRING_SET_IF_NON_EMPTY(emitter, error, key, table) \
|
||||
+ do \
|
||||
+ { \
|
||||
+ if (NON_EMPTY_TABLE (table)) \
|
||||
+ { \
|
||||
+ EMIT_STRING_SET (emitter, error, key, table); \
|
||||
+ } \
|
||||
+ } \
|
||||
+ while (0)
|
||||
+
|
||||
+#define EMIT_STRING_SET_FULL(emitter, error, key, table, sequence_style) \
|
||||
+ do \
|
||||
+ { \
|
||||
EMIT_SCALAR (emitter, error, key); \
|
||||
- EMIT_SEQUENCE_START (emitter, error); \
|
||||
+ EMIT_SEQUENCE_START_WITH_STYLE (emitter, error, sequence_style); \
|
||||
gsize i; \
|
||||
g_autoptr (GPtrArray) keys = \
|
||||
modulemd_ordered_str_keys (table, modulemd_strcmp_sort); \
|
||||
for (i = 0; i < keys->len; i++) \
|
||||
{ \
|
||||
@@ -668,20 +686,10 @@ skip_unknown_yaml (yaml_parser_t *parser, GError **error);
|
||||
} \
|
||||
EMIT_SEQUENCE_END (emitter, error); \
|
||||
} \
|
||||
while (0)
|
||||
|
||||
-#define EMIT_STRING_SET_IF_NON_EMPTY(emitter, error, key, table) \
|
||||
- do \
|
||||
- { \
|
||||
- if (NON_EMPTY_TABLE (table)) \
|
||||
- { \
|
||||
- EMIT_STRING_SET (emitter, error, key, table); \
|
||||
- } \
|
||||
- } \
|
||||
- while (0)
|
||||
-
|
||||
#define EMIT_ARRAY_VALUES(emitter, error, key, array, emitfn) \
|
||||
do \
|
||||
{ \
|
||||
if (!NON_EMPTY_ARRAY (array)) \
|
||||
{ \
|
||||
diff --git a/modulemd/v2/modulemd-dependencies.c b/modulemd/v2/modulemd-dependencies.c
|
||||
index f71bebe9fbc852fa6df729ce80bd0e0375e023bd..ee918e02a87dfdee04a5a6af7dc96e949159a046 100644
|
||||
--- a/modulemd/v2/modulemd-dependencies.c
|
||||
+++ b/modulemd/v2/modulemd-dependencies.c
|
||||
@@ -470,73 +470,22 @@ modulemd_dependencies_parse_yaml (yaml_parser_t *parser,
|
||||
}
|
||||
return g_steal_pointer (&d);
|
||||
}
|
||||
|
||||
|
||||
-static gboolean
|
||||
-modulemd_dependencies_emit_yaml_nested_set_value (GHashTable *values,
|
||||
- yaml_emitter_t *emitter,
|
||||
- yaml_sequence_style_t style,
|
||||
- GError **error)
|
||||
-{
|
||||
- MODULEMD_INIT_TRACE ();
|
||||
- int ret;
|
||||
- g_autoptr (GError) nested_error = NULL;
|
||||
- MMD_INIT_YAML_EVENT (event);
|
||||
- GHashTableIter iter;
|
||||
- gpointer key;
|
||||
-
|
||||
- ret = mmd_emitter_start_sequence (emitter, style, &nested_error);
|
||||
- if (!ret)
|
||||
- {
|
||||
- g_propagate_prefixed_error (
|
||||
- error,
|
||||
- g_steal_pointer (&nested_error),
|
||||
- "Failed to start dependencies nested mapping values: ");
|
||||
- return FALSE;
|
||||
- }
|
||||
-
|
||||
- g_hash_table_iter_init (&iter, values);
|
||||
- while (g_hash_table_iter_next (&iter, &key, NULL))
|
||||
- {
|
||||
- ret = mmd_emitter_scalar (
|
||||
- emitter, (const gchar *)key, YAML_PLAIN_SCALAR_STYLE, &nested_error);
|
||||
- if (!ret)
|
||||
- {
|
||||
- g_propagate_prefixed_error (
|
||||
- error,
|
||||
- g_steal_pointer (&nested_error),
|
||||
- "Failed to start dependencies nested mapping entry: ");
|
||||
- return FALSE;
|
||||
- }
|
||||
- }
|
||||
-
|
||||
- ret = mmd_emitter_end_sequence (emitter, &nested_error);
|
||||
- if (!ret)
|
||||
- {
|
||||
- g_propagate_prefixed_error (
|
||||
- error,
|
||||
- g_steal_pointer (&nested_error),
|
||||
- "Failed to end dependencies nested mapping values: ");
|
||||
- return FALSE;
|
||||
- }
|
||||
-
|
||||
- return TRUE;
|
||||
-}
|
||||
-
|
||||
-
|
||||
static gboolean
|
||||
modulemd_dependencies_emit_yaml_nested_set (GHashTable *table,
|
||||
yaml_emitter_t *emitter,
|
||||
GError **error)
|
||||
{
|
||||
MODULEMD_INIT_TRACE ();
|
||||
int ret;
|
||||
g_autoptr (GError) nested_error = NULL;
|
||||
MMD_INIT_YAML_EVENT (event);
|
||||
- GHashTableIter iter;
|
||||
- gpointer key, value;
|
||||
+ g_autoptr (GPtrArray) keys = NULL;
|
||||
+ GHashTable *dep = NULL;
|
||||
+ gchar *key = NULL;
|
||||
|
||||
ret = mmd_emitter_start_mapping (
|
||||
emitter, YAML_BLOCK_MAPPING_STYLE, &nested_error);
|
||||
if (!ret)
|
||||
{
|
||||
@@ -545,34 +494,18 @@ modulemd_dependencies_emit_yaml_nested_set (GHashTable *table,
|
||||
g_steal_pointer (&nested_error),
|
||||
"Failed to start dependencies nested mapping: ");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
- g_hash_table_iter_init (&iter, table);
|
||||
- while (g_hash_table_iter_next (&iter, &key, &value))
|
||||
+ keys = modulemd_ordered_str_keys (table, modulemd_strcmp_sort);
|
||||
+ for (gint i = 0; i < keys->len; i++)
|
||||
{
|
||||
- ret = mmd_emitter_scalar (
|
||||
- emitter, (const gchar *)key, YAML_PLAIN_SCALAR_STYLE, &nested_error);
|
||||
- if (!ret)
|
||||
- {
|
||||
- g_propagate_prefixed_error (
|
||||
- error,
|
||||
- g_steal_pointer (&nested_error),
|
||||
- "Failed to emit dependencies nested key: ");
|
||||
- return FALSE;
|
||||
- }
|
||||
+ key = g_ptr_array_index (keys, i);
|
||||
+ dep = g_hash_table_lookup (table, key);
|
||||
|
||||
- ret = modulemd_dependencies_emit_yaml_nested_set_value (
|
||||
- (GHashTable *)value, emitter, YAML_FLOW_SEQUENCE_STYLE, &nested_error);
|
||||
- if (!ret)
|
||||
- {
|
||||
- g_propagate_prefixed_error (
|
||||
- error,
|
||||
- g_steal_pointer (&nested_error),
|
||||
- "Failed to emit dependencies nested sequence: ");
|
||||
- return FALSE;
|
||||
- }
|
||||
+ EMIT_STRING_SET_FULL (
|
||||
+ emitter, error, key, dep, YAML_FLOW_SEQUENCE_STYLE);
|
||||
}
|
||||
|
||||
ret = mmd_emitter_end_mapping (emitter, &nested_error);
|
||||
if (!ret)
|
||||
{
|
||||
diff --git a/modulemd/v2/tests/test-modulemd-modulestream.c b/modulemd/v2/tests/test-modulemd-modulestream.c
|
||||
index 8136b6ec626b3648339840c7cd667423c3ea1cc9..b68f4a650e15535d606aae031afc90a41bb4bcec 100644
|
||||
--- a/modulemd/v2/tests/test-modulemd-modulestream.c
|
||||
+++ b/modulemd/v2/tests/test-modulemd-modulestream.c
|
||||
@@ -308,19 +308,21 @@ module_stream_v2_test_parse_dump (ModuleStreamFixture *fixture,
|
||||
"Beerware\n - GPLv2+\n - zlib\n xmd:\n some_key: some_data\n "
|
||||
"dependencies:\n - buildrequires:\n platform: [-epel7, -f27, "
|
||||
"-f28]\n "
|
||||
" requires:\n platform: [-epel7, -f27, -f28]\n - buildrequires:\n "
|
||||
" "
|
||||
- "compatible: [v3]\n platform: [f27]\n buildtools: [v1, v2]\n "
|
||||
+ "buildtools: [v1, v2]\n compatible: [v3]\n platform: [f27]\n "
|
||||
"requires:\n compatible: [v3, v4]\n "
|
||||
"platform: [f27]\n - buildrequires:\n platform: [f28]\n "
|
||||
"requires:\n platform: [f28]\n runtime: [a, b]\n - "
|
||||
- "buildrequires:\n extras: []\n platform: [epel7]\n "
|
||||
- "moreextras: [foo, bar]\n "
|
||||
- "requires:\n extras: []\n platform: [epel7]\n "
|
||||
- "moreextras: [foo, bar]\n references:\n community: "
|
||||
- "http://www.example.com/\n documentation: http://www.example.com/\n "
|
||||
+ "buildrequires:\n extras: []\n moreextras: [bar, foo]\n "
|
||||
+ "platform: [epel7]\n "
|
||||
+ "requires:\n extras: []\n "
|
||||
+ "moreextras: [bar, foo]\n platform: [epel7]\n references:\n "
|
||||
+ "community: "
|
||||
+ "http://www.example.com/\n documentation: "
|
||||
+ "http://www.example.com/\n "
|
||||
"tracker: http://www.example.com/\n profiles:\n buildroot:\n "
|
||||
"rpms:\n - bar-devel\n container:\n rpms:\n - bar\n "
|
||||
" - bar-devel\n default:\n rpms:\n - bar\n - "
|
||||
"bar-extras\n - baz\n minimal:\n description: Minimal "
|
||||
"profile installing only the bar package.\n rpms:\n - bar\n "
|
||||
--
|
||||
2.20.1
|
||||
|
38
0003-Use-glib2-valgrind-suppression-file.patch
Normal file
38
0003-Use-glib2-valgrind-suppression-file.patch
Normal file
@ -0,0 +1,38 @@
|
||||
From 430fddbaae4c9e8ae8b3b43d9a792c71d93256dd Mon Sep 17 00:00:00 2001
|
||||
From: Stephen Gallagher <sgallagh@redhat.com>
|
||||
Date: Mon, 7 Jan 2019 14:46:30 -0500
|
||||
Subject: [PATCH 3/3] Use glib2 valgrind suppression file
|
||||
|
||||
Make sure to filter out known issues with glib2 so our tests don't
|
||||
fail for situations we cannot control (or may be false-positives).
|
||||
|
||||
Signed-off-by: Stephen Gallagher <sgallagh@redhat.com>
|
||||
---
|
||||
modulemd/common/tests/test-valgrind.py | 4 +++-
|
||||
1 file changed, 3 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/modulemd/common/tests/test-valgrind.py b/modulemd/common/tests/test-valgrind.py
|
||||
index 94bf6e0dc5b437751189b0f5ea2eb27660a13227..9f193207ceff1cc85b34ec2dd8fe19d21a5bfd73 100644
|
||||
--- a/modulemd/common/tests/test-valgrind.py
|
||||
+++ b/modulemd/common/tests/test-valgrind.py
|
||||
@@ -46,14 +46,16 @@ for test in unfiltered_tests:
|
||||
continue
|
||||
tests.append(test)
|
||||
|
||||
with tempfile.TemporaryDirectory(prefix="libmodulemd_valgrind_") as tmpdirname:
|
||||
for test in tests:
|
||||
+ # TODO: auto-detect the location of the suppression file
|
||||
valgrind_command = "/usr/bin/valgrind " \
|
||||
"--leak-check=full " \
|
||||
+ "--suppressions=/usr/share/glib-2.0/valgrind/glib.supp " \
|
||||
"--xml=yes " \
|
||||
- "--xml-file=%s/%s.xml" % (tmpdirname, test)
|
||||
+ "--xml-file=%s/%s.xml " % (tmpdirname, test)
|
||||
proc_result = subprocess.run(
|
||||
[
|
||||
'meson',
|
||||
'test',
|
||||
'-t', '10',
|
||||
--
|
||||
2.20.1
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
Name: libmodulemd
|
||||
Version: %{libmodulemd_version}
|
||||
Release: 2%{?dist}
|
||||
Release: 3%{?dist}
|
||||
Summary: Module metadata manipulation library
|
||||
|
||||
License: MIT
|
||||
@ -29,6 +29,8 @@ Obsoletes: python3-modulemd < 1.3.4
|
||||
|
||||
# Patches
|
||||
Patch0001: 0001-Include-modified-value-when-copying-Defaults-objects.patch
|
||||
Patch0002: 0002-Always-sort-the-dependencies.patch
|
||||
Patch0003: 0003-Use-glib2-valgrind-suppression-file.patch
|
||||
|
||||
%description
|
||||
C Library for manipulating module metadata files.
|
||||
@ -171,6 +173,10 @@ ln -s libmodulemd.so.%{libmodulemd_v1_version} \
|
||||
%{_datadir}/gtk-doc/html/modulemd-1.0/
|
||||
|
||||
%changelog
|
||||
* Fri Jan 11 2019 Stephen Gallagher <sgallagh@redhat.com> - 2.0.0-3
|
||||
- Fix ordering issue with dependencies
|
||||
- Use glib2 suppression file when running valgrind tests
|
||||
|
||||
* Fri Jan 11 2019 Stephen Gallagher <sgallagh@redhat.com> - 2.0.0-2
|
||||
- Fix issue reading modified value for defaults from YAML streams
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user