<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2025 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.
-->
<configuration description="Config for vts_treble_vintf_trusted_hal_test">
    <object type="module_controller" class="com.android.tradefed.testtype.suite.module.CommandSuccessModuleController">
        <!--Skip the test when trusty VM is not enabled. -->
        <option name="run-command"
           value="(getprop trusty.security_vm.enabled | grep 1) || (getprop trusty.widevine_vm.enabled | grep 1)" />
    </object>
    <target_preparer class="com.android.tradefed.targetprep.RootTargetPreparer"/>
    <target_preparer class="com.android.tradefed.targetprep.PushFilePreparer">
        <option name="cleanup" value="true" />
        <option name="push-file" key="trusty-ut-ctrl.system" value="/data/local/tmp/trusty_test_vm/trusty-ut-ctrl" />
        <option name="push-file" key="trusty-vm-launcher.sh" value="/data/local/tmp/trusty_test_vm/trusty-vm-launcher.sh" />
        <option name="push-file" key="trusty-vm-kill.sh" value="/data/local/tmp/trusty_test_vm/trusty-vm-kill.sh" />
        <option name="push-file" key="trusty-wait-ready.sh" value="/data/local/tmp/trusty_test_vm/trusty-wait-ready.sh" />
        <option name="push-file" key="trusty-test_vm-config.json" value="/data/local/tmp/trusty_test_vm/trusty-test_vm-config.json" />
        <option name="push-file" key="trusty_test_vm.elf" value="/data/local/tmp/trusty_test_vm/trusty_test_vm.elf" />
        <option name="push" value="vts_treble_vintf_trusted_hal_test->/data/local/tmp/vts_treble_vintf_trusted_hal_test" />
    </target_preparer>
    <target_preparer class="com.android.compatibility.common.tradefed.targetprep.FilePusher">
        <option name="push" value="android.frameworks.txt->/data/local/tmp/frameworks/hardware/interfaces/current.txt"/>
        <option name="push" value="android.hardware.txt->/data/local/tmp/hardware/interfaces/current.txt"/>
        <option name="push" value="android.system.txt->/data/local/tmp/system/hardware/interfaces/current.txt"/>
    </target_preparer>
    <target_preparer class="com.android.tradefed.targetprep.RunCommandTargetPreparer">
        <option name="throw-if-cmd-fail" value="true" />
        <!--Note: the first run-command shall not expect the background command to have started -->
        <option name="run-bg-command" value="sh /data/local/tmp/trusty_test_vm/trusty-vm-launcher.sh" />
        <option name="run-command" value="sh /data/local/tmp/trusty_test_vm/trusty-wait-ready.sh" />
        <!-- Wait one second for the VM to fully launch to reduce test flakiness -->
        <option name="run-command" value="sleep 3" />
        <option name="run-command" value="start storageproxyd_test_vm" />
        <option name="teardown-command" value="stop storageproxyd_test_vm" />
        <option name="teardown-command" value="killall storageproxyd_test_vm || true" />
        <option name="teardown-command" value="sh /data/local/tmp/trusty_test_vm/trusty-vm-kill.sh" />
    </target_preparer>
    <test class="com.android.tradefed.testtype.GTest" >
        <option name="native-test-device-path" value="/data/local/tmp" />
        <option name="module-name" value="vts_treble_vintf_trusted_hal_test" />
    </test>
    <metrics_collector class="com.android.tradefed.device.metric.FilePullerLogCollector">
        <option name="directory-keys" value="/data/local/tmp/trusty_test_vm/logs" />
        <option name="clean-up" value="false"/>
    </metrics_collector>
</configuration>
