[LTP] [PATCH v2 07/33] keyctl15: Test KEYCTL_GET_SECURITY label retrieval
Petr Vorel
pvorel@suse.cz
Fri Sep 11 11:11:10 CEST 2026
...
> > +static void run(void)
> > +{
> > + memset(buf, 0, sizeof(buf));
> > +
> > + TEST(keyctl(KEYCTL_GET_SECURITY, key, (unsigned long)buf, sizeof(buf), 0));
> > + if (TST_RET < 0)
> > + tst_brk(TBROK | TTERRNO, "KEYCTL_GET_SECURITY failed");
> > +
> TST_EXP_POSITIVE()?
Well, it would not help much because Andrea wanted to use tst_brk().
I've been thinking for a while to add TST_EXP_*_BRK() variants.
Therefore it would need to check the result anyway:
TST_EXP_POSITIVE(keyctl(KEYCTL_GET_SECURITY, key, (unsigned long)buf, sizeof(buf), 0));
if (TST_PASS)
tst_brk(TBROK | TTERRNO, "KEYCTL_GET_SECURITY failed");
(And I ignore that we don't have TST_EXP_POSITIVE_SILENT() and probably we don't
want to call TST_EXP_POSITIVE_() to make it quiet on TPASS).
Kind regards,
Petr
> > + if (TST_RET < 1) {
> > + tst_res(TFAIL, "returned %ld, expected at least 1", TST_RET);
> > + return;
> > + }
> > + if (TST_RET == 1) {
> > + if (buf[0] != '\0') {
> > + tst_res(TFAIL, "empty label is not NUL terminated");
> > + return;
> > + }
> > +
> > + tst_res(TPASS, "no label set, empty string returned");
> > + return;
> > + }
> Is the string supposed to be null terminated? Shouldn't we just check
> that the is null at the end regardless the length (we fail the test if <
> 1 either way)?
+1
Kind regards,
Petr
More information about the ltp
mailing list