diff options
author | Giampaolo Rodola <g.rodola@gmail.com> | 2016-10-25 00:50:40 +0200 |
---|---|---|
committer | Giampaolo Rodola <g.rodola@gmail.com> | 2016-10-25 00:50:40 +0200 |
commit | 21b54747b531fbbc3624244eacd9bb305de80d30 (patch) | |
tree | 22190117c59fdffc37501088478aec705b607a9d | |
parent | c6947ce73aae4147dab50d34545b8128ebb1317c (diff) | |
download | psutil-21b54747b531fbbc3624244eacd9bb305de80d30.tar.gz |
add mtu test for osx and bsd
-rwxr-xr-x | psutil/tests/test_bsd.py | 12 | ||||
-rwxr-xr-x | psutil/tests/test_osx.py | 11 |
2 files changed, 23 insertions, 0 deletions
diff --git a/psutil/tests/test_bsd.py b/psutil/tests/test_bsd.py index 28245cc5..244672e6 100755 --- a/psutil/tests/test_bsd.py +++ b/psutil/tests/test_bsd.py @@ -12,6 +12,7 @@ import datetime import os +import re import subprocess import sys import time @@ -134,6 +135,17 @@ class BSDSpecificTestCase(unittest.TestCase): num = sysctl('hw.physmem') self.assertEqual(num, psutil.virtual_memory().total) + def test_net_if_stats(self): + for name, stats in psutil.net_if_stats().items(): + try: + out = sh("ifconfig %s" % name) + except RuntimeError: + pass + else: + self.assertEqual(stats.isup, 'RUNNING' in out, msg=out) + self.assertEqual(stats.mtu, + int(re.findall('mtu (\d+)', out)[0])) + # ===================================================================== # --- FreeBSD diff --git a/psutil/tests/test_osx.py b/psutil/tests/test_osx.py index 064972f1..7b61bc74 100755 --- a/psutil/tests/test_osx.py +++ b/psutil/tests/test_osx.py @@ -206,6 +206,17 @@ class TestSystemAPIs(unittest.TestCase): # self.assertEqual(psutil_smem.used, human2bytes(used)) # self.assertEqual(psutil_smem.free, human2bytes(free)) + def test_net_if_stats(self): + for name, stats in psutil.net_if_stats().items(): + try: + out = sh("ifconfig %s" % name) + except RuntimeError: + pass + else: + self.assertEqual(stats.isup, 'RUNNING' in out, msg=out) + self.assertEqual(stats.mtu, + int(re.findall('mtu (\d+)', out)[0])) + if __name__ == '__main__': run_test_module_by_name(__file__) |