Skip to content

Commit 76a7085

Browse files
frenzymadnesshroncok
authored andcommitted
Expect that tests may run without root privileges
Partially fixes #40 Merges #43
1 parent 89ae35e commit 76a7085

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

tests/test_ethtool.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,13 @@ def _functions_accepting_devnames(self, devname):
145145
'[Errno 95] Operation not supported')
146146

147147
self.assertIsInt(ethtool.get_sg(devname))
148-
self.assertIsInt(ethtool.get_ufo(devname))
148+
149+
try:
150+
self.assertIsInt(ethtool.get_ufo(devname))
151+
except (OSError, IOError):
152+
# This test may fail due to insufficient privileges
153+
# That's IOError on 2.7, OSError (PermissionError) on 3
154+
pass
149155

150156
self.assertIsInt(ethtool.get_tso(devname))
151157

tests/test_scripts.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,21 @@ def test_show_coalesce_lo(self):
7272

7373
def test_show_offload_lo(self):
7474
self.assertIsNone(peth.show_offload(loopback))
75+
76+
# Check if we have rights to obtain ufo and set proper expected output
77+
try:
78+
ethtool.get_ufo(loopback)
79+
expected_ufo = 'on'
80+
except (OSError, IOError):
81+
expected_ufo = 'not supported'
82+
7583
self.assertEqual(self._output(),
7684
'''scatter-gather: on
7785
tcp segmentation offload: on
78-
udp fragmentation offload: on
86+
udp fragmentation offload: {expected_ufo}
7987
generic segmentation offload: on
8088
generic receive offload: on
81-
'''
89+
'''.format(expected_ufo=expected_ufo)
8290
)
8391

8492
# Tests for another device

0 commit comments

Comments
 (0)