Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ISC Open Source Projects
Kea
Commits
2e95197a
Commit
2e95197a
authored
May 25, 2012
by
Mukund Sivaraman
Browse files
[1704] Test remove_lock_files()
parent
7c1277b0
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/bin/bind10/bind10_src.py.in
View file @
2e95197a
...
...
@@ -1138,7 +1138,9 @@ def remove_lock_files():
lpath = os.environ["B10_FROM_SOURCE_LOCALSTATEDIR"]
for f in lockfiles:
os.unlink(lpath + '/' + f)
fname = lpath + '/' + f
if os.path.isfile(fname):
os.unlink(fname)
return
...
...
src/bin/bind10/tests/Makefile.am
View file @
2e95197a
...
...
@@ -23,6 +23,7 @@ endif
chmod +x $(abs_builddir)/$$pytest ;
\
$(LIBRARY_PATH_PLACEHOLDER)
\
PYTHONPATH=$(COMMON_PYTHON_PATH):$(abs_top_srcdir)/src/bin:$(abs_top_builddir)/src/bin/bind10:$(abs_top_builddir)/src/lib/util/io/.libs
\
LOCKFILE_TESTPATH=$(abs_top_builddir)/src/bin/bind10/tests/lockfile_test
\
BIND10_MSGQ_SOCKET_FILE=$(abs_top_builddir)/msgq_socket
\
$(PYCOVERAGE_RUN) $(abs_builddir)/$$pytest || exit ;
\
done
src/bin/bind10/tests/bind10_test.py.in
View file @
2e95197a
...
...
@@ -1463,6 +1463,43 @@ class SocketSrvTest(unittest.TestCase):
self.assertEqual({}, self.__boss._unix_sockets)
self.assertTrue(sock.closed)
class TestFunctions(unittest.TestCase):
def test_remove_lock_files(self):
if not os.path.isdir(os.environ["LOCKFILE_TESTPATH"]):
os.mkdir(os.environ["LOCKFILE_TESTPATH"])
if "B10_FROM_BUILD" in os.environ:
oldenv = os.environ["B10_FROM_BUILD"]
else:
oldenv = None
os.environ["B10_FROM_BUILD"] = os.environ["LOCKFILE_TESTPATH"]
# create lockfiles for the testcase
lockfiles = ["logger_lockfile"]
for f in lockfiles:
fname = os.environ["B10_FROM_BUILD"] + '/' + f
if not os.path.isfile(fname):
open(fname, "w").close()
# first call should clear up all the lockfiles
bind10_src.remove_lock_files()
# check if the lockfiles exist
for f in lockfiles:
fname = os.environ["B10_FROM_BUILD"] + '/' + f
self.assertFalse(os.path.isfile(fname))
# second call should not assert anyway
bind10_src.remove_lock_files()
os.rmdir(os.environ["LOCKFILE_TESTPATH"])
if oldenv is not None:
os.environ["B10_FROM_BUILD"] = oldenv
else:
os.environ.pop("B10_FROM_BUILD")
if __name__ == '__main__':
# store os.environ for test_unchanged_environment
original_os_environ = copy.deepcopy(os.environ)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment