]> git.ipfire.org Git - thirdparty/libvirt.git/commit
tests: Use virTestCompareToString() more
authorMichal Privoznik <mprivozn@redhat.com>
Wed, 30 Nov 2022 08:57:49 +0000 (09:57 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Thu, 1 Dec 2022 13:22:39 +0000 (14:22 +0100)
commita156b69c3578e20c5ebbd84c2f7ffbda4f243a1f
treea8002f5713fd6a97118945febb1fd62f56cf5b6f
parent1fffd1605df473183b64d6479edc2b2ca1fb57f1
tests: Use virTestCompareToString() more

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>
15 files changed:
tests/commandtest.c
tests/esxutilstest.c
tests/nwfilterebiptablestest.c
tests/openvzutilstest.c
tests/sockettest.c
tests/utiltest.c
tests/vboxsnapshotxmltest.c
tests/virbuftest.c
tests/virfirewalltest.c
tests/virjsontest.c
tests/virkmodtest.c
tests/virnetdevbandwidthtest.c
tests/virnetdevopenvswitchtest.c
tests/virnetsockettest.c
tests/virshtest.c