Eclipse Yocto Test Cases
Setuo Development Environment
- 1. Setup Docker, Crops/Poky and Crops/Toolchain image
- a) follow the setup instruction here :
- b) run below command to download Crops/Toolchain Images
docker pull chinhuatang/toolchain
:: <pre>docker pull crops/poky :[[File:Screen_Shot_2018-10-30_at_2.07.31_PM.png]] : : 2. Setup build tree ( if you familiar with bitbake tools you can build any target machine image at your preferences) ::a) clone poky and checkout to working branch >git clone git://git.yoctoproject.org/poky >git checkout tags/yocto-2.5 -b my-yocto-2.5 b) run crops/poky and initiate build environment >docker run -it --rm -v </path/to/poky>:/workdir crops/poky --worldir=/workdir >source oe-init-build-env c) open another window/terminal to edit poky local.conf file. add below line to poky/build/conf/local.conf >EXTRA_IMAGE_FEATURES += "eclipse-debug" >EXTRA_IMAGE_FEATURES += "tools-sdk" >EXTRA_IMAGE_FEATURES += "ssh-server-openssh" d) back to terminal in use in step 3.b, run below command. >bitbake core-image-sato >bitbake meta-ide-support >bitbake meta-toolchain 3. Setup YP SDK toolchain a) Look for SDK toolchain script created in steps 2 in path poky/build/tmp/deploy/sdk/ >E.g: /poky/build/tmp/deploy/sdk/poky-glibc-x86_64-meta-toolchain-core2-64-toolchain-2.5+snapshot.sh b) execute the script in terminal c) (optional) enter your preferred path to setup SDK d) press "Enter" -> press "y" -> press "Enter" 4. Setup Eclipse to run Docker a) In Eclipse workbench window, go to "Run" menu -> "Run configurations..." b) In "Configurations" window, go to "Run" menu -> right click "Run Docker Image" -> new configuration c) In "Configurations" window, select the new created configuration -> select "crops/poky:latest" for Image -> check "Keep STDIN open to console even if not attached (-i)" d) In "Configurations" window, select "Volumes" tab, -> "Add..." e) In "Data Volume" window, check "mount a host directory or host file" -> click "Directory" -> look for build tree path (path setup on step 2) -> copy build tree path and paste to Container path -> click "OK " f) In "Configurations" window, click "Run" expected result: docker running in eclipse console and path mount correctly. [[File:example.jpg|frameless|caption]] ===Common Prerequisites=== : 1. Have a clone of poky: :: <pre>$ git clone git://git.yoctoproject.org/poky
- 2. Check out the required commit using git:
$ git checkout [COMMIT_HASH]
- 3. Source the build environment to create the configuration files:
$ cd [POKY_PATH]
$ . oe-init-build-env
- 4. Open the conf/local.conf file:
$ vi conf/local.conf
- Establish the machine to qemux86-64 by setting the line:
MACHINE = "qemux86-64"
- 5. Compile a minimal image:
$ bitbake core-image-minimal
- 6. Get and take note of the linux-yocto kernel version (only the first two numbers, for example: 4.10):
$ bitbake virtual/kernel -e | grep LINUX_VERSION
- 7. Create a layer to store kernel test metadata. For this task, you could use the bitbake-layers and its default recipe values:
$ cd [POKY_PATH]
$ bitbake-layers create-layer [LAYER-NAME]
- Note: In the rest of this document "meta-kerneltest" is used as the [LAYER-NAME].
- 8. Create the recipe directory structure inside the created layer:
$ mkdir -p meta-kerneltest/recipes-kernel/linux/
- 9. Create a recipe append file inside the directory:
$ touch meta-kerneltest/recipes-kernel/linux/linux-yocto_4%.bbappend
- 10. Copy the recipe file corresponding to the linux-yocto version inside the directory:
$ cp meta/recipes-kernel/linux/linux-yocto_[VERSION].bb meta-kerneltest/recipes-kernel/linux/linux-yocto-custom_[VERSION].bb
- 11. Edit the linux-yocto-custom recipe:
$ vi meta-kerneltest/recipes-kernel/linux/linux-yocto-custom_[VERSION].bb
- Set the PV variable with the LINUX_VERSION variable value:
PV = "${LINUX_VERSION}"
- 12. Create directory "linux-yocto":
$ mkdir meta-kerneltest/recipes-kernel/linux/linux-yocto/
- 13. Create directory "linux-yocto-custom":
$ mkdir meta-kerneltest/recipes-kernel/linux/linux-yocto-custom/
- 14. Add the created layer to bblayers.conf. For this task, you could use the bitbake-layers script from inside the build directory:
$ cd build
$ bitbake-layers add-layer ../meta-kerneltest
General Remarks
- 1. As a suggestion, open another terminal in order to perform git commands.
- 2. Remember to source the environment and ensure your current work directory is [POKY_PATH]/build before using bitbake scripts and tools.
- 3. You can edit any required file with vim, emacs, or your preferred text editor.
- 4. If there is not a proper response after building an image, be sure to clean the shared state, and try again. To clean it, you can use:
$ bitbake virtual/kernel -c cleansstate
- 5. Be careful with the information added to recipe and recipe append files, using the same values -- including spaces-- to set a recipe variable value.
- 6. To ensure all the sources are correctly downloaded and the required taks are executed, ensure no shared states proxies are set on conf/local.conf.
- 7. Make sure to point to the correct linux-yocto version.
TC_KD_01 – Applying Patches
Use Case
As a developer, I want to be able to apply a single patch to the Linux kernel source.
Prerequisites
- 1. Generate the patch:
- 1.1. Go to kernel source directory:
$ cd [POKY_PATH]/build/tmp/work-shared/qemux86-64/kernel-source
- 1.2. Add some information at the end of the README file:
$ echo This is a test to apply a patch to the kernel. >> README
- 1.3. Add the modified file to the patch:
$ git add README
- 1.4. Commit the change:
$ git commit -s -m "KERNEL DEV TEST CASE"
- 1.5. Format the patch:
$ git format-patch -1
- 1.1. Go to kernel source directory:
Steps
- 1. Move the generated patch to the "linux-yocto" directory :
$ mv 0001-KERNEL-DEV-TEST-CASE.patch [POKY_PATH]/meta-kerneltest/recipes-kernel/linux/linux-yocto/
- 2. Add the SRC_URI var with the patch to the linux-yocto_4%.bbappend file:
$ cd [POKY_PATH]
$ vi meta-kerneltest/recipes-kernel/linux/linux-yocto_4%.bbappend
- Add the following lines and save and close the file:
SRC_URI += "file://0001-KERNEL-DEV-TEST-CASE.patch"
FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
- 3. Delete the README file:
$ rm build/tmp/work-shared/qemux86-64/kernel-source/README
- 4. Clean the shared state:
$ cd build
$ bitbake virtual/kernel -c cleansstate
- 5. Build the patch:
$ bitbake virtual/kernel -c patch
- 6. Verify the patch is applied properly:
$ tail tmp/work-shared/qemux86-64/kernel-source/README
Expected Results
- 1. Bitbake should complete the build without errors.
- 2. The README file should exist.
- 3. The patch changes should be displayed at the end of the file.
TC_KD_02 – linux-yocto Local Source
Use Case
As a developer, I want to to be able to work with my own Linux kernel sources.
Prerequisites
- 1. Have a recipe append file for linux-yocto (created previously).
- 2. Clone in a specific directory (different of poky):
$ cd [KERNEL_REPOS_PATH]
$ git clone git://git.yoctoproject.org/yocto-kernel-cache
$ git clone git://git.yoctoproject.org/linux-yocto-[VERSION]
$ For Linux version 4.14 and onwards, use following command
$ git clone git://git.yoctoproject.org/linux-yocto
- 3. Go to the cloned yocto-kernel-cache directory:
$ cd [KERNEL_REPOS_PATH]/yocto-kernel-cache
- Checkout the required yocto-version branch:
$ git checkout yocto-[VERSION] # For example: $ git checkout yocto-4.8
- 4. Go to the linux-yocto-[VERSION] directory:
$ cd [KERNEL_REPOS_PATH]/linux-yocto-[VERSION]
- Checkout the standard/base branch:
$ git checkout standard/base
$ For Linux version 4.14 and onwards, use following command
$ git checkout v[VERSION]/standard/base
- 5. Edit the conf/local.conf file in the repository where you are working for execution:
$ cd [POKY_PATH]
$ vi build/conf/local.conf
- Set the following line:
PREFERRED_VERSION_linux-yocto_qemux86-64="[VERSION]%"
Steps
- 1. Edit the linux-yocto recipe append file previously created at your "meta-kerneltest" directory:
$ vi meta-kerneltest/recipes-kernel/linux/linux-yocto_4%.bbappend
- Set the SRC_URI variable with the following information:
SRC_URI = "git://[KERNEL_REPOS_PATH]/linux-yocto-[VERSION];protocol=file;name=machine;branch=${KBRANCH}; \
git://[KERNEL_REPOS_PATH]/yocto-kernel-cache;protocol=file;type=kmeta;name=meta;branch=yocto-[VERSION];destsuffix=${KMETA}"
- 2. Clean the shared state:
$ cd build
$ bitbake virtual/kernel -c cleansstate
- 3. Build the kernel:
$ bitbake virtual/kernel
- 4. Verify the changes by executing:
$ bitbake virtual/kernel -e | grep "name=machine;branch"
Expected Results
- 1. The changes should be performed successfully.
- 2. The build should be completed successfully.
- 3. The bitbake variables output should display that the SRC_URI variable is now:
SRC_URI = "git://[KERNEL_REPOS_PATH]/linux-yocto-[VERSION];protocol=file;name=machine;branch=${KBRANCH}; \
git://[KERNEL_REPOS_PATH]/yocto-kernel-cache;protocol=file;type=kmeta;name=meta;branch=yocto-[VERSION];destsuffix=${KMETA}"
TC_KD_03 – linux-yocto Custom Local Source
Use Case
As a developer, I want to be able to work with my own local sources for a customized linux-yocto kernel.
Prerequisites
- 1. Make sure you have the custom recipe file corresponding to the latest linux-yocto version:
[POKY_PATH]/meta-kerneltest/recipes-kernel/linux/linux-yocto-custom_[VERSION].bb
- This file should originate from [POKY_PATH]/meta/recipes-kernel/linux/linux-yocto_[VERSION].bb
- 2. Edit the linux-yocto-custom recipe file:
$ cd [POKY_PATH]
$ vi meta-kerneltest/recipes-kernel/linux/linux-yocto-custom_[VERSION].bb
- Set the SRC_URI variable with the following information:
SRC_URI = "git://[KERNEL_REPOS_PATH]/linux-yocto-[VERSION];protocol=file;name=machine;branch=${KBRANCH}; \
git://[KERNEL_REPOS_PATH]/yocto-kernel-cache;protocol=file;type=kmeta;name=meta;branch=yocto-[VERSION];destsuffix=${KMETA}"
Steps
- 1. Go to the poky build directory:
$ cd [POKY_PATH]/build
- 2. At conf/local.conf add the following variable:
PREFERRED_PROVIDER_virtual/kernel = "linux-yocto-custom"
- 3. Clean the shared state:
$ bitbake virtual/kernel -c cleansstate
- 4. Compile the kernel:
$ bitbake virtual/kernel
- 5. Verify the changes by executing:
$ bitbake virtual/kernel -e | grep -E "PREFERRED_PROVIDER_virtual/kernel|SRC_URI"