Permalink
Browse files

Support running integration tests under bazel.

$ 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 13, 2016
1 parent b37f762 commit e919434485fb9ff3967aa58417b5581149111259
Showing with 264 additions and 9 deletions.
  1. +7 −0 BUILD
  2. +196 −0 scripts/BUILD
  3. +26 −8 scripts/run_tests.py
  4. +4 −1 scripts/xiosim_driver.py
  5. +26 −0 tests/BUILD
  6. +5 −0 xiosim/BUILD
View
7 BUILD
@@ -10,6 +10,7 @@ filegroup(
name = "xiosim",
srcs = [
"//third_party/pin:cp_pinbin",
"//xiosim:configs",
"//xiosim/pintool:feeder_zesto.so",
"//xiosim/pintool:harness",
"//xiosim/pintool:timing_sim",
@@ -24,3 +25,9 @@ test_suite(
"//xiosim/pintool:unit_tests",
],
)
test_suite(
name = "all_integration",
tags = ["large"],
tests = ["//scripts:integration_tests"],
)
View
@@ -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"],
)
View
@@ -13,21 +13,39 @@
import xiosim_stat as xs
def CreateDriver():
XIOSIM_INSTALL = os.environ["XIOSIM_INSTALL"]
XIOSIM_TREE = os.environ["XIOSIM_TREE"]
ARCH = os.environ["TARGET_ARCH"]
xio = xd.XIOSimDriver(XIOSIM_INSTALL, XIOSIM_TREE, ARCH)
def CreateDriver(bazel_env):
if bazel_env:
TEST_DIR = os.environ["TEST_SRCDIR"]
XIOSIM_INSTALL = TEST_DIR
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
class XIOSimTest(unittest.TestCase):
''' Test fixtures for XIOSim end-to-end tests.'''
def setUp(self):
''' Set up a driver with common options and a temp run directory.'''
self.xio = CreateDriver()
self.run_dir = tempfile.mkdtemp()
self.clean_run_dir = ("LEAVE_TEST_DIR" not in os.environ)
# Running under bazel, we don't need no other environment
bazel_env = ("TEST_SRCDIR" 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.expected_vals = []
self.expected_exprs = []
View
@@ -3,7 +3,7 @@
import subprocess
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.
'''
self.cmd = ""
@@ -13,6 +13,7 @@ def __init__(self, INSTALL_DIR, TREE_DIR, TARGET_ARCH, clean_arch=None, env=""):
self.TREE_DIR = TREE_DIR
self.TARGET_ARCH = TARGET_ARCH
self.test = ""
self.bridge_dirs = bridge_dirs
if clean_arch:
self.AddCleanArch()
self.AddEnvironment(env)
@@ -78,6 +79,8 @@ def AddTraceFile(self, file):
self.cmd += "-trace %s " % file
def AddZestoOptions(self, cfg):
if self.bridge_dirs:
self.cmd += "-buffer_bridge_dirs %s " % self.bridge_dirs
self.cmd += "-s "
self.cmd += "-config " + cfg + " "
View
@@ -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"},
)
View
@@ -27,6 +27,11 @@ cc_library(
],
)
filegroup(
name = "configs",
srcs = glob(["config/*.cfg"]),
)
cc_library(
name = "zesto-uncore",
srcs = ["zesto-uncore.cpp"],

0 comments on commit e919434

Please sign in to comment.