[LTP] [PATCH v3 4/9] Rewrite rename04.c using new LTP API

Richard Palethorpe rpalethorpe@suse.de
Wed Jul 13 07:36:37 CEST 2022


Hello,

Avinesh Kumar <akumar@suse.de> writes:

> -/*
> - * setup() - performs all ONE TIME setup for this test.
> - */
> -void setup(void)
> +static void run(void)
>  {
> -
> -	tst_sig(NOFORK, DEF_HANDLER, cleanup);
> -
> -	TEST_PAUSE;
> -
> -	/* Create a temporary directory and make it current. */
> -	tst_tmpdir();
> -
> -	sprintf(fdir, "./tdir_%d", getpid());
> -	sprintf(mdir, "./rndir_%d", getpid());
> -	sprintf(tstfile, "%s/tstfile_%d", mdir, getpid());
> -
> -	/* create "old" directory */
> -	SAFE_MKDIR(cleanup, fdir, 00770);
> -
> -	SAFE_STAT(cleanup, fdir, &buf1);
> -
> -	/* save "old"'s dev and ino */
> -	olddev = buf1.st_dev;
> -	oldino = buf1.st_ino;
> -
> -	/* create another directory */
> -	SAFE_MKDIR(cleanup, mdir, 00770);
> -
> -	SAFE_TOUCH(cleanup, tstfile, 0700, NULL);
> -
> -	SAFE_STAT(cleanup, mdir, &buf2);
> -
> -	/* save "new"'s dev and ino */
> -	olddev1 = buf2.st_dev;
> -	oldino1 = buf2.st_ino;
> +	TEST(rename(DIR1, DIR2));
> +
> +	if (TST_RET == -1 && (TST_ERR == ENOTEMPTY || TST_ERR == EEXIST))
> +		tst_res(TPASS | TERRNO, "rename() failed as expected");

To print TST_ERR you need to use TTERRNO not TERRNO

> +	else if (TST_RET == 0)
> +		tst_res(TFAIL, "rename() succeeded unexpectedly");
> +	else
> +		tst_res(TFAIL | TERRNO, "rename() failed, but not with
> expected errno");

Here as well

With that change:

Reviewed-by: Richard Palethorpe <rpalethorpe@suse.com>

-- 
Thank you,
Richard.


More information about the ltp mailing list