1#!/bin/bash
2#
3# libjingle
4# Copyright 2013 Google Inc.
5#
6# Redistribution and use in source and binary forms, with or without
7# modification, are permitted provided that the following conditions are met:
8#
9#  1. Redistributions of source code must retain the above copyright notice,
10#     this list of conditions and the following disclaimer.
11#  2. Redistributions in binary form must reproduce the above copyright notice,
12#     this list of conditions and the following disclaimer in the documentation
13#     and/or other materials provided with the distribution.
14#  3. The name of the author may not be used to endorse or promote products
15#     derived from this software without specific prior written permission.
16#
17# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
18# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
19# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
20# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
23# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
25# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
26# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28# Wrapper script for running the Java tests under this directory. This script
29# will only work if it has been massaged by the build action and placed in
30# the PRODUCT_DIR (e.g. out/Debug).
31
32# Exit with error immediately if any subcommand fails.
33set -e
34
35# Change directory to the PRODUCT_DIR (e.g. out/Debug).
36cd -P $(dirname $0)
37
38if [ -z "$LD_PRELOAD" ]; then
39  echo "LD_PRELOAD isn't set. It should be set to something like "
40  echo "/usr/lib/x86_64-linux-gnu/libpulse.so.0. I will now refuse to run "
41  echo "to protect you from the consequences of your folly."
42  exit 1
43fi
44
45export CLASSPATH=`pwd`/junit-4.11.jar
46CLASSPATH=$CLASSPATH:`pwd`/libjingle_peerconnection_test.jar
47CLASSPATH=$CLASSPATH:`pwd`/libjingle_peerconnection.jar
48
49# This sets java.library.path so lookup of libjingle_peerconnection_so.so works.
50export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:`pwd`:`pwd`/lib:`pwd`/lib.target
51
52# The RHS value is replaced by the build action that copies this script to
53# <(PRODUCT_DIR), using search-and-replace by the build action.
54export JAVA_HOME=GYP_JAVA_HOME
55
56${JAVA_HOME}/bin/java -Xcheck:jni -classpath $CLASSPATH \
57    junit.textui.TestRunner org.webrtc.PeerConnectionTestJava
58