اعتبارًا من 27 آذار (مارس) 2025، ننصحك باستخدام android-latest-release
بدلاً من aosp-main
لإنشاء AOSP والمساهمة فيه. لمزيد من المعلومات، يُرجى الاطّلاع على التغييرات في AOSP.
النماذج والعناصر المضمّنة في إعداد ملف XML في Tradefed
تنظيم صفحاتك في مجموعات
يمكنك حفظ المحتوى وتصنيفه حسب إعداداتك المفضّلة.
إنّ إنشاء ملف إعداد XML واحد شامل لتحديد اختبار قد لا يكون دائمًا
عمليًا. إذا أردت إعادة استخدام جزء من الإعداد لإجراء اختبارات مشابهة،
ستضطر إلى نسخ ملفَّي XML كبيرَين والاحتفاظ بهما.
هذا هو المكان الذي تصبح فيه علامتا template
وinclude
في ملف إعداد XML في Tradefed مفيدة. تتيح لك هذه العناصر ضبط عناصر نائبة في بعض إعدادات XML
لإضافة جزء من إعدادات XML أخرى.
مثال على تعريف النماذج
<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>
النماذج هي عناصر نائبة تحتوي على name
للإشارة إليها، وحقل default
اختياري. يحدِّد الحقل التلقائي ملف XML البديل التلقائي الذي ينبغي استخدامه.
لاستبدال نموذج بإعدادات معيّنة، يجب إضافة المَعلمة التالية
إلى سطر الأوامر:
--template:map <name of template>=<replacement XML config path>
--template:map preparers=empty
مثلاً:
<template-include name="preparers" default="empty" />
يشير مرجع empty
في هذه الحالة إلى إعداد empty.xml
الذي
لا يحتوي على أيّ شيء، ونحن نستخدمه كمرجع للاستبدال بقيمة فارغة.
يمكن أن يكون مسار ملفات الإعدادات بتنسيق XML مطلقًا أو نسبيًا لملف res/config
داخل موارد JAR في Tradefed. في ما يلي بعض المواقع الجغرافية التي تتوفّر فيها هذه الخدمة:
- tools/tradefederation/core/res/config
- tools/tradefederation/core/tests/res/config
- tools/tradedeferation/contrib/res/config
مثال على تعريف العناصر المضمّنة
<configuration description="Common base configuration for local runs with minimum overhead">
<build_provider class="com.android.tradefed.build.BootstrapBuildProvider" />
<include name="empty"/>
</configuration>
إنّ العناصر المضمّنة أبسط من النماذج لأنّها لا تتطلّب وسيطات سطر الأوامر،
بل يتم توسيعها مباشرةً إلى ملف XML المُشار إليه في علامة name
. على غرار النماذج،
يمكن أن يكون مسار الإعداد مطلقًا أو نسبيًا. ومع ذلك، بالنسبة إلى includes
،
ننصح باستخدام المسارات النسبية فقط لأنّها أكثر سهولة في النقل في Tradefed.
لن تكون المسارات المطلقة صالحة إذا تم نقل Tradefed إلى جهاز آخر.
الضبط الخاطئ
في حال عدم ضبط الإعدادات بشكل صحيح، مثلاً عندما يتعذّر العثور على ملف XML البديل، ConfigurationException
يخضع كل من المحتوى وعيّنات التعليمات البرمجية في هذه الصفحة للتراخيص الموضحّة في ترخيص استخدام المحتوى. إنّ Java وOpenJDK هما علامتان تجاريتان مسجَّلتان لشركة Oracle و/أو الشركات التابعة لها.
تاريخ التعديل الأخير: 2025-07-27 (حسب التوقيت العالمي المتفَّق عليه)
[[["يسهُل فهم المحتوى.","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-07-27 (حسب التوقيت العالمي المتفَّق عليه)"],[],[],null,["# Templates and includes in Tradefed XML configuration\n\nCreating 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\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=\"empty\" /\u003e\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\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 \u003cinclude name=\"empty\"/\u003e\n \u003c/configuration\u003e\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----------------\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."]]