Skip to content

Commit de2e391

Browse files
mangelajoclaude
andcommitted
Fix uboot test OOM: stream RPM extraction instead of loading into memory
rpmfile decompresses the entire 572MB CPIO payload into memory. Use rpm2cpio | cpio for streaming extraction with rpmfile as fallback. Also adds download progress logging and a 120s timeout. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 8b0aed3 commit de2e391

1 file changed

Lines changed: 37 additions & 15 deletions

File tree

  • python/packages/jumpstarter-driver-uboot/jumpstarter_driver_uboot

python/packages/jumpstarter-driver-uboot/jumpstarter_driver_uboot/driver_test.py

Lines changed: 37 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import os
22
import platform
3+
import shutil
4+
import subprocess
35

46
import pytest
57
import requests
@@ -10,25 +12,45 @@
1012
from .driver import UbootConsole
1113
from jumpstarter.common.utils import serve
1214

15+
UBOOT_RPM_URL = "https://kojipkgs.fedoraproject.org/packages/uboot-tools/2025.10/1.fc43/noarch/uboot-images-armv8-2025.10-1.fc43.noarch.rpm"
16+
1317

1418
@pytest.fixture(scope="session")
1519
def uboot_image(tmpdir_factory):
1620
tmp_path = tmpdir_factory.mktemp("uboot-images")
17-
18-
url = "https://kojipkgs.fedoraproject.org/packages/uboot-tools/2025.10/1.fc43/noarch/uboot-images-armv8-2025.10-1.fc43.noarch.rpm"
19-
20-
with requests.get(url, stream=True) as r:
21-
r.raise_for_status()
22-
with (tmp_path / "uboot-images-armv8.rpm").open("wb") as f:
23-
for chunk in r.iter_content(chunk_size=8192):
24-
f.write(chunk)
25-
26-
with rpmfile.open(tmp_path / "uboot-images-armv8.rpm") as rpm:
27-
fd = rpm.extractfile("./usr/share/uboot/qemu_arm64/u-boot.bin")
28-
with (tmp_path / "u-boot.bin").open("wb") as f:
29-
f.write(fd.read())
30-
31-
yield tmp_path / "u-boot.bin"
21+
rpm_path = tmp_path / "uboot-images-armv8.rpm"
22+
bin_path = tmp_path / "u-boot.bin"
23+
24+
print(f"\nDownloading u-boot RPM from {UBOOT_RPM_URL}")
25+
try:
26+
with requests.get(UBOOT_RPM_URL, stream=True, timeout=120) as r:
27+
r.raise_for_status()
28+
total = int(r.headers.get("content-length", 0))
29+
downloaded = 0
30+
with rpm_path.open("wb") as f:
31+
for chunk in r.iter_content(chunk_size=8192):
32+
f.write(chunk)
33+
downloaded += len(chunk)
34+
print(f"Downloaded {downloaded} bytes (expected {total})")
35+
except requests.RequestException as e:
36+
raise AssertionError(f"Failed to download u-boot RPM: {e}") from e
37+
38+
print("Extracting u-boot.bin from RPM...")
39+
if shutil.which("rpm2cpio") and shutil.which("cpio"):
40+
subprocess.run(
41+
f"rpm2cpio {rpm_path} | cpio -idm --quiet ./usr/share/uboot/qemu_arm64/u-boot.bin",
42+
shell=True, cwd=str(tmp_path), check=True,
43+
)
44+
extracted = tmp_path / "usr" / "share" / "uboot" / "qemu_arm64" / "u-boot.bin"
45+
extracted.rename(bin_path)
46+
else:
47+
with rpmfile.open(rpm_path) as rpm:
48+
fd = rpm.extractfile("./usr/share/uboot/qemu_arm64/u-boot.bin")
49+
with bin_path.open("wb") as f:
50+
f.write(fd.read())
51+
print(f"Extracted u-boot.bin ({bin_path.size()} bytes)")
52+
53+
yield bin_path
3254

3355

3456
@pytest.mark.xfail(

0 commit comments

Comments
 (0)