utils: Add partition concatenation routine.
Follow kernel convention and add 'p' if the block device ends with a digit.
Fixes platform_PartitionCheck test.
Follow same method for faft test.
BUG=chromium:776029
TEST=unit test, test latform_PartitionCheck on NVMe.
Change-Id: I61f2f194e149634e132a4ad548335ea7c10d8366
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/741483
Reviewed-by: Sridhar Sonti <sontis@google.com>
Reviewed-by: Wai-Hong Tam <waihong@google.com>
diff --git a/client/bin/utils.py b/client/bin/utils.py
index 79b4d15..a60b658 100644
--- a/client/bin/utils.py
+++ b/client/bin/utils.py
@@ -910,6 +910,20 @@
# For harddisk rtt > 0
return rtt and int(rtt) > 0
+def concat_partition(disk_name, partition_number):
+ """
+ Return the name of a partition:
+ sda, 3 --> sda3
+ mmcblk0, 3 --> mmcblk0p3
+
+ @param disk_name: diskname string
+ @param partition_number: integer
+ """
+ if disk_name.endswith(tuple(str(i) for i in range(0, 10))):
+ sep = 'p'
+ else:
+ sep = ''
+ return disk_name + sep + str(partition_number)
def verify_hdparm_feature(disk_name, feature):
"""