diff --git a/embdgen-core/src/embdgen/plugins/content/Fat32Content.py b/embdgen-core/src/embdgen/plugins/content/Fat32Content.py index b8aef4b..f521545 100644 --- a/embdgen-core/src/embdgen/plugins/content/Fat32Content.py +++ b/embdgen-core/src/embdgen/plugins/content/Fat32Content.py @@ -40,6 +40,7 @@ def _prepare_result(self): subprocess.run([ "mkfs.vfat", + "-F", "32", self.result_file ], check=True, diff --git a/embdgen-core/tests/content/test_Fat32Content.py b/embdgen-core/tests/content/test_Fat32Content.py index 39c0112..4710ec1 100644 --- a/embdgen-core/tests/content/test_Fat32Content.py +++ b/embdgen-core/tests/content/test_Fat32Content.py @@ -16,11 +16,13 @@ class MInfo(SimpleCommandParser): ATTRIBUTE_MAP = { "sector size": ("sector_size", lambda x: int(x.split()[0])), - "big size": ("sectors", lambda x: int(x.split()[0])) + "big size": ("sectors", lambda x: int(x.split()[0])), + "disk type": ("disk_type", lambda x: x[1:-1].strip()) } sectors: int = -1 sector_size: int = -1 + disk_type: str = "" def __init__(self, image: Path) -> None: super().__init__(["minfo", "-i", image]) @@ -50,12 +52,12 @@ def test_files(self, tmp_path: Path): obj.prepare() assert obj.size.is_undefined - obj.size = SizeType.parse("10MB") + obj.size = SizeType.parse("32MB") obj.prepare() with image.open("wb") as out_file: obj.write(out_file) - assert image.stat().st_size == SizeType.parse("10MB").bytes + assert image.stat().st_size == SizeType.parse("32MB").bytes res = subprocess.run([ "mdir", @@ -79,3 +81,17 @@ def test_empty(self, tmp_path: Path) -> None: minfo = MInfo(image) assert minfo.ok, minfo.error + def test_type_small(self, tmp_path: Path) -> None: + BuildLocation().set_path(tmp_path) + image = tmp_path / "image" + + obj = Fat32Content() + obj.size = SizeType.parse("10 MB") + obj.prepare() + + with image.open("wb") as out_file: + obj.write(out_file) + + minfo = MInfo(image) + assert minfo.ok, minfo.error + assert minfo.disk_type == "FAT32" diff --git a/embdgen-core/tests/test_utils/SimpleCommandParser.py b/embdgen-core/tests/test_utils/SimpleCommandParser.py index fd708e0..c7ef124 100644 --- a/embdgen-core/tests/test_utils/SimpleCommandParser.py +++ b/embdgen-core/tests/test_utils/SimpleCommandParser.py @@ -21,7 +21,7 @@ def __init__(self, command: Iterable[str]) -> None: self.ok = ret.returncode == 0 for line in ret.stdout.splitlines(): - splits = re.split(r":\s+", line.strip(), 1) + splits = re.split(r"[:=]", line.strip(), 1) if len(splits) != 2: continue key, value = splits