3 from bup.helpers import *
4 import bup.xstat as xstat
9 cd = os.path.realpath('../../../t')
11 sd = os.path.realpath(cd + '/sampledata')
12 WVPASSEQ(index.realpath(cd + '/sampledata'), cd + '/sampledata')
13 WVPASSEQ(os.path.realpath(cd + '/sampledata/x'), sd + '/x')
14 WVPASSEQ(os.path.realpath(cd + '/sampledata/etc'), os.path.realpath('/etc'))
15 WVPASSEQ(index.realpath(cd + '/sampledata/etc'), sd + '/etc')
22 fs = xstat.stat('tindex.py')
23 w = index.Writer('index.tmp')
24 w.add('/var/tmp/sporky', fs)
25 w.add('/etc/passwd', fs)
33 print '%s%s %s' % (e.is_valid() and ' ' or 'M',
34 e.is_fake() and 'F' or ' ',
37 def fake_validate(*l):
40 e.validate(0100644, index.FAKE_SHA)
54 fs = xstat.stat('tindex.py')
56 w1 = index.Writer('index.tmp')
64 w2 = index.Writer('index2.tmp')
65 w2.add('/a/b/n/2', fs)
69 w3 = index.Writer('index3.tmp')
70 w3.add('/a/c/n/3', fs)
79 r1all = [e.name for e in r1]
81 ['/a/b/x', '/a/b/c', '/a/b/', '/a/', '/'])
82 r2all = [e.name for e in r2]
84 ['/a/b/n/2', '/a/b/n/', '/a/b/', '/a/', '/'])
85 r3all = [e.name for e in r3]
87 ['/a/c/n/3', '/a/c/n/', '/a/c/', '/a/', '/'])
88 m = index.MergeIter([r2,r1,r3])
89 all = [e.name for e in m]
91 ['/a/c/n/3', '/a/c/n/', '/a/c/',
92 '/a/b/x', '/a/b/n/2', '/a/b/n/', '/a/b/c',
97 print [hex(e.flags) for e in r1]
98 WVPASSEQ([e.name for e in r1 if e.is_valid()], r1all)
99 WVPASSEQ([e.name for e in r1 if not e.is_valid()], [])
100 WVPASSEQ([e.name for e in m if not e.is_valid()],
101 ['/a/c/n/3', '/a/c/n/', '/a/c/',
102 '/a/b/n/2', '/a/b/n/', '/a/b/', '/a/', '/'])
104 expect_invalid = ['/'] + r2all + r3all
105 expect_real = (set(r1all) - set(r2all) - set(r3all)) \
106 | set(['/a/b/n/2', '/a/c/n/3'])
109 print e.name, hex(e.flags), e.ctime
110 eiv = e.name in expect_invalid
111 er = e.name in expect_real
112 WVPASSEQ(eiv, not e.is_valid())
113 WVPASSEQ(er, e.is_real())
114 fake_validate(r2, r3)
116 WVPASSEQ([e.name for e in m if not e.is_valid()], [])
118 e = eget(m, '/a/b/c')
122 WVPASSEQ([e.name for e in m if not e.is_valid()],
123 ['/a/b/c', '/a/b/', '/a/', '/'])