Skip to content

Commit

Permalink
tc-testing: don't hardcode 'ip' in nsPlugin.py
Browse files Browse the repository at this point in the history
the following tdc test fails on Fedora:

 # ./tdc.py -e 2638
  -- ns/SubPlugin.__init__
 Test 2638: Add matchall and try to get it
 -----> prepare stage *** Could not execute: "$TC qdisc add dev $DEV1 clsact"
 -----> prepare stage *** Error message: "/bin/sh: ip: command not found"
 returncode 127; expected [0]
 -----> prepare stage *** Aborting test run.

Let nsPlugin.py use the 'IP' variable introduced with commit 92c1a19
("tc-tests: added path to ip command in tdc"), so that the path to 'ip' is
correctly resolved to the value we have in tdc_config.py.

 # ./tdc.py -e 2638
  -- ns/SubPlugin.__init__
 Test 2638: Add matchall and try to get it
 All test results:
 1..1
 ok 1 2638 - Add matchall and try to get it

Fixes: 489ce2f ("tc-testing: Restore original behaviour for namespaces in tdc")
Reported-by: Hangbin Liu <liuhangbin@gmail.com>
Signed-off-by: Davide Caratti <dcaratti@redhat.com>
Acked-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Davide Caratti authored and David S. Miller committed Sep 1, 2019
1 parent 3daa418 commit 02a3f0d
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions tools/testing/selftests/tc-testing/plugin-lib/nsPlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def adjust_command(self, stage, command):
cmdlist.insert(0, self.args.NAMES['NS'])
cmdlist.insert(0, 'exec')
cmdlist.insert(0, 'netns')
cmdlist.insert(0, 'ip')
cmdlist.insert(0, self.args.NAMES['IP'])
else:
pass

Expand All @@ -78,16 +78,16 @@ def adjust_command(self, stage, command):
return command

def _ports_create(self):
cmd = 'ip link add $DEV0 type veth peer name $DEV1'
cmd = '$IP link add $DEV0 type veth peer name $DEV1'
self._exec_cmd('pre', cmd)
cmd = 'ip link set $DEV0 up'
cmd = '$IP link set $DEV0 up'
self._exec_cmd('pre', cmd)
if not self.args.namespace:
cmd = 'ip link set $DEV1 up'
cmd = '$IP link set $DEV1 up'
self._exec_cmd('pre', cmd)

def _ports_destroy(self):
cmd = 'ip link del $DEV0'
cmd = '$IP link del $DEV0'
self._exec_cmd('post', cmd)

def _ns_create(self):
Expand All @@ -97,16 +97,16 @@ def _ns_create(self):
'''
self._ports_create()
if self.args.namespace:
cmd = 'ip netns add {}'.format(self.args.NAMES['NS'])
cmd = '$IP netns add {}'.format(self.args.NAMES['NS'])
self._exec_cmd('pre', cmd)
cmd = 'ip link set $DEV1 netns {}'.format(self.args.NAMES['NS'])
cmd = '$IP link set $DEV1 netns {}'.format(self.args.NAMES['NS'])
self._exec_cmd('pre', cmd)
cmd = 'ip -n {} link set $DEV1 up'.format(self.args.NAMES['NS'])
cmd = '$IP -n {} link set $DEV1 up'.format(self.args.NAMES['NS'])
self._exec_cmd('pre', cmd)
if self.args.device:
cmd = 'ip link set $DEV2 netns {}'.format(self.args.NAMES['NS'])
cmd = '$IP link set $DEV2 netns {}'.format(self.args.NAMES['NS'])
self._exec_cmd('pre', cmd)
cmd = 'ip -n {} link set $DEV2 up'.format(self.args.NAMES['NS'])
cmd = '$IP -n {} link set $DEV2 up'.format(self.args.NAMES['NS'])
self._exec_cmd('pre', cmd)

def _ns_destroy(self):
Expand All @@ -115,7 +115,7 @@ def _ns_destroy(self):
devices as well)
'''
if self.args.namespace:
cmd = 'ip netns delete {}'.format(self.args.NAMES['NS'])
cmd = '$IP netns delete {}'.format(self.args.NAMES['NS'])
self._exec_cmd('post', cmd)

def _exec_cmd(self, stage, command):
Expand Down

0 comments on commit 02a3f0d

Please sign in to comment.