summaryrefslogtreecommitdiff
path: root/install.sh
blob: 610d6d3e836f54cee03ed625918e131108c4e6d5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
#!/bin/bash

user=
password=

usage()
{
    echo "Usage: $0 --device=[name] --target=[mobile|tv] --version=[version] --skiprpminstall"
    echo "--device    - If there are more than one target,"
    echo "              you should pass the device name by using 'sdb devices' command"
    echo "--target    - Target device type (i.e. mobile, tv)"
    echo "--version   - You can add the specific binary version name."
    echo "              The name should can be found under http://165.213.149.200/download/public_mirror/tizen/"
    echo "              like tizen-mobile_20170215.2."
    echo "              Default is a latest repository."
    echo "--url       - You can specify the specific url of packages archive"
    echo "              like http://165.213.149.200/download/public_mirror/tizen/base/tizen-base_20170520.1/repos/arm/packages/"
    echo "              Default is a latest repository."
    echo "--url-user      - Specify user for url"
    echo "--url-password  - Specify password for url"
    echo "--prefix-dir  - You can specify the prefix directory for performing the unittest"
    echo "                like /opt/usr/coreclr-tc"
    echo "                Default is '/opt/usr/coreclr-tc'."
    echo "--tests-url   - The url of files in 'tests' directory to perform unittest."
    echo "                Default is to get those files from tizen branch"
    echo "--skiprpminstall  - Do not install rpm files"
    echo "--skiptcinstall   - Do not install TC archive"
    echo "--skiptcdirremove - Do not remove TC directory"
    echo "--uselatesttc - Download a latest unittest file from http://10.113.63.27:8080/"
    echo "                This option is off by default and use a local unittest file under tc directory."
    echo "--tc-url    - Download a TC archive file from the specified URL"
    exit 1
}

check_valid_url()
{
    status=$( curl -u $user:$password -s --head -w %{http_code} $1 -o /dev/null )
    if [[ $status != 200 ]]; then
        echo "Invalid webpage. (url=$1)"
        exit 1
    fi
}

opt=""
devicetype="mobile"
version="latest"
url=""
clrdir=""
skiprpminstall=0
skiptcinstall=0
uselatesttc=0
testsurl=""
tcurl=""
httpuser=""
httppassword=""

for i in "$@"
do
    if [ $# -le 0 ]; then
        break
    fi

    case $i in
        -h|--help)
            usage
            exit 1
            ;;
        --device=*)
            opt="-s "${i#*=}
            ;;
        --target=*)
            devicetype=${i#*=}
            ;;
        --version=*)
            version=${i#*=}
            ;;
        --url=*)
            url=${i#*=}
            ;;
        --prefix-dir=*)
            clrdir=${i#*=}
            ;;
        --tests-url=*)
            testsurl=${i#*=}
            ;;
        --skiprpminstall)
            skiprpminstall=1
            ;;
        --skiptcinstall)
            skiptcinstall=1
            ;;
        --skiptcdirremove)
            skiptcdirremove=1
            ;;
        --uselatesttc)
            uselatesttc=1
            ;;
        --tc-url=*)
            tcurl=${i#*=}
            ;;
        --url-user=*)
            urluser=${i#*=}
            ;;
        --url-password=*)
            urlpassword=${i#*=}
            ;;
        *)
            usage
            exit 1
            ;;
    esac
    shift
done


sdb ${opt} root on
sdb ${opt} shell mount -o remount,rw /

if [ $? != 0 ]; then
	exit 1
fi

if [[ ${devicetype} != "mobile" ]] && [[ ${devicetype} != "tv" ]]; then
	usage
	exit 1
fi

if [[ $urluser != "" ]]; then
	user=$urluser
fi

if [[ $urlpassword != "" ]]; then
	password=$urlpassword
fi

str=$( sdb ${opt} shell "uname -a" )
if [[ $str == *"x86_64"* ]]; then
    target_type="emulator"
    target=x86_64
    tcarch=x64
    tcjob="${tcarch}_Rel_CLEARED_TC_Pri2"
elif [[ $str == *"i686"* ]]; then
    target_type="emulator"
    target=i686
    tcarch=x86
    tcjob="${tcarch}_Rel_CLEARED_TC_Pri2"
elif [[ $str == *"armv7l"* ]]; then
    target_type="standard"
    target=armv7l
    tcarch=x86
    tcjob="ARM_Rel_CLEARED_TC_Pri2"
elif [[ $str == *"aarch64"* ]]; then
    target_type="standard"
    target=armv7l
    tcarch=x86
    tcjob="ARM_Rel_CLEARED_TC_Pri2"
else
    echo "not support target $str"
    exit 1
fi

if [[ $clrdir == "" ]]; then
	clrdir="/opt/usr/coreclr-tc"
fi
tcdir="$clrdir/Windows_NT.${tcarch}.Release"

if [[ $skiptcdirremove == 0 ]]; then
    sdb ${opt} shell rm -rf $clrdir
fi
sdb ${opt} shell mkdir -p ${clrdir}

if [[ $skiprpminstall == 0 ]]; then
    echo "Target arch : ${target}"
    echo "Check valid repository url"
    if [[ $url == "" ]]; then
        repo_url="http://165.213.149.200/download/public_mirror/tizen/unified"
        url=$repo_url"/"$version"/repos/"$target_type"/packages/"
    elif [[ ! $url == *"noarch"* ]]; then
        url=$url"/"$target"/"
    fi
    check_valid_url $url

    echo -e " \n\n---- Donwload coreclr-test-*.rpm ----"
    wget -r --no-parent -nd -R 'index.html*' -R '*debug*' -P rpms -A 'coreclr-test-*.rpm' $url --http-user=$user --http-password=$password

    echo -e "\n\n---- Install rpm files ----"
    tmpdir="$clrdir/tmp"
    sdb ${opt} shell mkdir -p $tmpdir
    sdb ${opt} push rpms/*.${target}.rpm $tmpdir
    sdb ${opt} push rpms/*.noarch.rpm $tmpdir
    sdb ${opt} shell rpm -ivh --force $tmpdir/*.rpm
    sdb ${opt} shell rm -rf $tmpdir
    rm -rf rpms/coreclr-test-*.rpm
fi

if [ $skiptcinstall == 0 ]; then
    if [ $uselatesttc == 1 ]; then
        echo -e "\n\n---- Download CoreCLR TC ----"
        tc_url="https://ci.dot.net/job/dotnet_coreclr/job/master/job/${tcarch}_release_windows_nt/lastSuccessfulBuild/artifact/bin/tests/tests.zip"
        tc_dir="testcases"
        mkdir ${tc_dir}
        pushd ${tc_dir}
        wget $tc_url
        unzip -q tests.zip
        rm -rf tests.zip
        find . -name "*.sh" -type f -exec sed -i 's/\r//g' {} \;
        tar zcf testcases.bin.tgz ./*
        popd
        cp -L ${tc_dir}/testcases.bin.tgz testcases.bin.tgz
    elif [[ ${tcurl} != "" ]]; then
        echo -e "\n\n---- Download CoreCLR TC ----"
        wget $tcurl -O testcases.bin.tgz
    else
        echo -e "\n\n---- Use tc/testcases.${tcarch}.bin.tgz ----"
        cp -L tc/testcases.${tcarch}.bin.tgz testcases.bin.tgz
    fi

    echo -e "\n\n---- Install CoreCLR TC ----"
    sdb ${opt} push testcases.bin.tgz $clrdir
    sdb ${opt} shell mkdir -p $tcdir
    sdb ${opt} shell tar xzf $clrdir/testcases.bin.tgz -C $tcdir
    sdb ${opt} shell rm $clrdir/testcases.bin.tgz
    rm testcases.bin.tgz
fi

if [[ ${testsurl} != "" ]]; then
    echo -e "\n\n---- wget tests files from tests-url ----"
    wget ${testsurl}
    testsfile=${testsurl##*/}
    tar zxf ${testsfile}
    rm -rf ${testsfile}
else
    echo -e "\n\n---- Checkout runtest.sh from master branch ----"
    git checkout tizen -- ./tests/runtest.sh
    git checkout tizen -- ./tests/tests*.txt
    git checkout tizen -- ./tests/skipCrossGenFiles.*.txt
    git checkout tizen -- ./tests/setup-stress-dependencies.sh
fi
#sed -i "s/((maxProcesses = \$NumProc.*/((maxProcesses = 1))/g" tests/runtest.sh
sed -i "s/NumProc=\$(nproc.*/NumProc=1/g" tests/runtest.sh
git apply Add-skipped-testcase-on-TM1.diff
sdb ${opt} push ./tests/runtest.sh $clrdir
sdb ${opt} push ./tests/tests*.txt $clrdir
sdb ${opt} push ./tests/skipCrossGenFiles.*.txt $clrdir
sdb ${opt} push ./tests/setup-stress-dependencies.sh $clrdir
rm -rf ./tests
git reset -- tests/*

echo -e "\n\n---- Create TC Overlay ----"
overlaydir="$tcdir/Tests/coreoverlay"
sdb ${opt} shell mkdir -p $overlaydir
sdb ${opt} shell cp -rf $tcdir/Tests/Core_Root/* $overlaydir
sdb ${opt} shell cp -L /usr/share/dotnet/shared/Microsoft.NETCore.App/2.0.0/* $overlaydir
sdb ${opt} shell cp -L /usr/share/dotnet.tizen/framework/* $overlaydir
# runtest.sh does not consider link files so copy directly
sdb ${opt} shell find /usr/share/dotnet.tizen/test/ -name "*.so" -exec cp {} $overlaydir \\\;
sdb ${opt} shell chmod 644 $overlaydir/*.dll $overlaydir/*.so
sdb ${opt} shell chmod +x $overlaydir/corerun

sdb ${opt} shell sync

echo -e "\n\n---- Finish ----"
echo -e "CoreOverlay dir : $overlaydir"
echo -e "How to run CoreCLR TC : "
echo -e "# cd $clrdir"
echo -e "# ./runtest.sh --testRootDir=$tcdir \\"
echo -e "> --testNativeBinDir=/usr/share/dotnet.tizen/test \\"
echo -e "> --coreOverlayDir=$overlaydir --show-time --no-lf-conversion | tee clr.log"
echo -e "Output results : $tcdir/coreclrtests.xml"
echo -e "(You can use run.sh file in your host machine.)"
echo -e "\nHow to convert useful csv file : "
echo -e "(In host machine, not target)"
echo -e "coreclr$ cd script"
echo -e "coreclr/script$ ./get_clr_results.sh --prefix-dir=${clrdir}"