* [PATCH V3 0/1] linux-yocto: add ptest support @ 2018-07-05 4:09 Dengke Du 2018-07-05 4:09 ` [PATCH V3 1/1] " Dengke Du 0 siblings, 1 reply; 3+ messages in thread From: Dengke Du @ 2018-07-05 4:09 UTC (permalink / raw) To: bruce.ashfield; +Cc: openembedded-core Changed in V3: 1. Add comments and documentation for the tests 2. Changed the results of the kernel ptest output in this format: "[PASS|SKIP|FAIL]" : testname, according to Lei yang's comments. The tests output: #####result##### PASS: dma-example PASS: bytestream-example PASS: inttype-example PASS: record-example PASS: kobject-example PASS: kset-example PASS: trace-events-sample PASS: trace-printk PASS: kprobe_example PASS: kretprobe_example The following changes since commit 611013a23a0082faa4fda2cd2529668965586a76: mesa: add lost Upstream-Status tag (2018-07-05 00:22:08 +0100) are available in the git repository at: https://github.com/DengkeDu/openembedded-core.git dengke/kernel-ptest https://github.com//tree/dengke/kernel-ptest Dengke Du (1): linux-yocto: add ptest support meta/recipes-kernel/linux/linux-yocto/run-ptest | 144 ++++++++++++++++++++++++ meta/recipes-kernel/linux/linux-yocto_4.14.bb | 15 +++ 2 files changed, 159 insertions(+) create mode 100644 meta/recipes-kernel/linux/linux-yocto/run-ptest -- 2.7.4 ^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH V3 1/1] linux-yocto: add ptest support 2018-07-05 4:09 [PATCH V3 0/1] linux-yocto: add ptest support Dengke Du @ 2018-07-05 4:09 ` Dengke Du 2018-07-05 6:34 ` Dengke Du 0 siblings, 1 reply; 3+ messages in thread From: Dengke Du @ 2018-07-05 4:09 UTC (permalink / raw) To: bruce.ashfield; +Cc: openembedded-core Signed-off-by: Dengke Du <dengke.du@windriver.com> --- meta/recipes-kernel/linux/linux-yocto/run-ptest | 144 ++++++++++++++++++++++++ meta/recipes-kernel/linux/linux-yocto_4.14.bb | 15 +++ 2 files changed, 159 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..d8391b4 --- /dev/null +++ b/meta/recipes-kernel/linux/linux-yocto/run-ptest @@ -0,0 +1,144 @@ +#!/bin/bash +depmod +touch kernel.log + +# dma-example: This module shows how to handle fifo dma operations. +# bytestream-example: This module shows how to create a byte stream fifo. +# inttype-example: This module shows how to create a int type fifo. +# record-example: This module shows how to create a variable sized record fifo. +list1=("dma-example" "bytestream-example" "inttype-example" "record-example") +for i in "${list1[@]}" +do + dmesg -c + modprobe "$i" + mod=${i//-/_} + lsmod | grep -q "$mod" + if [ $? -eq 0 ];then + dmesg | grep "test passed" + if [ $? -eq 0 ];then + echo "PASS: $i" >> kernel.log + fi + else + echo "FAIL: $i" >> kernel.log + fi + rmmod "$i" +done + +# kobject-example: +/* + * This module shows how to create a simple subdirectory in sysfs called + * /sys/kernel/kobject-example In that directory, 3 files are created: + * "foo", "baz", and "bar". If an integer is written to these files, it can be + * later read out of it. + */ + +# kset-example: +/* + * This module shows how to create a kset in sysfs called + * /sys/kernel/kset-example + * Then tree kobjects are created and assigned to this kset, "foo", "baz", + * and "bar". In those kobjects, attributes of the same name are also + * created and if an integer is written to these files, it can be later + * read out of it. + */ + +list2=("kobject-example" "kset-example") +for i in "${list2[@]}" +do + dmesg -c + modprobe "$i" + mod=${i//-/_} + basedir="/sys/kernel/${mod}" + echo "$basedir" + if [ -e ${basedir}/bar -a -e ${basedir}/baz -a -e ${basedir}/foo ];then + echo "PASS: $i" >> kernel.log + else + echo "FAIL: $i" >> kernel.log + fi + rmmod "$i" +done + +# trace-events-sample +# This modules test trace-events for a thread "foo_bar", return string "foo_bar" when everything goes well. +list3="trace-events-sample" +mod=${list3//-/_} +modprobe "$list3" +lsmod | grep "$mod" +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 "PASS: $list3" >> kernel.log + else + echo "FAIL: $list3" >> kernel.log + fi + else + echo "FAIL: $list3" >> kernel.log + fi +else + echo "FAILED: $list3" >> kernel.log +fi +rmmod "$list3" + +# trace-printk +# This modules just a simple test for trace-printk, return string "trace_printk_irq_work" when everything goes well. +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 "PASS: $list4" >> kernel.log + else + echo "FAIL: $list4" >> kernel.log + fi +else + echo "FAIL: $list4" >> kernel.log +fi +rmmod "$list4" + +# kprobe_example +# Here's a sample kernel module showing the use of kprobes to dump a +# stack trace and selected registers when _do_fork() is called. +list5="kprobe_example" +dmesg -c +modprobe "$list5" +lsmod | grep "$list5" +if [ $? -eq 0 ];then + dmesg | grep "_do_fork" + if [ $? -eq 0 ];then + echo "PASS: $list5" >> kernel.log + else + echo "FAIL: $list5" >> kernel.log + fi +else + echo "FAIL: $list5" >> kernel.log +fi +rmmod "$list5" + +# kretprobe_example +# Here's a sample kernel module showing the use of return probes to +# report the return value and total time taken for probed function +# to run. +# When everything goes well, the result contain "_do_fork" +list6="kretprobe_example" +dmesg -c +modprobe "$list6" +lsmod | grep "$list6" +if [ $? -eq 0 ];then + dmesg | grep "_do_fork returned" + if [ $? -eq 0 ];then + echo "PASS: $list6" >> kernel.log + else + echo "FAIL: $list6" >> kernel.log + fi +else + echo "FAIL: $list6" >> 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..4755acb 100644 --- a/meta/recipes-kernel/linux/linux-yocto_4.14.bb +++ b/meta/recipes-kernel/linux/linux-yocto_4.14.bb @@ -45,3 +45,18 @@ 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_compile_ptest_append() { + echo ${CC} + echo ${CFLAGS} +# oe_runmake CFLAGS="${CFLAGS} -I${RECIPE_SYSROOT}/usr/include" -C ${S}/tools/testing/selftests +} +do_install_ptest_append() { + install -D ${WORKDIR}/run-ptest ${D}${PTEST_PATH}/run-ptest + install -D ${S}/tools/testing/fault-injection/failcmd.sh ${D}${PTEST_PATH}/failcmd.sh +} +KERNEL_FEATURES_append = " ${@bb.utils.contains("DISTRO_FEATURES", "ptest", "features/kernel-sample/kernel-sample.scc", "", d)}" -- 2.7.4 ^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH V3 1/1] linux-yocto: add ptest support 2018-07-05 4:09 ` [PATCH V3 1/1] " Dengke Du @ 2018-07-05 6:34 ` Dengke Du 0 siblings, 0 replies; 3+ messages in thread From: Dengke Du @ 2018-07-05 6:34 UTC (permalink / raw) To: bruce.ashfield; +Cc: openembedded-core Please ignore this. On 2018年07月05日 12:09, Dengke Du wrote: > Signed-off-by: Dengke Du <dengke.du@windriver.com> > --- > meta/recipes-kernel/linux/linux-yocto/run-ptest | 144 ++++++++++++++++++++++++ > meta/recipes-kernel/linux/linux-yocto_4.14.bb | 15 +++ > 2 files changed, 159 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..d8391b4 > --- /dev/null > +++ b/meta/recipes-kernel/linux/linux-yocto/run-ptest > @@ -0,0 +1,144 @@ > +#!/bin/bash > +depmod > +touch kernel.log > + > +# dma-example: This module shows how to handle fifo dma operations. > +# bytestream-example: This module shows how to create a byte stream fifo. > +# inttype-example: This module shows how to create a int type fifo. > +# record-example: This module shows how to create a variable sized record fifo. > +list1=("dma-example" "bytestream-example" "inttype-example" "record-example") > +for i in "${list1[@]}" > +do > + dmesg -c > + modprobe "$i" > + mod=${i//-/_} > + lsmod | grep -q "$mod" > + if [ $? -eq 0 ];then > + dmesg | grep "test passed" > + if [ $? -eq 0 ];then > + echo "PASS: $i" >> kernel.log > + fi > + else > + echo "FAIL: $i" >> kernel.log > + fi > + rmmod "$i" > +done > + > +# kobject-example: > +/* > + * This module shows how to create a simple subdirectory in sysfs called > + * /sys/kernel/kobject-example In that directory, 3 files are created: > + * "foo", "baz", and "bar". If an integer is written to these files, it can be > + * later read out of it. > + */ > + > +# kset-example: > +/* > + * This module shows how to create a kset in sysfs called > + * /sys/kernel/kset-example > + * Then tree kobjects are created and assigned to this kset, "foo", "baz", > + * and "bar". In those kobjects, attributes of the same name are also > + * created and if an integer is written to these files, it can be later > + * read out of it. > + */ > + > +list2=("kobject-example" "kset-example") > +for i in "${list2[@]}" > +do > + dmesg -c > + modprobe "$i" > + mod=${i//-/_} > + basedir="/sys/kernel/${mod}" > + echo "$basedir" > + if [ -e ${basedir}/bar -a -e ${basedir}/baz -a -e ${basedir}/foo ];then > + echo "PASS: $i" >> kernel.log > + else > + echo "FAIL: $i" >> kernel.log > + fi > + rmmod "$i" > +done > + > +# trace-events-sample > +# This modules test trace-events for a thread "foo_bar", return string "foo_bar" when everything goes well. > +list3="trace-events-sample" > +mod=${list3//-/_} > +modprobe "$list3" > +lsmod | grep "$mod" > +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 "PASS: $list3" >> kernel.log > + else > + echo "FAIL: $list3" >> kernel.log > + fi > + else > + echo "FAIL: $list3" >> kernel.log > + fi > +else > + echo "FAILED: $list3" >> kernel.log > +fi > +rmmod "$list3" > + > +# trace-printk > +# This modules just a simple test for trace-printk, return string "trace_printk_irq_work" when everything goes well. > +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 "PASS: $list4" >> kernel.log > + else > + echo "FAIL: $list4" >> kernel.log > + fi > +else > + echo "FAIL: $list4" >> kernel.log > +fi > +rmmod "$list4" > + > +# kprobe_example > +# Here's a sample kernel module showing the use of kprobes to dump a > +# stack trace and selected registers when _do_fork() is called. > +list5="kprobe_example" > +dmesg -c > +modprobe "$list5" > +lsmod | grep "$list5" > +if [ $? -eq 0 ];then > + dmesg | grep "_do_fork" > + if [ $? -eq 0 ];then > + echo "PASS: $list5" >> kernel.log > + else > + echo "FAIL: $list5" >> kernel.log > + fi > +else > + echo "FAIL: $list5" >> kernel.log > +fi > +rmmod "$list5" > + > +# kretprobe_example > +# Here's a sample kernel module showing the use of return probes to > +# report the return value and total time taken for probed function > +# to run. > +# When everything goes well, the result contain "_do_fork" > +list6="kretprobe_example" > +dmesg -c > +modprobe "$list6" > +lsmod | grep "$list6" > +if [ $? -eq 0 ];then > + dmesg | grep "_do_fork returned" > + if [ $? -eq 0 ];then > + echo "PASS: $list6" >> kernel.log > + else > + echo "FAIL: $list6" >> kernel.log > + fi > +else > + echo "FAIL: $list6" >> 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..4755acb 100644 > --- a/meta/recipes-kernel/linux/linux-yocto_4.14.bb > +++ b/meta/recipes-kernel/linux/linux-yocto_4.14.bb > @@ -45,3 +45,18 @@ 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_compile_ptest_append() { > + echo ${CC} > + echo ${CFLAGS} > +# oe_runmake CFLAGS="${CFLAGS} -I${RECIPE_SYSROOT}/usr/include" -C ${S}/tools/testing/selftests > +} > +do_install_ptest_append() { > + install -D ${WORKDIR}/run-ptest ${D}${PTEST_PATH}/run-ptest > + install -D ${S}/tools/testing/fault-injection/failcmd.sh ${D}${PTEST_PATH}/failcmd.sh > +} > +KERNEL_FEATURES_append = " ${@bb.utils.contains("DISTRO_FEATURES", "ptest", "features/kernel-sample/kernel-sample.scc", "", d)}" ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-07-05 6:37 UTC | newest] Thread overview: 3+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2018-07-05 4:09 [PATCH V3 0/1] linux-yocto: add ptest support Dengke Du 2018-07-05 4:09 ` [PATCH V3 1/1] " Dengke Du 2018-07-05 6:34 ` Dengke Du
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox