From: Igor Kulaychuk Date: Wed, 27 Mar 2019 13:16:08 +0000 (+0300) Subject: Update run_tests_sdb.sh script X-Git-Tag: submit/tizen/20190813.035844~12^2~4 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=bf87fab5fa8159e01878fd6e60d35ff1668ad62f;p=sdk%2Ftools%2Fnetcoredbg.git Update run_tests_sdb.sh script Now the script performs all necessary actions by itself --- diff --git a/tests/run_tests_sdb.sh b/tests/run_tests_sdb.sh index b670d84..2e85b37 100755 --- a/tests/run_tests_sdb.sh +++ b/tests/run_tests_sdb.sh @@ -1,28 +1,60 @@ #!/bin/sh -# Before running this script: -# 1. Enable root mode: sdb root on -# 2. Remount system partition: sdb shell mount -o rw,remount / -# 3. Install netcoredbg rpm: sdb push netcoredbg-*.rpm /tmp && sdb shell rpm -i --force /tmp/netcoredbg-*.rpm -# 4. Create dotnet symlink: sdb shell ln -s /usr/share/dotnet/corerun /usr/bin/dotnet - SDB=${SDB:-sdb} +GBSROOT=$HOME/GBS-ROOT +TOOLS_ABS_PATH=/home/owner/share/tmp/sdk_tools + SCRIPTDIR=$(dirname $(readlink -f $0)) +# Detect target arch + +if $SDB shell cat /proc/cpuinfo | grep -q ARMv7; then ARCH=armv7l; else ARCH=i686; fi + +# The following command assumes that GBS build was performed on a clean system (or in Docker), +# which means only one such file exists. +RPMFILE=$(find $GBSROOT/local/repos/ -type f -name netcoredbg-[0-9]\*$ARCH.rpm -print -quit) + +# Repackage RPM file as TGZ + +if [ ! -f "$RPMFILE" ]; then exit 1; fi +PKGNAME=`rpm -q --qf "%{n}" -p $RPMFILE` +PKGVERSION=`rpm -q --qf "%{v}" -p $RPMFILE` +PKGARCH=`rpm -q --qf "%{arch}" -p $RPMFILE` +TARGZNAME=$PKGNAME-$PKGVERSION-$PKGARCH.tar.gz +if [ -d $SCRIPTDIR/unpacked ]; then rm -rf $SCRIPTDIR/unpacked; fi +mkdir $SCRIPTDIR/unpacked && cd $SCRIPTDIR/unpacked +rpm2cpio "$RPMFILE" | cpio -idmv +touch .$TOOLS_ABS_PATH/$PKGNAME/version-$PKGVERSION +tar cfz ../$TARGZNAME --owner=root --group=root -C .$TOOLS_ABS_PATH . +cd .. + +# Upload TGZ to target and unpack + +REMOTETESTDIR=$TOOLS_ABS_PATH/netcoredbg-tests + +$SDB root on +$SDB shell rm -rf $TOOLS_ABS_PATH/netcoredbg +$SDB shell mkdir -p $TOOLS_ABS_PATH/on-demand +$SDB push $TARGZNAME $TOOLS_ABS_PATH/on-demand +$SDB shell "cd $TOOLS_ABS_PATH && tar xf $TOOLS_ABS_PATH/on-demand/$(basename $TARGZNAME)" +$SDB shell rm -rf $REMOTETESTDIR +$SDB shell mkdir $REMOTETESTDIR + # Upload all test dlls and pdbs + find $SCRIPTDIR -name '*Test.runtimeconfig.json' | while read fname; do base=$(echo $fname | rev | cut -f 3- -d '.' | rev) - $SDB push ${base}.dll ${base}.pdb /tmp - # After push some targets set SMACK access label to System, but the debugger can not access System files. - # Also, prevent sdb from consuming input. - cat /dev/null | $SDB shell "chsmack -a '*' /tmp/$(basename ${base}).dll /tmp/$(basename ${base}).pdb" + $SDB push ${base}.dll ${base}.pdb $REMOTETESTDIR done +$SDB shell "echo -e '#!/bin/sh\nexec /lib/ld-linux.so.3 /usr/share/dotnet/corerun --clr-path /usr/share/dotnet/shared/Microsoft.NETCore.App/2.0.0 \$@' > $REMOTETESTDIR/dotnet" +$SDB shell chmod +x $REMOTETESTDIR/dotnet + # Run tests -DEBUGGER=/home/owner/share/tmp/sdk_tools/netcoredbg/netcoredbg +DEBUGGER=$TOOLS_ABS_PATH/netcoredbg/netcoredbg # sdb always allocates a terminal for a shell command, but we do not want MI commands to be echoed. # So we need to delay stdin by 1 second and hope that `stty raw -echo` turns the echo off during the delay. -TESTDIR=/tmp PIPE="(sleep 1; cat) | $SDB shell stty raw -echo\\;$DEBUGGER --interpreter=mi" dotnet test $SCRIPTDIR --logger "trx;LogFileName=$SCRIPTDIR/Results.trx" +TESTDIR=$REMOTETESTDIR PIPE="(sleep 1; cat) | $SDB shell stty raw -echo\\; export PATH=\$PATH:$TOOLS_ABS_PATH/netcoredbg-tests\\; $DEBUGGER --log=file --interpreter=mi" dotnet test $SCRIPTDIR --logger "trx;LogFileName=$SCRIPTDIR/Results.trx"