Hex Artifact Content
Not logged in

Artifact 08d7071c425e560715a6c8d2916369ec5679fa2e:

File test/delta1.test part of check-in [dbda8d6ce9] - Initial check-in of m1 sources. by drh on 2007-07-21 14:10:57.

0000: 23 0a 23 20 43 6f 70 79 72 69 67 68 74 20 28 63  #.# Copyright (c
0010: 29 20 32 30 30 36 20 44 2e 20 52 69 63 68 61 72  ) 2006 D. Richar
0020: 64 20 48 69 70 70 0a 23 0a 23 20 54 68 69 73 20  d Hipp.#.# This 
0030: 70 72 6f 67 72 61 6d 20 69 73 20 66 72 65 65 20  program is free 
0040: 73 6f 66 74 77 61 72 65 3b 20 79 6f 75 20 63 61  software; you ca
0050: 6e 20 72 65 64 69 73 74 72 69 62 75 74 65 20 69  n redistribute i
0060: 74 20 61 6e 64 2f 6f 72 0a 23 20 6d 6f 64 69 66  t and/or.# modif
0070: 79 20 69 74 20 75 6e 64 65 72 20 74 68 65 20 74  y it under the t
0080: 65 72 6d 73 20 6f 66 20 74 68 65 20 47 4e 55 20  erms of the GNU 
0090: 47 65 6e 65 72 61 6c 20 50 75 62 6c 69 63 0a 23  General Public.#
00a0: 20 4c 69 63 65 6e 73 65 20 76 65 72 73 69 6f 6e   License version
00b0: 20 32 20 61 73 20 70 75 62 6c 69 73 68 65 64 20   2 as published 
00c0: 62 79 20 74 68 65 20 46 72 65 65 20 53 6f 66 74  by the Free Soft
00d0: 77 61 72 65 20 46 6f 75 6e 64 61 74 69 6f 6e 2e  ware Foundation.
00e0: 0a 23 0a 23 20 54 68 69 73 20 70 72 6f 67 72 61  .#.# This progra
00f0: 6d 20 69 73 20 64 69 73 74 72 69 62 75 74 65 64  m is distributed
0100: 20 69 6e 20 74 68 65 20 68 6f 70 65 20 74 68 61   in the hope tha
0110: 74 20 69 74 20 77 69 6c 6c 20 62 65 20 75 73 65  t it will be use
0120: 66 75 6c 2c 0a 23 20 62 75 74 20 57 49 54 48 4f  ful,.# but WITHO
0130: 55 54 20 41 4e 59 20 57 41 52 52 41 4e 54 59 3b  UT ANY WARRANTY;
0140: 20 77 69 74 68 6f 75 74 20 65 76 65 6e 20 74 68   without even th
0150: 65 20 69 6d 70 6c 69 65 64 20 77 61 72 72 61 6e  e implied warran
0160: 74 79 20 6f 66 0a 23 20 4d 45 52 43 48 41 4e 54  ty of.# MERCHANT
0170: 41 42 49 4c 49 54 59 20 6f 72 20 46 49 54 4e 45  ABILITY or FITNE
0180: 53 53 20 46 4f 52 20 41 20 50 41 52 54 49 43 55  SS FOR A PARTICU
0190: 4c 41 52 20 50 55 52 50 4f 53 45 2e 20 20 53 65  LAR PURPOSE.  Se
01a0: 65 20 74 68 65 20 47 4e 55 0a 23 20 47 65 6e 65  e the GNU.# Gene
01b0: 72 61 6c 20 50 75 62 6c 69 63 20 4c 69 63 65 6e  ral Public Licen
01c0: 73 65 20 66 6f 72 20 6d 6f 72 65 20 64 65 74 61  se for more deta
01d0: 69 6c 73 2e 0a 23 20 0a 23 20 59 6f 75 20 73 68  ils..# .# You sh
01e0: 6f 75 6c 64 20 68 61 76 65 20 72 65 63 65 69 76  ould have receiv
01f0: 65 64 20 61 20 63 6f 70 79 20 6f 66 20 74 68 65  ed a copy of the
0200: 20 47 4e 55 20 47 65 6e 65 72 61 6c 20 50 75 62   GNU General Pub
0210: 6c 69 63 0a 23 20 4c 69 63 65 6e 73 65 20 61 6c  lic.# License al
0220: 6f 6e 67 20 77 69 74 68 20 74 68 69 73 20 6c 69  ong with this li
0230: 62 72 61 72 79 3b 20 69 66 20 6e 6f 74 2c 20 77  brary; if not, w
0240: 72 69 74 65 20 74 6f 20 74 68 65 0a 23 20 46 72  rite to the.# Fr
0250: 65 65 20 53 6f 66 74 77 61 72 65 20 46 6f 75 6e  ee Software Foun
0260: 64 61 74 69 6f 6e 2c 20 49 6e 63 2e 2c 20 35 39  dation, Inc., 59
0270: 20 54 65 6d 70 6c 65 20 50 6c 61 63 65 20 2d 20   Temple Place - 
0280: 53 75 69 74 65 20 33 33 30 2c 0a 23 20 42 6f 73  Suite 330,.# Bos
0290: 74 6f 6e 2c 20 4d 41 20 20 30 32 31 31 31 2d 31  ton, MA  02111-1
02a0: 33 30 37 2c 20 55 53 41 2e 0a 23 0a 23 20 41 75  307, USA..#.# Au
02b0: 74 68 6f 72 20 63 6f 6e 74 61 63 74 20 69 6e 66  thor contact inf
02c0: 6f 72 6d 61 74 69 6f 6e 3a 0a 23 20 20 20 64 72  ormation:.#   dr
02d0: 68 40 68 77 61 63 69 2e 63 6f 6d 0a 23 20 20 20  h@hwaci.com.#   
02e0: 68 74 74 70 3a 2f 2f 77 77 77 2e 68 77 61 63 69  http://www.hwaci
02f0: 2e 63 6f 6d 2f 64 72 68 2f 0a 23 0a 23 23 23 23  .com/drh/.#.####
0300: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23  ################
0310: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23  ################
0320: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23  ################
0330: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23  ################
0340: 23 23 23 23 23 23 23 23 0a 23 0a 23 20 54 65 73  ########.#.# Tes
0350: 74 73 20 6f 66 20 74 68 65 20 64 65 6c 74 61 20  ts of the delta 
0360: 6d 65 63 68 61 6e 69 73 6d 2e 0a 23 0a 0a 23 20  mechanism..#..# 
0370: 55 73 65 20 74 65 73 74 20 73 63 72 69 70 74 20  Use test script 
0380: 66 69 6c 65 73 20 61 73 20 74 68 65 20 62 61 73  files as the bas
0390: 69 73 20 66 6f 72 20 74 68 69 73 20 74 65 73 74  is for this test
03a0: 2e 0a 23 0a 23 20 46 6f 72 20 65 61 63 68 20 74  ..#.# For each t
03b0: 65 73 74 2c 20 63 6f 70 79 20 74 68 65 20 66 69  est, copy the fi
03c0: 6c 65 20 69 6e 74 61 63 74 20 74 6f 20 22 2e 2f  le intact to "./
03d0: 74 31 22 2e 20 20 4d 61 6b 65 0a 23 20 73 6f 6d  t1".  Make.# som
03e0: 65 20 72 61 6e 64 6f 6d 20 63 68 61 6e 67 65 73  e random changes
03f0: 20 69 6e 20 22 2e 2f 74 32 22 2e 20 20 54 68 65   in "./t2".  The
0400: 6e 20 63 61 6c 6c 20 74 65 73 74 2d 64 65 6c 74  n call test-delt
0410: 61 20 6f 6e 20 74 68 65 0a 23 20 74 77 6f 20 66  a on the.# two f
0420: 69 6c 65 73 20 74 6f 20 6d 61 6b 65 20 73 75 72  iles to make sur
0430: 65 20 74 68 61 74 20 64 65 6c 74 61 73 20 62 65  e that deltas be
0440: 74 77 65 65 6e 20 74 68 65 73 65 20 74 77 6f 20  tween these two 
0450: 66 69 6c 65 73 0a 23 20 77 6f 72 6b 20 70 72 6f  files.# work pro
0460: 70 65 72 6c 79 2e 0a 23 0a 73 65 74 20 66 69 6c  perly..#.set fil
0470: 65 6c 69 73 74 20 5b 67 6c 6f 62 20 24 74 65 73  elist [glob $tes
0480: 74 64 69 72 2f 2a 5d 0a 66 6f 72 65 61 63 68 20  tdir/*].foreach 
0490: 66 20 24 66 69 6c 65 6c 69 73 74 20 7b 0a 20 20  f $filelist {.  
04a0: 73 65 74 20 62 61 73 65 20 5b 66 69 6c 65 20 72  set base [file r
04b0: 6f 6f 74 20 5b 66 69 6c 65 20 74 61 69 6c 20 24  oot [file tail $
04c0: 66 5d 5d 0a 20 20 73 65 74 20 66 31 20 5b 72 65  f]].  set f1 [re
04d0: 61 64 5f 66 69 6c 65 20 24 66 5d 0a 20 20 77 72  ad_file $f].  wr
04e0: 69 74 65 5f 66 69 6c 65 20 74 31 20 24 66 31 0a  ite_file t1 $f1.
04f0: 20 20 66 6f 72 20 7b 73 65 74 20 69 20 30 7d 20    for {set i 0} 
0500: 7b 24 69 3c 31 30 30 7d 20 7b 69 6e 63 72 20 69  {$i<100} {incr i
0510: 7d 20 7b 0a 20 20 20 20 77 72 69 74 65 5f 66 69  } {.    write_fi
0520: 6c 65 20 74 32 20 5b 72 61 6e 64 6f 6d 5f 63 68  le t2 [random_ch
0530: 61 6e 67 65 73 20 24 66 31 20 31 20 31 20 30 20  anges $f1 1 1 0 
0540: 30 2e 31 5d 0a 20 20 20 20 66 6f 73 73 69 6c 20  0.1].    fossil 
0550: 74 65 73 74 2d 64 65 6c 74 61 20 74 31 20 74 32  test-delta t1 t2
0560: 0a 20 20 20 20 74 65 73 74 20 64 65 6c 74 61 2d  .    test delta-
0570: 24 62 61 73 65 2d 24 69 2d 31 20 7b 24 52 45 53  $base-$i-1 {$RES
0580: 55 4c 54 3d 3d 22 6f 6b 22 7d 0a 20 20 20 20 77  ULT=="ok"}.    w
0590: 72 69 74 65 5f 66 69 6c 65 20 74 32 20 5b 72 61  rite_file t2 [ra
05a0: 6e 64 6f 6d 5f 63 68 61 6e 67 65 73 20 24 66 31  ndom_changes $f1
05b0: 20 31 20 31 20 30 20 30 2e 32 5d 0a 20 20 20 20   1 1 0 0.2].    
05c0: 66 6f 73 73 69 6c 20 74 65 73 74 2d 64 65 6c 74  fossil test-delt
05d0: 61 20 74 31 20 74 32 0a 20 20 20 20 74 65 73 74  a t1 t2.    test
05e0: 20 64 65 6c 74 61 2d 24 62 61 73 65 2d 24 69 2d   delta-$base-$i-
05f0: 32 20 7b 24 52 45 53 55 4c 54 3d 3d 22 6f 6b 22  2 {$RESULT=="ok"
0600: 7d 0a 20 20 20 20 77 72 69 74 65 5f 66 69 6c 65  }.    write_file
0610: 20 74 32 20 5b 72 61 6e 64 6f 6d 5f 63 68 61 6e   t2 [random_chan
0620: 67 65 73 20 24 66 31 20 31 20 31 20 30 20 30 2e  ges $f1 1 1 0 0.
0630: 34 5d 0a 20 20 20 20 66 6f 73 73 69 6c 20 74 65  4].    fossil te
0640: 73 74 2d 64 65 6c 74 61 20 74 31 20 74 32 0a 20  st-delta t1 t2. 
0650: 20 20 20 74 65 73 74 20 64 65 6c 74 61 2d 24 62     test delta-$b
0660: 61 73 65 2d 24 69 2d 33 20 7b 24 52 45 53 55 4c  ase-$i-3 {$RESUL
0670: 54 3d 3d 22 6f 6b 22 7d 0a 20 20 7d 0a 7d 0a     T=="ok"}.  }.}.