Re: [OE-core] [PATCH V2 1/1] linux-yocto: add ptest support
On 2018年06月21日 20:57, Bruce Ashfield wrote: My general comment still stands from v1, That I don't see a lot of value in creating a whole set of custom tests and wrappers just for ptest use. i.e. ltp already has a lot of these covered. kprobes, as do the built-in self tests. The ltp doesn't contain kernel selftests, the kprobes in kernel samples directory just contain some easy test for kprobes. I want to be sure that we aren't creating custom wrappers that will need to be maintained for a long time. The maintaining work very little, because the kernel samples and kernel selftest's change were not constantly changing very much. Comments/documentation in the script don't exist, so it is difficult to look at this and understand what it is actually trying to test. A header block and comments before each test are required. Ok, I have complete it and will send V3. On Wed, Jun 13, 2018 at 10:49 PM, Dengke Du wrote: Signed-off-by: Dengke Du --- 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 000..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" All of the modprobes really should be checking for failure, I realize you are doing some lsmod calls and checking those, but that isn't always the case in this script. Cheers, Bruce + 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 + 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 + 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
Re: [OE-core] [PATCH V2 1/1] linux-yocto: add ptest support
My general comment still stands from v1, That I don't see a lot of value in creating a whole set of custom tests and wrappers just for ptest use. i.e. ltp already has a lot of these covered. kprobes, as do the built-in self tests. I want to be sure that we aren't creating custom wrappers that will need to be maintained for a long time. Comments/documentation in the script don't exist, so it is difficult to look at this and understand what it is actually trying to test. A header block and comments before each test are required. On Wed, Jun 13, 2018 at 10:49 PM, Dengke Du wrote: > > Signed-off-by: Dengke Du > --- > 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 000..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" All of the modprobes really should be checking for failure, I realize you are doing some lsmod calls and checking those, but that isn't always the case in this script. Cheers, Bruce > + 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 > + 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 > + 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 > ---
Re: [OE-core] [PATCH V2 1/1] linux-yocto: add ptest support
On 2018年06月14日 10:49, Dengke Du wrote: Signed-off-by: Dengke Du --- 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 000..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
[OE-core] [PATCH V2 1/1] linux-yocto: add ptest support
Signed-off-by: Dengke Du --- 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 000..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 + 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 + 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 @@ -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)}" -- 2.7.4 -- ___ Openembedded-core mailing list Openembedded-core@lists.openembedded.org http://lists.openembedded.org/mailman/listinfo/openembedded-core