Add a pile of dependency matching tests for "obvious" cases
authorPanu Matilainen <pmatilai@redhat.com>
Thu, 16 Dec 2010 15:39:00 +0000 (17:39 +0200)
committerPanu Matilainen <pmatilai@redhat.com>
Thu, 16 Dec 2010 15:39:00 +0000 (17:39 +0200)
tests/Makefile.am
tests/local.at
tests/rpmdepmatch.at [new file with mode: 0644]
tests/rpmtests.at

index cb24562..21113da 100644 (file)
@@ -26,6 +26,7 @@ TESTSUITE_AT += rpmconflict.at
 TESTSUITE_AT += rpmconfig.at
 TESTSUITE_AT += rpmmacro.at
 TESTSUITE_AT += rpmpython.at
+TESTSUITE_AT += rpmdepmatch.at
 EXTRA_DIST += $(TESTSUITE_AT)
 
 ## testsuite data
index 64564cb..7ee8060 100644 (file)
@@ -13,7 +13,7 @@ rm -rf "${abs_builddir}"/testing`run rpm --eval '%_dbpath'`/*
 m4_define([RPMPY_RUN],[
 cat << EOF > test.py
 import rpm, sys
-def myprint(msg):
+def myprint(msg = ''):
     sys.stdout.write('%s\n' % msg)
 $1
 EOF
diff --git a/tests/rpmdepmatch.at b/tests/rpmdepmatch.at
new file mode 100644 (file)
index 0000000..a7843b4
--- /dev/null
@@ -0,0 +1,89 @@
+
+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]))
+],
+[]
+)
index be0bdb0..7f0807d 100644 (file)
@@ -10,3 +10,4 @@ m4_include([rpmconflict.at])
 m4_include([rpmconfig.at])
 m4_include([rpmmacro.at])
 m4_include([rpmpython.at])
+m4_include([rpmdepmatch.at])