summaryrefslogtreecommitdiff
path: root/t/t9801-git-p4-branch.sh
diff options
context:
space:
mode:
authorSZEDER Gábor <szeder.dev@gmail.com>2019-03-13 12:24:16 (GMT)
committerJunio C Hamano <gitster@pobox.com>2019-03-14 03:34:39 (GMT)
commit07353d9042f19fec749ec8413ff7e6824460ee59 (patch)
tree620d0d044041d29861e3693af6776bb6736c2fac /t/t9801-git-p4-branch.sh
parent99e37c2560ecb1cc44bb743a2e4aaaedb5da1a90 (diff)
downloadgit-07353d9042f19fec749ec8413ff7e6824460ee59.zip
git-07353d9042f19fec749ec8413ff7e6824460ee59.tar.gz
git-07353d9042f19fec749ec8413ff7e6824460ee59.tar.bz2
git p4 test: clean up the p4d cleanup functions
Confusingly, the 'git p4' tests used two cleanup functions: - 'kill_p4d' was run in the last test before 'test_done', and it not only killed 'p4d', but it killed the watchdog process, and cleaned up after 'p4d' as well by removing all directories used by the P4 daemon and client. This cleanup is not necessary right before 'test_done', because the whole trash directory is about to get removed anyway, but it is necessary in 't9801-git-p4-branch.sh', which uses 'kill_p4d' to stop 'p4d' before re-starting it in the middle of the test script. - 'cleanup' was run in the trap on EXIT, and it killed 'p4d', but, it didn't kill the watchdog process, and, contrarily to its name, didn't perform any cleanup whatsoever. Make it clearer what's going on by renaming and simplifying the cleanup functions, so in the end we'll have: - 'stop_p4d_and_watchdog' replaces 'cleanup' as it will try to live up to its name and stop both the 'p4d' and the watchdog processes, and as the sole function registered with 'test_atexit' it will be responsible for no leaving any stray processes behind after 'git p4' tests were finished or interrupted. - 'stop_and_cleanup_p4d' replaces 'kill_p4d' as it will stop 'p4d' (and the watchdog) and remove all directories used by the P4 daemon and cliean, so it can be used mid-script to stop and then re-start 'p4d'. Note that while 'cleanup' sent a single SIGKILL to 'p4d', 'kill_p4d' was quite brutal, as it first sent SIGTERM to the daemon repeatedly, either until its pid disappeared or until a given timeout was up, and then it sent SIGKILL repeatedly, for good measure. This is overkill (pardon the pun): a single SIGKILL should be able to take down any process in a sensible state, and if a process were to somehow end up stuck in the dreaded uninterruptible sleep state then even repeated SIGKILLs won't bring immediate help. So ditch all the repeated SIGTERM/SIGKILL parts, and use a single SIGKILL to stop 'p4d', and make sure that there are no races between asynchron signal delivery and subsequent restart of 'p4d' by waiting for it to die. With this change the 'retry_until_fail' helper has no callers left, remove it. Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t9801-git-p4-branch.sh')
-rwxr-xr-xt/t9801-git-p4-branch.sh4
1 files changed, 2 insertions, 2 deletions
diff --git a/t/t9801-git-p4-branch.sh b/t/t9801-git-p4-branch.sh
index 5001313..38d6b90 100755
--- a/t/t9801-git-p4-branch.sh
+++ b/t/t9801-git-p4-branch.sh
@@ -151,7 +151,7 @@ test_expect_success 'import depot, branch detection, branchList branch definitio
'
test_expect_success 'restart p4d' '
- kill_p4d &&
+ stop_and_cleanup_p4d &&
start_p4d
'
@@ -505,7 +505,7 @@ test_expect_success 'use-client-spec detect-branches skips files in branches' '
'
test_expect_success 'restart p4d' '
- kill_p4d &&
+ stop_and_cleanup_p4d &&
start_p4d
'