[LTP] [PATCH v2] lib/tst_tmpdir: Add tst_default_rmdir() for old testcases

Cyril Hrubis chrubis@suse.cz
Wed Feb 2 17:07:57 CET 2022


Hi!
> In some old testcases, cleanup() will not run since it exit
> form tst_brk. For example, because of the calling of ltp_syscall
> have no real cleanup when syscall not support, testcase ssetmask01
> will leave tmp file.

Actually you can pass cleanup to ltp_syscall(), all you need to do is
ti define CLEANUP before including LTP headers as:

#define CLEANUP cleanup

#include "test.h"
...
...

See the include/old/cleanup.c for details.

> Signed-off-by: Zhao Gongyi <zhaogongyi@huawei.com>
> ---
> v1->v2: add tst_default_rmdir() in tst_tmpdir.c
> 
>  lib/tst_tmpdir.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/lib/tst_tmpdir.c b/lib/tst_tmpdir.c
> index 6e38ae977..0045c7bb6 100644
> --- a/lib/tst_tmpdir.c
> +++ b/lib/tst_tmpdir.c
> @@ -342,6 +342,8 @@ void tst_rmdir(void)
>  		tst_resm(TWARN, "%s: rmobj(%s) failed: %s",
>  			 __func__, TESTDIR, errmsg);
>  	}
> +
> +	TESTDIR == NULL;

This is useless statement, it does literaly nothing.

>  }
> 
>  void tst_purge_dir(const char *path)
> @@ -351,3 +353,8 @@ void tst_purge_dir(const char *path)
>  	if (purge_dir(path, &err))
>  		tst_brkm(TBROK, NULL, "%s: %s", __func__, err);
>  }
> +
> +void __attribute__((destructor)) tst_default_rmdir(void)
> +{
> +	tst_rmdir();
> +}

I do not think that we should run the tst_rmdir() for all tests like
this.


-- 
Cyril Hrubis
chrubis@suse.cz


More information about the ltp mailing list