speccpu: support build_type for SPEC commands
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import copy
|
||||
import enum
|
||||
import os
|
||||
from collections.abc import MutableMapping
|
||||
from pathlib import Path
|
||||
@@ -99,6 +100,11 @@ class SPEC:
|
||||
def env(self):
|
||||
return create_spec_env(self.dir)
|
||||
|
||||
class BuildType(enum.Enum):
|
||||
Default = "default"
|
||||
Nobuild = "nobuild"
|
||||
Rebuild = "rebuild"
|
||||
|
||||
def mkcmd_runcpu(
|
||||
self,
|
||||
config: str,
|
||||
@@ -106,6 +112,7 @@ class SPEC:
|
||||
setprocgroup: bool = True,
|
||||
workload: str = "ref",
|
||||
output_root: Path | None = None,
|
||||
build_type: BuildType = BuildType.Default,
|
||||
):
|
||||
return [
|
||||
"runcpu",
|
||||
@@ -116,6 +123,8 @@ class SPEC:
|
||||
config,
|
||||
*(["--output_root", str(output_root)] if output_root else []),
|
||||
*benchmarks,
|
||||
*(["--nobuild"] if build_type == self.BuildType.Nobuild else []),
|
||||
*(["--rebuild"] if build_type == self.BuildType.Rebuild else []),
|
||||
]
|
||||
|
||||
|
||||
|
||||
@@ -80,6 +80,33 @@ class TestSPEC:
|
||||
assert "--output_root" in cmd
|
||||
assert str(output_dir) in cmd
|
||||
|
||||
def test_mkcmd_runcpu_build_type_default(self):
|
||||
"""Test that mkcmd_runcpu doesn't add build flags with default build type."""
|
||||
spec = SPEC(Path("/path/to/spec"))
|
||||
cmd = spec.mkcmd_runcpu(
|
||||
"myconfig", ["benchmark1"], build_type=SPEC.BuildType.Default
|
||||
)
|
||||
assert "--nobuild" not in cmd
|
||||
assert "--rebuild" not in cmd
|
||||
|
||||
def test_mkcmd_runcpu_build_type_nobuild(self):
|
||||
"""Test that mkcmd_runcpu adds --nobuild flag with Nobuild build type."""
|
||||
spec = SPEC(Path("/path/to/spec"))
|
||||
cmd = spec.mkcmd_runcpu(
|
||||
"myconfig", ["benchmark1"], build_type=SPEC.BuildType.Nobuild
|
||||
)
|
||||
assert "--nobuild" in cmd
|
||||
assert "--rebuild" not in cmd
|
||||
|
||||
def test_mkcmd_runcpu_build_type_rebuild(self):
|
||||
"""Test that mkcmd_runcpu adds --rebuild flag with Rebuild build type."""
|
||||
spec = SPEC(Path("/path/to/spec"))
|
||||
cmd = spec.mkcmd_runcpu(
|
||||
"myconfig", ["benchmark1"], build_type=SPEC.BuildType.Rebuild
|
||||
)
|
||||
assert "--rebuild" in cmd
|
||||
assert "--nobuild" not in cmd
|
||||
|
||||
|
||||
class TestCheckBenchDir:
|
||||
def test_valid_bench_dir(self, tmpdir):
|
||||
|
||||
@@ -45,6 +45,7 @@ def x264_disable_mc_mul(
|
||||
setprocgroup=True,
|
||||
workload="ref",
|
||||
output_root=spec_outputroot,
|
||||
build_type=SPEC.BuildType.Nobuild,
|
||||
),
|
||||
env=spec_env,
|
||||
) as process:
|
||||
|
||||
Reference in New Issue
Block a user