From cbd822c9dfe8cf18d828bd558290f15775b4d837 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Fri, 17 Jul 2009 19:40:47 +0200 Subject: tests: First work on the new testsuite. The module tests.test_all will run all available tests. Each test placed herein must be using unittest and provide at least 1 test case. It must be prefixed with test_. --- tests/old/lock.py | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 tests/old/lock.py (limited to 'tests/old/lock.py') diff --git a/tests/old/lock.py b/tests/old/lock.py new file mode 100644 index 00000000..d45b3964 --- /dev/null +++ b/tests/old/lock.py @@ -0,0 +1,47 @@ +#!/usr/bin/env python2.4 +# +# Test for the pkgCache code +# + +import apt_pkg +import sys +import os + + +if __name__ == "__main__": + lock = "/tmp/test.lck" + + apt_pkg.init() + + # system-lock + apt_pkg.PkgSystemLock() + + pid = os.fork() + if pid == 0: + try: + apt_pkg.PkgSystemLock() + except SystemError, s: + print "Can't get lock: (error text:\n%s)" % s + sys.exit(0) + + apt_pkg.PkgSystemUnLock() + + # low-level lock + fd = apt_pkg.GetLock(lock, True) + print "Lockfile fd: %s" % fd + + # try to get lock without error flag + pid = os.fork() + if pid == 0: + # child + fd = apt_pkg.GetLock(lock, False) + print "Lockfile fd (child): %s" % fd + sys.exit(0) + + # try to get lock with error flag + pid = os.fork() + if pid == 0: + # child + fd = apt_pkg.GetLock(lock, True) + print "Lockfile fd (child): %s" % fd + sys.exit(0) -- cgit v1.2.3