2020
2121import pytest
2222import inspect
23+ import os
2324import pathlib
2425import shutil
2526import subprocess
2627
2728from treecript .collector import execution_metrics_collector
2829from treecript .tdp_finder import tdp_finder_from_series
30+ from treecript import tdp_sources
2931
3032from typing import (
3133 TYPE_CHECKING ,
@@ -96,6 +98,12 @@ def test_tdp_finder_from_series(
9698 metrics_path = test_collector (tmpdir , command_line , should_fail )
9799
98100 spec_path = pathlib .Path (tmpdir ) / "cpu_spec_dataset"
101+ # Try materialising from cached contents
102+ if not spec_path .exists ():
103+ source_spec_path = os .environ .get ("CACHED_CPU_SPEC_DATASET" )
104+ if source_spec_path is not None and os .path .exists (source_spec_path ):
105+ shutil .copytree (source_spec_path , spec_path )
106+
99107 if not spec_path .exists ():
100108 git_path = shutil .which ("git" )
101109 assert git_path is not None , "git not found"
@@ -109,6 +117,20 @@ def test_tdp_finder_from_series(
109117
110118 assert len (processors_files ) > 0
111119
120+ # Try materialising from cached contents
121+ cpumark_path = pathlib .Path (tmpdir ) / "cpumark_table.csv"
122+ if not cpumark_path .exists ():
123+ source_cpumark_path = os .environ .get ("CACHED_CPUMARK_DATASET" )
124+ if source_cpumark_path is not None and os .path .exists (source_cpumark_path ):
125+ shutil .copy2 (source_cpumark_path , cpumark_path , follow_symlinks = False )
126+
127+ if not cpumark_path .exists ():
128+ tdp_sources .scrape_tdp_table_cpubenchmark (cpumark_path )
129+
130+ assert cpumark_path .is_file ()
131+
132+ processors_files .append (cpumark_path )
133+
112134 try :
113135 tdp_finder_from_series (metrics_path , processors_files )
114136 except BaseException :
0 commit comments