diff mbox series

lib/tst_test.c: add *cleanup() before exit

Message ID 20211108073828.33126-1-zhaogongyi@huawei.com
State Changes Requested
Headers show
Series lib/tst_test.c: add *cleanup() before exit | expand

Commit Message

Zhao Gongyi Nov. 8, 2021, 7:38 a.m. UTC
If the main process exit without *cleanup() and when the lib process
has exit, the test environment would not be reset when the testcase
needs resource of device or tmpfs.

Signed-off-by: Zhao Gongyi <zhaogongyi@huawei.com>
---
 lib/tst_test.c | 2 ++
 1 file changed, 2 insertions(+)

--
2.17.1

Comments

Li Wang Nov. 8, 2021, 9:08 a.m. UTC | #1
On Mon, Nov 8, 2021 at 3:37 PM Zhao Gongyi <zhaogongyi@huawei.com> wrote:

> If the main process exit without *cleanup() and when the lib process
> has exit, the test environment would not be reset when the testcase
> needs resource of device or tmpfs.
>
> Signed-off-by: Zhao Gongyi <zhaogongyi@huawei.com>
>

Reviewed-by: Li Wang <liwang@redhat.com>


> ---
>  lib/tst_test.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/lib/tst_test.c b/lib/tst_test.c
> index 02ae28335..4c7e3a97b 100644
> --- a/lib/tst_test.c
> +++ b/lib/tst_test.c
> @@ -1226,6 +1226,8 @@ static void heartbeat(void)
>                  * We need kill the task group immediately since the
>                  * main process has exit.
>                  */
> +               do_test_cleanup();
> +               do_cleanup();
>                 kill(0, SIGKILL);
>                 exit(TBROK);
>         }
> --
> 2.17.1
>
>
> --
> Mailing list info: https://lists.linux.it/listinfo/ltp
>
>
Cyril Hrubis Nov. 8, 2021, 1:12 p.m. UTC | #2
Hi!
> If the main process exit without *cleanup() and when the lib process
> has exit, the test environment would not be reset when the testcase
> needs resource of device or tmpfs.

This looks like working around the real problem. The test library
process is supposed to outlive the child in all circumstances.

What exactly happens in your case that this code gets triggered?
diff mbox series

Patch

diff --git a/lib/tst_test.c b/lib/tst_test.c
index 02ae28335..4c7e3a97b 100644
--- a/lib/tst_test.c
+++ b/lib/tst_test.c
@@ -1226,6 +1226,8 @@  static void heartbeat(void)
 		 * We need kill the task group immediately since the
 		 * main process has exit.
 		 */
+		do_test_cleanup();
+		do_cleanup();
 		kill(0, SIGKILL);
 		exit(TBROK);
 	}