source: yum/trunk/test/rpmdb-cache.py@ 1569

Last change on this file since 1569 was 2, checked in by Yuri Dario, 15 years ago

Initial import for vendor code.

  • Property svn:eol-style set to native
File size: 3.0 KB
Line 
1#! /usr/bin/python -tt
2
3import sys
4import yum
5
6__provides_of_requires_exact__ = False
7
8yb1 = yum.YumBase()
9yb1.conf.cache = True
10yb2 = yum.YumBase()
11yb2.conf.cache = True
12
13if len(sys.argv) > 1 and sys.argv[1].lower() == 'full':
14 print "Doing full test"
15 __provides_of_requires_exact__ = True
16
17assert hasattr(yb1.rpmdb, '__cache_rpmdb__')
18yb1.rpmdb.__cache_rpmdb__ = False
19yb2.setCacheDir()
20
21# Version
22ver1 = yb1.rpmdb.simpleVersion(main_only=True)[0]
23ver2 = yb2.rpmdb.simpleVersion(main_only=True)[0]
24if ver1 != ver2:
25 print >>sys.stderr, "Error: Version mismatch:", ver1, ver2
26
27# Conflicts
28cpkgs1 = yb1.rpmdb.returnConflictPackages()
29cpkgs2 = yb2.rpmdb.returnConflictPackages()
30if len(cpkgs1) != len(cpkgs2):
31 print >>sys.stderr, "Error: Conflict len mismatch:", len(cpkgs1),len(cpkgs2)
32for pkg in cpkgs1:
33 if pkg not in cpkgs2:
34 print >>sys.stderr, "Error: Conflict cache missing", pkg
35for pkg in cpkgs2:
36 if pkg not in cpkgs1:
37 print >>sys.stderr, "Error: Conflict cache extra", pkg
38
39# File Requires
40frd1, blah, fpd1 = yb1.rpmdb.fileRequiresData()
41frd2, blah, fpd2 = yb2.rpmdb.fileRequiresData()
42if len(frd1) != len(frd2):
43 print >>sys.stderr, "Error: FileReq len mismatch:", len(frd1), len(frd2)
44for pkgtup in frd1:
45 if pkgtup not in frd2:
46 print >>sys.stderr, "Error: FileReq cache missing", pkgtup
47 continue
48 if len(set(frd1[pkgtup])) != len(set(frd2[pkgtup])):
49 print >>sys.stderr, ("Error: FileReq[%s] len mismatch:" % (pkgtup,),
50 len(frd1[pkgtup]), len(frd2[pkgtup]))
51 for name in frd1[pkgtup]:
52 if name not in frd2[pkgtup]:
53 print >>sys.stderr, ("Error: FileReq[%s] cache missing" % (pkgtup,),
54 name)
55for pkgtup in frd2:
56 if pkgtup not in frd1:
57 print >>sys.stderr, "Error: FileReq cache extra", pkgtup
58 continue
59 for name in frd2[pkgtup]:
60 if name not in frd1[pkgtup]:
61 print >>sys.stderr, ("Error: FileReq[%s] cache extra" % (pkgtup,),
62 name)
63
64# File Provides (of requires) -- not exact
65if len(fpd1) != len(fpd2):
66 print >>sys.stderr, "Error: FileProv len mismatch:", len(fpd1), len(fpd2)
67for name in fpd1:
68 if name not in fpd2:
69 print >>sys.stderr, "Error: FileProv cache missing", name
70 continue
71
72 if not __provides_of_requires_exact__:
73 continue # We might be missing some providers
74
75 if len(fpd1[name]) != len(fpd2[name]):
76 print >>sys.stderr, ("Error: FileProv[%s] len mismatch:" % (pkgtup,),
77 len(fpd1[name]), len(fpd2[name]))
78 for pkgtup in fpd1[name]:
79 if pkgtup not in fpd2[name]:
80 print >>sys.stderr,"Error: FileProv[%s] cache missing" % name,pkgtup
81for name in fpd2:
82 if name not in fpd1:
83 print >>sys.stderr, "Error: FileProv cache extra", name
84 continue
85 for pkgtup in fpd2[name]:
86 if pkgtup not in fpd1[name]:
87 print >>sys.stderr,"Error: FileProv[%s] cache extra" % name,pkgtup
Note: See TracBrowser for help on using the repository browser.