# import common import os from atoslib import utils, atos_lib TEST_CASE = "ATOS atos cookies" args = common.atos_setup_args(ATOS_DEBUG_FILE="debug.log") sha1dir = os.path.join(common.SRCDIR, 'examples', 'sha1-c') status = utils.invoque( "atos-init", args, run_script=os.path.join(sha1dir, "run.sh"), build_script="gcc -o sha1-c %s %s" % (os.path.join(sha1dir, "sha.c"), os.path.join(sha1dir, "sha1.c"))) assert status == 0 # atos-opt status = utils.invoque("atos-opt", args, options="-O2", record=True, cookies=["AA", "BB"]) assert status == 0 results = atos_lib.results_filter_cookie(common.atos_results(), "AA") assert len(results) == 1
import itertools import re from atoslib import utils from atoslib import atos_lib from atoslib import generators TEST_CASE = "ATOS generators - staged" args = common.atos_setup_args(ATOS_DEBUG_FILE="debug.log") sha1dir = os.path.join(common.SRCDIR, 'examples', 'sha1-c') status = utils.invoque( "atos-init", args, run_script=os.path.join(sha1dir, "run.sh"), build_script="gcc -o sha1-c %s %s" % ( os.path.join(sha1dir, "sha.c"), os.path.join(sha1dir, "sha1.c")), no_run=True) assert status == 0 # reference results entry = {'target': 'sha1-c', 'variant': 'REF', 'conf': '', 'time': 1000, 'size': 1000} db = atos_lib.atos_db.db('atos-configurations') atos_lib.atos_client_db(db).add_result(entry) def query_configs(cfg, **kwargs): def match(x): return all( map(lambda (k, v):
atos_lib.generate_script( "get_res.sh", ";" "echo ATOS: aaa: size: 2000;" "x=`cat - | grep test | awk '{ print ($2 + 1) * 1000 }'`;" "echo ATOS: aaa: time: $x", {}) atos_lib.generate_script( "get_res_2.sh", ";" "echo ATOS: bin1: size: 1001;" "echo ATOS: bin1: time: 1000;" "echo ATOS: bin2: size: 2002;" "echo ATOS: bin2: time: 2000;" "echo ATOS: bin3: size: 3003;" "echo ATOS: bin3: time: 3000;", {}) status = utils.invoque("atos-init", args, build_script="./build.sh", run_script="./run.sh") assert status == 0 assert len(common.atos_results({"variant": "REF"})) == 1 # # -r, --record # -a OPTIONS, --options OPTIONS # status = utils.invoque("atos-run", args, options="-O2", record=True) assert status == 0 results = common.atos_results({"variant": "OPT-O2"}) assert len(results) == 1 and results[0]["time"] == 99000 os.putenv("TIME", "90")
import random import itertools import re from atoslib import utils from atoslib import generators TEST_CASE = "ATOS generators - simple" args = common.atos_setup_args(ATOS_DEBUG_FILE="debug.log") sha1dir = os.path.join(common.SRCDIR, 'examples', 'sha1-c') status = utils.invoque( "atos-init", args, run_script=os.path.join(sha1dir, "run.sh"), build_script="gcc -o sha1-c %s %s" % (os.path.join(sha1dir, "sha.c"), os.path.join(sha1dir, "sha1.c"))) assert status == 0 def generated_configs(gen, max_iter=None): random.seed(0) configs = [] for ic in itertools.count(): if max_iter != None and ic >= max_iter: break try: configs.append(gen.next()) except StopIteration: break return configs
from atoslib import generators from atoslib import profile TEST_CASE = "ATOS generators - function_by_function" args = common.atos_setup_args(ATOS_DEBUG_FILE="debug.log") sha1dir = os.path.join(common.SRCDIR, 'examples', 'sha1-c') atos_lib.generate_script("profile.sh", ";" "true", {}) status = utils.invoque( "atos-init", args, run_script=os.path.join(sha1dir, "run.sh"), build_script="gcc -o sha1-c %s %s" % ( os.path.join(sha1dir, "sha.c"), os.path.join(sha1dir, "sha1.c")), prof_script = "./profile.sh", no_run=True) assert status == 0 def query_configs(cfg, **kwargs): def match(x): return all( map(lambda (k, v): re.match('^%s$' % v, getattr(x, k, None) or ''), kwargs.items())) return filter(match, cfg)
from atoslib import process from atoslib import generators from atoslib import profile TEST_CASE = "ATOS generators - function_by_function" args = common.atos_setup_args(ATOS_DEBUG_FILE="debug.log") sha1dir = os.path.join(common.SRCDIR, 'examples', 'sha1-c') atos_lib.generate_script("profile.sh", ";" "true", {}) status = utils.invoque( "atos-init", args, run_script=os.path.join(sha1dir, "run.sh"), build_script="gcc -o sha1-c %s %s" % (os.path.join(sha1dir, "sha.c"), os.path.join(sha1dir, "sha1.c")), prof_script="./profile.sh", no_run=True) assert status == 0 def query_configs(cfg, **kwargs): def match(x): return all( map(lambda (k, v): re.match('^%s$' % v, getattr(x, k, None) or ''), kwargs.items())) return filter(match, cfg)
# import common import os from atoslib import utils TEST_CASE = "ATOS atos-opt invocation" log = "debug.log" args = common.atos_setup_args(ATOS_DEBUG_FILE=log) sha1dir = os.path.join(common.SRCDIR, 'examples', 'sha1-c') status = utils.invoque( "atos-init", args, run_script=os.path.join(sha1dir, "run.sh"), build_script="gcc -o sha1-c %s %s" % ( os.path.join(sha1dir, "sha.c"), os.path.join(sha1dir, "sha1.c"))) assert status == 0 # # -r, --record # -a OPTIONS, --options OPTIONS # status = utils.invoque("atos-opt", args, options="-O2", record=True) assert status == 0 results = common.atos_results({"variant" : "OPT-O2"}) assert len(results) == 1
# import common import os, shutil, filecmp from atoslib import utils TEST_CASE = "ATOS atos-build invocation" log = "debug.log" args = common.atos_setup_args(ATOS_DEBUG_FILE=log, ATOS_PREFIX=common.ROOT) sha1dir = os.path.join(common.SRCDIR, 'examples', 'sha1-c') status = utils.invoque( "atos-init", args, run_script=os.path.join(sha1dir, "run.sh"), build_script="gcc -o sha1-c %s %s" % ( os.path.join(sha1dir, "sha.c"), os.path.join(sha1dir, "sha1.c"))) assert status == 0 # # -a OPTIONS, --options OPTIONS # status = utils.invoque("atos-build", args, options="-O2") assert status == 0 and len(common.grep(log, "DEBUG: command \[gcc .* -O2\]$")) == 1 shutil.copyfile("sha1-c", "sha1-c.O2") status = utils.invoque("atos-build", args, options="-O3 -g") assert status == 0 and len(common.grep(log, "DEBUG: command \[gcc .* -O3 -g\]$")) == 1 shutil.copyfile("sha1-c", "sha1-c.O3g")
# import common import os from atoslib import utils, atos_lib TEST_CASE = "ATOS atos cookies" args = common.atos_setup_args(ATOS_DEBUG_FILE="debug.log") sha1dir = os.path.join(common.SRCDIR, 'examples', 'sha1-c') status = utils.invoque( "atos-init", args, run_script=os.path.join(sha1dir, "run.sh"), build_script="gcc -o sha1-c %s %s" % ( os.path.join(sha1dir, "sha.c"), os.path.join(sha1dir, "sha1.c"))) assert status == 0 # atos-opt status = utils.invoque( "atos-opt", args, options="-O2", record=True, cookies=["AA", "BB"]) assert status == 0 results = atos_lib.results_filter_cookie(common.atos_results(), "AA") assert len(results) == 1 results = atos_lib.results_filter_cookie(common.atos_results(), "A") assert len(results) == 0
import common import os, shutil, filecmp from atoslib import utils TEST_CASE = "ATOS atos-build invocation" log = "debug.log" args = common.atos_setup_args(ATOS_DEBUG_FILE=log, ATOS_PREFIX=common.ROOT) sha1dir = os.path.join(common.SRCDIR, 'examples', 'sha1-c') status = utils.invoque( "atos-init", args, run_script=os.path.join(sha1dir, "run.sh"), build_script="gcc -o sha1-c %s %s" % (os.path.join(sha1dir, "sha.c"), os.path.join(sha1dir, "sha1.c"))) assert status == 0 # # -a OPTIONS, --options OPTIONS # status = utils.invoque("atos-build", args, options="-O2") assert status == 0 and len(common.grep(log, "DEBUG: command \[gcc .* -O2\]$")) == 1 shutil.copyfile("sha1-c", "sha1-c.O2") status = utils.invoque("atos-build", args, options="-O3 -g") assert status == 0 and len(