changeset 50235:385977432227 stable

dirstate: add append/new-file variants in the dirstate's read race tests This covers more ground and finds more bugs. At that point I gave up on making things as `known-bad-output` / `missing-correct-output` as this gets too messy.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Mon, 27 Feb 2023 03:14:30 +0100
parents 2be6d5782728
children 53f196622699
files tests/test-dirstate-read-race.t
diffstat 1 files changed, 140 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/tests/test-dirstate-read-race.t	Tue Dec 13 14:51:36 2022 +0100
+++ b/tests/test-dirstate-read-race.t	Mon Feb 27 03:14:30 2023 +0100
@@ -3,6 +3,7 @@
 ==============================================================================
 
 #testcases dirstate-v1 dirstate-v2-append dirstate-v2-rewrite
+#testcases pre-all-read pre-some-read
 
 Some commands, like `hg status`, do not need to take the wlock but need to
 access dirstate data.
@@ -46,6 +47,17 @@
   $ d2args="--config devel.dirstate.v2.data_update_mode=force-append"
 #endif
 
+
+#if dirstate-v1
+  $ cfg="devel.sync.dirstate.pre-read-file"
+#else
+#if pre-all-read
+  $ cfg="devel.sync.dirstate.pre-read-file"
+#else
+  $ cfg="devel.sync.dirstate.post-docket-read-file"
+#endif
+#endif
+
   $ directories="dir dir/nested dir2"
   $ first_files="dir/nested/a dir/b dir/c dir/d dir2/e f"
   $ second_files="g dir/nested/h dir/i dir/j dir2/k dir2/l dir/nested/m"
@@ -134,7 +146,7 @@
 
   $ hg st >$TESTTMP/status-race-lock.out 2>$TESTTMP/status-race-lock.log \
   > --config rhg.on-unsupported=abort \
-  > --config devel.sync.dirstate.pre-read-file=$TESTTMP/status-race-lock \
+  > --config ${cfg}=$TESTTMP/status-race-lock \
   > &
   $ $RUNTESTDIR/testlib/wait-on-file 5 $TESTTMP/status-race-lock.waiting
 
@@ -165,6 +177,7 @@
   $ cat $TESTTMP/status-race-lock.log
 #else
 #if rhg
+#if pre-all-read
   $ cat $TESTTMP/status-race-lock.out
   A dir/n
   A dir/o
@@ -173,12 +186,34 @@
   ? q
   $ cat $TESTTMP/status-race-lock.log
 #else
+#if dirstate-v2-append
+  $ cat $TESTTMP/status-race-lock.out
+  A dir/o
+  R dir/nested/m
+  ? dir/n
+  ? p
+  ? q
+  $ cat $TESTTMP/status-race-lock.log
+#else
+  $ cat $TESTTMP/status-race-lock.out
+  $ cat $TESTTMP/status-race-lock.log
+  abort: dirstate-v2 parse error: not enough bytes on disk
+#endif
+#endif
+#else
 #if rust
 #if dirstate-v2-rewrite
   $ cat $TESTTMP/status-race-lock.out
   $ cat $TESTTMP/status-race-lock.log
   abort: $ENOENT$: '$TESTTMP/race-with-add/.hg/dirstate.* (glob)
 #else
+  $ cat $TESTTMP/status-race-lock.out
+  A dir/o
+  R dir/nested/m
+  ? dir/n
+  ? p
+  ? q
+  $ cat $TESTTMP/status-race-lock.log
 #endif
 #else
   $ cat $TESTTMP/status-race-lock.out
@@ -203,7 +238,7 @@
 
   $ hg st >$TESTTMP/status-race-lock.out 2>$TESTTMP/status-race-lock.log \
   > --config rhg.on-unsupported=abort \
-  > --config devel.sync.dirstate.pre-read-file=$TESTTMP/status-race-lock \
+  > --config ${cfg}=$TESTTMP/status-race-lock \
   > &
   $ $RUNTESTDIR/testlib/wait-on-file 5 $TESTTMP/status-race-lock.waiting
 
@@ -245,18 +280,41 @@
   warning: ignoring unknown working parent 02a67a77ee9b! (no-rhg !)
 #else
 #if rhg
+#if pre-all-read
   $ cat $TESTTMP/status-race-lock.out
   ? dir/n
   ? p
   ? q
   $ cat $TESTTMP/status-race-lock.log
 #else
+#if dirstate-v2-append
+  $ cat $TESTTMP/status-race-lock.out
+  A dir/o
+  R dir/nested/m
+  ? dir/n
+  ? p
+  ? q
+  $ cat $TESTTMP/status-race-lock.log
+#else
+  $ cat $TESTTMP/status-race-lock.out
+  $ cat $TESTTMP/status-race-lock.log
+  abort: dirstate-v2 parse error: not enough bytes on disk
+#endif
+#endif
+#else
 #if rust
 #if dirstate-v2-rewrite
   $ cat $TESTTMP/status-race-lock.out
   $ cat $TESTTMP/status-race-lock.log
   abort: $ENOENT$: '$TESTTMP/race-with-commit/.hg/dirstate.* (glob)
 #else
+  $ cat $TESTTMP/status-race-lock.out
+  A dir/o
+  R dir/nested/m
+  ? dir/n
+  ? p
+  ? q
+  $ cat $TESTTMP/status-race-lock.log
 #endif
 #else
   $ cat $TESTTMP/status-race-lock.out
@@ -281,7 +339,7 @@
 
   $ hg st >$TESTTMP/status-race-lock.out 2>$TESTTMP/status-race-lock.log \
   > --config rhg.on-unsupported=abort \
-  > --config devel.sync.dirstate.pre-read-file=$TESTTMP/status-race-lock \
+  > --config ${cfg}=$TESTTMP/status-race-lock \
   > &
   $ $RUNTESTDIR/testlib/wait-on-file 5 $TESTTMP/status-race-lock.waiting
 do an update
@@ -301,6 +359,25 @@
   0 files updated, 0 files merged, 6 files removed, 0 files unresolved
   $ touch $TESTTMP/status-race-lock
   $ wait
+#if rhg dirstate-v2-append pre-some-read
+  $ hg log -GT '{node|short} {desc}\n'
+  @  9a86dcbfb938 more files to have two commit
+  |
+  o  4f23db756b09 recreate a bunch of files to facilitate dirstate-v2 append
+  
+  $ hg status
+  A dir/o
+  R dir/nested/m
+  ! dir/i
+  ! dir/j
+  ! dir/nested/h
+  ! dir2/k
+  ! dir2/l
+  ! g
+  ? dir/n
+  ? p
+  ? q
+#else
   $ hg log -GT '{node|short} {desc}\n'
   o  9a86dcbfb938 more files to have two commit
   |
@@ -311,6 +388,7 @@
   ? dir/n
   ? p
   ? q
+#endif
 
 The status process should return a consistent result and not crash.
 
@@ -323,6 +401,7 @@
   $ cat $TESTTMP/status-race-lock.log
 #else
 #if rhg
+#if pre-all-read
   $ cat $TESTTMP/status-race-lock.out
   A dir/o
   ? dir/n
@@ -330,12 +409,46 @@
   ? q
   $ cat $TESTTMP/status-race-lock.log
 #else
+#if dirstate-v2-append
+  $ cat $TESTTMP/status-race-lock.out
+  A dir/o
+  R dir/nested/m
+  ! dir/i
+  ! dir/j
+  ! dir/nested/h
+  ! dir2/k
+  ! dir2/l
+  ! g
+  ? dir/n
+  ? p
+  ? q
+  $ cat $TESTTMP/status-race-lock.log
+#else
+  $ cat $TESTTMP/status-race-lock.out
+  $ cat $TESTTMP/status-race-lock.log
+  abort: dirstate-v2 parse error: not enough bytes on disk
+#endif
+#endif
+#else
 #if rust
 #if dirstate-v2-rewrite
   $ cat $TESTTMP/status-race-lock.out
   $ cat $TESTTMP/status-race-lock.log
   abort: $ENOENT$: '$TESTTMP/race-with-update/.hg/dirstate.* (glob)
 #else
+  $ cat $TESTTMP/status-race-lock.out
+  A dir/o
+  R dir/nested/m
+  ! dir/i
+  ! dir/j
+  ! dir/nested/h
+  ! dir2/k
+  ! dir2/l
+  ! g
+  ? dir/n
+  ? p
+  ? q
+  $ cat $TESTTMP/status-race-lock.log
 #endif
 #else
   $ cat $TESTTMP/status-race-lock.out
@@ -362,7 +475,7 @@
 
   $ hg st >$TESTTMP/status-race-lock.out 2>$TESTTMP/status-race-lock.log \
   > --config rhg.on-unsupported=abort \
-  > --config devel.sync.dirstate.pre-read-file=$TESTTMP/status-race-lock \
+  > --config ${cfg}=$TESTTMP/status-race-lock \
   > &
   $ $RUNTESTDIR/testlib/wait-on-file 5 $TESTTMP/status-race-lock.waiting
 do an update
@@ -389,6 +502,16 @@
   $ cat $TESTTMP/status-race-lock.log
 #else
 #if rhg
+#if pre-all-read
+  $ cat $TESTTMP/status-race-lock.out
+  A dir/o
+  R dir/nested/m
+  ? dir/n
+  ? p
+  ? q
+  $ cat $TESTTMP/status-race-lock.log
+#else
+#if dirstate-v2-append
   $ cat $TESTTMP/status-race-lock.out
   A dir/o
   R dir/nested/m
@@ -397,12 +520,25 @@
   ? q
   $ cat $TESTTMP/status-race-lock.log
 #else
+  $ cat $TESTTMP/status-race-lock.out
+  $ cat $TESTTMP/status-race-lock.log
+  abort: dirstate-v2 parse error: not enough bytes on disk
+#endif
+#endif
+#else
 #if rust
 #if dirstate-v2-rewrite
   $ cat $TESTTMP/status-race-lock.out
   $ cat $TESTTMP/status-race-lock.log
   abort: $ENOENT$: '$TESTTMP/race-with-status/.hg/dirstate.* (glob)
 #else
+  $ cat $TESTTMP/status-race-lock.out
+  A dir/o
+  R dir/nested/m
+  ? dir/n
+  ? p
+  ? q
+  $ cat $TESTTMP/status-race-lock.log
 #endif
 #else
   $ cat $TESTTMP/status-race-lock.out