#!/usr/bin/env bash


APK_FILENAME=$1

export TIME="time: %e
kernel-cpu-time: %S
user-cpu-time: %U
max-rss-mem: %M
avg-rss-mem: %t
avg-total-mem: %K
page-size: %Z
nb-major-page-fault: %F
nb-minor-page-fault: %R
nb-fs-input: %I
nb-fs-output: %O
nb-socket-msg-received: %r
nb-socket-msg-sent: %s
nb-signal-delivered: %k
exit-status: %x"


cd /workspace/ic3
mkdir -p /mnt/ic3_out

HASH=`echo ${APK_FILENAME} | cut -d '.' -f '1'`

# Command to execute
CMD="java ${JAVA_PARAM} -jar /workspace/ic3/target/ic3-0.2.1-full.jar -protobuf /mnt/ic3_out -out /mnt/ic3_out -a  /mnt/${APK_FILENAME} -cp /opt/android-sdk/platforms"

echo "Doing: ${CMD}"

# Monitoring time of IC3 FORK
/usr/bin/time -o /mnt/report -q /usr/bin/timeout --kill-after=20s ${TIMEOUT}  ${CMD} >> /mnt/stdout 2>> /mnt/stderr

echo "IC3 FORK finished"

