1#!/bin/bash
2
3# This script runs a bunch of room related compilations repeatedly
4# to avoid a native library loading bug in xerial
5# https://github.com/xerial/sqlite-jdbc/issues/97
6
7set -e
8
9cd "$(dirname $0)/../.."
10
11if [ ! -f gradlew ]; then
12    echo "./gradlew does not exist! Make sure I live under frameworks/support/room"
13    exit 1
14fi
15
16NOW=`date +%F-%H-%M-%S`
17SUCCESS_MSG="BUILD SUCCESSFUL"
18OUTPUT_PREFIX="o_"
19ERROR_PREFIX="e_"
20OUTPUT_FOLDER="room_stress_test_output_${NOW}"
21REPEAT=50
22rm -rf $OUTPUT_FOLDER
23mkdir $OUTPUT_FOLDER
24
25function printResult {
26   success=`grep "${SUCCESS_MSG}" $1 | wc -l`
27   if [ $success -eq 1 ]
28   then
29       echo "SUCCESS"
30   else
31       echo "FAIL"
32   fi
33}
34
35echo "output folder:${OUTPUT_FOLDER}. Will run ${REPEAT} times"
36
37for (( i=0; i<$REPEAT; i++ ))
38do
39   echo "START RUN $i"
40   ./gradlew --no-build-cache --stacktrace  \
41         :room:integration-tests:room-testapp-noappcompat:asAnTest \
42         :room:integration-tests:room-testapp-autovalue:asAnTest \
43         :room:integration-tests:room-testapp:asAnTest \
44         :room:integration-tests:room-testapp-kotlin:asAnTest \
45         > "${OUTPUT_FOLDER}/${OUTPUT_PREFIX}${i}" 2>"${OUTPUT_FOLDER}/${ERROR_PREFIX}${i}" || true
46   echo "END RUN $i"
47   printResult "${OUTPUT_FOLDER}/${OUTPUT_PREFIX}${i}"
48done
49
50totalSuccess=`grep "${SUCCESS_MSG}" ${OUTPUT_FOLDER}/* |wc -l`
51echo "${totalSuccess} over ${REPEAT} succeeded"
52
53