From 3c10bcbe72d12c4b9f12838c5ab09da539350855 Mon Sep 17 00:00:00 2001 From: Panu Matilainen Date: Fri, 1 Jul 2011 11:14:26 +0300 Subject: [PATCH] Add basic test for rpmio python bindings --- tests/rpmpython.at | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tests/rpmpython.at b/tests/rpmpython.at index d9d93b5..89002b1 100644 --- a/tests/rpmpython.at +++ b/tests/rpmpython.at @@ -32,6 +32,30 @@ prexp(mname) ], []) +RPMPY_TEST([basic rpmio],[ +msg = 'Killroy was here\n' +data = msg * 10 +# TODO: test other compression types too if built in +for iot in [ 'fpio', 'fdio', 'ufdio', 'gzdio' ]: + fn = 'pyio.%s' % iot + fd = rpm.fd(fn, 'w', iot) + if fd.write(data) != len(data): + myprint('%s write fail' % iot) + fd = rpm.fd(fn, 'r', iot) + rdata = fd.read() + if rdata != data: + myprint('%s read fail (got %d bytes)' % (iot, len(rdata), rdata)) + # compressed io types cant seek + if iot == 'ufdio': + fd.seek(0) + else: + fd = rpm.fd(fn, 'r', iot) + rdata = fd.read(len(msg)) + if rdata != msg: + myprint('%s sized read fail (got %d bytes)\n%s' % (iot, len(rdata), rdata)) +], +[]) + RPMPY_TEST([basic header manipulation],[ h = rpm.hdr() h['name'] = 'testpkg' -- 2.7.4