Re: Testing of non-exposed functions

Christian Grothoff <[email protected]> Wed, 5 Jun 2024 18:36:23 +0200
Newsgroups gmane.network.gnunet.devel
Message-ID <[email protected]>
On 6/5/24 11:57, Julius Bünger wrote:
> Hi all,
> 
> I have a question of secondary importance:
> 
> I recently asked the question whether we do unit tests in gnunet. Looking
> at the examples pointed to in reply, I realize that I probably didn't
> ask for what I meant. What I meant was:
> 
> Do we write tests for functions that are not exposed via API? And if so:
> How do we?

We so far never do, we only write unit tests against the exposed API. 
This has so far usually been more than enough, but also see below...

> The example at hand:
> I think the pattern matching function of GNUNET_DISK_glob() has a bug
> and I would like to test the pattern matching function without actually
> interacting with the file system, without calling GNUNET_DISK_glob().
> 
> If there's no proper way, I'll simply go ahead and expand the
> test_disk.c to cover GNUNET_DISK_glob() via the exposed API call.

Well, one thing you could do in this case is to expose the pattern 
matching function as part of the API, after all, the pattern matching 
logic itself could be useful to others as well.

My 2 cents

Christian