def get_available_trace_files(): trace_dir_path = backend.get_trace_dir_path() ret = [] for trace_dir_path, dirs, files in os.walk(trace_dir_path): for file_name in files: if re.match(r'.+\.k7\.gz$', file_name) is not None: trace_file_path = os.path.join(trace_dir_path, file_name) with gzip.GzipFile(trace_file_path, 'r') as f: config_line = f.readline() config = json.loads(config_line) ret.append({ 'file_name': file_name, 'file_path': os.path.abspath(trace_file_path), 'config': config }) return sorted(ret, key=lambda item: item['file_name'])
def test_get_available_trace_files(): trace_file_name = 'grenoble.k7.gz' trace_dir_path = backend.get_trace_dir_path() trace_file_path = os.path.join(trace_dir_path, trace_file_name) with gzip.GzipFile(trace_file_path, 'r') as f: config_line = f.readline() config = json.loads(config_line) assert len(os.listdir(trace_dir_path)) == 1 assert os.path.exists(trace_file_path) is True ret = backend.sim.get_available_trace_files() assert len(ret) == 1 assert ret[0]['file_name'] == trace_file_name assert ret[0]['file_path'] == os.path.abspath(trace_file_path) assert ret[0]['config'] == config