diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 18:07:41 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 18:07:41 +0000 |
commit | 76926159194e180003aa78de97e5f287bf4325a5 (patch) | |
tree | 2cea7245cdc3f66355900c820c145eba90598766 /tests/old/lock.py | |
parent | Initial commit. (diff) | |
download | python-apt-76926159194e180003aa78de97e5f287bf4325a5.tar.xz python-apt-76926159194e180003aa78de97e5f287bf4325a5.zip |
Adding upstream version 2.7.6.upstream/2.7.6
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | tests/old/lock.py | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/tests/old/lock.py b/tests/old/lock.py new file mode 100644 index 0000000..c09983c --- /dev/null +++ b/tests/old/lock.py @@ -0,0 +1,47 @@ +#!/usr/bin/env python2.4 +# +# Test for the pkgCache code +# + +import os +import sys + +import apt_pkg + +if __name__ == "__main__": + lock = "/tmp/test.lck" + + apt_pkg.init() + + # system-lock + apt_pkg.pkgsystem_lock() + + pid = os.fork() + if pid == 0: + try: + apt_pkg.pkgsystem_lock() + except SystemError as s: + print("Can't get lock: (error text:\n%s)" % s) + sys.exit(0) + + apt_pkg.pkgsystem_unlock() + + # low-level lock + fd = apt_pkg.get_lock(lock, True) + print("Lockfile fd: %s" % fd) + + # try to get lock without error flag + pid = os.fork() + if pid == 0: + # child + fd = apt_pkg.get_lock(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.get_lock(lock, True) + print("Lockfile fd (child): %s" % fd) + sys.exit(0) |