[OE-core] [PATCH V2 1/1] linux-yocto: add ptest support
lei yang
lei.yang at windriver.com
Thu Jun 21 07:03:45 UTC 2018
On 2018年06月14日 10:49, Dengke Du wrote:
> Signed-off-by: Dengke Du <dengke.du at windriver.com>
> ---
> meta/recipes-kernel/linux/linux-yocto/run-ptest | 138 ++++++++++++++++++++++++
> meta/recipes-kernel/linux/linux-yocto_4.14.bb | 9 ++
> 2 files changed, 147 insertions(+)
> create mode 100644 meta/recipes-kernel/linux/linux-yocto/run-ptest
>
> diff --git a/meta/recipes-kernel/linux/linux-yocto/run-ptest b/meta/recipes-kernel/linux/linux-yocto/run-ptest
> new file mode 100644
> index 0000000..6db4d93
> --- /dev/null
> +++ b/meta/recipes-kernel/linux/linux-yocto/run-ptest
> @@ -0,0 +1,138 @@
> +#!/bin/bash
> +depmod
> +touch kernel.log
> +
> +#dma-example bytestream-example inttype-example record-example
> +list1=("dma-example" "bytestream-example" "inttype-example" "record-example")
> +for i in "${list1[@]}"
> +do
> + dmesg -c
> + modprobe "$i"
> + result=""
> + IFS="-" read -ra array <<< "$i"
> + len=${#array[@]}
> + if [ $len -eq 2 ];then
> + result="${array[0]}_${array[1]}"
> + elif [ $len -eq 3 ];then
> + result="${array[0]}_${array[1]}_${array[2]}"
> + fi
if you want to substitute "-" to "_" here, using bash pattern
substitution will be much easier
# i="xx-yy-zz-ff"
# echo ${i//-/_}
xx_yy_zz_ff
> + lsmod | grep -q "$result"
> + if [ $? -eq 0 ];then
> + dmesg | grep "test passed"
> + if [ $? -eq 0 ];then
> + echo "$i: PASS" >> kernel.log
> + fi
> + else
> + echo "$i: FAILED" >> kernel.log
> + fi
most ptest (but not all) result format are following the same rule
"[PASS|SKIP|FAIL]" : testname
look at here
https://www.yoctoproject.org/docs/2.5/dev-manual/dev-manual.html#testing-packages-with-ptest
PS: unified test output matters for LAVA testparse patten.
> + rmmod "$i"
> +done
> +
> +#kobject-example kset-example
> +list2=("kobject-example" "kset-example")
> +for i in "${list2[@]}"
> +do
> + dmesg -c
> + modprobe "$i"
> + result=""
> + IFS="-" read -ra array <<< "$i"
> + len=${#array[@]}
> + if [ $len -eq 2 ];then
> + result="${array[0]}_${array[1]}"
> + elif [ $len -eq 3 ];then
> + result="${array[0]}_${array[1]}_${array[2]}"
> + fi
> + basedir="/sys/kernel/${result}"
> + echo "$basedir"
> + if [ -e ${basedir}/bar -a -e ${basedir}/baz -a -e ${basedir}/foo ];then
> + echo "$i: PASS" >> kernel.log
> + else
> + echo "$i: FAILED" >> kernel.log
> + fi
> + rmmod "$i"
> +done
> +
> +#trace-events-sample
> +list3="trace-events-sample"
> +result=""
> +IFS="-" read -ra array <<< "$list3"
> +len=${#array[@]}
> +if [ $len -eq 2 ];then
> + result="${array[0]}_${array[1]}"
> +elif [ $len -eq 3 ];then
> + result="${array[0]}_${array[1]}_${array[2]}"
> +fi
> +modprobe "$list3"
> +lsmod | grep "$result"
> +if [ $? -eq 0 ];then
> + if [ -e "/sys/kernel/debug/tracing/events/sample-trace" ];then
> + echo 1 > /sys/kernel/debug/tracing/events/sample-trace/enable
> + sleep 5
> + ret=`cat /sys/kernel/debug/tracing/trace | grep hello | head -n1 | cut -d':' -f2`
> + if [ "$ret" = " foo_bar" ];then
> + echo "$list3: PASS" >> kernel.log
> + else
> + echo "$list3: FAILED-" >> kernel.log
> + fi
> + else
> + echo "$list3: FAILED--" >> kernel.log
> + fi
> +else
> + echo "$list3: FAILED---" >> kernel.log
> +fi
> +rmmod "$list3"
> +
> +#trace-printk
> +list4="trace-printk"
> +modprobe "$list4"
> +lsmod | grep "trace_printk"
> +if [ $? -eq 0 ];then
> + ret=`cat /sys/kernel/debug/tracing/trace | grep trace_printk | head -n1 | cut -d':' -f2`
> + if [ "$ret" = " trace_printk_irq_work" ];then
> + echo "$list4: PASS" >> kernel.log
> + rmmod "$list4"
> + else
> + echo "$list4: FAILED" >> kernel.log
> + fi
> +else
> + echo "$list4: FAILED" >> kernel.log
> +fi
> +rmmod "$list4"
> +
> +#kprobe_example
> +list5="kprobe_example"
> +dmesg -c
> +modprobe "$list5"
> +lsmod | grep "$list5"
> +if [ $? -eq 0 ];then
> + dmesg | grep "_do_fork"
> + if [ $? -eq 0 ];then
> + echo "$list5: PASS" >> kernel.log
> + else
> + echo "$list5: FAILED" >> kernel.log
> + fi
> +else
> + echo "$list5: FAILED" >> kernel.log
> +fi
> +rmmod "$list5"
> +
> +#kretprobe_example
> +list6="kretprobe_example"
> +dmesg -c
> +modprobe "$list6"
> +lsmod | grep "$list6"
> +if [ $? -eq 0 ];then
> + dmesg | grep "_do_fork returned"
> + if [ $? -eq 0 ];then
> + echo "$list6: PASS" >> kernel.log
> + else
> + echo "$list6: FAILED" >> kernel.log
> + fi
> +else
> + echo "$list6: FAILED" >> kernel.log
> +fi
> +rmmod "$list6"
> +
> +echo "#####result#####"
> +cat kernel.log
> +rm kernel.log
> diff --git a/meta/recipes-kernel/linux/linux-yocto_4.14.bb b/meta/recipes-kernel/linux/linux-yocto_4.14.bb
> index 0449213..9650ee2 100644
> --- a/meta/recipes-kernel/linux/linux-yocto_4.14.bb
> +++ b/meta/recipes-kernel/linux/linux-yocto_4.14.bb
only enable ptest for linux-yocto_4.14 is not good.
we can still have one copy of run-ptest for different kernel version,
but we need to make it works for different kernel.
To be clear, for example, linux-yocto-4.14, you might have 10 test
cases, while in linux-yocto-4.15, you might have 12 test cases
so run-ptest might be like
a) run whatever test case we have, and the first thing is the check
whether the test case exists, for example, if directory
"samples/trace_printk" exists, run it, if not , do nothing or SKIP.
or
b) maintain a test list in different kernel recipes, run-pest would run
the test in the given list from the kernel recipe.
Lei
> @@ -45,3 +45,12 @@ KERNEL_FEATURES_append_qemuall=" cfg/virtio.scc"
> KERNEL_FEATURES_append_qemux86=" cfg/sound.scc cfg/paravirt_kvm.scc"
> KERNEL_FEATURES_append_qemux86-64=" cfg/sound.scc cfg/paravirt_kvm.scc"
> KERNEL_FEATURES_append = " ${@bb.utils.contains("TUNE_FEATURES", "mx32", " cfg/x32.scc", "" ,d)}"
> +
> +FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
> +inherit ptest
> +SRC_URI_append = " file://run-ptest \
> +"
> +do_install_ptest_append() {
> + install -D ${WORKDIR}/run-ptest ${D}${PTEST_PATH}/run-ptest
> +}
> +KERNEL_FEATURES_append = " ${@bb.utils.contains("DISTRO_FEATURES", "ptest", "features/kernel-sample/kernel-sample.scc", "", d)}"
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openembedded.org/pipermail/openembedded-core/attachments/20180621/9c5893e3/attachment-0002.html>
More information about the Openembedded-core
mailing list