[LTP] [PATCH v2 1/1] syscalls/clock_getres01: convert to use new test library API

Cyril Hrubis chrubis@suse.cz
Tue Nov 15 17:08:44 CET 2016


Hi!
> +	TEST(clock_getres(tcase[i].clk_id, tcase[i].res));
> +
> +	if (TEST_RETURN != tcase[i].ret) {
> +		if (TEST_ERRNO != EINVAL) {
> +				tst_res(TFAIL | TTERRNO,
> +				 "clock_getres %s failed",
> +				 tcase[i].name);
                ^
		Fix the indentation here, (1 tab instead of two).

> +		} else {
> +				tst_res(TCONF,
> +				 "clock_getres %s NO SUPPORTED",
> +				 tcase[i].name);
> +		}

And we can simplify the code flow a bit as:


	if (TEST_RETURN != tcase[i].ret) {
		if (TEST_ERRNO == EINVAL) {
			tst_res(TCONF, ...);
			return;
		}

		tst_res(TFAIL ...);
		return;
	}


	if (TEST_ERRNO != tcase[i].err) {
		tst_res(TFAIL, ...);
		return;
	}

	tst_res(TPASS, ...);


> +	} else {
> +		if (TEST_ERRNO != tcase[i].err) {
> +				tst_res(TFAIL,
> +				 "clock_getres %s failed with "
> +				 "unexpect errno: %d",
> +				 tcase[i].name, TEST_ERRNO);
                                     ^

				 This message should print what errno we
				 got and what was the expected one, it
				 should be something as:


				 tst_res(TFAIL | TTERRNO,
				         "clock_getres(%s, ...) failed unexpectedly, expected %s",
					 tcase[i].name, tst_strerrno(tcase[i].err));

> +		} else {
> +				tst_res(TPASS,
> +				 "clock_getres %s succeeded",
> +				 tcase[i].name);
>  		}
>  	}
> -
> -	cleanup();
> -	tst_exit();
> -}
> -
> -static void setup(void)
> -{
> -	TEST_PAUSE;
>  }
>  
> -static void cleanup(void)
> -{
> -}
> +static struct tst_test test = {
> +	.tid = "clock_getres01",
> +	.test = do_test,
> +	.tcnt = ARRAY_SIZE(tcase),
> +};
> -- 
> 2.10.2
> 
> 
> -- 
> Mailing list info: https://lists.linux.it/listinfo/ltp

-- 
Cyril Hrubis
chrubis@suse.cz


More information about the ltp mailing list