#!/usr/bin/env sh
AR=ar
AR_FOR_TARGET=arm-xilinx-linux-gnueabi-ar
AS='as '
BUILD_AR=ar
BUILD_AS='as '
BUILD_CC='gcc '
BUILD_CCLD='gcc '
BUILD_CFLAGS='-isystemFIXMESTAGINGDIR/x86_64-linux/usr/include -O2 -pipe'
BUILD_CPP='gcc  -E'
BUILD_CPPFLAGS=-isystemFIXMESTAGINGDIR/x86_64-linux/usr/include
BUILD_CXX='g++ '
BUILD_CXXFLAGS='-isystemFIXMESTAGINGDIR/x86_64-linux/usr/include -O2 -pipe -D_GLIBCXX_USE_CXX11_ABI=0'
BUILD_FC='gfortran '
BUILD_LD='ld '
BUILD_LDFLAGS='-LFIXMESTAGINGDIR/x86_64-linux/usr/lib -LFIXMESTAGINGDIR/x86_64-linux/lib -Wl,-rpath-link,FIXMESTAGINGDIR/x86_64-linux/usr/lib -Wl,-rpath-link,FIXMESTAGINGDIR/x86_64-linux/lib -Wl,-rpath,FIXMESTAGINGDIR/x86_64-linux/usr/lib -Wl,-rpath,FIXMESTAGINGDIR/x86_64-linux/lib -Wl,-O1'
BUILD_NM=nm
BUILD_RANLIB=ranlib
BUILD_STRIP=strip
CC='gcc '
CCACHE_DIR=/home/xbrbbot/.ccache
CCACHE_DISABLE=1
CCLD='gcc '
CC_FOR_BUILD='gcc '
CC_FOR_TARGET=' arm-xilinx-linux-gnueabi-gcc'
CFLAGS='-isystemFIXMESTAGINGDIR/x86_64-linux/usr/include -O2 -pipe'
CFLAGS_FOR_BUILD='-isystemFIXMESTAGINGDIR/x86_64-linux/usr/include -O2 -pipe'
CFLAGS_FOR_TARGET='-O2 -pipe -g -feliminate-unused-debug-types -fdebug-prefix-map=/tmp/petalinux-yocto/yocto_sdk_full_2017.1/build/tmp/work/x86_64-linux/gcc-cross-arm/linaro-6.2-r2016.11=/usr/src/debug/gcc-cross-arm/linaro-6.2-r2016.11 -fdebug-prefix-map=FIXMESTAGINGDIR/x86_64-linux= -fdebug-prefix-map=FIXMESTAGINGDIR/x86_64-linux='
CONFIG_SITE='/tmp/petalinux-yocto/yocto_sdk_full_2017.1/sources/core/meta/site/endian-little /tmp/petalinux-yocto/yocto_sdk_full_2017.1/sources/core/meta/site/common-linux /tmp/petalinux-yocto/yocto_sdk_full_2017.1/sources/core/meta/site/common-glibc /tmp/petalinux-yocto/yocto_sdk_full_2017.1/sources/core/meta/site/x86_64-linux /tmp/petalinux-yocto/yocto_sdk_full_2017.1/sources/core/meta/site/common /tmp/petalinux-yocto/yocto_sdk_full_2017.1/sources/core/../meta-openembedded/meta-gnome/site/x86_64-linux /tmp/petalinux-yocto/yocto_sdk_full_2017.1/sources/core/../meta-openembedded/meta-oe/site/endian-little '
CPP='gcc  -E'
CPPFLAGS=
CPPFLAGS_FOR_BUILD=-isystemFIXMESTAGINGDIR/x86_64-linux/usr/include
CPPFLAGS_FOR_TARGET=
CPP_FOR_BUILD='gcc  -E'
CXX='g++ '
CXXFLAGS='-isystemFIXMESTAGINGDIR/x86_64-linux/usr/include -O2 -pipe'
CXXFLAGS_FOR_BUILD='-isystemFIXMESTAGINGDIR/x86_64-linux/usr/include -O2 -pipe -D_GLIBCXX_USE_CXX11_ABI=0'
CXXFLAGS_FOR_TARGET='-O2 -pipe -g -feliminate-unused-debug-types -fdebug-prefix-map=/tmp/petalinux-yocto/yocto_sdk_full_2017.1/build/tmp/work/x86_64-linux/gcc-cross-arm/linaro-6.2-r2016.11=/usr/src/debug/gcc-cross-arm/linaro-6.2-r2016.11 -fdebug-prefix-map=FIXMESTAGINGDIR/x86_64-linux= -fdebug-prefix-map=FIXMESTAGINGDIR/x86_64-linux='
CXX_FOR_BUILD='g++ '
FC='gfortran '
LD='ld '
LDFLAGS='-LFIXMESTAGINGDIR/x86_64-linux/usr/lib -LFIXMESTAGINGDIR/x86_64-linux/lib -Wl,-rpath-link,FIXMESTAGINGDIR/x86_64-linux/usr/lib -Wl,-rpath-link,FIXMESTAGINGDIR/x86_64-linux/lib -Wl,-rpath,FIXMESTAGINGDIR/x86_64-linux/usr/lib -Wl,-rpath,FIXMESTAGINGDIR/x86_64-linux/lib -Wl,-O1'
LDFLAGS_FOR_BUILD='-LFIXMESTAGINGDIR/x86_64-linux/usr/lib -LFIXMESTAGINGDIR/x86_64-linux/lib -Wl,-rpath-link,FIXMESTAGINGDIR/x86_64-linux/usr/lib -Wl,-rpath-link,FIXMESTAGINGDIR/x86_64-linux/lib -Wl,-rpath,FIXMESTAGINGDIR/x86_64-linux/usr/lib -Wl,-rpath,FIXMESTAGINGDIR/x86_64-linux/lib -Wl,-O1'
LDFLAGS_FOR_TARGET='-Wl,-O1  -Wl,--as-needed'
LD_FOR_BUILD='ld '
LD_FOR_TARGET=arm-xilinx-linux-gnueabi-ld
MAKE=make
NM=nm
NM_FOR_TARGET=arm-xilinx-linux-gnueabi-nm
OBJCOPY=objcopy
OBJDUMP=objdump
OLDPWD=/tmp/petalinux-yocto/yocto_sdk_full_2017.1/build
PATH=FIXMESTAGINGDIR/x86_64-linux/usr/bin/texinfo-dummy-native:FIXMESTAGINGDIR-uninative/x86_64-linux/usr/bin:/tmp/petalinux-yocto/yocto_sdk_full_2017.1/sources/core/scripts:FIXMESTAGINGDIR/x86_64-linux/usr/bin/arm-xilinx-linux-gnueabi:FIXMESTAGINGDIR/x86_64-linuxFIXMESTAGINGDIR/x86_64-linux/usr/bin/arm-xilinx-linux-gnueabi/crossscripts:FIXMESTAGINGDIR/x86_64-linux/usr/sbin:FIXMESTAGINGDIR/x86_64-linux/usr/bin:FIXMESTAGINGDIR/x86_64-linux/sbin:FIXMESTAGINGDIR/x86_64-linux/bin:/tmp/petalinux-yocto/yocto_sdk_full_2017.1/sources/core/scripts:/tmp/petalinux-yocto/yocto_sdk_full_2017.1/sources/core/bitbake/bin:/lib:/home/xbrbbot/env_scripts/modules/hw_tools:/home/xbrbbot/env_scripts/modules/lsf_tools:/home/xbrbbot/env_scripts/tools/fastgit:/home/xbrbbot/env_scripts/modules/git_tools:/home/xbrbbot/env_scripts/modules/local_tools:/home/xbrbbot/ssw_tools/RHEL67/x86_64/scripts:/home/xbrbbot/ssw_tools/RHEL67/x86_64/bin:/home/xbrbbot/env_scripts/modules/xilinx:/home/xbrbbot/env_scripts/helpers/:/opt/rh/devtoolset-2/root/usr/bin:/bin:/usr/bin:/tmp/petalinux-yocto/yocto_sdk_full_2017.1/scripts
PWD=/tmp/petalinux-yocto/yocto_sdk_full_2017.1/build/tmp/work/x86_64-linux/gcc-cross-arm/linaro-6.2-r2016.11/gcc-linaro-6.2-2016.11/build.x86_64-linux.arm-xilinx-linux-gnueabi
RANLIB=ranlib
RANLIB_FOR_TARGET=arm-xilinx-linux-gnueabi-ranlib
READELF=readelf
STRINGS=strings
STRIP=strip
TARGET_CFLAGS='-O2 -pipe -g -feliminate-unused-debug-types -fdebug-prefix-map=/tmp/petalinux-yocto/yocto_sdk_full_2017.1/build/tmp/work/x86_64-linux/gcc-cross-arm/linaro-6.2-r2016.11=/usr/src/debug/gcc-cross-arm/linaro-6.2-r2016.11 -fdebug-prefix-map=FIXMESTAGINGDIR/x86_64-linux= -fdebug-prefix-map=FIXMESTAGINGDIR/x86_64-linux='
TARGET_CPPFLAGS=
TARGET_CXXFLAGS='-O2 -pipe -g -feliminate-unused-debug-types -fdebug-prefix-map=/tmp/petalinux-yocto/yocto_sdk_full_2017.1/build/tmp/work/x86_64-linux/gcc-cross-arm/linaro-6.2-r2016.11=/usr/src/debug/gcc-cross-arm/linaro-6.2-r2016.11 -fdebug-prefix-map=FIXMESTAGINGDIR/x86_64-linux= -fdebug-prefix-map=FIXMESTAGINGDIR/x86_64-linux='
TARGET_LDFLAGS='-Wl,-O1  -Wl,--as-needed'
_='#!/usr/bin/env sh'
base_bindir=FIXMESTAGINGDIR/x86_64-linux/usr/bin/arm-xilinx-linux-gnueabi
base_libdir=FIXMESTAGINGDIR/x86_64-linux/lib
base_prefix=FIXMESTAGINGDIR/x86_64-linux
base_sbindir=FIXMESTAGINGDIR/x86_64-linux/usr/bin/arm-xilinx-linux-gnueabi
bindir=FIXMESTAGINGDIR/x86_64-linux/usr/bin/arm-xilinx-linux-gnueabi
datadir=FIXMESTAGINGDIR/x86_64-linux/usr/share
docdir=FIXMESTAGINGDIR/x86_64-linux/usr/share/doc
exec_prefix=FIXMESTAGINGDIR/x86_64-linux/usr
gcc_cv_collect2_libs='none required'
includedir=FIXMESTAGINGDIR/x86_64-linux/usr/include
infodir=FIXMESTAGINGDIR/x86_64-linux/usr/share/info
libdir=FIXMESTAGINGDIR/x86_64-linux/usr/lib/arm-xilinx-linux-gnueabi
libexecdir=FIXMESTAGINGDIR/x86_64-linux/usr/libexec/arm-xilinx-linux-gnueabi
localstatedir=FIXMESTAGINGDIR/x86_64-linux/var
lt_cv_sys_lib_dlsearch_path_spec='FIXMESTAGINGDIR/x86_64-linux/usr/lib/arm-xilinx-linux-gnueabi FIXMESTAGINGDIR/x86_64-linux/lib /lib /lib64 /usr/lib /usr/lib64'
mandir=FIXMESTAGINGDIR/x86_64-linux/usr/share/man
nonarch_base_libdir=FIXMESTAGINGDIR/x86_64-linux/lib
nonarch_libdir=FIXMESTAGINGDIR/x86_64-linux/usr/lib
oldincludedir=FIXMESTAGINGDIR/x86_64-linux/usr/include
prefix=FIXMESTAGINGDIR/x86_64-linux/usr
sbindir=FIXMESTAGINGDIR/x86_64-linux/usr/bin/arm-xilinx-linux-gnueabi
servicedir=FIXMESTAGINGDIR/x86_64-linux/srv
sharedstatedir=FIXMESTAGINGDIR/x86_64-linux/com
sysconfdir=FIXMESTAGINGDIR/x86_64-linux/etc
systemd_system_unitdir=FIXMESTAGINGDIR/x86_64-linux/lib/systemd/system
systemd_unitdir=FIXMESTAGINGDIR/x86_64-linux/lib/systemd
systemd_user_unitdir=FIXMESTAGINGDIR/x86_64-linux/usr/lib/systemd/user
target="$1"
usage () {
	echo "Usage:"
	echo "$0 user@target 'extra options to dejagnu'"
	echo "$0 target 'extra options to dejagnu'"
	echo "$0 target"
	echo "e.g. $0 192.168.7.2 ' dg.exp=visibility-d.c'"
	echo "will only run visibility-d.c test case"
	echo "e.g. $0 192.168.7.2 '/-mthumb dg.exp=visibility-d.c'"
	echo "will only run visibility-d.c test case in thumb mode"
	echo "You need to have dejagnu autogen expect installed"
	echo "on the build host"
    }
if [ "x$target" = "x" ]
then
	echo "Please specify the target machine and remote user in form of user@target\n"
	usage
	exit 1;
fi

shift

echo "$target" | grep "@" 2>&1 > /dev/null
if [ "x$?" = "x0" ]
then
   user=$(echo $target | cut -d '@' -f 1)
   target=$(echo $target | cut -d '@' -f 2)
else
   user=$USER
fi
ssh $user@$target date 2>&1 > /dev/null
if [ "x$?" != "x0" ]
then
	echo "Failed connecting to $user@$target it could be because"
	echo "you don't have passwordless ssh setup to access $target"
	echo "or sometimes host key has been changed"
	echo "in such case do something like below on build host"
	echo "ssh-keygen -f "~/.ssh/known_hosts" -R $target"
	echo "and then try ssh $user@$target"

	usage
	exit 1
fi
	echo "lappend boards_dir [pwd]/../../.." > /tmp/petalinux-yocto/yocto_sdk_full_2017.1/build/tmp/work/x86_64-linux/gcc-cross-arm/linaro-6.2-r2016.11/gcc-linaro-6.2-2016.11/build.x86_64-linux.arm-xilinx-linux-gnueabi/site.exp
	echo "load_generic_config \"unix\"" > /tmp/petalinux-yocto/yocto_sdk_full_2017.1/build/tmp/work/x86_64-linux/gcc-cross-arm/linaro-6.2-r2016.11/gcc-linaro-6.2-2016.11/build.x86_64-linux.arm-xilinx-linux-gnueabi/x86_64.exp
	echo "set_board_info username $user" >> /tmp/petalinux-yocto/yocto_sdk_full_2017.1/build/tmp/work/x86_64-linux/gcc-cross-arm/linaro-6.2-r2016.11/gcc-linaro-6.2-2016.11/build.x86_64-linux.arm-xilinx-linux-gnueabi/x86_64.exp
	echo "set_board_info rsh_prog ssh" >> /tmp/petalinux-yocto/yocto_sdk_full_2017.1/build/tmp/work/x86_64-linux/gcc-cross-arm/linaro-6.2-r2016.11/gcc-linaro-6.2-2016.11/build.x86_64-linux.arm-xilinx-linux-gnueabi/x86_64.exp
	echo "set_board_info rcp_prog scp" >> /tmp/petalinux-yocto/yocto_sdk_full_2017.1/build/tmp/work/x86_64-linux/gcc-cross-arm/linaro-6.2-r2016.11/gcc-linaro-6.2-2016.11/build.x86_64-linux.arm-xilinx-linux-gnueabi/x86_64.exp
	echo "set_board_info hostname $target" >> /tmp/petalinux-yocto/yocto_sdk_full_2017.1/build/tmp/work/x86_64-linux/gcc-cross-arm/linaro-6.2-r2016.11/gcc-linaro-6.2-2016.11/build.x86_64-linux.arm-xilinx-linux-gnueabi/x86_64.exp
	DEJAGNU=/tmp/petalinux-yocto/yocto_sdk_full_2017.1/build/tmp/work/x86_64-linux/gcc-cross-arm/linaro-6.2-r2016.11/gcc-linaro-6.2-2016.11/build.x86_64-linux.arm-xilinx-linux-gnueabi/site.exp make -k check RUNTESTFLAGS="--target_board=x86_64$@"

