diff options
author | Panu Matilainen <pmatilai@redhat.com> | 2010-12-09 16:32:56 +0200 |
---|---|---|
committer | Panu Matilainen <pmatilai@redhat.com> | 2010-12-10 17:05:22 +0200 |
commit | c83affa7fb7aa75fd56a9199394990937324dd03 (patch) | |
tree | f8737da9ef44cfffce041cf4cfb8f7e81463fb22 | |
parent | 1b66b93045e680cf2121faed4c520205dcb00b47 (diff) | |
download | rpm-c83affa7fb7aa75fd56a9199394990937324dd03.tar.gz rpm-c83affa7fb7aa75fd56a9199394990937324dd03.tar.bz2 rpm-c83affa7fb7aa75fd56a9199394990937324dd03.zip |
Add beginnings of python bindings test-suite
- Add some basic infrastructure: point PYTHONPATH to the testing
directory, helper macros to allow use of in-line python in test-suite
- Throw in a couple of simple tests for starters
(cherry picked from commit 2a37d9a4dcfd172db9a63584ec2267702153e00b)
-rw-r--r-- | tests/Makefile.am | 1 | ||||
-rw-r--r-- | tests/atlocal.in | 4 | ||||
-rw-r--r-- | tests/rpmpython.at | 59 | ||||
-rw-r--r-- | tests/rpmtests.at | 1 |
4 files changed, 65 insertions, 0 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am index 97644c706..cb2456229 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -25,6 +25,7 @@ TESTSUITE_AT += rpmdeps.at TESTSUITE_AT += rpmconflict.at TESTSUITE_AT += rpmconfig.at TESTSUITE_AT += rpmmacro.at +TESTSUITE_AT += rpmpython.at EXTRA_DIST += $(TESTSUITE_AT) ## testsuite data diff --git a/tests/atlocal.in b/tests/atlocal.in index 011f9beb1..d0ea0c8d3 100644 --- a/tests/atlocal.in +++ b/tests/atlocal.in @@ -3,6 +3,10 @@ export LD_LIBRARY_PATH PATH="${abs_builddir}/testing@rpmbindir@:${abs_builddir}/testing@usrbindir@:$PATH" export PATH +PYLIBDIR=`python -c "from distutils.sysconfig import get_python_lib; import sys; sys.stdout.write(get_python_lib(1))"` +PYTHONPATH="${abs_builddir}/testing${PYLIBDIR}" +export PYTHONPATH + RPMTEST="${abs_builddir}/testing" RPMDATA="${abs_srcdir}/data/" diff --git a/tests/rpmpython.at b/tests/rpmpython.at new file mode 100644 index 000000000..8651ca540 --- /dev/null +++ b/tests/rpmpython.at @@ -0,0 +1,59 @@ +# rpmpython.at: test rpm python bindings +# TODO: conditionalize on python availability + +AT_BANNER([Python bindings]) + +m4_define([RUNPY],[ +cat << EOF > test.py +import rpm, sys +def myprint(msg): + sys.stdout.write('%s\n' % msg) +$1 +EOF +python test.py +]) + +m4_define([PY_CHECK],[ +AT_SETUP([$1]) +AT_KEYWORDS([python]) +AT_CHECK([RUNPY([[$2]])], [], [$3], [$4]) +AT_CLEANUP +]) + +PY_CHECK([module import],[ +myprint(rpm.__version__) +], +[AT_PACKAGE_VERSION] +) + +PY_CHECK([basic header manipulation],[ +h = rpm.hdr() +h['name'] = 'testpkg' +h['version'] = '1.0' +h['release'] = '1' +h['epoch'] = 5 +h['arch'] = 'noarch' +myprint(h['nevra']) +del h['epoch'] +myprint(h['nevra']) +], +[testpkg-5:1.0-1.noarch +testpkg-1.0-1.noarch] +) + +PY_CHECK([reading a package file],[ +ts = rpm.ts() +h = ts.hdrFromFdno('${RPMDATA}/RPMS/hello-1.0-1.ppc64.rpm') +myprint(h['arch']) +], +[ppc64] +) + +PY_CHECK([add package to transaction],[ +ts = rpm.ts() +ts.addInstall('${RPMDATA}/RPMS/foo-1.0-1.noarch.rpm', 'u') +for e in ts: + myprint(e.NEVRA()) +], +[foo-1.0-1.noarch] +) diff --git a/tests/rpmtests.at b/tests/rpmtests.at index 315318fce..be0bdb091 100644 --- a/tests/rpmtests.at +++ b/tests/rpmtests.at @@ -9,3 +9,4 @@ m4_include([rpmdeps.at]) m4_include([rpmconflict.at]) m4_include([rpmconfig.at]) m4_include([rpmmacro.at]) +m4_include([rpmpython.at]) |