File: 023_parallel_changes

package info (click to toggle)
fsvs 1.2.7-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid, stretch
  • size: 2,964 kB
  • ctags: 1,464
  • sloc: ansic: 16,650; sh: 5,885; perl: 783; makefile: 338; python: 90
file content (86 lines) | stat: -rwxr-xr-x 1,828 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/bin/bash
# Tests whether parallel changes in multiple working copies are ok.

# How many WCs we use
NUM_WC=5
# How often we do that (change*n ; update) cycles
NUM_LOOPS=15

set -e 
$PREPARE_CLEAN WC_COUNT=$NUM_WC > /dev/null
$INCLUDE_FUNCS


#
# Thread i
#   - creates file i+1
#   - changes file i
#   - removes file (i-1)
# i <= i+4, modulo (4*N)

for loop in `seq 1 $NUM_LOOPS`
do
  $INFO "Parallel changes -- loop #$loop of $NUM_LOOPS."
	exec 5> $LOGDIR/023.round_$loop.log
	perl -e '
	$wc_cnt=shift;
	$base=shift;
	$loop=shift;
	$mult=5;
	sub FN { return "$base$i/$n"; }
	sub P { print(join("\t","°°",$loop,$wc_cnt,$mult,$i,$n,$$,$_[0],FN()),"\n"); }
	for $i (1 .. $wc_cnt)
	{
	  $n=1000 + ( $i*$mult + $loop ) % ($wc_cnt * $mult);
		P("-");

		(
		  unlink(FN()) &&
		  P("remove")
		) || die $!  if -f FN() && !(($i + $loop) % 7);
		$n++;

		(
		 open(F,">> ".FN()) && 
		 print(F $$," ",$i," ",$n,"\n") &&
		 close(F) &&
		 P("append")
		) || die $! if -f FN();
		$n++;

		(
		 open(F,"> ".FN()) && 
		 print(F localtime()." ",$$," ",$i," ",$n,"\n") &&
		 close(F) &&
		 P("write")
		) || die $! if !-f FN();
	}
	' $NUM_WC $WCBASE $loop  >&5 2>&5

	for i in `seq 1 $NUM_WC`
	do
		( cd $WCBASE$i &&
			echo "=== update $i" && $BINdflt up &&
			echo "=== commit $i" && $BINdflt ci -m "$i-$loop" ) || false
	done >&5 2>&5

	for i in `seq 1 $NUM_WC`
	do
		( cd $WCBASE$i &&
			echo "=== update $i" && $BINdflt up &&
			echo "=== status $i" && $BINdflt st -C -C ) || false
		echo "=== check  $i"
		if [[ `cd $WCBASE$i && $BINdflt st` != '' ]]
		then
			$ERROR "$WCBASE$i has a bad status!" > `tty` 2>&1
		fi
		echo "=== compare $i"
		$COMPAREWITH $WCBASE$i
	done >&5 2>&5
done


$SUCCESS "Parallel working copy modifications ok."
# cat /tmp/ram/fsvs-test-1000/log/023.round_* | grep °° | sort -n -k2 -k5 | grep 1011