• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env bash
2# Copyright 2016 The TensorFlow Authors. All Rights Reserved.
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8#     http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15# ==============================================================================
16
17set -ex
18
19# Sanity test for the package C-library archive.
20# - Unarchive
21# - Compile a trivial C file that uses the archive
22# - Run it
23
24# Tools needed: A C-compiler and tar
25CC="${CC}"
26TAR="${TAR}"
27
28[ -z "${CC}" ] && CC="/usr/bin/gcc"
29[ -z "${TAR}" ] && TAR="tar"
30
31# bazel tests run with ${PWD} set to the root of the bazel workspace
32TARFILE="${PWD}/tensorflow/tools/lib_package/libtensorflow.tar.gz"
33CFILE="${PWD}/tensorflow/tools/lib_package/libtensorflow_test.c"
34
35cd ${TEST_TMPDIR}
36
37# Extract the archive into tensorflow/
38mkdir tensorflow
39${TAR} -xzf ${TARFILE} -Ctensorflow
40
41# Compile the test .c file. Assumes with_framework_lib=True.
42${CC} ${CFILE} -Itensorflow/include -Ltensorflow/lib\
43  -ltensorflow_framework -ltensorflow -oa.out
44
45# Execute it, with the shared library available.
46# DYLD_LIBRARY_PATH is used on OS X, LD_LIBRARY_PATH on Linux.
47#
48# The tests for GPU require CUDA libraries to be accessible, which
49# are in DYLD_LIBRARY_PATH in the test harness for OS X.
50export DYLD_LIBRARY_PATH=tensorflow/lib:${DYLD_LIBRARY_PATH}
51export LD_LIBRARY_PATH=tensorflow/lib:${LD_LIBRARY_PATH}
52./a.out
53