Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,7 @@ int showHelpMessage(String xtsType, Path xtsRootDir)
String result =
commandExecutor.run(
com.google.devtools.mobileharness.shared.util.command.Command.of(
XtsCommandUtil.getXtsJavaCommand(
getXtsJavaCommand(
xtsType,
xtsRootDir,
ImmutableList.of(),
Expand Down Expand Up @@ -874,6 +874,22 @@ int runWithCommand(ImmutableList<String> command)
return ExitCode.OK;
}

private ImmutableList<String> getXtsJavaCommand(
String xtsType,
Path xtsRootDir,
ImmutableList<String> jvmFlags,
String concatenatedJarPath,
ImmutableList<String> xtsRunCommandArgs) {
Path javaBinary = XtsCommandUtil.getJavaBinary(xtsType, xtsRootDir);
return XtsCommandUtil.getTradefedJavaCommand(
javaBinary.toString(),
jvmFlags,
concatenatedJarPath,
ImmutableList.of(XtsCommandUtil.getXtsRootJavaProperty(xtsType, xtsRootDir)),
XtsCommandUtil.getConsoleClassName(),
xtsRunCommandArgs);
}

/** Future callback which prints {@code AtsSessionPluginOutput} to console. */
private static class RunCommandFutureCallback implements FutureCallback<AtsSessionPluginOutput> {

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Copyright 2022 Google LLC
#
# 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
#
# https://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.
#

load("@rules_java//java:java_library.bzl", "java_library")

package(
default_applicable_licenses = ["//:license"],
default_visibility = [
"//:deviceinfra_all_pkg",
],
)

java_library(
name = "tradefed_run_strategy_lib",
srcs = [
"TradefedRunStrategy.java",
"XtsRunStrategy.java",
],
deps = [
"//src/java/com/google/devtools/mobileharness/api/model/error",
"//src/java/com/google/devtools/mobileharness/platform/android/shared/emulator:android_jit_emulator_util",
"//src/java/com/google/devtools/mobileharness/platform/android/xts/common/util:xts_command_util",
"//src/java/com/google/devtools/mobileharness/platform/android/xts/common/util:xts_constants",
"//src/java/com/google/devtools/mobileharness/platform/android/xts/common/util:xts_dir_util",
"//src/java/com/google/devtools/mobileharness/shared/util/base:proto_text_format",
"//src/java/com/google/devtools/mobileharness/shared/util/file/local",
"//src/java/com/google/devtools/mobileharness/shared/util/file/local:res_util",
"//src/java/com/google/devtools/mobileharness/shared/util/flags",
"//src/java/com/google/devtools/mobileharness/shared/util/logging:google_logger",
"//src/java/com/google/devtools/mobileharness/shared/util/path",
"//src/java/com/google/devtools/mobileharness/shared/util/system",
"//src/java/com/google/wireless/qa/mobileharness/shared/api",
"//src/java/com/google/wireless/qa/mobileharness/shared/api/spec:xts_tradefed_test_spec",
"//src/java/com/google/wireless/qa/mobileharness/shared/constant:dimension",
"//src/java/com/google/wireless/qa/mobileharness/shared/model/job",
"//src/java/com/google/wireless/qa/mobileharness/shared/proto/spec:xts_tradefed_test_spec_java_proto",
"@maven//:com_google_code_gson_gson",
"@maven//:com_google_errorprone_error_prone_annotations",
"@maven//:com_google_guava_guava:base",
"@maven//:com_google_guava_guava:collect",
],
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
/*
* Copyright 2022 Google LLC
*
* 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
*
* https://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.
*/

package com.google.devtools.mobileharness.infra.ats.tradefed;

import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.devtools.mobileharness.api.model.error.MobileHarnessException;
import com.google.wireless.qa.mobileharness.shared.api.device.Device;
import com.google.wireless.qa.mobileharness.shared.model.job.TestInfo;
import com.google.wireless.qa.mobileharness.shared.proto.spec.driver.XtsTradefedTestDriverSpec;
import java.nio.file.Path;
import java.util.function.Predicate;

/**
* Strategy interface for Tradefed based test suite runners, to differentiate between xTS and
* Non-XTS runs.
*
* <p>The "work dir" is the working directory for Tradefed, used to store logs, results, and other
* temporary files. It is passed to Tradefed via the TF_WORK_DIR environment variable.
*/
public interface TradefedRunStrategy {

/**
* Sets up the work directory and prepares for the test run, including linking JDK, test cases,
* tools and libs for xTS runs.
*
* @param spec the driver spec
* @param workDir the working directory for the test run
* @param xtsType the type of xTS suite
* @param testInfo the test info
*/
void setUpWorkDir(XtsTradefedTestDriverSpec spec, Path workDir, String xtsType, TestInfo testInfo)
throws MobileHarnessException, InterruptedException;

/**
* Returns the concatenated classpath for the Tradefed command.
*
* @param workDir the working directory for the test run
* @param spec the driver spec
* @param xtsType the type of xTS suite
*/
String getConcatenatedJarPath(Path workDir, XtsTradefedTestDriverSpec spec, String xtsType)
throws MobileHarnessException;

/**
* Returns the environment variables for the Tradefed command.
*
* @param workDir the working directory for the test run
* @param xtsType the type of xTS suite
* @param spec the driver spec
* @param device the device
* @param envPath the environment path
*/
ImmutableMap<String, String> getEnvironment(
Path workDir, String xtsType, XtsTradefedTestDriverSpec spec, Device device, String envPath)
throws MobileHarnessException, InterruptedException;

/**
* Returns the path to the Java executable.
*
* @param workDir the working directory for the test run
* @param xtsType the type of xTS suite
*/
String getJavaPath(Path workDir, String xtsType);

/** Returns the main class to run. */
String getMainClass();

/** Returns a list of JVM defines to use. */
ImmutableList<String> getJvmDefines(Path workDir, String xtsType);

/**
* Returns a predicate for filtering result directories/files to only include ones from the
* current session.
*/
Predicate<Path> getCurrentSessionResultFilter();
}
Loading