Add virtualenv for our own tests

This is so we can use mock in our unit tests

BUG=chromium:703769
TEST=None

Change-Id: Ia3a4405deed2ae785e10234a1efc5ef1dc58799c
diff --git a/bin/find_virtualenv.sh b/bin/find_virtualenv.sh
new file mode 100644
index 0000000..9cdd775
--- /dev/null
+++ b/bin/find_virtualenv.sh
@@ -0,0 +1,31 @@
+#!/bin/bash
+# Copyright 2017 The Chromium OS Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+#
+# Find the virtualenv repo to use.
+#
+# This is meant to be sourced in scripts that need virtualenv.  The
+# sourcing script should cd into the directory containing this script
+# first.  This script defines functions for performing common tasks:
+#
+# exec_python -- Execute Python module inside of virtualenv
+set -eu
+
+realpath() {
+    readlink -f -- "$1"
+}
+
+readonly virtualenv_dir=$(realpath ..)
+readonly venv_dir=$(realpath ../venv/.venv)
+readonly reqs_file=$(realpath ../venv/requirements.txt)
+
+_create_venv() {
+    "$virtualenv_dir/create_venv" "$venv_dir" "$reqs_file" >&2
+}
+
+exec_python_module() {
+    _create_venv
+    export PYTHONPATH='../venv'
+    exec "$venv_dir/bin/python" -m "$@"
+}
diff --git a/bin/run_tests b/bin/run_tests
index a5f0b3e..3623da8 100755
--- a/bin/run_tests
+++ b/bin/run_tests
@@ -4,6 +4,7 @@
 # found in the LICENSE file.
 set -eu
 cd -- "$(readlink -e -- "$(dirname -- "$0")")"
+. ./find_virtualenv.sh
 cd ..
 find . -name "*.pyc" -print0 | xargs -0 rm
-python2 -m unittest discover cros_venv
+exec_python_module unittest discover cros_venv
diff --git a/venv/.gitignore b/venv/.gitignore
new file mode 100644
index 0000000..126a1a9
--- /dev/null
+++ b/venv/.gitignore
@@ -0,0 +1 @@
+/.venv*
diff --git a/venv/requirements.txt b/venv/requirements.txt
new file mode 100644
index 0000000..14fe0d3
--- /dev/null
+++ b/venv/requirements.txt
@@ -0,0 +1 @@
+mock==2.0.0