annotate tests/test-racy-mutations.t @ 47859:155a2ec8a9dc

merge with stable
author Matt Harbison <matt_harbison@yahoo.com>
date Sun, 22 Aug 2021 16:32:06 -0400
parents 906a7bcaac86
children bd752712ccaf
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
46607
e9901d01d135 revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff changeset
1 #testcases skip-detection fail-if-detected
e9901d01d135 revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff changeset
2
e9901d01d135 revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff changeset
3 Test situations that "should" only be reproducible:
e9901d01d135 revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff changeset
4 - on networked filesystems, or
e9901d01d135 revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff changeset
5 - user using `hg debuglocks` to eliminate the lock file, or
e9901d01d135 revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff changeset
6 - something (that doesn't respect the lock file) writing to the .hg directory
e9901d01d135 revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff changeset
7 while we're running
e9901d01d135 revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff changeset
8
e9901d01d135 revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff changeset
9 $ hg init a
e9901d01d135 revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff changeset
10 $ cd a
e9901d01d135 revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff changeset
11
e9901d01d135 revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff changeset
12 $ cat > "$TESTTMP/waitlock_editor.sh" <<EOF
e9901d01d135 revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff changeset
13 > [ -n "\${WAITLOCK_ANNOUNCE:-}" ] && touch "\${WAITLOCK_ANNOUNCE}"
e9901d01d135 revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff changeset
14 > f="\${WAITLOCK_FILE}"
e9901d01d135 revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff changeset
15 > start=\`date +%s\`
e9901d01d135 revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff changeset
16 > timeout=5
e9901d01d135 revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff changeset
17 > while [ \\( ! -f \$f \\) -a \\( ! -L \$f \\) ]; do
e9901d01d135 revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff changeset
18 > now=\`date +%s\`
e9901d01d135 revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff changeset
19 > if [ "\`expr \$now - \$start\`" -gt \$timeout ]; then
e9901d01d135 revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff changeset
20 > echo "timeout: \$f was not created in \$timeout seconds (it is now \$(date +%s))"
e9901d01d135 revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff changeset
21 > exit 1
e9901d01d135 revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff changeset
22 > fi
e9901d01d135 revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff changeset
23 > sleep 0.1
e9901d01d135 revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff changeset
24 > done
e9901d01d135 revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff changeset
25 > if [ \$# -gt 1 ]; then
e9901d01d135 revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff changeset
26 > cat "\$@"
e9901d01d135 revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff changeset
27 > fi
e9901d01d135 revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff changeset
28 > EOF
e9901d01d135 revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff changeset
29
e9901d01d135 revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff changeset
30 Things behave differently if we don't already have a 00changelog.i file when
e9901d01d135 revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff changeset
31 this all starts, so let's make one.
e9901d01d135 revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff changeset
32
e9901d01d135 revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff changeset
33 $ echo r0 > r0
e9901d01d135 revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff changeset
34 $ hg commit -qAm 'r0'
e9901d01d135 revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff changeset
35
e9901d01d135 revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff changeset
36 Start an hg commit that will take a while
e9901d01d135 revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff changeset
37 $ EDITOR_STARTED="$(pwd)/.editor_started"
e9901d01d135 revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff changeset
38 $ MISCHIEF_MANAGED="$(pwd)/.mischief_managed"
e9901d01d135 revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff changeset
39 $ JOBS_FINISHED="$(pwd)/.jobs_finished"
e9901d01d135 revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff changeset
40
e9901d01d135 revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff changeset
41 #if fail-if-detected
e9901d01d135 revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff changeset
42 $ cat >> .hg/hgrc << EOF
e9901d01d135 revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff changeset
43 > [debug]
e9901d01d135 revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff changeset
44 > revlog.verifyposition.changelog = fail
e9901d01d135 revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff changeset
45 > EOF
e9901d01d135 revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff changeset
46 #endif
e9901d01d135 revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff changeset
47
e9901d01d135 revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff changeset
48 $ echo foo > foo
e9901d01d135 revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff changeset
49 $ (WAITLOCK_ANNOUNCE="${EDITOR_STARTED}" \
e9901d01d135 revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff changeset
50 > WAITLOCK_FILE="${MISCHIEF_MANAGED}" \
47065
a12819559ccb tests: invoke some shell scripts through the shell interpreter for Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 46607
diff changeset
51 > HGEDITOR="sh $TESTTMP/waitlock_editor.sh" \
46607
e9901d01d135 revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff changeset
52 > hg commit -qAm 'r1 (foo)' --edit foo > .foo_commit_out 2>&1 ; touch "${JOBS_FINISHED}") &
e9901d01d135 revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff changeset
53
e9901d01d135 revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff changeset
54 Wait for the "editor" to actually start
47065
a12819559ccb tests: invoke some shell scripts through the shell interpreter for Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 46607
diff changeset
55 $ WAITLOCK_FILE="${EDITOR_STARTED}" sh "$TESTTMP/waitlock_editor.sh"
46607
e9901d01d135 revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff changeset
56
e9901d01d135 revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff changeset
57 Break the locks, and make another commit.
e9901d01d135 revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff changeset
58 $ hg debuglocks -LW
e9901d01d135 revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff changeset
59 $ echo bar > bar
e9901d01d135 revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff changeset
60 $ hg commit -qAm 'r2 (bar)' bar
e9901d01d135 revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff changeset
61 $ hg debugrevlogindex -c
e9901d01d135 revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff changeset
62 rev linkrev nodeid p1 p2
e9901d01d135 revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff changeset
63 0 0 222799e2f90b 000000000000 000000000000
e9901d01d135 revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff changeset
64 1 1 6f124f6007a0 222799e2f90b 000000000000
e9901d01d135 revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff changeset
65
e9901d01d135 revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff changeset
66 Awaken the editor from that first commit
e9901d01d135 revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff changeset
67 $ touch "${MISCHIEF_MANAGED}"
e9901d01d135 revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff changeset
68 And wait for it to finish
47065
a12819559ccb tests: invoke some shell scripts through the shell interpreter for Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 46607
diff changeset
69 $ WAITLOCK_FILE="${JOBS_FINISHED}" sh "$TESTTMP/waitlock_editor.sh"
46607
e9901d01d135 revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff changeset
70
e9901d01d135 revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff changeset
71 #if skip-detection
e9901d01d135 revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff changeset
72 (Ensure there was no output)
e9901d01d135 revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff changeset
73 $ cat .foo_commit_out
e9901d01d135 revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff changeset
74 And observe a corrupted repository -- rev 2's linkrev is 1, which should never
e9901d01d135 revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff changeset
75 happen for the changelog (the linkrev should always refer to itself).
e9901d01d135 revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff changeset
76 $ hg debugrevlogindex -c
e9901d01d135 revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff changeset
77 rev linkrev nodeid p1 p2
e9901d01d135 revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff changeset
78 0 0 222799e2f90b 000000000000 000000000000
e9901d01d135 revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff changeset
79 1 1 6f124f6007a0 222799e2f90b 000000000000
e9901d01d135 revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff changeset
80 2 1 ac80e6205bb2 222799e2f90b 000000000000
e9901d01d135 revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff changeset
81 #endif
e9901d01d135 revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff changeset
82
e9901d01d135 revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff changeset
83 #if fail-if-detected
e9901d01d135 revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff changeset
84 $ cat .foo_commit_out
e9901d01d135 revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff changeset
85 transaction abort!
e9901d01d135 revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff changeset
86 rollback completed
e9901d01d135 revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff changeset
87 note: commit message saved in .hg/last-message.txt
e9901d01d135 revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff changeset
88 note: use 'hg commit --logfile .hg/last-message.txt --edit' to reuse it
e9901d01d135 revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff changeset
89 abort: 00changelog.i: file cursor at position 249, expected 121
e9901d01d135 revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff changeset
90 And no corruption in the changelog.
e9901d01d135 revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff changeset
91 $ hg debugrevlogindex -c
e9901d01d135 revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff changeset
92 rev linkrev nodeid p1 p2
e9901d01d135 revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff changeset
93 0 0 222799e2f90b 000000000000 000000000000
47214
906a7bcaac86 revlog: introduce a mandatory `_writing` context to update revlog content
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47065
diff changeset
94 1 1 6f124f6007a0 222799e2f90b 000000000000 (missing-correct-output !)
46607
e9901d01d135 revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff changeset
95 And, because of transactions, there's none in the manifestlog either.
e9901d01d135 revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff changeset
96 $ hg debugrevlogindex -m
e9901d01d135 revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff changeset
97 rev linkrev nodeid p1 p2
e9901d01d135 revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff changeset
98 0 0 7b7020262a56 000000000000 000000000000
e9901d01d135 revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff changeset
99 1 1 ad3fe36d86d9 7b7020262a56 000000000000
e9901d01d135 revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff changeset
100 #endif
e9901d01d135 revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff changeset
101