Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Knot DNS
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
22
Issues
22
List
Boards
Labels
Milestones
Merge Requests
5
Merge Requests
5
Packages
Packages
Container Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Knot projects
Knot DNS
Commits
257b55c9
Commit
257b55c9
authored
Sep 22, 2016
by
Daniel Salzman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tests-extra: add support for libknot control interface
parent
8e90439f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
62 additions
and
21 deletions
+62
-21
python/libknot/control.py
python/libknot/control.py
+47
-21
tests-extra/tools/dnstest/libknot.py
tests-extra/tools/dnstest/libknot.py
+13
-0
tests-extra/tools/dnstest/params.py
tests-extra/tools/dnstest/params.py
+2
-0
No files found.
python/libknot/control.py
View file @
257b55c9
"""Libknot server control interface wrapper.
Example:
import json
from libknot.control import *
ctl = KnotCtl()
ctl.connect("/var/run/knot/knot.sock")
...
...
@@ -25,35 +28,56 @@ Example:
from
ctypes
import
cdll
,
c_void_p
,
c_int
,
c_char_p
,
c_uint
,
byref
from
enum
import
IntEnum
LIB
=
cdll
.
LoadLibrary
(
'libknot.so'
)
CTL_ALLOC
=
None
CTL_FREE
=
None
CTL_SET_TIMEOUT
=
None
CTL_CONNECT
=
None
CTL_CLOSE
=
None
CTL_SEND
=
None
CTL_RECEIVE
=
None
CTL_ERROR
=
None
def
load_lib
(
path
=
"libknot.so"
):
"""Loads the libknot library."""
LIB
=
cdll
.
LoadLibrary
(
path
)
CTL_ALLOC
=
LIB
.
knot_ctl_alloc
CTL_ALLOC
.
restype
=
c_void_p
global
CTL_ALLOC
CTL_ALLOC
=
LIB
.
knot_ctl_alloc
CTL_ALLOC
.
restype
=
c_void_p
CTL_FREE
=
LIB
.
knot_ctl_free
CTL_FREE
.
argtypes
=
[
c_void_p
]
global
CTL_FREE
CTL_FREE
=
LIB
.
knot_ctl_free
CTL_FREE
.
argtypes
=
[
c_void_p
]
CTL_SET_TIMEOUT
=
LIB
.
knot_ctl_set_timeout
CTL_SET_TIMEOUT
.
argtypes
=
[
c_void_p
,
c_int
]
global
CTL_SET_TIMEOUT
CTL_SET_TIMEOUT
=
LIB
.
knot_ctl_set_timeout
CTL_SET_TIMEOUT
.
argtypes
=
[
c_void_p
,
c_int
]
CTL_CONNECT
=
LIB
.
knot_ctl_connect
CTL_CONNECT
.
restype
=
c_int
CTL_CONNECT
.
argtypes
=
[
c_void_p
,
c_char_p
]
global
CTL_CONNECT
CTL_CONNECT
=
LIB
.
knot_ctl_connect
CTL_CONNECT
.
restype
=
c_int
CTL_CONNECT
.
argtypes
=
[
c_void_p
,
c_char_p
]
CTL_CLOSE
=
LIB
.
knot_ctl_close
CTL_CLOSE
.
argtypes
=
[
c_void_p
]
global
CTL_CLOSE
CTL_CLOSE
=
LIB
.
knot_ctl_close
CTL_CLOSE
.
argtypes
=
[
c_void_p
]
CTL_SEND
=
LIB
.
knot_ctl_send
CTL_SEND
.
restype
=
c_int
CTL_SEND
.
argtypes
=
[
c_void_p
,
c_uint
,
c_void_p
]
global
CTL_SEND
CTL_SEND
=
LIB
.
knot_ctl_send
CTL_SEND
.
restype
=
c_int
CTL_SEND
.
argtypes
=
[
c_void_p
,
c_uint
,
c_void_p
]
CTL_RECEIVE
=
LIB
.
knot_ctl_receive
CTL_RECEIVE
.
restype
=
c_int
CTL_RECEIVE
.
argtypes
=
[
c_void_p
,
c_void_p
,
c_void_p
]
global
CTL_RECEIVE
CTL_RECEIVE
=
LIB
.
knot_ctl_receive
CTL_RECEIVE
.
restype
=
c_int
CTL_RECEIVE
.
argtypes
=
[
c_void_p
,
c_void_p
,
c_void_p
]
CTL_ERROR
=
LIB
.
knot_strerror
CTL_ERROR
.
restype
=
c_char_p
CTL_ERROR
.
argtypes
=
[
c_int
]
global
CTL_ERROR
CTL_ERROR
=
LIB
.
knot_strerror
CTL_ERROR
.
restype
=
c_char_p
CTL_ERROR
.
argtypes
=
[
c_int
]
class
KnotCtlType
(
IntEnum
):
...
...
@@ -114,6 +138,8 @@ class KnotCtl(object):
"""Libknot server control interface."""
def
__init__
(
self
):
if
not
CTL_ALLOC
:
load_lib
()
self
.
obj
=
CTL_ALLOC
()
def
__del__
(
self
):
...
...
tests-extra/tools/dnstest/libknot.py
0 → 100644
View file @
257b55c9
#!/usr/bin/env python3
import
sys
from
dnstest.utils
import
Skip
import
dnstest.params
as
params
try
:
sys
.
path
.
append
(
params
.
repo_binary
(
"python"
))
import
libknot.control
libknot
.
control
.
load_lib
(
params
.
libknot_lib
)
except
:
raise
Skip
(
"libknot not available"
)
tests-extra/tools/dnstest/params.py
View file @
257b55c9
...
...
@@ -50,6 +50,8 @@ gdb_bin = get_binary("KNOT_TEST_GDB", "gdb")
vgdb_bin
=
get_binary
(
"KNOT_TEST_VGDB"
,
"vgdb"
)
# KNOT_TEST_LIBTOOL - libtool script.
libtool_bin
=
get_binary
(
"KNOT_TEST_LIBTOOL"
,
repo_binary
(
"libtool"
))
# KNOT_TEST_LIBKNOT - libknot library.
libknot_lib
=
get_binary
(
"KNOT_TEST_LIBKNOT"
,
repo_binary
(
"src/.libs/libknot.so"
))
# KNOT_TEST_KNOT - Knot binary.
knot_bin
=
get_binary
(
"KNOT_TEST_KNOT"
,
repo_binary
(
"src/knotd"
))
# KNOT_TEST_KNOTC - Knot control binary.
...
...
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