Hex Artifact Content
Not logged in

Artifact a13b6b3efec3c09d07229f887d57a46cae0fb0e6:


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 53 69 6d 70  erms of the Simp
0090: 6c 69 66 69 65 64 20 42 53 44 20 4c 69 63 65 6e  lified BSD Licen
00a0: 73 65 20 28 61 6c 73 6f 0a 23 20 6b 6e 6f 77 6e  se (also.# known
00b0: 20 61 73 20 74 68 65 20 22 32 2d 43 6c 61 75 73   as the "2-Claus
00c0: 65 20 4c 69 63 65 6e 73 65 22 20 6f 72 20 22 46  e License" or "F
00d0: 72 65 65 42 53 44 20 4c 69 63 65 6e 73 65 22 2e  reeBSD License".
00e0: 29 0a 23 0a 23 20 54 68 69 73 20 70 72 6f 67 72  ).#.# This progr
00f0: 61 6d 20 69 73 20 64 69 73 74 72 69 62 75 74 65  am is distribute
0100: 64 20 69 6e 20 74 68 65 20 68 6f 70 65 20 74 68  d in the hope th
0110: 61 74 20 69 74 20 77 69 6c 6c 20 62 65 20 75 73  at it will be us
0120: 65 66 75 6c 2c 0a 23 20 62 75 74 20 77 69 74 68  eful,.# but with
0130: 6f 75 74 20 61 6e 79 20 77 61 72 72 61 6e 74 79  out any warranty
0140: 3b 20 77 69 74 68 6f 75 74 20 65 76 65 6e 20 74  ; without even t
0150: 68 65 20 69 6d 70 6c 69 65 64 20 77 61 72 72 61  he implied warra
0160: 6e 74 79 20 6f 66 0a 23 20 6d 65 72 63 68 61 6e  nty of.# merchan
0170: 74 61 62 69 6c 69 74 79 20 6f 72 20 66 69 74 6e  tability or fitn
0180: 65 73 73 20 66 6f 72 20 61 20 70 61 72 74 69 63  ess for a partic
0190: 75 6c 61 72 20 70 75 72 70 6f 73 65 2e 0a 23 0a  ular purpose..#.
01a0: 23 20 41 75 74 68 6f 72 20 63 6f 6e 74 61 63 74  # Author contact
01b0: 20 69 6e 66 6f 72 6d 61 74 69 6f 6e 3a 0a 23 20   information:.# 
01c0: 20 20 64 72 68 40 68 77 61 63 69 2e 63 6f 6d 0a    drh@hwaci.com.
01d0: 23 20 20 20 68 74 74 70 3a 2f 2f 77 77 77 2e 68  #   http://www.h
01e0: 77 61 63 69 2e 63 6f 6d 2f 64 72 68 2f 0a 23 0a  waci.com/drh/.#.
01f0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23  ################
0200: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23  ################
0210: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23  ################
0220: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23  ################
0230: 23 23 23 23 23 23 23 23 23 23 23 23 0a 23 0a 23  ############.#.#
0240: 20 54 65 73 74 73 20 6f 66 20 74 68 65 20 64 65   Tests of the de
0250: 6c 74 61 20 6d 65 63 68 61 6e 69 73 6d 2e 0a 23  lta mechanism..#
0260: 0a 0a 23 20 55 73 65 20 74 65 73 74 20 73 63 72  ..# Use test scr
0270: 69 70 74 20 66 69 6c 65 73 20 61 73 20 74 68 65  ipt files as the
0280: 20 62 61 73 69 73 20 66 6f 72 20 74 68 69 73 20   basis for this 
0290: 74 65 73 74 2e 0a 23 0a 23 20 46 6f 72 20 65 61  test..#.# For ea
02a0: 63 68 20 74 65 73 74 2c 20 63 6f 70 79 20 74 68  ch test, copy th
02b0: 65 20 66 69 6c 65 20 69 6e 74 61 63 74 20 74 6f  e file intact to
02c0: 20 22 2e 2f 74 31 22 2e 20 20 4d 61 6b 65 0a 23   "./t1".  Make.#
02d0: 20 73 6f 6d 65 20 72 61 6e 64 6f 6d 20 63 68 61   some random cha
02e0: 6e 67 65 73 20 69 6e 20 22 2e 2f 74 32 22 2e 20  nges in "./t2". 
02f0: 20 54 68 65 6e 20 63 61 6c 6c 20 74 65 73 74 2d   Then call test-
0300: 64 65 6c 74 61 20 6f 6e 20 74 68 65 0a 23 20 74  delta on the.# t
0310: 77 6f 20 66 69 6c 65 73 20 74 6f 20 6d 61 6b 65  wo files to make
0320: 20 73 75 72 65 20 74 68 61 74 20 64 65 6c 74 61   sure that delta
0330: 73 20 62 65 74 77 65 65 6e 20 74 68 65 73 65 20  s between these 
0340: 74 77 6f 20 66 69 6c 65 73 0a 23 20 77 6f 72 6b  two files.# work
0350: 20 70 72 6f 70 65 72 6c 79 2e 0a 23 0a 73 65 74   properly..#.set
0360: 20 66 69 6c 65 6c 69 73 74 20 5b 67 6c 6f 62 20   filelist [glob 
0370: 24 74 65 73 74 64 69 72 2f 2a 5d 0a 66 6f 72 65  $testdir/*].fore
0380: 61 63 68 20 66 20 24 66 69 6c 65 6c 69 73 74 20  ach f $filelist 
0390: 7b 0a 20 20 69 66 20 7b 5b 66 69 6c 65 20 69 73  {.  if {[file is
03a0: 64 69 72 20 24 66 5d 7d 20 63 6f 6e 74 69 6e 75  dir $f]} continu
03b0: 65 0a 20 20 73 65 74 20 62 61 73 65 20 5b 66 69  e.  set base [fi
03c0: 6c 65 20 72 6f 6f 74 20 5b 66 69 6c 65 20 74 61  le root [file ta
03d0: 69 6c 20 24 66 5d 5d 0a 20 20 73 65 74 20 66 31  il $f]].  set f1
03e0: 20 5b 72 65 61 64 5f 66 69 6c 65 20 24 66 5d 0a   [read_file $f].
03f0: 20 20 77 72 69 74 65 5f 66 69 6c 65 20 74 31 20    write_file t1 
0400: 24 66 31 0a 20 20 66 6f 72 20 7b 73 65 74 20 69  $f1.  for {set i
0410: 20 30 7d 20 7b 24 69 3c 31 30 30 7d 20 7b 69 6e   0} {$i<100} {in
0420: 63 72 20 69 7d 20 7b 0a 20 20 20 20 77 72 69 74  cr i} {.    writ
0430: 65 5f 66 69 6c 65 20 74 32 20 5b 72 61 6e 64 6f  e_file t2 [rando
0440: 6d 5f 63 68 61 6e 67 65 73 20 24 66 31 20 31 20  m_changes $f1 1 
0450: 31 20 30 20 30 2e 31 5d 0a 20 20 20 20 66 6f 73  1 0 0.1].    fos
0460: 73 69 6c 20 74 65 73 74 2d 64 65 6c 74 61 20 74  sil test-delta t
0470: 31 20 74 32 0a 20 20 20 20 74 65 73 74 20 64 65  1 t2.    test de
0480: 6c 74 61 2d 24 62 61 73 65 2d 24 69 2d 31 20 7b  lta-$base-$i-1 {
0490: 24 52 45 53 55 4c 54 3d 3d 22 6f 6b 22 7d 0a 20  $RESULT=="ok"}. 
04a0: 20 20 20 77 72 69 74 65 5f 66 69 6c 65 20 74 32     write_file t2
04b0: 20 5b 72 61 6e 64 6f 6d 5f 63 68 61 6e 67 65 73   [random_changes
04c0: 20 24 66 31 20 31 20 31 20 30 20 30 2e 32 5d 0a   $f1 1 1 0 0.2].
04d0: 20 20 20 20 66 6f 73 73 69 6c 20 74 65 73 74 2d      fossil test-
04e0: 64 65 6c 74 61 20 74 31 20 74 32 0a 20 20 20 20  delta t1 t2.    
04f0: 74 65 73 74 20 64 65 6c 74 61 2d 24 62 61 73 65  test delta-$base
0500: 2d 24 69 2d 32 20 7b 24 52 45 53 55 4c 54 3d 3d  -$i-2 {$RESULT==
0510: 22 6f 6b 22 7d 0a 20 20 20 20 77 72 69 74 65 5f  "ok"}.    write_
0520: 66 69 6c 65 20 74 32 20 5b 72 61 6e 64 6f 6d 5f  file t2 [random_
0530: 63 68 61 6e 67 65 73 20 24 66 31 20 31 20 31 20  changes $f1 1 1 
0540: 30 20 30 2e 34 5d 0a 20 20 20 20 66 6f 73 73 69  0 0.4].    fossi
0550: 6c 20 74 65 73 74 2d 64 65 6c 74 61 20 74 31 20  l test-delta t1 
0560: 74 32 0a 20 20 20 20 74 65 73 74 20 64 65 6c 74  t2.    test delt
0570: 61 2d 24 62 61 73 65 2d 24 69 2d 33 20 7b 24 52  a-$base-$i-3 {$R
0580: 45 53 55 4c 54 3d 3d 22 6f 6b 22 7d 0a 20 20 7d  ESULT=="ok"}.  }
0590: 0a 7d 0a                                         .}.