diff options
-rw-r--r-- | tensorflow/go/BUILD | 12 | ||||
-rwxr-xr-x | tensorflow/go/test.sh | 72 | ||||
-rw-r--r-- | tensorflow/tools/ci_build/Dockerfile.cpu | 1 | ||||
-rw-r--r-- | tensorflow/tools/ci_build/Dockerfile.debian.jessie.cpu | 1 | ||||
-rw-r--r-- | tensorflow/tools/ci_build/Dockerfile.gpu | 1 | ||||
-rwxr-xr-x | tensorflow/tools/ci_build/install/install_golang.sh | 22 |
6 files changed, 109 insertions, 0 deletions
diff --git a/tensorflow/go/BUILD b/tensorflow/go/BUILD index d69233f4fe..f16cffac99 100644 --- a/tensorflow/go/BUILD +++ b/tensorflow/go/BUILD @@ -9,6 +9,18 @@ licenses(["notice"]) # Apache 2.0 exports_files(["LICENSE"]) +sh_test( + name = "test", + size = "small", + srcs = ["test.sh"], + data = [ + ":all_files", # Go sources + "//tensorflow:libtensorflow.so", # C library + "//tensorflow/c:headers", # C library header + "//tensorflow/cc/saved_model:saved_model_half_plus_two", # Testdata for LoadSavedModel + ], +) + filegroup( name = "all_files", srcs = glob( diff --git a/tensorflow/go/test.sh b/tensorflow/go/test.sh new file mode 100755 index 0000000000..8ef4afbd72 --- /dev/null +++ b/tensorflow/go/test.sh @@ -0,0 +1,72 @@ +#!/usr/bin/env bash +# Copyright 2017 The TensorFlow Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============================================================================== + +# TensorFlow uses 'bazel' for builds and tests. +# The TensorFlow Go API aims to be usable with the 'go' tool +# (using 'go get' etc.) and thus without bazel. +# +# This script acts as a brige between bazel and go so that: +# bazel test :test +# succeeds iff +# go test github.com/tensorflow/tensorflow/tensorflow/go +# succeeds. + +set -ex + +# Find the 'go' tool +if [[ ! -x "go" ]] +then + if [[ -x "/usr/local/go/bin/go" ]] + then + export PATH="${PATH}:/usr/local/go/bin" + else + echo "Could not find the 'go' tool in PATH or /usr/local/go" + exit 1 + fi +fi + +# Setup a GOPATH that includes just the TensorFlow Go API. +export GOPATH="${TEST_TMPDIR}/go" +mkdir -p "${GOPATH}/src/github.com/tensorflow" +ln -s "${PWD}" "${GOPATH}/src/github.com/tensorflow/tensorflow" + +# Ensure that the TensorFlow C library is accessible to the +# linker at build and run time. +export LIBRARY_PATH="${PWD}/tensorflow" +OS=$(uname -s) +if [[ "${OS}" = "Linux" ]] +then + if [[ -z "${LD_LIBRARY_PATH}" ]] + then + export LD_LIBRARY_PATH="${PWD}/tensorflow" + else + export LD_LIBRARY_PATH="${PWD}/tensorflow:${LD_LIBRARY_PATH}" + fi +elif [[ "${OS}" = "Darwin" ]] +then + if [[ -z "${DYLD_LIBRARY_PATH}" ]] + then + export DYLD_LIBRARY_PATH="${PWD}/tensorflow" + else + export DYLD_LIBRARY_PATH="${PWD}/tensorflow:${DYLD_LIBRARY_PATH}" + fi +fi + +# Document the Go version and run tests +echo "Go version: $(go version)" +go test \ + github.com/tensorflow/tensorflow/tensorflow/go \ + github.com/tensorflow/tensorflow/tensorflow/go/op diff --git a/tensorflow/tools/ci_build/Dockerfile.cpu b/tensorflow/tools/ci_build/Dockerfile.cpu index 94f54351c7..8e0be14ca6 100644 --- a/tensorflow/tools/ci_build/Dockerfile.cpu +++ b/tensorflow/tools/ci_build/Dockerfile.cpu @@ -13,6 +13,7 @@ RUN /install/install_bazel.sh RUN /install/install_proto3.sh RUN /install/install_buildifier.sh RUN /install/install_auditwheel.sh +RUN /install/install_golang.sh # Set up bazelrc. COPY install/.bazelrc /root/.bazelrc diff --git a/tensorflow/tools/ci_build/Dockerfile.debian.jessie.cpu b/tensorflow/tools/ci_build/Dockerfile.debian.jessie.cpu index fa74320b1e..16ff229c59 100644 --- a/tensorflow/tools/ci_build/Dockerfile.debian.jessie.cpu +++ b/tensorflow/tools/ci_build/Dockerfile.debian.jessie.cpu @@ -9,6 +9,7 @@ RUN echo "deb http://http.debian.net/debian jessie-backports main" | tee -a /etc RUN /install/install_deb_packages.sh RUN /install/install_pip_packages.sh RUN /install/install_bazel.sh +RUN /install/install_golang.sh # Fix a virtualenv install issue specific to Debian Jessie. RUN pip install --upgrade virtualenv diff --git a/tensorflow/tools/ci_build/Dockerfile.gpu b/tensorflow/tools/ci_build/Dockerfile.gpu index ee01793e1c..1cf1e40404 100644 --- a/tensorflow/tools/ci_build/Dockerfile.gpu +++ b/tensorflow/tools/ci_build/Dockerfile.gpu @@ -10,6 +10,7 @@ RUN add-apt-repository -y ppa:openjdk-r/ppa && \ RUN /install/install_deb_packages.sh RUN /install/install_pip_packages.sh RUN /install/install_bazel.sh +RUN /install/install_golang.sh # Set up bazelrc. COPY install/.bazelrc /root/.bazelrc diff --git a/tensorflow/tools/ci_build/install/install_golang.sh b/tensorflow/tools/ci_build/install/install_golang.sh new file mode 100755 index 0000000000..fef203b869 --- /dev/null +++ b/tensorflow/tools/ci_build/install/install_golang.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash +# Copyright 2017 The TensorFlow Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============================================================================== + +set -ex + +GOLANG_URL="https://storage.googleapis.com/golang/go1.7.5.linux-amd64.tar.gz" + +sudo mkdir -p /usr/local +wget -q -O - "${GOLANG_URL}" | sudo tar -C /usr/local -xz |