diff options
| author | Michael Vogt <michael.vogt@ubuntu.com> | 2005-09-12 12:39:05 +0000 |
|---|---|---|
| committer | Michael Vogt <michael.vogt@ubuntu.com> | 2005-09-12 12:39:05 +0000 |
| commit | 481269830ce99cef316c09db10235adca8fcc53d (patch) | |
| tree | be3143fa020c8e2a6b75e43142e1e8434549762b /tests | |
| parent | 3a03685e6c656fac6c11d6df299f0e651b00b4f4 (diff) | |
| download | python-apt-481269830ce99cef316c09db10235adca8fcc53d.tar.gz | |
* export locking
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/lock.py | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/tests/lock.py b/tests/lock.py new file mode 100644 index 00000000..5d2697f1 --- /dev/null +++ b/tests/lock.py @@ -0,0 +1,47 @@ +#!/usr/bin/env python2.4 +# +# Test for the pkgCache code +# + +import apt_pkg +import sys, 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) + |
