mirror of
https://github.com/systemd/systemd-stable.git
synced 2024-10-27 18:55:09 +03:00
test-network: add get_operstate() and check_operstate() helper functions
This commit is contained in:
parent
525b95f10e
commit
2be0b6fc5e
@ -220,6 +220,19 @@ class Utilities():
|
||||
args += ['--any']
|
||||
subprocess.check_call(args)
|
||||
|
||||
def get_operstate(self, link, show_status=True, setup_state='configured'):
|
||||
output = subprocess.check_output(['networkctl', 'status', link], universal_newlines=True).rstrip()
|
||||
if show_status:
|
||||
print(output)
|
||||
for line in output.splitlines():
|
||||
if 'State:' in line and (not setup_state or setup_state in line):
|
||||
return line.split()[1]
|
||||
return None
|
||||
|
||||
def check_operstate(self, link, expected, show_status=True, setup_state='configured'):
|
||||
self.assertRegex(self.get_operstate(link, show_status, setup_state), expected)
|
||||
|
||||
|
||||
class NetworkdNetDevTests(unittest.TestCase, Utilities):
|
||||
|
||||
links =[
|
||||
|
Loading…
Reference in New Issue
Block a user