Skip to content

Commit 64df265

Browse files
committed
tests: replace disk with parted
parted is the tool used in the SoC, let's keep parted the unique tool. Signed-off-by: Douglas Landgraf <[email protected]>
1 parent 69eb6fe commit 64df265

File tree

1 file changed

+24
-20
lines changed

1 file changed

+24
-20
lines changed

Diff for: tests/e2e/lib/diskutils

+24-20
Original file line numberDiff line numberDiff line change
@@ -32,30 +32,34 @@ select_disk_to_partition(){
3232
info_message "select_disk_to_partition, found ${disks_arr}"
3333
info_message "=============================="
3434

35-
for disk in $disks_arr; do
36-
if [[ ${disk} == "vda" || \
37-
$(echo "${disk_table}" | grep -c "${disk}" ) -eq 1 && ${disk} != "zram0" ]];then
38-
new_part="$( (echo n; echo p; echo ; echo ; echo ; echo w) | fdisk "/dev/${disk}")"
39-
part_id="$(echo "${new_part}" | grep -Po "new partition \K([0-9])")"
40-
DISK="${disk}"
41-
if [[ $(echo "${DISK}" | grep -c nvme) -eq 1 ]]; then
42-
PART_ID="p${part_id}"
43-
info_message "select_disk_to_partition, found /dev/${DISK}${PART_ID}"
44-
info_message "=============================="
45-
break;
46-
fi
35+
for disk in "${disks_arr[@]}"; do
36+
if [[ ${disk} == "vda" || \
37+
$(echo "${disk_table}" | grep -c "${disk}") -eq 1 && ${disk} != "zram0" ]]; then
38+
# Create a new partition using parted
39+
parted -s "/dev/${disk}" mkpart primary 0% 100%
40+
part_id=$(lsblk -no PARTNUM "/dev/${disk}" | tail -n1)
41+
DISK="${disk}"
42+
43+
if [[ $(echo "${DISK}" | grep -c nvme) -eq 1 ]]; then
44+
PART_ID="p${part_id}"
45+
info_message "select_disk_to_partition, found /dev/${DISK}${PART_ID}"
46+
info_message "=============================="
47+
break;
4748
fi
48-
if [ -e "${SOC_DISTRO_FILE}" ]; then
49-
if grep -qi "${QC_SOC}" "${SOC_DISTRO_FILE}"; then
50-
if [[ "${disk}" == "${QC_SOC_DISK}" ]]; then
51-
DISK=${disk}
52-
part=$(echo "${disk_table}" | grep "G" | grep "${QC_SOC_DISK}[0-9]." | grep -v "/" | cut -d" " -f1 )
53-
PART_ID=${part:3}
54-
break;
55-
fi
49+
fi
50+
51+
if [ -e "${SOC_DISTRO_FILE}" ]; then
52+
if grep -qi "${QC_SOC}" "${SOC_DISTRO_FILE}"; then
53+
if [[ "${disk}" == "${QC_SOC_DISK}" ]]; then
54+
DISK=${disk}
55+
part=$(echo "${disk_table}" | grep "G" | grep "${QC_SOC_DISK}[0-9]." | grep -v "/" | cut -d" " -f1)
56+
PART_ID=${part:3}
57+
break;
5658
fi
5759
fi
60+
fi
5861
done
62+
5963
parted /dev/${DISK} rescan
6064
}
6165

0 commit comments

Comments
 (0)