def test_make_clean(): fs.cd("labm8/data/test/makeproj") make.make() assert fs.isfile("foo") assert fs.isfile("foo.o") make.clean() assert not fs.isfile("foo") assert not fs.isfile("foo.o") fs.cdpop()
def test_make_clean(self,): fs.cd("tests/data/makeproj") make.make() self._test(True, fs.isfile("foo")) self._test(True, fs.isfile("foo.o")) make.clean() self._test(False, fs.isfile("foo")) self._test(False, fs.isfile("foo.o")) fs.cdpop()
def main(): os.environ["OMNITUNE_OFFLINE_TRAINING"] = "1" fs.cd(experiment.EXAMPLES_BUILD) # Build sources. ret, _, _ = make.make() if ret: labm8.exit(ret) while True: sample_space()
def main(): jobs = get_jobs() io.info("Loaded", len(jobs), "jobs") # Build example programs. fs.cd(experiment.EXAMPLES_BUILD) make.make() for i,job in enumerate(jobs): run_job(i, len(jobs), *job.split("\t")) lab.exit()
def make(target="all", dir=".", **kwargs): """ Run make clean. Arguments: target (str, optional): Name of the target to build. Defaults to "all". dir (str, optional): Path to directory containing Makefile. **kwargs (optional): Any additional arguments to be passed to system.run(). Returns: (int, str, str): The first element is the return code of the make command. The second and third elements are the stdout and stderr of the process. Raises: NoMakefileError: In case a Makefile is not found in the target directory. NoTargetError: In case the Makefile does not support the requested target. MakeError: In case the target rule fails. """ if not fs.isfile(fs.path(dir, "Makefile")): raise NoMakefileError("No makefile in '{}'".format(fs.abspath(dir))) fs.cd(dir) # Default parameters to system.run() if "timeout" not in kwargs: kwargs["timeout"] = 300 ret, out, err = system.run(["make", target], **kwargs) fs.cdpop() if ret > 0: if re.search(_BAD_TARGET_RE, err): raise NoTargetError("No rule for target '{}'" .format(target)) else: raise MakeError("Target '{}' failed".format(target)) raise MakeError("Failed") return ret, out, err
def make(target="all", dir=".", **kwargs): """ Run make. Arguments: target (str, optional): Name of the target to build. Defaults to "all". dir (str, optional): Path to directory containing Makefile. **kwargs (optional): Any additional arguments to be passed to system.run(). Returns: (int, str, str): The first element is the return code of the make command. The second and third elements are the stdout and stderr of the process. Raises: NoMakefileError: In case a Makefile is not found in the target directory. NoTargetError: In case the Makefile does not support the requested target. MakeError: In case the target rule fails. """ if not fs.isfile(fs.path(dir, "Makefile")): raise NoMakefileError("No makefile in '{}'".format(fs.abspath(dir))) fs.cd(dir) # Default parameters to system.run() if "timeout" not in kwargs: kwargs["timeout"] = 300 ret, out, err = system.run(["make", target], **kwargs) fs.cdpop() if ret > 0: if re.search(_BAD_TARGET_RE, err): raise NoTargetError("No rule for target '{}'".format(target)) else: raise MakeError("Target '{}' failed".format(target)) raise MakeError("Failed") return ret, out, err
def run_example_prog(prog, args): """ Run a SkelCL example program. Arguments: prog (str): The name of the program to run args (list of str): Any arguments """ fs.cd(fs.path(experiment.EXAMPLES_BUILD, prog)) cmd = ["./" + prog] + args cmd_str = " ".join(cmd) io.info("COMMAND:", io.colourise(io.Colours.RED, cmd_str)) ret, _, _ = system.run(cmd, stdout=system.STDOUT, stderr=system.STDERR) if ret: system.echo(cmd_str, "/tmp/naughty.txt", append=True) return ret
def unpack_archive(*components, **kwargs): """ Unpack a compressed archive. Arguments: *components (str[]): Absolute path. compression (str, optional): Archive compression type. """ path = fs.path(*components) compression = kwargs.get("compression", "bz2") # extract tar relative to it's directory fs.cd(fs.dirname(path)) tar = tarfile.open(path, "r:" + compression) tar.extractall() tar.close() fs.cdpop()
def run_job(i, n, wgsize, program, args): wg_c, wg_r = unhash_params(wgsize) # Set environment variable. os.environ["OMNITUNE_OFFLINE_TRAINING"] = "1" os.environ["OMNITUNE_STENCIL_WG_C"] = str(wg_c) os.environ["OMNITUNE_STENCIL_WG_R"] = str(wg_r) fs.cd(fs.path(experiment.EXAMPLES_BUILD, program)) cmd_str = "./{} {}".format(program, args.rstrip()) cmd = cmd_str.split() io.info(i, "of", n, " - ", wgsize, "COMMAND:", io.colourise(io.Colours.RED, cmd_str)) ret, _, _ = system.run(cmd, stdout=system.STDOUT, stderr=system.STDERR) if ret: print(ret, wgsize, program, args, sep="\t", file=errlog) else: print(ret, wgsize, program, args, sep="\t", file=runlog)
def gather(): benchmarks = { "canny": {}, "fdtd": {}, "gol": {}, "gaussian": {}, "heat": {}, "simple": {}, "simplecomplex": {} } for benchmark in benchmarks: io.info("Benchmark %s" % benchmark) fs.cd("/home/chris/src/msc-thesis/scraps/05-12/kernels/%s" % benchmark) instcounts = [] for file in fs.ls(): instcounts.append(get_instcount(file)) benchmarks[benchmark] = merge_counts(instcounts) return benchmarks
def test_cd(self): cwd = os.getcwd() new = fs.abspath("..") self._test(new, fs.cd("..")) self._test(new, os.getcwd()) self._test(cwd, fs.cdpop()) self._test(cwd, os.getcwd()) self._test(cwd, fs.cdpop()) self._test(cwd, os.getcwd()) self._test(cwd, fs.cdpop()) self._test(cwd, os.getcwd())
def test_cd(): cwd = os.getcwd() new = fs.abspath("..") assert new == fs.cd("..") assert new == os.getcwd() assert cwd == fs.cdpop() assert cwd == os.getcwd() assert cwd == fs.cdpop() assert cwd == os.getcwd() assert cwd == fs.cdpop() assert cwd == os.getcwd()
def unpack_archive(*components, **kwargs) -> str: """ Unpack a compressed archive. Arguments: *components (str[]): Absolute path. **kwargs (dict, optional): Set "compression" to compression type. Default: bz2. Set "dir" to destination directory. Defaults to the directory of the archive. Returns: str: Path to directory. """ path = fs.abspath(*components) compression = kwargs.get("compression", "bz2") dir = kwargs.get("dir", fs.dirname(path)) fs.cd(dir) tar = tarfile.open(path, "r:" + compression) tar.extractall() tar.close() fs.cdpop() return dir