2 # Library code for git p4 tests
5 # p4 tests never use the top-level repo; always build/clone into
6 # a subdirectory called "$git"
7 TEST_NO_CREATE_REPO
=NoThanks
11 if ! test_have_prereq PYTHON
; then
12 skip_all
='skipping git p4 tests; python not available'
15 ( p4
-h && p4d
-h ) >/dev
/null
2>&1 ||
{
16 skip_all
='skipping git p4 tests; no p4 or p4d'
20 # Try to pick a unique port: guess a large number, then hope
21 # no more than one of each test is running.
23 # This does not handle the case where somebody else is running the
24 # same tests and has chosen the same ports.
26 git_p4_test_start
=9800
27 P4DPORT
=$
((10669 + ($testid - $git_p4_test_start)))
29 export P4PORT
=localhost
:$P4DPORT
30 export P4CLIENT
=client
33 db
="$TRASH_DIRECTORY/db"
34 cli
=$
(test-path-utils real_path
"$TRASH_DIRECTORY/cli")
35 git
="$TRASH_DIRECTORY/git"
36 pidfile
="$TRASH_DIRECTORY/p4d.pid"
39 mkdir
-p "$db" "$cli" "$git" &&
42 p4d
-q -r "$db" -p $P4DPORT &
46 # This gives p4d a long time to start up, as it can be
47 # quite slow depending on the machine. Set this environment
48 # variable to something smaller to fail faster in, say,
49 # an automated test setup. If the p4d process dies, that
50 # will be caught with the "kill -0" check below.
51 i
=${P4D_START_PATIENCE:-300}
56 # succeed when p4 client commands start to work
57 if p4 info
>/dev
/null
2>&1
63 kill -0 $pid 2>/dev
/null ||
break
64 echo waiting
for p4d to start
82 View: //depot/... //client/...
90 # it had better exist for the first kill
92 for i
in 1 2 3 4 5 ; do
93 kill $pid >/dev
/null
2>&1 ||
break
96 # complain if it would not die
97 test_must_fail
kill $pid >/dev
/null
2>&1 &&
98 rm -rf "$db" "$cli" "$pidfile"
109 cat >"$TRASH_DIRECTORY/marshal-dump.py" <<-EOF &&
112 for i in range($line):
113 d = marshal.load(sys.stdin)
116 "$PYTHON_PATH" "$TRASH_DIRECTORY/marshal-dump.py"