summaryrefslogtreecommitdiff
path: root/tests/vboxsnapshotxmltest.c
Commit message (Collapse)AuthorAgeFilesLines
* tests: Use virTestCompareToString() moreMichal Privoznik2022-12-011-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Instead of using: if (STRNEQ(a, b)) { virTestDifference(stderr, a, b); ... } we can use: if (virTestCompareToString(a, b) < ) { ... } Generated by the following spatch: @@ expression a, b; @@ - if (STRNEQ(a, b)) { + if (virTestCompareToString(a, b) < 0) { ... - virTestDifference(stderr, a, b); ... } and its variations (STRNEQ_NULLABLE() instead of STRNEQ(), then in some cases variables passed to STRNEQ() are in reversed order when compared to virTestCompareToString()). However, coccinelle failed to recognize the pattern in testNWFilterEBIPTablesAllTeardown() so I had to fix it manually. Also, I manually fixed testFormat() in tests/sockettest.c as I didn't bother writing another spatch rule just for that. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
* Remove empty cleanup sectionsJán Tomko2021-12-131-6/+2
| | | | | | | | | After recent cleanups, there are some pointless cleanup sections. Clean them up. Signed-off-by: Ján Tomko <jtomko@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
* Prefer g_auto(GStrv) over g_strfreev()Michal Privoznik2021-11-111-2/+1
| | | | | | | | | There are a few cases where a string list is freed by an explicit call of g_strfreev(), but the same result can be achieved by g_atuo(GStrv). Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Tim Wiederhake <twiederh@redhat.com>
* tests: use g_autofreeJán Tomko2021-09-091-8/+4
| | | | | Signed-off-by: Ján Tomko <jtomko@redhat.com> Reviewed-by: Laine Stump <laine@redhat.com>
* lib: Drop internal virXXXPtr typedefsMichal Privoznik2021-04-131-1/+1
| | | | | | | | | | | | | | | | | | | | | | Historically, we declared pointer type to our types: typedef struct _virXXX virXXX; typedef virXXX *virXXXPtr; But usefulness of such declaration is questionable, at best. Unfortunately, we can't drop every such declaration - we have to carry some over, because they are part of public API (e.g. virDomainPtr). But for internal types - we can do drop them and use what every other C project uses 'virXXX *'. This change was generated by a very ugly shell script that generated sed script which was then called over each file in the repository. For the shell script refer to the cover letter: https://listman.redhat.com/archives/libvir-list/2021-March/msg00537.html Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Peter Krempa <pkrempa@redhat.com>
* lib: Replace virFileMakePath() with g_mkdir_with_parents()Michal Privoznik2021-03-041-1/+1
| | | | | | | | | | | | | | | | | Generated using the following spatch: @@ expression path; @@ - virFileMakePath(path) + g_mkdir_with_parents(path, 0777) However, 14 occurrences were not replaced, e.g. in virHostdevManagerNew(). I don't really understand why. Fixed by hand afterwards. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
* Replace virStringSplit with g_strsplitPeter Krempa2021-02-111-1/+1
| | | | | | | | Our implementation was heavily inspired by the glib version so it's a drop-in replacement. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
* check for NULL before calling g_regex_unrefJán Tomko2020-09-081-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | g_regex_unref reports an error if called with a NULL argument. We have two cases in the code where we (possibly) call it on a NULL argument. The interesting one is in virDomainQemuMonitorEventCleanup. Based on VIR_CONNECT_DOMAIN_QEMU_MONITOR_EVENT_REGISTER_REGEX, we unref data->regex, which has two problems: * On the client side, flags is -1 so the comparison is true even if no regex was used, reproducible by: $ virsh qemu-monitor-event --timeout 1 which results in an ugly error: (process:1289846): GLib-CRITICAL **: 14:58:42.631: g_regex_unref: assertion 'regex != NULL' failed * On the server side, we only create the regex if both the flag and the string are present, so it's possible to trigger this message by: $ virsh qemu-monitor-event --regex --timeout 1 Use a non-NULL comparison instead of the flag to decide whether we need to unref the regex. And add a non-NULL check to the unref in the VirtualBox test too. Signed-off-by: Ján Tomko <jtomko@redhat.com> Fixes: 71efb59a4de7c51b1bc889a316f1796ebf55738f https://bugzilla.redhat.com/show_bug.cgi?id=1876907 Reviewed-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
* Use g_strfeev instead of virStringFreeListJán Tomko2020-08-031-1/+1
| | | | | | | | | Both accept a NULL value gracefully and virStringFreeList does not zero the pointer afterwards, so a straight replace is safe. Signed-off-by: Ján Tomko <jtomko@redhat.com> Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
* tests: use g_auto for all virBuffersLaine Stump2020-07-081-2/+1
| | | | | Signed-off-by: Laine Stump <laine@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
* Include unistd.h where usedJán Tomko2020-02-241-0/+2
| | | | | | | | Include unistd.h in all files that use it, instead of relying on it being pulled in via virutil.h Signed-off-by: Ján Tomko <jtomko@redhat.com> Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
* Add a space before ending a commentJán Tomko2020-01-301-1/+1
| | | | | | | Also add a space after the start in some of the cases. Signed-off-by: Ján Tomko <jtomko@redhat.com> Reviewed-by: Peter Krempa <pkrempa@redhat.com>
* tests: use GRegex in vboxsnapshotxmltestJán Tomko2019-11-141-12/+8
| | | | | Signed-off-by: Ján Tomko <jtomko@redhat.com> Reviewed-by: Peter Krempa <pkrempa@redhat.com>
* tests: Use g_strdup_printf() instead of virAsprintf()Michal Privoznik2019-11-121-3/+2
| | | | | Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
* util: buffer: Remove virBufferErrorPeter Krempa2019-10-241-5/+0
| | | | | | | The function now does not return an error so we can drop it fully. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
* tests: use g_strdup instead of VIR_STRDUPJán Tomko2019-10-211-3/+1
| | | | | | | | | | | Replace all occurrences of if (VIR_STRDUP(a, b) < 0) /* effectively dead code */ with: a = g_strdup(b); Signed-off-by: Ján Tomko <jtomko@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
* Revert "Include unistd.h directly by files using it"Peter Krempa2019-04-101-1/+0
| | | | | | | | | | This reverts commit a5e16020907e91bca1b0ab6c4ee5dbbdcccf6a54. Getting rid of unistd.h from our headers will require more work than just fixing the broken mingw build. Revert it until I have a more complete proposal. Signed-off-by: Peter Krempa <pkrempa@redhat.com>
* Include unistd.h directly by files using itPeter Krempa2019-04-101-0/+1
| | | | | | | | util/virutil.h bogously included unistd.h. Drop it and replace it by including it directly where needed. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
* src: More cleanup of some system headers already contained in internal.hErik Skultety2018-09-201-1/+0
| | | | | | | | | | | All of the ones being removed are pulled in by internal.h. The only exception is sanlock which expects the application to include <stdint.h> before sanlock's headers, because sanlock prototypes use fixed width int, but they don't include stdint.h themselves, so we have to leave that one in place. Signed-off-by: Erik Skultety <eskultet@redhat.com> Acked-by: Michal Privoznik <mprivozn@redhat.com>
* internal: Move <stdio.h> include to internal.hErik Skultety2018-09-201-1/+0
| | | | | | | | It doesn't really make sense for us to have stdlib.h and string.h but not stdio.h in the internal.h header. Signed-off-by: Erik Skultety <eskultet@redhat.com> Acked-by: Michal Privoznik <mprivozn@redhat.com>
* Remove backslash alignment attemptsAndrea Bolognani2017-11-031-3/+3
| | | | | | | | | | | | | | | | | | Right-aligning backslashes when defining macros or using complex commands in Makefiles looks cute, but as soon as any changes is required to the code you end up with either distractingly broken alignment or unnecessarily big diffs where most of the changes are just pushing all backslashes a few characters to one side. Generated using $ git grep -El '[[:blank:]][[:blank:]]\\$' | \ grep -E '*\.([chx]|am|mk)$$' | \ while read f; do \ sed -Ei 's/[[:blank:]]*[[:blank:]]\\$/ \\/g' "$f"; \ done Signed-off-by: Andrea Bolognani <abologna@redhat.com>
* tests: Rename VIRT_TEST_* macros to VIR_TEST_*Andrea Bolognani2017-04-041-1/+1
| | | | | | We use the "vir" prefix pretty consistently in our APIs, both external and internal, which made these macros stood out.
* virstring: Unify string list function namesMichal Privoznik2016-11-251-1/+1
| | | | | | | | | | | | | | | | | | | | | We have couple of functions that operate over NULL terminated lits of strings. However, our naming sucks: virStringJoin virStringFreeList virStringFreeListCount virStringArrayHasString virStringGetFirstWithPrefix We can do better: virStringListJoin virStringListFree virStringListFreeCount virStringListHasString virStringListGetFirstWithPrefix Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
* Rename virtTestLoadFile to virTestLoadFile.Tomáš Ryšavý2016-06-081-2/+2
| | | | This function doesn't follow our convention of naming functions.
* Rename virtTestDifference to virTestDifference.Tomáš Ryšavý2016-06-081-1/+1
| | | | This function doesn't follow our convention of naming functions.
* tests: Rename virtTestRun to virTestRun.Tomáš Ryšavý2016-06-081-2/+2
| | | | This function doesn't follow our convention of naming functions.
* vboxsnapshotxmltest: Don't write to a file in abs_srcdirMichal Privoznik2014-07-011-13/+16
| | | | | | | | | | | | | | In the test, the snapshot XML is written into a file that's located under: abs_srcdir/vboxsnapshotxmldata/testResult.vbox However, the abs_srcdir doesn't have to be necessarily writable. It should have been abs_builddir instead. Moreover, the label in the func creating the file is called 'fail' while it fulfils the duty of 'cleanup' label. Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
* Add vbox_snapshot_conf structYohan BELLEGUIC2014-06-101-0/+161
This structure contains the data to be saved in the VirtualBox XML file and can be manipulated with severals exposed functions. The structure is created by vboxSnapshotLoadVboxFile taking the machine XML file. It also can rewrite the XML by using vboxSnapshotSaveVboxFile.