Hi!
> -struct test_case {
> +static struct test_case {
> + char *name;
> clockid_t clk_id;
> int ttype;
> int ret;
> int err;
> +} tcase[] = {
> + {"CLOCK_REALTIME", CLOCK_REALTIME, NORMAL, 0, 0,},
> + {"CLOCK_MONOTONIC", CLOCK_MONOTONIC, NORMAL, 0, 0,},
> + {"CLOCK_PROCESS_CPUTIME_ID", CLOCK_PROCESS_CPUTIME_ID, NORMAL, 0, 0,},
> + {"CLOCK_THREAD_CPUTIME_ID", CLOCK_THREAD_CPUTIME_ID, NORMAL, 0, 0,},
> + {"-1", -1, NORMAL, -1, EINVAL, },
> + {"CLOCK_REALTIME", CLOCK_REALTIME, NULL_POINTER, 0, 0,},
> };
Remove comas at the end of the list too.
> + for (i = 0; i < TST_TOTAL; ++i) {
> + if (tcase->ttype == NULL_POINTER)
> + TEST(clock_getres(tcase->clk_id, NULL));
> + else
> + TEST(clock_getres(tcase->clk_id, &res));
> +
> + if (TEST_RETURN != 0) {
> + if (TEST_ERRNO == EINVAL) {
> + tst_resm(TCONF, "clock_getres %s not "
> + "supported", tcase[i].name);
> + } else {
> + tst_resm(TFAIL, "clock_getres %s"
> + "failed", tcase[i].name);
> }
The tcase->ttype and tcase->clk_id is wrong, it should be tcase[i].ttype
and tcase[i].clk_id, otherwise you are testing only the first structure
from the tcase array again and again while the tst_resm() testcases
lists different clock id names.
Moreover you should check against expected return value and expected
errno, i.e. tcase[i].ret and tcase[i].err. And return TCONF only in case
that the expected return value is 0 (success) and is not and errno is
set to EINVAL.
Also do not abort the test on first failure, (i.e. remove the cleanup
and exit if returned value does not match the expected one).
--
Cyril Hrubis
[email protected]
------------------------------------------------------------------------------
November Webinars for C, C++, Fortran Developers
Accelerate application performance with scalable programming models. Explore
techniques for threading, error checking, porting, and tuning. Get the most
from the latest Intel processors and coprocessors. See abstracts and register
http://pubads.g.doubleclick.net/gampad/clk?id=60136231&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list