Message ID | 20240111012650.9731-1-wegao@suse.com |
---|---|
State | Changes Requested |
Headers | show |
Series | [v1] Add TST_EXP_FAIL_PTR | expand |
Hi Wei, > Signed-off-by: Wei Gao <wegao@suse.com> > --- > include/tst_test_macros.h | 28 ++++++++++++++++++++++++++++ > 1 file changed, 28 insertions(+) > This is draft patch and should rebase after following patch merge. > https://patchwork.ozlabs.org/project/ltp/patch/20240103115700.14585-1-chrubis@suse.cz/ Patch was accepted, please rebase. Also, please add at least one test which uses it. Also, I wonder if we need TST_EXP_PASS_PTR(). > diff --git a/include/tst_test_macros.h b/include/tst_test_macros.h > index 3f4f9f11d..6e45e0b27 100644 > --- a/include/tst_test_macros.h > +++ b/include/tst_test_macros.h > @@ -212,6 +212,26 @@ extern void *TST_RET_PTR; > } \ > } while (0) > +#define TST_EXP_FAIL_SILENT_PTR_(SCALL, SSCALL, ERRNO, ...) \ > + do { \ > + TESTPTR(SCALL); \ > + \ > + TST_PASS = 0; \ > + \ > + if (TST_RET_PTR) { \ > + TST_MSG_(TFAIL, " succeeded", SSCALL, ##__VA_ARGS__); \ > + break; \ > + } \ > + \ > + if (TST_ERR == (ERRNO)) { \ > + TST_PASS = 1; \ > + } else { \ > + TST_MSGP_(TFAIL | TTERRNO, " expected %s", \ > + tst_strerrno(ERRNO), \ > + SSCALL, ##__VA_ARGS__); \ > + } \ Maybe follow the pattern of already used tests (break saves else clause)? if (TST_ERR != (ERRNO)) { \ TST_MSGP_(TFAIL | TTERRNO, " expected %s", \ tst_strerrno(ERRNO), \ SSCALL, ##__VA_ARGS__); \ break; \ } \ \ TST_PASS = 1; \ > + } while (0) > +
On Tue, Jan 16, 2024 at 06:49:26PM +0100, Petr Vorel wrote: > Hi Wei, > > > Signed-off-by: Wei Gao <wegao@suse.com> > > --- > > include/tst_test_macros.h | 28 ++++++++++++++++++++++++++++ > > 1 file changed, 28 insertions(+) > > > This is draft patch and should rebase after following patch merge. > > https://patchwork.ozlabs.org/project/ltp/patch/20240103115700.14585-1-chrubis@suse.cz/ > > Patch was accepted, please rebase. Also, please add at least one test which > uses it. > > Also, I wonder if we need TST_EXP_PASS_PTR(). Sure, i can create another patch for TST_EXP_PASS_PTR. > > > diff --git a/include/tst_test_macros.h b/include/tst_test_macros.h > > index 3f4f9f11d..6e45e0b27 100644 > > --- a/include/tst_test_macros.h > > +++ b/include/tst_test_macros.h > > @@ -212,6 +212,26 @@ extern void *TST_RET_PTR; > > } \ > > } while (0) > > > +#define TST_EXP_FAIL_SILENT_PTR_(SCALL, SSCALL, ERRNO, ...) \ > > + do { \ > > + TESTPTR(SCALL); \ > > + \ > > + TST_PASS = 0; \ > > + \ > > + if (TST_RET_PTR) { \ > > + TST_MSG_(TFAIL, " succeeded", SSCALL, ##__VA_ARGS__); \ > > + break; \ > > + } \ > > + \ > > + if (TST_ERR == (ERRNO)) { \ > > + TST_PASS = 1; \ > > + } else { \ > > + TST_MSGP_(TFAIL | TTERRNO, " expected %s", \ > > + tst_strerrno(ERRNO), \ > > + SSCALL, ##__VA_ARGS__); \ > > + } \ > > Maybe follow the pattern of already used tests (break saves else clause)? > if (TST_ERR != (ERRNO)) { \ > TST_MSGP_(TFAIL | TTERRNO, " expected %s", \ > tst_strerrno(ERRNO), \ > SSCALL, ##__VA_ARGS__); \ > break; \ > } \ > \ > TST_PASS = 1; \ > > > > + } while (0) > > +
diff --git a/include/tst_test_macros.h b/include/tst_test_macros.h index 3f4f9f11d..6e45e0b27 100644 --- a/include/tst_test_macros.h +++ b/include/tst_test_macros.h @@ -212,6 +212,26 @@ extern void *TST_RET_PTR; } \ } while (0) +#define TST_EXP_FAIL_SILENT_PTR_(SCALL, SSCALL, ERRNO, ...) \ + do { \ + TESTPTR(SCALL); \ + \ + TST_PASS = 0; \ + \ + if (TST_RET_PTR) { \ + TST_MSG_(TFAIL, " succeeded", SSCALL, ##__VA_ARGS__); \ + break; \ + } \ + \ + if (TST_ERR == (ERRNO)) { \ + TST_PASS = 1; \ + } else { \ + TST_MSGP_(TFAIL | TTERRNO, " expected %s", \ + tst_strerrno(ERRNO), \ + SSCALL, ##__VA_ARGS__); \ + } \ + } while (0) + #define TST_EXP_FAIL(SCALL, ERRNO, ...) \ do { \ TST_EXP_FAIL_SILENT_(TST_RET == 0, SCALL, #SCALL, \ @@ -228,6 +248,14 @@ extern void *TST_RET_PTR; TST_MSG_(TPASS | TTERRNO, " ", #SCALL, ##__VA_ARGS__); \ } while (0) +#define TST_EXP_FAIL_PTR(SCALL, ERRNO, ...) \ + do { \ + TST_EXP_FAIL_SILENT_PTR_(SCALL, #SCALL, \ + ERRNO, ##__VA_ARGS__); \ + if (TST_PASS) \ + TST_MSG_(TPASS | TTERRNO, " ", #SCALL, ##__VA_ARGS__); \ + } while (0) + #define TST_EXP_FAIL_SILENT(SCALL, ERRNO, ...) \ TST_EXP_FAIL_SILENT_(TST_RET == 0, SCALL, #SCALL, ERRNO, ##__VA_ARGS__)
Signed-off-by: Wei Gao <wegao@suse.com> --- include/tst_test_macros.h | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) This is draft patch and should rebase after following patch merge. https://patchwork.ozlabs.org/project/ltp/patch/20240103115700.14585-1-chrubis@suse.cz/