tests: Ensure loc_database_lookup finds a match

Message ID 20250407012929.19255-1-valter.jansons@gmail.com
State Accepted
Commit c0898d1dc3d441119d5560df938aff68a19f9e48
Headers
Series tests: Ensure loc_database_lookup finds a match |

Commit Message

Valters Jansons April 7, 2025, 1:29 a.m. UTC
  Commit 9e72b8a modified the lookup function to return 0 even if no
matches are found. As result, the test case could pass even if the
database lookup did not find any matches.

This commit restores the original intent of the test case, by adding
a failure condition when `network1` is NULL. This is similar to how
the subsequent test case was modified for the inverse condition.
---
I was checking https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1021952
and wondering why the "Could not look up 2001:db8::" issue would
suddenly disappear. This change popped up as a potential reason.
So I am expecting hppa builds will start failing intermittently again.

 src/test-network.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Michael Tremer April 7, 2025, 10:10 a.m. UTC | #1
Hello Valters,

Thank you for this patch.

I have merged it. Indeed there should be no error returned, but the result pointer should be NULL. That was a change in the API but it should always have been like this.

On all the architectures that we are now testing on Jenkins, this is building just fine. I currently don’t build for hppa.

-Michael

> On 7 Apr 2025, at 02:29, Valters Jansons <valter.jansons@gmail.com> wrote:
> 
> Commit 9e72b8a modified the lookup function to return 0 even if no
> matches are found. As result, the test case could pass even if the
> database lookup did not find any matches.
> 
> This commit restores the original intent of the test case, by adding
> a failure condition when `network1` is NULL. This is similar to how
> the subsequent test case was modified for the inverse condition.
> ---
> I was checking https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1021952
> and wondering why the "Could not look up 2001:db8::" issue would
> suddenly disappear. This change popped up as a potential reason.
> So I am expecting hppa builds will start failing intermittently again.
> 
> src/test-network.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/test-network.c b/src/test-network.c
> index 0cac1a4..73062f4 100644
> --- a/src/test-network.c
> +++ b/src/test-network.c
> @@ -351,7 +351,7 @@ int main(int argc, char** argv) {
> 
> // Lookup an address in the subnet
> err = loc_database_lookup_from_string(db, "2001:db8::", &network1);
> - if (err) {
> + if (err || !network1) {
> fprintf(stderr, "Could not look up 2001:db8::\n");
> exit(EXIT_FAILURE);
> }
> -- 
> 2.49.0
> 
>
  

Patch

diff --git a/src/test-network.c b/src/test-network.c
index 0cac1a4..73062f4 100644
--- a/src/test-network.c
+++ b/src/test-network.c
@@ -351,7 +351,7 @@  int main(int argc, char** argv) {
 
 	// Lookup an address in the subnet
 	err = loc_database_lookup_from_string(db, "2001:db8::", &network1);
-	if (err) {
+	if (err || !network1) {
 		fprintf(stderr, "Could not look up 2001:db8::\n");
 		exit(EXIT_FAILURE);
 	}