diff options
author | Thomas Haller <thaller@redhat.com> | 2017-03-02 14:03:39 +0100 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2017-03-02 14:10:50 +0100 |
commit | 24be1fd913887464e1ed0c0a523df7302140fc99 (patch) | |
tree | f4f5ea1bc392838fd1ffcdedae196af198cab01d /src/settings/plugins | |
parent | 670e088efec40ca5cc3432e347c5226c9fa7cffc (diff) | |
download | NetworkManager-24be1fd913887464e1ed0c0a523df7302140fc99.tar.gz |
ifcfg/trivial: rename svFileSetName() and svFileSetModified() to mark for testing
The filename of the shvarFile instance should be immutable and stay
unchanged for the entire lifetime of the instance. Similarly, the
modified flag should not be explicitly set.
However, for testing it is still useful to give the unit test a
direct access to those functions.
Rename the setters to make it clear that this is test-only.
Diffstat (limited to 'src/settings/plugins')
-rw-r--r-- | src/settings/plugins/ifcfg-rh/shvar.c | 8 | ||||
-rw-r--r-- | src/settings/plugins/ifcfg-rh/shvar.h | 4 | ||||
-rw-r--r-- | src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c | 4 |
3 files changed, 10 insertions, 6 deletions
diff --git a/src/settings/plugins/ifcfg-rh/shvar.c b/src/settings/plugins/ifcfg-rh/shvar.c index a058657932..d847ba73f0 100644 --- a/src/settings/plugins/ifcfg-rh/shvar.c +++ b/src/settings/plugins/ifcfg-rh/shvar.c @@ -637,15 +637,19 @@ svFileGetName (const shvarFile *s) } void -svFileSetName (shvarFile *s, const char *fileName) +svFileSetName_test_only (shvarFile *s, const char *fileName) { + /* changing the file name is not supported for regular + * operation. Only allowed to use in tests, othewise, + * the filename is immutable. */ g_free (s->fileName); s->fileName = g_strdup (fileName); } void -svFileSetModified (shvarFile *s) +svFileSetModified_test_only (shvarFile *s) { + /* marking a file as modified is only for testing. */ s->modified = TRUE; } diff --git a/src/settings/plugins/ifcfg-rh/shvar.h b/src/settings/plugins/ifcfg-rh/shvar.h index 5c384bb229..8eaf9b878e 100644 --- a/src/settings/plugins/ifcfg-rh/shvar.h +++ b/src/settings/plugins/ifcfg-rh/shvar.h @@ -34,9 +34,9 @@ typedef struct _shvarFile shvarFile; const char *svFileGetName (const shvarFile *s); -void svFileSetName (shvarFile *s, const char *fileName); -void svFileSetModified (shvarFile *s); +void svFileSetName_test_only (shvarFile *s, const char *fileName); +void svFileSetModified_test_only (shvarFile *s); /* Create the file <name>, return a shvarFile (never fails) */ shvarFile *svCreateFile (const char *name); diff --git a/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c b/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c index 58c50492db..bd6068ce15 100644 --- a/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c +++ b/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c @@ -8863,8 +8863,8 @@ test_write_unknown (gconstpointer test_data) sv = _svOpenFile (testfile); - svFileSetName (sv, filename_tmp_1); - svFileSetModified (sv); + svFileSetName_test_only (sv, filename_tmp_1); + svFileSetModified_test_only (sv); if (g_str_has_suffix (testfile, "ifcfg-test-write-unknown-4")) { _svGetValue_check (sv, "NAME", "l4x"); |