> On Tue, Sep 16, 2025 at 02:35:55PM -0500, Nathan Bossart wrote:
> > On Thu, Sep 11, 2025 at 04:18:00PM -0500, Nathan Bossart wrote:
> >> I've committed 0001, and I plan to look closer at 0002 soon.
> >
> > I ended up rewriting 0002 as an ordinary regression test, which resulted in
> > a much smaller patch with comparable coverage. (Yes, it needs some
> > comments.) Thoughts?
>
> Sorry for the noise. I was able to simplify the test code further.
This is a trimmed down test suite, but it does cover quite a bit:
tranche name length, NULL tranche names, number of tranches registered,
tranche name lookup. Overall this is still good test coverage.
A few comments.
1/
startup tranches should be:
#define NUM_STARTUP_TRANCHES (2)
instead of:
#define NUM_STARTUP_TRANCHES (256 - 2)
2/
I do think we should add tests for LWLockInitialize to test error for
an unregistered tranche.
```
Datum
test_lwlock_tranche_initialize(PG_FUNCTION_ARGS)
{
LWLock lock;
LWLockInitialize(&lock, LWTRANCHE_FIRST_USER_DEFINED + PG_GETARG_INT32(0));
PG_RETURN_VOID();
}
```
and we can run this test as the first query, before we create any
dynamic tranches
```
SELECT test_lwlock_tranche_initialize(2);
```
The error message will change when a built-in tranche is added, so
the out file will need to be updated at that point, but that does not occur
too often.
--
Sami