<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2020 The Android Open Source Project
     Licensed under the Apache License, Version 2.0 (the "License");
     you may not use this file except in compliance with the License.
     You may obtain a copy of the License at
          http://www.apache.org/licenses/LICENSE-2.0
     Unless required by applicable law or agreed to in writing, software
     distributed under the License is distributed on an "AS IS" BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.
-->
<!DOCTYPE configuration [
<!ENTITY ltp_dir "/data/local/tmp/{MODULE}">
<!ENTITY ltp_env "export LTPROOT=/data/local/tmp/{MODULE}/{target} LTP_DEV_FS_TYPE=ext4; export PATH=/system/bin:$LTPROOT TMP=$LTPROOT/tmp; export TMPBASE=$TMP/tmpbase LTPTMP=$TMP/ltptemp TMPDIR=$TMP/tmpdir">
]>
<configuration description="Runs vts_ltp_test.">
    <target_preparer class="com.android.tradefed.targetprep.RootTargetPreparer"/>
    <target_preparer class="com.android.tradefed.targetprep.StopServicesSetup"/>

    <object type="module_controller" class="com.android.tradefed.testtype.suite.module.KernelTestModuleController" >
{module_controller_option}
    </object>

    <target_preparer class="com.android.tradefed.targetprep.PushFilePreparer">
        <option name="cleanup" value="true" />
        <option name="push-file" key="{MODULE}" value="&ltp_dir;" />
        <option name="post-push" value='chmod -R 755 &ltp_dir;;  find &ltp_dir; -type f | xargs grep -l -e "bin/sh" -e "bin/bash" | xargs sed -i -e "s?/bin/echo?echo?" -i -e "s?#!/bin/sh?#!/system/bin/sh?" -i -e "s?#!/bin/bash?#!/system/bin/sh?" -i -e "s?bs=1M?#bs=1m?"' />
    </target_preparer>

    <target_preparer class="com.android.tradefed.targetprep.RunCommandTargetPreparer">
        <option name="run-command" value='&ltp_env;; mkdir -p $LTPROOT/testcases/bin/data; mkdir -p $TMP; mkdir -p $TMPBASE; mkdir -p $LTPTMP; mkdir -p $TMPDIR; chmod -R 777 $TMP; restorecon -F -R $LTPROOT' />
        <option name="teardown-command" value="rm -rf &ltp_dir;/{target}/tmp" />
    </target_preparer>

    <!-- Mandatory tests (must pass and cannot skip). -->
    <test class="com.android.tradefed.testtype.binary.KernelTargetTest">
        <option name="skip-binary-check" value="true" />
        <option name="abort-if-device-lost" value="true" />
        <option name="abort-if-root-lost" value="true" />
        <!-- Set binary timeout to be 18 min which is greater than the default 5 min timeout. Otherwise TF will retry to the command and attempt to do device recovery. -->
        <option name="per-binary-timeout" value="1080000" />
{mandatory_test_cases}
    </test>

    <test class="com.android.tradefed.testtype.binary.KernelTargetTest">
        <!-- Identify LTP's TCONF code (incompatible configuration) as a skip. -->
        <option name="exit-code-skip" value="32" />
        <option name="skip-binary-check" value="true" />
        <option name="abort-if-device-lost" value="true" />
        <option name="abort-if-root-lost" value="true" />
        <!-- Set binary timeout to be 18 min which is greater than the default 5 min timeout. Otherwise TF will retry to the command and attempt to do device recovery. -->
        <option name="per-binary-timeout" value="1080000" />
{skippable_test_cases}
    </test>

</configuration>
