Fixing grep in validate mount point

When we look for the mount point of a labeled partition it can
happen that the grep command reports more than one mount point
because the devices start with the same path.

As an example, let's consider /dev/vda1, assigned from the
command ``/sbin/blkid | grep 'ephemeral0' | cut -d':'``
If we now call the ``mount`` command and grep for that
device, we actually get 2 different mount point:
sudo mount | grep '/dev/vda1' | cut -d' ' -f1
/dev/vda1
/dev/vda15

This output will make the test fail.

As a fix, we call the grep command with the -w option that match
only entire words:
sudo mount | grep -w '/dev/vda1' | cut -d' ' -f1
/dev/vda1

Change-Id: I2eaad4c91d9beec7077fb71186713e552afaa11a
This commit is contained in:
Riccardo Pittau 2019-04-29 18:32:04 +02:00
parent 70cbfe7f8c
commit 8cfd0e16f4
1 changed files with 1 additions and 1 deletions

View File

@ -107,7 +107,7 @@ class BaremetalBasicOps(baremetal_manager.BaremetalScenarioTest):
self.assertNotEqual('', device)
# Validate the mount point for the device
cmd = "mount | grep '%s' | cut -d' ' -f3" % device
cmd = "mount | grep -w '%s' | cut -d' ' -f3" % device
actual_mount = client.exec_command(cmd).rstrip('\n')
LOG.debug("Partition mount point is %s", actual_mount)
self.assertEqual(actual_mount, mount)