Add fiemap_writer_test to VTS.

Note: fiemap_writer_test's default argument now defaults to
/data/local/unencrypted or /data (whichever exists), since there is no
way to pass arguments via AndroidTest.xml.

Bug: 129000341
Test: vts-tradefed run commandAndExit vts-kernel --primary-abi-only --module VtsFiemapWriterTest
Change-Id: I8cc2e39e170b26b53cf0a829b308171890ae82fd
This commit is contained in:
David Anderson 2019-03-20 18:10:25 -07:00
parent 605eab93c6
commit db64c82fe7
3 changed files with 60 additions and 4 deletions

View File

@ -0,0 +1,22 @@
#
# Copyright (C) 2019 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.
#
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := VtsFiemapWriterTest
include test/vts/tools/build/Android.host_config.mk

View File

@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2019 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 VtsFiemapWriterTest">
<option name="config-descriptor:metadata" key="plan" value="vts-kernel" />
<target_preparer class="com.android.compatibility.common.tradefed.targetprep.VtsFilePusher">
<option name="abort-on-push-failure" value="false"/>
<option name="push-group" value="HostDrivenTest.push"/>
</target_preparer>
<test class="com.android.tradefed.testtype.VtsMultiDeviceTest">
<option name="test-module-name" value="VtsFiemapWriterTest"/>
<option name="binary-test-source" value="_32bit::DATA/nativetest/fiemap_writer_test/fiemap_writer_test" />
<option name="binary-test-source" value="_64bit::DATA/nativetest64/fiemap_writer_test/fiemap_writer_test" />
<option name="binary-test-type" value="gtest"/>
<option name="test-timeout" value="1m"/>
</test>
</configuration>

View File

@ -498,17 +498,22 @@ using namespace android::fiemap_writer;
int main(int argc, char** argv) {
::testing::InitGoogleTest(&argc, argv);
if (argc <= 1) {
cerr << "Usage: <test_dir> [file_size]\n";
if (argc > 1 && argv[1] == "-h"s) {
cerr << "Usage: [test_dir] [file_size]\n";
cerr << "\n";
cerr << "Note: test_dir must be a writable, unencrypted directory.\n";
exit(EXIT_FAILURE);
}
::android::base::InitLogging(argv, ::android::base::StderrLogger);
std::string tempdir = argv[1] + "/XXXXXX"s;
std::string root_dir = "/data/local/unencrypted";
if (access(root_dir.c_str(), F_OK)) {
root_dir = "/data";
}
std::string tempdir = root_dir + "/XXXXXX"s;
if (!mkdtemp(tempdir.data())) {
cerr << "unable to create tempdir on " << argv[1] << "\n";
cerr << "unable to create tempdir on " << root_dir << "\n";
exit(EXIT_FAILURE);
}
if (!android::base::Realpath(tempdir, &gTestDir)) {