2 # Library code for git-p4 tests
7 if ! test_have_prereq PYTHON; then
8 skip_all='skipping git-p4 tests; python not available'
11 ( p4 -h && p4d -h ) >/dev/null 2>&1 || {
12 skip_all='skipping git-p4 tests; no p4 or p4d'
16 GITP4="$GIT_BUILD_DIR/contrib/fast-import/git-p4"
18 # Try to pick a unique port: guess a large number, then hope
19 # no more than one of each test is running.
21 # This does not handle the case where somebody else is running the
22 # same tests and has chosen the same ports.
24 git_p4_test_start=9800
25 P4DPORT=$((10669 + ($testid - $git_p4_test_start)))
27 export P4PORT=localhost:$P4DPORT
28 export P4CLIENT=client
30 db="$TRASH_DIRECTORY/db"
31 cli="$TRASH_DIRECTORY/cli"
32 git="$TRASH_DIRECTORY/git"
33 pidfile="$TRASH_DIRECTORY/p4d.pid"
36 mkdir -p "$db" "$cli" "$git" &&
38 p4d -q -r "$db" -p $P4DPORT &
41 for i in 1 2 3 4 5 ; do
42 p4 info >/dev/null 2>&1 && break || true &&
43 echo waiting for p4d to start &&
46 # complain if it never started
54 View: //depot/... //client/...
61 # it had better exist for the first kill
63 for i in 1 2 3 4 5 ; do
64 kill $pid >/dev/null 2>&1 || break
67 # complain if it would not die
68 test_must_fail kill $pid >/dev/null 2>&1 &&
69 rm -rf "$db" "$cli" "$pidfile"