|
1 | 1 | # |
2 | 2 | # Copyright(c) 2019-2022 Intel Corporation |
3 | 3 | # Copyright(c) 2023-2025 Huawei Technologies Co., Ltd. |
| 4 | +# Copyright(c) 2026 Unvertical |
4 | 5 | # SPDX-License-Identifier: BSD-3-Clause |
5 | 6 | # |
6 | 7 |
|
|
14 | 15 | from core.test_run import TestRun |
15 | 16 | from test_tools.dd import Dd |
16 | 17 | from test_tools.fs_tools import readlink, parse_ls_output, ls, check_if_directory_exists, \ |
17 | | - create_directory, wipefs, is_mounted |
| 18 | + create_directory, is_mounted |
18 | 19 | from test_tools.udev import Udev |
19 | 20 | from type_def.size import Size, Unit |
20 | 21 |
|
@@ -254,8 +255,11 @@ def remove_partitions(device): |
254 | 255 |
|
255 | 256 | TestRun.LOGGER.info(f"Removing partitions from device: {device.path} " |
256 | 257 | f"({device.get_device_id()}).") |
257 | | - wipefs(device) |
258 | | - Udev.trigger() |
| 258 | + # We can't use wipefs here. wipefs only erases magic bytes, not the partition |
| 259 | + # table itself, so the kernel may still see stale partitions after partprobe. |
| 260 | + # parted mklabel replaces the entire partition table and triggers kernel re-read. |
| 261 | + # The label type choice does not really matter, so we just pick gpt. |
| 262 | + TestRun.executor.run_expect_success(f"parted --script {device.path} mklabel gpt") |
259 | 263 | Udev.settle() |
260 | 264 | output = TestRun.executor.run(f"ls {device.path}* -1") |
261 | 265 | if len(output.stdout.split('\n')) > 1: |
|
0 commit comments