اعتبارًا من 27 آذار (مارس) 2025، ننصحك باستخدام android-latest-release
بدلاً من aosp-main
لإنشاء AOSP والمساهمة فيه. لمزيد من المعلومات، يُرجى الاطّلاع على التغييرات في AOSP.
اختبار نظام Android الأساسي
تنظيم صفحاتك في مجموعات
يمكنك حفظ المحتوى وتصنيفه حسب إعداداتك المفضّلة.
يوفّر "المشروع المفتوح المصدر لنظام Android" (AOSP) العديد من الأدوات ومجموعات الاختبار
لاختبار أجزاء مختلفة من عملية التنفيذ. قبل استخدام الصفحات في
هذا القسم، يجب أن تكون على دراية بالمصطلحات التالية:
- جهاز متوافق مع Android
- جهاز يمكنه تشغيل أي تطبيق تابع لجهة خارجية كتبه مطوّرون تابعون لجهات خارجية
باستخدام حِزم تطوير البرامج (SDK) وNDK لنظام التشغيل Android يجب أن تلتزم الأجهزة المتوافقة مع Android ب requirements of the
مستند تعريف التوافق (CDD) وأن تجتاز اختبارات
مجموعة اختبار التوافق (CTS). إنّ الأجهزة المتوافقة مع Android
مؤهَّلة للمشاركة في منظومة Android المتكاملة، والتي تشمل
ترخيصًا محتملًا لخدمة Google Play وترخيصًا محتملًا لسلسلة Google Mobile Services (GMS) من
التطبيقات وواجهات برمجة التطبيقات واستخدام علامة Android التجارية. يمكن لأي مستخدم استخدام رمز المصدر لنظام التشغيل Android، ولكن لكي يُعدّ الجهاز جزءًا من منظومة Android المتكاملة، يجب أن يكون متوافقًا مع Android.
- العنصر
- سجلّ مرتبط بالإصدار يتيح تحديد المشاكل وحلّها على الجهاز
- مستند تعريف التوافق (CDD)
- مستند يسرد متطلبات البرامج والأجهزة لجهاز
متوافق مع Android
- مجموعة أدوات اختبار التوافق (CTS)
مجموعة اختبارات مجانية من المستوى التجاري، متاحة للتنزيل كملف ثنائي أو كملف مصدر في AOSP اختبارات CTS هي مجموعة من اختبارات الوحدة المصمّمة للدمج في
سير عملك اليومي. يهدف إطار عمل CTS إلى الكشف عن حالات عدم التوافق، و
ضمان بقاء البرنامج متوافقًا طوال عملية التطوير.
لا يتعارض اختبار CTS مع اختبارات النظام الأساسي. في ما يلي بعض الإرشادات العامة:
- إذا كان الاختبار يؤكّد صحة وظائف واجهة برمجة التطبيقات أو سلوكيات إطار العمل،
ويجب فرض الاختبار على جميع شركاء المصنّعين الأصليّين للأجهزة، يجب أن يكون الاختبار مُدرَجًا في CTS.
- إذا كان الغرض من الاختبار هو رصد حالات التراجع أثناء تطوير المنصة،
وقد يتطلّب إذنًا متميزًا لتنفيذه، وقد يعتمد
على تفاصيل التنفيذ (على النحو الذي تم إصداره في AOSP)، يجب أن يكون اختبارًا
للمنصّة.
- خدمات Google للأجهزة الجوّالة (GMS)
مجموعة من تطبيقات Google وواجهات برمجة التطبيقات التي يمكن تثبيتها مسبقًا على الأجهزة
- GoogleTest (GTest)
إطار عمل لاختبار وتقليد C++ وعادةً ما تَستخدم الوحدات الثنائية لـ GTest
طبقات التجريد من المستوى الأدنى أو تُجري وظائف معالجة المعلومات بين العمليات (IPC) الأوّلية مع خدمات النظام المختلفة. عادةً ما يكون نهج الاختبار في GTest مرتبطًا بشكل وثيق بال
الخدمة التي يتم اختبارها. يحتوي CTS على إطار عمل GTest.
- اختبار لقياس حالة التطبيق
بيئة تنفيذ اختبار خاصة
يتم تشغيلها من خلال الأمر am instrument
، حيث تتم إعادة تشغيل عملية التطبيق المستهدفة
وإعدادها باستخدام سياق التطبيق الأساسي، ويتم بدء سلسلت رسائل برمجية
للعملية الفحص داخل المعالج الافتراضية
لعملية التطبيق. تحتوي مجموعة اختبار التوافق (CTS) على اختبارات الأدوات.
- Logcat
أداة سطر أوامر تنشئ سجلاً لرسائل النظام، بما في ذلك
تتبُّع تسلسل استدعاء الدوال البرمجية عند ظهور خطأ على الجهاز والرسائل التي
كتبتها من تطبيقك باستخدام فئة Log
.
- التسجّل
استخدام سجلّ لتتبُّع أحداث نظام الكمبيوتر، مثل
الأخطاء إنّ تسجيل البيانات في Android معقّد بسبب مزيج المعايير المستخدَمة التي يتم دمجها في أداة Logcat.
- postsubmit test
اختبار Android الذي يتم إجراؤه عند تأكيد تصحيح جديد في مسار kernel (النواة)
المشترَك من خلال إدخال aosp_kernel
كاسم فرع جزئي،
يمكنك الاطّلاع على قائمة بفروع النواة التي تتوفّر فيها نتائج. على سبيل المثال، يمكن العثور على نتائج
android-mainline
على الرابط
https://ci.android.com/builds/branches/aosp_kernel-common-android-mainline/grid.
- اختبار التقديم المُسبَق
اختبار يُستخدَم لمنع حدوث أعطال في ملفّات kernel
المشترَكة
- اتحاد التجارة
يُعرف هذا الإطار أيضًا باسم Tradefed، وهو إطار عمل اختبار متواصل مُصمّم لإجراء الاختبارات على أجهزة Android. على سبيل المثال،
يُستخدَم Tradefed لإجراء اختبارات مجموعة أدوات اختبار التوافق ومجموعة أدوات اختبار المورّدين.
- مجموعة اختبار المورّد (VTS)
مجموعة من الإمكانات الواسعة النطاق لاختبار Android، وتعزيز عملية التطوير المستنِد إلى الاختبار، وبرمجة اختبارات ملف HAL واختبار نواة نظام التشغيل
أنواع اختبارات النظام الأساسي
يتفاعل اختبار النظام الأساسي عادةً مع خدمة واحدة أو أكثر من خدمات نظام Android
أو طبقات HAL، وينفِّذ وظائف
الموضوع الذي يتم اختباره، ويؤكّد صحة نتيجة
الاختبار. يمكن أن يؤدي اختبار النظام الأساسي إلى:
- (النوع 1) اختبار واجهات برمجة تطبيقات إطار العمل باستخدام إطار عمل Android يمكن أن تشمل واجهات برمجة التطبيقات المحدّدة التي يتم استخدامها ما يلي:
- واجهات برمجة التطبيقات المتاحة للجميع والمخصّصة للتطبيقات التابعة لجهات خارجية
- واجهات برمجة التطبيقات المخفية المخصّصة للتطبيقات المميّزة، مثل واجهات برمجة تطبيقات النظام أو
واجهات برمجة التطبيقات الخاصة (
@hide
أو protected
أو package private
)
- (النوع 2) استدعاء خدمات نظام Android باستخدام رابط رابط خام أو وسطاء IPC
مباشرةً
- (النوع 3) التفاعل مباشرةً مع HAL باستخدام واجهات برمجة تطبيقات أو واجهات IPC منخفضة المستوى
عادةً ما تكون اختبارات النوعَين 1 و2 هي اختبارات الأدوات، في حين تكون اختبارات النوع 3 عادةً هي اختبارات GTests.
ما هي الخطوات التالية؟
في ما يلي قائمة بالمستندات التي يمكنك قراءتها للحصول على معلومات أكثر تفصيلاً:
يخضع كل من المحتوى وعيّنات التعليمات البرمجية في هذه الصفحة للتراخيص الموضحّة في ترخيص استخدام المحتوى. إنّ 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,["# Android platform testing\n\nAndroid Open Source Project (AOSP) provides several tools and test suites\nfor testing various parts of your implementation. Before using the pages in this\nsection, you should be familiar with the following terms:\n\n*Android-compatible device*\n: A device that can run any third-party app written by third-party developers\n using the Android SDK and NDK. Android-compatible devices must adhere to the\n requirements of the\n [Compatibility Definition Document (CDD)](#CDD) and pass the\n [Compatibility Test Suite (CTS)](#cts). Android-compatible\n devices are eligible to participate in the Android ecosystem, which includes\n potential licensure of Google Play, potential licensure of the\n [Google Mobile Services (GMS)](#gms) suite of\n app and APIs, and use of the Android trademark. Anyone is welcome to\n use the Android source code, but to be considered part of the Android ecosystem,\n a device must be Android compatible.\n\n*artifact*\n: A build-related log that enables local troubleshooting.\n\n*Compatibility Definition Document (CDD)*\n: A document that enumerates the software and hardware requirements for an\n Android-compatible device.\n\n*Compatibility Test Suite (CTS)*\n\n: A free, commercial-grade test suite, available for download as a binary or as\n source in AOSP. The CTS is a set of unit tests designed to be integrated into\n your daily workflow. The intent of CTS is to reveal incompatibilities, and\n ensure that the software remains compatible throughout the development process.\n\n CTS and platform tests aren't mutually exclusive. Here are some general\n guidelines:\n\n - If a test is asserting correctness of framework API functions or behaviors, and the test should be enforced across OEM partners, it should be in CTS.\n - If a test is intended to catch regressions during platform development, and might require privileged permission to carry out, and might be dependent on implementation details (as released in AOSP), it should be a platform test.\n\n*Google Mobile Services (GMS)*\n\n: A collection of Google apps and APIs that can be preinstalled on devices.\n\n*GoogleTest (GTest)*\n\n: A C++ testing and mocking framework. GTest binaries typically\n access lower-level abstraction layers or perform raw IPC against various system\n services. The testing approach for GTest is usually tightly coupled with the\n service being tested. CTS contains the GTest framework.\n\n*instrumentation test*\n\n: A special test execution environment\n launched by the `am instrument` command, where the targeted app process\n is restarted and initialized with basic app context, and an\n instrumentation thread is started inside the app process virtual\n machine. CTS contains instrumentation tests.\n\n*Logcat*\n\n: A command-line tool that creates a log of system messages, including\n stack traces of when the device throws an error and messages that you have\n written from your app with the `Log` class.\n\n*logging*\n\n: Using a log to keep track of computer system events, such\n as errors. Logging in Android is complex due to the mix of standards used that\n are combined in the Logcat tool.\n\n*postsubmit test*\n\n: An Android test that is performed when a new patch is committed to a\n common kernel branch. By entering `aosp_kernel` as a partial branch name, you\n can see a list of kernel branches with results available. For example, results\n for `android-mainline` can be found at\n \u003chttps://ci.android.com/builds/branches/aosp_kernel-common-android-mainline/grid\u003e.\n\n*presubmit test*\n\n: A test used to prevent failures from being introduced into the\n common kernels.\n\n*Trade Federation*\n\n: Also called Tradefed, a continuous test\n framework designed for running tests on Android devices. For example,\n Tradefed is used to run Compatibility Test Suite and Vendor Test Suite tests.\n\n*Vendor Test Suite (VTS)*\n\n: A set of extensive capabilities for\n Android testing, promoting a test-driven development process, and automating\n hardware abstraction layer (HAL) and OS kernel testing.\n\nPlatform test types\n-------------------\n\nA platform test typically interacts with one or more of the Android system\nservices or HAL layers, exercises the\nfunctionalities of the subject under test, and asserts correctness of the\ntesting outcome. A platform test might:\n\n- (Type 1) Exercise framework APIs using Android framework. Specific APIs being exercised can include:\n - Public APIs intended for third-party apps\n - Hidden APIs intended for privileged apps, namely system APIs or private APIs (`@hide`, or `protected`, `package private`)\n- (Type 2) Invoke Android system services using raw binder or IPC proxies directly.\n- (Type 3) Interact directly with HALs using low-level APIs or IPC interfaces.\n\nType 1 and 2 tests are typically instrumentation tests, while type 3 tests are\nusually GTests.\n\nWhat's next?\n------------\n\nHere is a list of documents that you can read for more detailed information:\n\n- If you haven't studied Android architecture, see\n [Architecture overview](/docs/core/architecture).\n\n- If you're creating an Android-compatible device, see\n the [Android compatibility program overview](/docs/compatibility/overview).\n\n- To integrate instrumentation, functional, metric, and JAR host tests\n into a platform continuous testing service, see\n [Test development workflow](/docs/core/tests/development).\n\n- To detect and harden your devices against vulnerabilities,\n see [Security testing](/docs/security/test/fuzz-sanitize).\n\n- To learn about testing your HAL and kernel implementations, see\n [Vendor Test Suite (VTS) and infrastructure](/docs/core/tests/vts).\n\n- For app testing, read\n [Fundamentals of testing Android\n apps](https://developer.android.com/training/testing/fundamentals)\n and conduct the [Advanced Android in Kotlin 05.1:Testing\n Basics](https://codelabs.developers.google.com/codelabs/advanced-android-kotlin-training-testing-basics/index.html)\n using the\n [samples](https://github.com/android/testing-samples) provided.\n\n- Learn about the basic presubmit testing available to you through repo hooks.\n These hooks can be used to run linters, check formatting, and trigger unit\n tests before proceeding, such as uploading a commit. These hooks are disabled\n by default. For further information, see [AOSP Preupload\n Hooks](https://android.googlesource.com/platform/tools/repohooks/+/refs/heads/android16-release/README.md).\n\n- To read more about logging, see [Understand logging](/docs/core/tests/debug/understanding-logging).\n\n- To understand how to debug Android code, see\n [Debug native Android platform code](/docs/core/tests/debug)."]]