metadata:
    name: cts-host
    format: "Lava-Test-Shell Test Definition 1.0"
    description: "Run CTS on Linaro android. Host side;
                  Get user defined CTS test command from JSON and run;
                  The value put in params section in this file is default, user can overwrite them by the values in JSON file."
    maintainer:
        - milosz.wasilewski@linaro.org
    os:
        - ubuntu
    devices:
        - kvm
    scope:
        - functional

run:
    steps:
        - apt-get install -y git android-tools-adb time zip
        - git clone git://git.linaro.org/qa/android-apk-automation.git
        - lava-wait adb-push-send-ip
        - IPADDR=`awk -F '=' '{print $2}' /tmp/lava_multi_node_cache.txt`
        - if [ $IPADDR != "_MISSING_" ]
        - then
        - adb connect $IPADDR
        - echo $IPADDR
        - adb -s $IPADDR:5555 wait-for-device
        - adb devices
        - echo "-------------group start:$(date)--------------------">> /tmp/adb_push_time.txt
        - for i in {1..10}; do
        - /usr/bin/time -f "\t%E real,\t%U user,\t%S sys" -a -o /tmp/adb_push_time.txt adb push ./android-apk-automation/ /data/local/tmp/android-apk-automation/
        - done
        - echo "-------------group end:$(date)--------------------" >> /tmp/adb_push_time.txt
        - fi
        - zip -r android-apk-automation.zip android-apk-automation
        - echo "-------------zip group start:$(date)--------------------">> /tmp/adb_push_time.txt
        - for i in {1..10}; do
        - /usr/bin/time -f "\t%E real,\t%U user,\t%S sys" -a -o /tmp/adb_push_time.txt adb push android-apk-automation.zip /data/local/tmp/android-apk-automation.zip
        - done
        - echo "-------------zip group end:$(date)--------------------" >> /tmp/adb_push_time.txt
        - echo "-------------cp zip group start:$(date)--------------------">> /tmp/adb_push_time.txt
        - for i in {1..10}; do
        - /usr/bin/time -f "\t%E real,\t%U user,\t%S sys" -a -o /tmp/adb_push_time.txt adb shell cp /data/local/tmp/android-apk-automation.zip /data/local/tmp/android-apk-automation_${i}.zip
        - done
        - echo "-------------cp zip group end:$(date)--------------------" >> /tmp/adb_push_time.txt
        - echo "-------------cp dir group start:$(date)--------------------">> /tmp/adb_push_time.txt
        - for i in {1..10}; do
        - /usr/bin/time -f "\t%E real,\t%U user,\t%S sys" -a -o /tmp/adb_push_time.txt adb shell cp -r /data/local/tmp/android-apk-automation /data/local/tmp/android-apk-automation_${i}
        - done
        - echo "-------------cp dir group end:$(date)--------------------" >> /tmp/adb_push_time.txt
        - adb shell dmesg > /tmp/dmesg.log
        - if [ -f /tmp/adb_push_time.txt ]; then lava-test-run-attach /tmp/adb_push_time.txt text/plain; fi
        - if [ -f /tmp/dmesg.log ]; then lava-test-run-attach /tmp/dmesg.log text/plain; fi
        - lava-sync adb-push-finished
