Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Kea
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
450
Issues
450
List
Boards
Labels
Service Desk
Milestones
Merge Requests
75
Merge Requests
75
Operations
Operations
Incidents
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
ISC Open Source Projects
Kea
Commits
9cffd7d9
Commit
9cffd7d9
authored
May 21, 2012
by
Tomek Mrugalski
🛰
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[1503] Basic Python test for b10-dhcp4 added.
parent
2be06486
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
85 additions
and
0 deletions
+85
-0
src/bin/dhcp4/tests/Makefile.am
src/bin/dhcp4/tests/Makefile.am
+12
-0
src/bin/dhcp4/tests/dhcp4_test.py
src/bin/dhcp4/tests/dhcp4_test.py
+73
-0
No files found.
src/bin/dhcp4/tests/Makefile.am
View file @
9cffd7d9
PYCOVERAGE_RUN
=
@PYCOVERAGE_RUN@
PYTESTS
=
dhcp4_test.py
EXTRA_DIST
=
$(PYTESTS)
# If necessary (rare cases), explicitly specify paths to dynamic libraries
# required by loadable python modules.
LIBRARY_PATH_PLACEHOLDER
=
...
...
@@ -7,6 +10,15 @@ if SET_ENV_LIBRARY_PATH
LIBRARY_PATH_PLACEHOLDER
+=
$(ENV_LIBRARY_PATH)
=
$(abs_top_builddir)
/src/lib/cryptolink/.libs:
$(abs_top_builddir)
/src/lib/dns/.libs:
$(abs_top_builddir)
/src/lib/dns/python/.libs:
$(abs_top_builddir)
/src/lib/cc/.libs:
$(abs_top_builddir)
/src/lib/config/.libs:
$(abs_top_builddir)
/src/lib/log/.libs:
$(abs_top_builddir)
/src/lib/util/.libs:
$(abs_top_builddir)
/src/lib/exceptions/.libs:
$(abs_top_builddir)
/src/lib/util/io/.libs:
$(abs_top_builddir)
/src/lib/datasrc/.libs:
$$$(ENV_LIBRARY_PATH)
endif
# test using command-line arguments, so use check-local target instead of TESTS
check-local
:
for
pytest
in
$(PYTESTS)
;
do
\
echo
Running
test
:
$$
pytest
;
\
PYTHONPATH
=
$(COMMON_PYTHON_PATH)
:
$(abs_top_srcdir)
/src/bin:
$(abs_top_builddir)
/src/bin/bind10:
$(abs_top_builddir)
/src/lib/util/io/.libs
\
$(LIBRARY_PATH_PLACEHOLDER)
\
$(PYCOVERAGE_RUN)
$(abs_srcdir)
/
$$
pytest
||
exit
;
\
done
AM_CPPFLAGS
=
-I
$(top_srcdir)
/src/lib
-I
$(top_builddir)
/src/lib
AM_CPPFLAGS
+=
-I
$(top_builddir)
/src/bin
# for generated spec_config.h header
AM_CPPFLAGS
+=
-I
$(top_srcdir)
/src/bin
...
...
src/bin/dhcp4/tests/dhcp4_test.py
0 → 100644
View file @
9cffd7d9
# Copyright (C) 2011 Internet Systems Consortium.
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SYSTEMS CONSORTIUM
# DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
# INTERNET SYSTEMS CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
# FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
# NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
# WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
from
bind10_src
import
ProcessInfo
,
parse_args
,
dump_pid
,
unlink_pid_file
,
_BASETIME
import
unittest
import
sys
import
os
import
signal
import
socket
from
isc.net.addr
import
IPAddr
import
time
import
isc
class
TestDhcpv4Daemon
(
unittest
.
TestCase
):
def
setUp
(
self
):
print
(
"Note: Purpose of some of the tests is to check if DHCPv4 server can be started,"
)
print
(
" not that is can bind sockets correctly. Please ignore binding errors."
)
# redirect stdout to a pipe so we can check that our
# process spawning is doing the right thing with stdout
self
.
old_stdout
=
os
.
dup
(
sys
.
stdout
.
fileno
())
self
.
pipes
=
os
.
pipe
()
os
.
dup2
(
self
.
pipes
[
1
],
sys
.
stdout
.
fileno
())
os
.
close
(
self
.
pipes
[
1
])
# note that we use dup2() to restore the original stdout
# to the main program ASAP in each test... this prevents
# hangs reading from the child process (as the pipe is only
# open in the child), and also insures nice pretty output
def
tearDown
(
self
):
# clean up our stdout munging
os
.
dup2
(
self
.
old_stdout
,
sys
.
stdout
.
fileno
())
os
.
close
(
self
.
pipes
[
0
])
def
test_alive
(
self
):
"""
Simple test. Checks that b10-dhcp4 can be started and prints out info
about starting DHCPv4 operation.
"""
pi
=
ProcessInfo
(
'Test Process'
,
[
'../b10-dhcp4'
,
'-v'
])
pi
.
spawn
()
time
.
sleep
(
1
)
os
.
dup2
(
self
.
old_stdout
,
sys
.
stdout
.
fileno
())
self
.
assertNotEqual
(
pi
.
process
,
None
)
self
.
assertTrue
(
type
(
pi
.
pid
)
is
int
)
output
=
os
.
read
(
self
.
pipes
[
0
],
4096
)
self
.
assertEqual
(
str
(
output
).
count
(
"[b10-dhcp4] Initiating DHCPv4 server operation."
),
1
)
# kill this process
# XXX: b10-dhcp6 is too dumb to understand 'shutdown' command for now,
# so let's just kill the bastard
# TODO: Ignore errors for now. This test will be more thorough once ticket #1503
# (passing port number to b10-dhcp6 daemon) is implemented.
try
:
os
.
kill
(
pi
.
pid
,
signal
.
SIGTERM
)
except
OSError
:
print
(
"Ignoring failed kill attempt. Process is dead already."
)
if
__name__
==
'__main__'
:
unittest
.
main
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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