Em qua., 21 de jan. de 2026 às 12:57, Ján Tomko <[email protected]> escreveu:
>
> On a Monday in 2026, Julio Faracco wrote:
> >Add comprehensive test coverage for virSocketAddrFormatWithPrefix()
>
> Calling it comprehensive is quite an exaggeration, since it has no
> negative tests for IP addresses.
>
> >to verify its behavior by adding macros DO_TEST_PARSE_AND_FORMAT_WITH_PREFIX
> >and DO_TEST_PARSE_AND_CHECK_FORMAT_WITH_PREFIX and the respective
>
> No need to name the long macros here, the reader can see them in the
> commit itself.
>
> >testing function testFormatWithPrefixHelper.
>
> The function name is self-evident.
>
> >This commit also adds
> >some error handling for the unsupported AF_UNIX family.
> >
> >Signed-off-by: Julio Faracco <[email protected]>
> >---
> > tests/sockettest.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++
> > 1 file changed, 63 insertions(+)
> >
> >diff --git a/tests/sockettest.c b/tests/sockettest.c
> >index 5cb8a9fb72..9e185cc234 100644
> >--- a/tests/sockettest.c
> >+++ b/tests/sockettest.c
> >@@ -55,6 +55,22 @@ static int testFormat(virSocketAddr *addr, const char 
> >*addrstr, bool pass)
> >     }
> > }
> >
> >+static int testFormatWithPrefix(virSocketAddr *addr, const char *addrstr,
> >+                              unsigned int prefix, bool pass)
>
> There's a TAB in the indentation here that makes the syntax check fail.
>
> >+{
> >+    g_autofree char *newaddrstr = NULL;
> >+
> >+    newaddrstr = virSocketAddrFormatWithPrefix(addr, prefix);
> >+    if (!newaddrstr)
> >+        return pass ? -1 : 0;
> >+
> >+    if (virTestCompareToString(newaddrstr, addrstr) < 0) {
> >+        return pass ? -1 : 0;
> >+    } else {
> >+        return pass ? 0 : -1;
>
> This needs at least a VIR_TEST_DEBUG here, since virTestCompareToString
> does not log anything in case of success

I think I will include VIR_TEST_DEBUG for both cases (success and failure).
Sometimes you are expecting to test a failure as the argument @pass suggests.
Let me create a third patch, because testFormat() has a similar behavior.

>
> Jano
>
> >+    }
> >+}
> >+
> > struct testParseData {
> >     virSocketAddr *addr;
> >     const char *addrstr;

--
Julio

Reply via email to