Skip to content

Commit

Permalink
Added kwarg lib_name to allow manual setting library path/name (#32)
Browse files Browse the repository at this point in the history
  • Loading branch information
thiezn committed Mar 27, 2018
1 parent 6135b36 commit 6656d04
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 6 deletions.
4 changes: 4 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
Release History
---------------

0.1.10 (2018-03-28)
+++++++++++++++++++
- Allow manual set of libiperf library path and name using lib_name kwarg on Iperf3 Class

0.1.9 (2018-02-22)
++++++++++++++++++
- Use find_library to load libiperf (Thanks to @Austinpayne). This should allow iperf3 lib to run on Mac OS X.
Expand Down
4 changes: 2 additions & 2 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@
# built documents.
#
# The short X.Y version.
version = '0.1.9'
version = '0.1.10'
# The full version, including alpha/beta/rc tags.
release = '0.1.9'
release = '0.1.10'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
12 changes: 8 additions & 4 deletions iperf3/iperf3.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class provides common settings for the :class:`Client` and :class:`Server`
from Queue import Queue # Python2 compatibility


__version__ = '0.1.9'
__version__ = '0.1.10'


MAX_UDP_BULKSIZE = (65535 - 8 - 20)
Expand Down Expand Up @@ -88,15 +88,19 @@ class IPerf3(object):
"""
def __init__(self,
role,
verbose=True):
verbose=True,
lib_name=None):
"""Initialise the iperf shared library
:param role: 'c' = client; 's' = server
:param verbose: enable verbose output
:param lib_name: optional name and path for libiperf.so.0 library
"""
lib_name = util.find_library('libiperf')
if lib_name is None:
lib_name = 'libiperf.so.0'
lib_name = util.find_library('libiperf')
if lib_name is None:
# If we still couldn't find it lets try the manual approach
lib_name = 'libiperf.so.0'

try:
self.lib = cdll.LoadLibrary(lib_name)
Expand Down
4 changes: 4 additions & 0 deletions tests/test_iperf3.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ def test_init_server(self):
server = iperf3.Server()
assert server._test

def test_lib_name(self):
client = iperf3.Client(lib_name='libiperf.so.0')
assert client._test

def test_run_not_implemented(self):
with pytest.raises(NotImplementedError):
client = iperf3.IPerf3(role='c')
Expand Down

0 comments on commit 6656d04

Please sign in to comment.