Skip to content

Commit

Permalink
Support running integration tests under bazel.
Browse files Browse the repository at this point in the history
$ bazel test :all_integration
does what you'd expect.

But we can also do things like:
$ bazel test --runs_per_test 10 scripts:NoneTest
to catch flakes.

TESTED=integration,duh

Change-Id: Ida7bfe51275edfa21afe53c9242a9621616e0629
  • Loading branch information
s-kanev committed Jan 14, 2016
1 parent b37f762 commit e919434
Show file tree
Hide file tree
Showing 6 changed files with 264 additions and 9 deletions.
7 changes: 7 additions & 0 deletions BUILD
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ filegroup(
name = "xiosim", name = "xiosim",
srcs = [ srcs = [
"//third_party/pin:cp_pinbin", "//third_party/pin:cp_pinbin",
"//xiosim:configs",
"//xiosim/pintool:feeder_zesto.so", "//xiosim/pintool:feeder_zesto.so",
"//xiosim/pintool:harness", "//xiosim/pintool:harness",
"//xiosim/pintool:timing_sim", "//xiosim/pintool:timing_sim",
Expand All @@ -24,3 +25,9 @@ test_suite(
"//xiosim/pintool:unit_tests", "//xiosim/pintool:unit_tests",
], ],
) )

test_suite(
name = "all_integration",
tags = ["large"],
tests = ["//scripts:integration_tests"],
)
196 changes: 196 additions & 0 deletions scripts/BUILD
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,196 @@
# Description:
# XIOSim integration tests

package(default_visibility = ["//visibility:public"])

licenses(["notice"]) # BSD

exports_files(["LICENSE"])

test_suite(
name = "integration_tests",
tags = ["large"],
)

py_test(
name = "Fib1Test",
size = "large",
srcs = [":integration_framework"],
args = ["Fib1Test"],
data = [":integration_data"],
main = "run_tests.py",
)

py_test(
name = "NoneTest",
size = "large",
srcs = [":integration_framework"],
args = ["NoneTest"],
data = [":integration_data"],
main = "run_tests.py",
)

py_test(
name = "Fib1LengthTest",
size = "large",
srcs = [":integration_framework"],
args = ["Fib1LengthTest"],
data = [":integration_data"],
main = "run_tests.py",
)

py_test(
name = "Fib1SkipTest",
size = "large",
srcs = [":integration_framework"],
args = ["Fib1SkipTest"],
data = [":integration_data"],
main = "run_tests.py",
)

py_test(
name = "Fib1PinPointTest",
size = "large",
srcs = [":integration_framework"],
args = ["Fib1PinPointTest"],
data = [":integration_data"],
main = "run_tests.py",
)

py_test(
name = "Fib1PinPointsTest",
size = "large",
srcs = [":integration_framework"],
args = ["Fib1PinPointsTest"],
data = [":integration_data"],
main = "run_tests.py",
)

py_test(
name = "ROITest",
size = "large",
srcs = [":integration_framework"],
args = ["ROITest"],
data = [":integration_data"],
main = "run_tests.py",
)

py_test(
name = "ReplaceTest",
size = "large",
srcs = [":integration_framework"],
args = ["ReplaceTest"],
data = [":integration_data"],
main = "run_tests.py",
)

py_test(
name = "PowerTest",
size = "large",
srcs = [":integration_framework"],
args = ["PowerTest"],
data = [":integration_data"],
main = "run_tests.py",
)

py_test(
name = "DFSTest",
size = "large",
srcs = [":integration_framework"],
args = ["DFSTest"],
data = [":integration_data"],
main = "run_tests.py",
)

py_test(
name = "Fib2Test",
size = "large",
srcs = [":integration_framework"],
args = ["Fib2Test"],
data = [":integration_data"],
main = "run_tests.py",
)

py_test(
name = "REPTest",
size = "large",
srcs = [":integration_framework"],
args = ["REPTest"],
data = [":integration_data"],
main = "run_tests.py",
)

py_test(
name = "SegfTest",
size = "large",
srcs = [":integration_framework"],
args = ["SegfTest"],
data = [":integration_data"],
main = "run_tests.py",
)

py_test(
name = "ChaseTest",
size = "large",
srcs = [":integration_framework"],
args = ["ChaseTest"],
data = [":integration_data"],
main = "run_tests.py",
)

py_test(
name = "PrefetchTest",
size = "large",
srcs = [":integration_framework"],
args = ["PrefetchTest"],
data = [":integration_data"],
main = "run_tests.py",
)

py_test(
name = "IgnorePCTest",
size = "large",
srcs = [":integration_framework"],
args = ["IgnorePCTest"],
data = [":integration_data"],
main = "run_tests.py",
)

py_test(
name = "TimeTest",
size = "large",
srcs = [":integration_framework"],
args = ["TimeTest"],
data = [":integration_data"],
main = "run_tests.py",
)

py_test(
name = "AttachTest",
size = "large",
srcs = [":integration_framework"],
args = ["AttachTest"],
data = [":integration_data"],
main = "run_tests.py",
)

# Framework files to launch the simulator and define tests
filegroup(
name = "integration_framework",
srcs = [
"run_tests.py",
"xiosim_driver.py",
"xiosim_stat.py",
],
visibility = ["//visibility:private"],
)

# The actual simulator and simulated programs
filegroup(
name = "integration_data",
srcs = [
"//:xiosim",
"//tests:ubench",
],
visibility = ["//visibility:private"],
)
34 changes: 26 additions & 8 deletions scripts/run_tests.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -13,21 +13,39 @@
import xiosim_stat as xs import xiosim_stat as xs




def CreateDriver(): def CreateDriver(bazel_env):
XIOSIM_INSTALL = os.environ["XIOSIM_INSTALL"] if bazel_env:
XIOSIM_TREE = os.environ["XIOSIM_TREE"] TEST_DIR = os.environ["TEST_SRCDIR"]
ARCH = os.environ["TARGET_ARCH"] XIOSIM_INSTALL = TEST_DIR
xio = xd.XIOSimDriver(XIOSIM_INSTALL, XIOSIM_TREE, ARCH) XIOSIM_TREE = TEST_DIR
# the bazel sandbox doesn't have /dev/shm mounted
BRIDGE_DIRS = "/tmp/"
else:
XIOSIM_INSTALL = os.environ["XIOSIM_INSTALL"]
XIOSIM_TREE = os.environ["XIOSIM_TREE"]
BRIDGE_DIRS = ""

if "TARGET_ARCH" in os.environ:
ARCH = os.environ["TARGET_ARCH"]
else:
# TODO(skanev): figure out how to plumb through bazel's cpu parameter
ARCH = "k8"
xio = xd.XIOSimDriver(XIOSIM_INSTALL, XIOSIM_TREE, ARCH, bridge_dirs=BRIDGE_DIRS)
return xio return xio




class XIOSimTest(unittest.TestCase): class XIOSimTest(unittest.TestCase):
''' Test fixtures for XIOSim end-to-end tests.''' ''' Test fixtures for XIOSim end-to-end tests.'''
def setUp(self): def setUp(self):
''' Set up a driver with common options and a temp run directory.''' ''' Set up a driver with common options and a temp run directory.'''
self.xio = CreateDriver() # Running under bazel, we don't need no other environment
self.run_dir = tempfile.mkdtemp() bazel_env = ("TEST_SRCDIR" in os.environ)
self.clean_run_dir = ("LEAVE_TEST_DIR" not in os.environ) self.xio = CreateDriver(bazel_env)
if bazel_env:
self.run_dir = os.environ["TEST_TMPDIR"]
else:
self.run_dir = tempfile.mkdtemp()
self.clean_run_dir = ("LEAVE_TEST_DIR" not in os.environ) and not bazel_env
self.setDriverParams() self.setDriverParams()
self.expected_vals = [] self.expected_vals = []
self.expected_exprs = [] self.expected_exprs = []
Expand Down
5 changes: 4 additions & 1 deletion scripts/xiosim_driver.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import subprocess import subprocess


class XIOSimDriver(object): class XIOSimDriver(object):
def __init__(self, INSTALL_DIR, TREE_DIR, TARGET_ARCH, clean_arch=None, env=""): def __init__(self, INSTALL_DIR, TREE_DIR, TARGET_ARCH, clean_arch=None, env="", bridge_dirs=""):
''' TARGET_ARCH uses bazel notation. "piii" is ia32, "k8" is ia64. ''' TARGET_ARCH uses bazel notation. "piii" is ia32, "k8" is ia64.
''' '''
self.cmd = "" self.cmd = ""
Expand All @@ -13,6 +13,7 @@ def __init__(self, INSTALL_DIR, TREE_DIR, TARGET_ARCH, clean_arch=None, env=""):
self.TREE_DIR = TREE_DIR self.TREE_DIR = TREE_DIR
self.TARGET_ARCH = TARGET_ARCH self.TARGET_ARCH = TARGET_ARCH
self.test = "" self.test = ""
self.bridge_dirs = bridge_dirs
if clean_arch: if clean_arch:
self.AddCleanArch() self.AddCleanArch()
self.AddEnvironment(env) self.AddEnvironment(env)
Expand Down Expand Up @@ -78,6 +79,8 @@ def AddTraceFile(self, file):
self.cmd += "-trace %s " % file self.cmd += "-trace %s " % file


def AddZestoOptions(self, cfg): def AddZestoOptions(self, cfg):
if self.bridge_dirs:
self.cmd += "-buffer_bridge_dirs %s " % self.bridge_dirs
self.cmd += "-s " self.cmd += "-s "
self.cmd += "-config " + cfg + " " self.cmd += "-config " + cfg + " "


Expand Down
26 changes: 26 additions & 0 deletions tests/BUILD
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,26 @@
# Description:
# XIOSim ubenchmarks for integration tests

package(default_visibility = ["//visibility:public"])

licenses(["notice"]) # BSD

exports_files(["LICENSE"])

filegroup(
name = "ubench",
srcs = select({
":k8": glob(["k8/*"]),
":piii": glob(["piii/*"]),
}),
)

config_setting(
name = "k8",
values = {"cpu": "k8"},
)

config_setting(
name = "piii",
values = {"cpu": "piii"},
)
5 changes: 5 additions & 0 deletions xiosim/BUILD
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ cc_library(
], ],
) )


filegroup(
name = "configs",
srcs = glob(["config/*.cfg"]),
)

cc_library( cc_library(
name = "zesto-uncore", name = "zesto-uncore",
srcs = ["zesto-uncore.cpp"], srcs = ["zesto-uncore.cpp"],
Expand Down

0 comments on commit e919434

Please sign in to comment.