lib/test.sh: Remove temporary directory only if we know the location
PATCH v2 1/2 lib/test.sh: Remove temporary directory only if we know the location
This is a problem when a test TCONF before calling tst_tmpdir, but has tst_rmdir in cleanup function (e.g. dhcp_lib.sh when failing on tst_check_cmds).
Now it has the same behaviour as deleting $TST_TMPDIR in tst_do_exit in tst_test.sh.
---
Ping old commit:
Changes v1->v2: just commit message.
--- testcases/lib/test.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
testcases/lib/test.sh +4 -2
@@ -132,8 +132,10 @@ tst_tmpdir() tst_rmdir() { - cd "$LTPROOT" - rm -r "$TST_TMPDIR" + if [ -n "$TST_TMPDIR" ]; then + cd "$LTPROOT" + rm -r "$TST_TMPDIR" + fi } #
Signature · 1 line
2.13.2
PATCH v2 2/2 doc: Cleanup typo
From: Petr Vorel <[email protected]>
---
Just to prevent copy & paste error for people reading our wiki.
--- doc/test-writing-guidelines.txt | 2 +- lib/tst_resource.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
doc/test-writing-guidelines.txt +1 -1
@@ -215,7 +215,7 @@ The path is constructed according to these rules: 1. if '$LTPROOT' is set, return '$LTPROOT/testcases/data/$TCID' 2. else if 'tst_tmpdir()' was called return '$STARTWD/datafiles' - (where '$STARTWD' is initial working directory as recorded by 'tst_tmdir()') + (where '$STARTWD' is initial working directory as recorded by 'tst_tmpdir()') 3. else return '$CWD/datafiles' See 'testcases/commands/file/' for example.
lib/tst_resource.c +1 -1
@@ -46,7 +46,7 @@ static void tst_dataroot_init(void)int ret;/* 1. if LTPROOT is set, use $LTPROOT/testcases/data/$TCID -* 2. else if startwd is set by tst_tmdir(), use $STARWD/datafiles +* 2. else if startwd is set by tst_tmpdir(), use $STARWD/datafiles * 3. else use $CWD/datafiles */ if (ltproot) { ret = snprintf(dataroot, PATH_MAX, "%s/testcases/data/%s",
Signature · 1 line
2.13.2
PATCH v2 2/2 doc: Cleanup typo
Hi!
Pushed, thanks.
Signature · 2 lines
Cyril Hrubis [email protected]
PATCH v2 1/2 lib/test.sh: Remove temporary directory only if we know the location
In reply to Petr VorelHi!
Quoted 3 lines
This is a problem when a test TCONF before calling
tst_tmpdir, but hastst_rmdirin cleanup function (e.g.dhcp_lib.shwhen failing ontst_check_cmds).
I was wondering if we should produce at least TINFO message that something is probably wrong with the cleanup function, but nobody would read that unless we used TWARN.
So I guess that the patch is OK as it is, pushed, thanks.
Signature · 2 lines
Cyril Hrubis [email protected]
PATCH v2 1/2 lib/test.sh: Remove temporary directory only if we know the location
Hi Cyril,
Quoted 8 lines
Hi!
Quoted 3 lines
This is a problem when a test TCONF before calling
tst_tmpdir, but hastst_rmdirin cleanup function (e.g.dhcp_lib.shwhen failing ontst_check_cmds).I was wondering if we should produce at least TINFO message that something is probably wrong with the cleanup function, but nobody would read that unless we used TWARN.
Actually I think it's a good idea to put TWARN. That would indeed help to us to catch errors in scripts.
Quoted 1 line
So I guess that the patch is OK as it is, pushed, thanks.
Thanks!
Kind regards,
Petr