From 2c4899c8d7346ae3a9dbd830939fda29efb7a6a6 Mon Sep 17 00:00:00 2001 From: Panu Matilainen Date: Thu, 16 Dec 2010 17:39:00 +0200 Subject: Add a pile of dependency matching tests for "obvious" cases --- tests/Makefile.am | 1 + tests/local.at | 2 +- tests/rpmdepmatch.at | 89 ++++++++++++++++++++++++++++++++++++++++++++++++++++ tests/rpmtests.at | 1 + 4 files changed, 92 insertions(+), 1 deletion(-) create mode 100644 tests/rpmdepmatch.at diff --git a/tests/Makefile.am b/tests/Makefile.am index cb2456229..21113da41 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -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 diff --git a/tests/local.at b/tests/local.at index 64564cb72..7ee80607d 100644 --- a/tests/local.at +++ b/tests/local.at @@ -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 index 000000000..a7843b41e --- /dev/null +++ b/tests/rpmdepmatch.at @@ -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])) +], +[] +) diff --git a/tests/rpmtests.at b/tests/rpmtests.at index be0bdb091..7f0807d0b 100644 --- a/tests/rpmtests.at +++ b/tests/rpmtests.at @@ -10,3 +10,4 @@ m4_include([rpmconflict.at]) m4_include([rpmconfig.at]) m4_include([rpmmacro.at]) m4_include([rpmpython.at]) +m4_include([rpmdepmatch.at]) -- cgit v1.2.3