--- /dev/null
+
+AT_BANNER([RPM dependency matching])
+
+RPMPY_CHECK([provide - require pairs],[
+# ((provides), (requires), match) expected values
+tests = [
+ (('=', '1.2'), ('=', '1.2'), 1),
+ (('=', '1.2'), ('>=', '1.2'), 1),
+ (('=', '1.2'), ('<=', '1.2'), 1),
+ (('=', '1.2'), ('<', '1.2'), 0),
+ (('=', '1.2'), ('>', '1.2'), 0),
+ (('=', '1.2'), ('<>', '1.2'), 0),
+
+ (('=', '1.2'), ('=', '1.3'), 0),
+ (('=', '1.2'), ('>=', '1.3'), 0),
+ (('=', '1.2'), ('<=', '1.3'), 1),
+ (('=', '1.2'), ('<', '1.3'), 1),
+ (('=', '1.2'), ('>', '1.3'), 0),
+ (('=', '1.2'), ('<>', '1.3'), 1),
+
+ (('=', '1.2-1'), ('=', '1.2-1'), 1),
+ (('=', '1.2-1'), ('>=', '1.2-1'), 1),
+ (('=', '1.2-1'), ('<=', '1.2-1'), 1),
+ (('=', '1.2-1'), ('<', '1.2-1'), 0),
+ (('=', '1.2-1'), ('>', '1.2-1'), 0),
+ (('=', '1.2-1'), ('<>', '1.2-1'), 0),
+
+ (('=', '1.2-1'), ('=', '1.2-2'), 0),
+ (('=', '1.2-1'), ('>=', '1.2-2'), 0),
+ (('=', '1.2-1'), ('<=', '1.2-2'), 1),
+ (('=', '1.2-1'), ('<', '1.2-2'), 1),
+ (('=', '1.2-1'), ('>', '1.2-2'), 0),
+ (('=', '1.2-1'), ('<>', '1.2-2'), 1),
+
+ (('=', '1.3-1'), ('=', '1.2-2'), 0),
+ (('=', '1.3-1'), ('>=', '1.2-2'), 1),
+ (('=', '1.3-1'), ('<=', '1.2-2'), 0),
+ (('=', '1.3-1'), ('<', '1.2-2'), 0),
+ (('=', '1.3-1'), ('>', '1.2-2'), 1),
+ (('=', '1.3-1'), ('<>', '1.2-2'), 1),
+
+ (('=', '0:1.2'), ('=', '1.2'), 1),
+ (('=', '0:1.2'), ('>=', '1.2'), 1),
+ (('=', '0:1.2'), ('<=', '1.2'), 1),
+ (('=', '0:1.2'), ('<', '1.2'), 0),
+ (('=', '0:1.2'), ('>', '1.2'), 0),
+ (('=', '0:1.2'), ('<>', '1.2'), 0),
+
+ (('=', '1.2'), ('=', '0:1.2'), 1),
+ (('=', '1.2'), ('>=', '0:1.2'), 1),
+ (('=', '1.2'), ('<=', '0:1.2'), 1),
+ (('=', '1.2'), ('<', '0:1.2'), 0),
+ (('=', '1.2'), ('>', '0:1.2'), 0),
+ (('=', '1.2'), ('<>', '0:1.2'), 0),
+
+ (('=', '1:1.2'), ('=', '1.2'), 0),
+ (('=', '1:1.2'), ('>=', '1.2'), 1),
+ (('=', '1:1.2'), ('<=', '1.2'), 0),
+ (('=', '1:1.2'), ('<', '1.2'), 0),
+ (('=', '1:1.2'), ('>', '1.2'), 1),
+ (('=', '1:1.2'), ('<>', '1.2'), 1),
+
+ (('=', '1.2'), ('=', '1:1.2'), 0),
+ (('=', '1.2'), ('>=', '1:1.2'), 0),
+ (('=', '1.2'), ('<=', '1:1.2'), 1),
+ (('=', '1.2'), ('<', '1:1.2'), 1),
+ (('=', '1.2'), ('>', '1:1.2'), 0),
+ (('=', '1.2'), ('<>', '1:1.2'), 1),
+
+ (('=', '2:1.2'), ('=', '2:1.2'), 1),
+ (('=', '2:1.2'), ('>=', '2:1.2'), 1),
+ (('=', '2:1.2'), ('<=', '2:1.2'), 1),
+ (('=', '2:1.2'), ('<', '2:1.2'), 0),
+ (('=', '2:1.2'), ('>', '2:1.2'), 0),
+ (('=', '2:1.2'), ('<>', '2:1.2'), 0),
+]
+
+ms = ['no match', 'match']
+
+myprint() # dumb kludge to fixup expected output
+for pv, rv, res in tests:
+ d1 = rpm.ds(('A', pv[0], pv[1]), 'provides')
+ d2 = rpm.ds(('A', rv[0], rv[1]), 'requires')
+ match = d1.Compare(d2)
+ if match != res:
+ myprint('FAILED: %s with %s: %s' % (d1.DNEVR(), d2.DNEVR(),ms[res]))
+],
+[]
+)