2025년 3월 27일부터 AOSP를 빌드하고 기여하려면 aosp-main
대신 android-latest-release
를 사용하는 것이 좋습니다. 자세한 내용은 AOSP 변경사항을 참고하세요.
Tradefed XML 구성의 템플릿 및 Include
컬렉션을 사용해 정리하기
내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.
단일 모놀리식 XML 구성을 생성하여 테스트를 정의하는 것이 실용적이지 않을 때도 있습니다. 설정의 일부를 재사용하여 유사한 테스트를 실행하고 싶은 경우에는 두 개의 대량 XML 파일을 복사하여 유지할 수 밖에 없습니다.
바로 여기서 Tradedfed XML 구성의 template
및 include
태그가 유용성을 발휘합니다. 이러한 태그를 사용하면 일부 XML 구성에 자리표시자를 설정하여 다른 XML 구성의 일부를 추가할 수 있습니다.
template 정의의 예
<configuration description="Common base configuration for local runs with minimum overhead">
<build_provider class="com.android.tradefed.build.BootstrapBuildProvider" />
<template-include name="preparers" default="empty" />
<template-include name="test" default="empty" />
<template-include name="reporters" default="empty" />
</configuration>
template은 템플릿을 참조하기 위한 name
및 선택사항 default
필드를 포함하는 자리표시자입니다. 기본 필드는 사용해야 하는 기본 대체 XML을 정의합니다.
구성의 template을 대체하기 위해서는 다음과 같은 명령어 매개변수를 명령줄에 추가해야 합니다.
--template:map <name of template>=<replacement XML config path>
--template:map preparers=empty
예:
<template-include name="preparers" default>=
"empty" /
이 경우의 empty
참조는 아무 것도 포함되지 않은 empty.xml
구성을 참조합니다. 이를 아무것도 교체하는 데 대한 참조로 사용합니다.
XML 구성의 경로는 Tradefed JAR 리소스 내의 res/config
폴더에 대해 절대적이거나 상대적일 수 있습니다. 위치는 다음과 같을 수 있습니다.
- tools/tradefederation/core/res/config
- tools/tradefederation/core/tests/res/config
- tools/tradedeferation/contrib/res/config
include 정의의 예
<configuration description="Common base configuration for local runs with minimum over>head&<quot;
build_provider class="com.android.tradefed.build.BootstrapB>uildPr<ovider" /
i>n<clude name=&qu>o
t;empty"/
/configuration
include는 template보다 단순합니다 template에는 명령줄 인수가 필요없으며 name
태그에서 참조된 XML을 직접적으로 확장하기 때문입니다. template과 마찬가지로 구성에 대한 경로는 절대적이거나 상대적일 수 있습니다. 하지만 includes
의 경우 Tradefed에서 훨씬 휴대성이 높은 만큼 상대 경로만 사용하는 것이 좋습니다.
Tradefed를 다른 시스템으로 이동한 경우에는 절대 경로가 유효하지 않습니다.
구성 오류
구성 오류가 발생한 경우(예: 대체 XML을 찾을 수 없는 경우) Tradefed는 ConfigurationException
ConfigurationException, 그리고 누락되었거나 잘못 구성된 요소에 대한 설명을 표시합니다.
이 페이지에 나와 있는 콘텐츠와 코드 샘플에는 콘텐츠 라이선스에서 설명하는 라이선스가 적용됩니다. 자바 및 OpenJDK는 Oracle 및 Oracle 계열사의 상표 또는 등록 상표입니다.
최종 업데이트: 2025-09-05(UTC)
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["필요한 정보가 없음","missingTheInformationINeed","thumb-down"],["너무 복잡함/단계 수가 너무 많음","tooComplicatedTooManySteps","thumb-down"],["오래됨","outOfDate","thumb-down"],["번역 문제","translationIssue","thumb-down"],["샘플/코드 문제","samplesCodeIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-09-05(UTC)"],[],[],null,["Creating one monolithic XML configuration to define a test is not always\npractical. If you want to re-use part of the setup to run similar tests, you\nwould be forced to copy and maintain two giant XML files.\n\nThis is where `template` and `include` tags in Tradefed XML Configuration\ndefinition come in handy. They allow you to set placeholders in some XML\nconfiguration to add part of another XML configuration.\n\nExample definition for templates \n\n \u003cconfiguration description=\"Common base configuration for local runs with minimum overhead\"\u003e\n \u003cbuild_provider class=\"com.android.tradefed.build.BootstrapBuildProvider\" /\u003e\n\n \u003ctemplate-include name=\"preparers\" default=\"empty\" /\u003e\n\n \u003ctemplate-include name=\"test\" default=\"empty\" /\u003e\n\n \u003ctemplate-include name=\"reporters\" default=\"empty\" /\u003e\n \u003c/configuration\u003e\n\nTemplates are placeholders with a `name` to reference them, and an optional\n`default` field. The default field defines the default replacement XML that\nshould be used.\n\nIn order to replace a template for a given configuration, the following command\nparameter needs to be added to the command line: \n\n --template:map \u003cname of template\u003e=\u003creplacement XML config path\u003e\n\n --template:map preparers=empty\n\nFor example: \n\n \u003ctemplate-include name=\"preparers\" default\u003e=\"empty\" /\n\nThe `empty` reference in this case refers to the `empty.xml` configuration that\ncontains nothing; we use it as our reference to *replace with nothing*.\n\nThe path of XML configs can be absolute or relative to the `res/config` folder\ninside Tradefed's JAR resources. Here are a few of their locations:\n\n- tools/tradefederation/core/res/config\n- tools/tradefederation/core/tests/res/config\n- tools/tradedeferation/contrib/res/config\n\nExample definition of includes \n\n \u003cconfiguration description=\"Common base configuration for local runs with minimum over\u003ehead&\u003cquot;\n build_provider class=\"com.android.tradefed.build.BootstrapB\u003euildPr\u003covider\" /\n\n i\u003en\u003cclude name=&qu\u003eot;empty\"/\n /configuration\n\nIncludes are simpler than Templates as they require no command line arguments;\nthey directly expand the referenced XML in the `name` tag. Similar to templates,\nthe path to the config can be absolute or relative. Still, for `includes` we\nrecommend using only relative paths as they are more portable in Tradefed.\nAbsolute paths would not be valid if Tradefed is moved to another machine.\n\nMisconfiguration\n\nIn case of misconfiguration, such as when the replacement XML cannot be found,\nTradefed will throw a `ConfigurationException` with description of what seems to\nbe missing or misconfigured."]]