linux-yocto: add ptest support
cover linux-yocto: add ptest support
Add ptest for kernel samples.
Prerequisite:
1. Install package kernel-modules
2. enable ptest distro feature
Runtime testing(x86):
1. cd /usr/lib/linux-yocto/ptest
2. ./run-ptest
Testing result:
#####result#####
dma-example: PASS
bytestream-example: PASS
inttype-example: PASS
record-example: PASS
kobject-example: PASS
kset-example: PASS
trace-events-sample: PASS
trace-printk: PASSkprobe_example: PASSkretprobe_example: PASS
The following changes since commit 719d068bde55ef29a3468bc0779d4cb0c11e8c1d:
bitbake: fetch2: fix import error for Python 3.6.5 (2018-05-29 21:07:46 +0100)
are available in the git repository at:
https://github.com/DengkeDu/openembedded-core.git dengke/dev
https://github.com//tree/dengke/dev
Dengke Du (1):
linux-yocto: add ptest support
meta/recipes-kernel/linux/files/run-ptest | 138 ++++++++++++++++++++++++++ meta/recipes-kernel/linux/linux-yocto.inc | 8 ++ meta/recipes-kernel/linux/linux-yocto_4.14.bb | 2 +- 3 files changed, 147 insertions(+), 1 deletion(-) create mode 100644 meta/recipes-kernel/linux/files/run-ptest
Signature · 1 line
2.7.4
PATCH 1/1 linux-yocto: add ptest support
--- meta/recipes-kernel/linux/files/run-ptest | 138 ++++++++++++++++++++++++++ meta/recipes-kernel/linux/linux-yocto.inc | 8 ++ meta/recipes-kernel/linux/linux-yocto_4.14.bb | 2 +- 3 files changed, 147 insertions(+), 1 deletion(-) create mode 100644 meta/recipes-kernel/linux/files/run-ptest
meta/recipes-kernel/linux/files/run-ptest new file +138 -0
@@ -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 + rmmod "$i" + else + echo "$i: FAILED" >> kernel.log + fi +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 + rmmod "$i" + else + echo "$i: FAILED" >> kernel.log + fi +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
meta/recipes-kernel/linux/linux-yocto.inc +8 -0
@@ -67,3 +67,11 @@ do_install_append(){ addtask kernel_version_sanity_check after do_kernel_metadata do_kernel_checkout before do_compile addtask validate_branches before do_patch after do_kernel_checkout addtask kernel_configcheck after do_configure before do_compile + +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)}"
meta/recipes-kernel/linux/linux-yocto_4.14.bb +1 -1
@@ -19,7 +19,7 @@ SRCREV_machine_qemux86 ?= "74f6cd2b6976e37491779fcb1bc4966d3a61492c" SRCREV_machine_qemux86-64 ?= "74f6cd2b6976e37491779fcb1bc4966d3a61492c" SRCREV_machine_qemumips64 ?= "9863b327e770b42b8c18da3e0cfaf06e8f99ae97" SRCREV_machine ?= "74f6cd2b6976e37491779fcb1bc4966d3a61492c" -SRCREV_meta ?= "ea9330894eea727bd1655569b16f338976b72563" +SRCREV_meta ?= "53336e1b7d969f21d8214ec9ceeb48fba4f99372" SRC_URI = "git://git.yoctoproject.org/linux-yocto.git;name=machine;branch=${KBRANCH}; \ git://git.yoctoproject.org/yocto-kernel-cache;type=kmeta;name=meta;branch=yocto-4.14;destsuffix=${KMETA}"
Signature · 1 line
2.7.4
Quoted 5 lines · Dengke Du
Signed-off-by Dengke Du <[email protected]>--- meta/recipes-kernel/linux/files/run-ptest | 138++++++++++++++++++++++++++
Nothing else in linux-yocto uses "files", and this shouldn't either.
We can't guarantee that these are version independent, so they need to be in a versioned
kernel subdirectory.
Quoted 13 lines
meta/recipes-kernel/linux/linux-yocto.inc | 8 ++ meta/recipes-kernel/linux/linux-yocto_4.14.bb | 2 +- 3 files changed, 147 insertions(+), 1 deletion(-) create mode 100644 meta/recipes-kernel/linux/files/run-ptestmeta/recipes-kernel/linux/files/run-ptest new file +0
-0
meta/recipes-kernel/linux/files/run-ptest line 1
Quoted 1 line
meta/recipes-kernel/linux/files/run-ptest new file +1
-0@@ -0,0 +1,138 @@ +#!/bin/bash
This script should have a license and proper header file.
Also, if the ptests are mainly trace/sample related, name the script to indicate that.
The kernel already has a significant number of selftests, which are likely better than
these ptests. Is there any reason why they aren't being used instead ?
Quoted 170 lines
meta/recipes-kernel/linux/files/run-ptest new file +5
-0+depmod +touch kernel.log + +#dma-example bytestream-example inttype-example record-example +list1=("dma-example" "bytestream-example" "inttype-example""record-example")
meta/recipes-kernel/linux/files/run-ptest new file +65
-0+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 + rmmod "$i" + else + echo "$i: FAILED" >> kernel.log + fi +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 + rmmod "$i" + else + echo "$i: FAILED" >> kernel.log + fi +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`
meta/recipes-kernel/linux/files/run-ptest new file +67
-1+ 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.logmeta/recipes-kernel/linux/linux-yocto.inc +0
-0@@ -67,3 +67,11 @@ do_install_append(){ addtask kernel_version_sanity_check after do_kernel_metadata
do_kernel_checkoutbeforedo_compile
addtaskvalidate_branchesbeforedo_patchafterdo_kernel_checkoutaddtaskkernel_configcheckafterdo_configurebeforedo_compilemeta/recipes-kernel/linux/linux-yocto.inc +8
-0+ +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)}"
meta/recipes-kernel/linux/linux-yocto_4.14.bb +0
-0@@ -19,7 +19,7 @@ SRCREV_machine_qemux86 ?= "
74f6cd2b6976e37491779fcb1bc4966d3a61492c"
SRCREV_machine_qemux86-64 ?= "74f6cd2b6976e37491779fcb1bc4966d3a61492c"SRCREV_machine_qemumips64?= "9863b327e770b42b8c18da3e0cfaf06e8f99ae97"SRCREV_machine?= "74f6cd2b6976e37491779fcb1bc4966d3a61492c"
meta/recipes-kernel/linux/linux-yocto_4.14.bb SRCREV_machine_qemux86 ?= "74f6cd2b6976e37491779fcb1bc4966d3a61492c" · line 22
Quoted 2 lines
meta/recipes-kernel/linux/linux-yocto_4.14.bb +1
-1-SRCREV_meta ?= "ea9330894eea727bd1655569b16f338976b72563" +SRCREV_meta ?= "53336e1b7d969f21d8214ec9ceeb48fba4f99372"
Do not bump the SRCREV for meta in this series.
If your feature depends on something in the meta branch (which it does), wait until I've sent my next series before sending this.
Bruce
Quoted 14 lines
SRC_URI= "git://git.yoctoproject.org/linux-yocto.git;name=machine;branch=${KBRANCH}; \ git://git.yoctoproject.org/yocto-kernel-cache;type=kmeta;name=meta;branch=yocto-4.14;destsuffix=${KMETA}"
--
2.7.4--
_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-core
Signature · 2 lines
"Thou shalt not follow the NULL pointer, for chaos and madness await thee at its end"
hi dengke,
some of the kernel modules were rmmod-ed twice, some of them forget to be rmmod-ed when it fails,
please take a look.
Lei
Quoted 252 lines · Bruce Ashfield
On Wed, May 30, 2018 at 11:08 PM, Dengke Du <[email protected] <mailto:[email protected]>> wrote:
Signed-off-by Dengke Du <[email protected]<mailto:[email protected]>>
---
meta/recipes-kernel/linux/files/run-ptest | 138
++++++++++++++++++++++++++Nothing else in linux-yocto uses "files", and this shouldn't either.
We can't guarantee that these are version independent, so they need to be in a versioned kernel subdirectory.
meta/recipes-kernel/linux/linux-yocto.inc | 8 ++ meta/recipes-kernel/linux/linux-yocto_4.14.bb <http://linux-yocto_4.14.bb> | 2 +- 3 files changed, 147 insertions(+), 1 deletion(-) create mode 100644 meta/recipes-kernel/linux/files/run-ptest diff --git a/meta/recipes-kernel/linux/files/run-ptest b/meta/recipes-kernel/linux/files/run-ptest new file mode 100644 index 0000000..a3d9e14 --- /dev/null +++ b/meta/recipes-kernel/linux/files/run-ptest @@ -0,0 +1,138 @@ +#!/bin/bashThis script should have a license and proper header file.
Also, if the ptests are mainly trace/sample related, name the script to indicate that.
The kernel already has a significant number of selftests, which are likely better than these ptests. Is there any reason why they aren't being used instead ?
+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
+ rmmod "$i"
+ else
+ echo "$i: FAILED" >> kernel.log
+ fi
+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
+ rmmod "$i"
+ else
+ echo "$i: FAILED" >> kernel.log
+ fi
+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_forkreturned"
+ 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.inc b/meta/recipes-kernel/linux/linux-yocto.inc
index 95ec2a2..7e1773e 100644
--- a/meta/recipes-kernel/linux/linux-yocto.inc
+++ b/meta/recipes-kernel/linux/linux-yocto.inc
@@ -67,3 +67,11 @@ do_install_append(){
addtaskkernel_version_sanity_checkafterdo_kernel_metadata
do_kernel_checkoutbeforedo_compile
addtaskvalidate_branchesbeforedo_patchafterdo_kernel_checkoutaddtaskkernel_configcheckafterdo_configurebeforedo_compile
+
+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)}" diff --git a/meta/recipes-kernel/linux/linux-yocto_4.14.bb
<http://linux-yocto_4.14.bb>
b/meta/recipes-kernel/linux/linux-yocto_4.14.bb
<http://linux-yocto_4.14.bb>
index 16142f8..7002693 100644
--- a/meta/recipes-kernel/linux/linux-yocto_4.14.bb
<http://linux-yocto_4.14.bb>
+++ b/meta/recipes-kernel/linux/linux-yocto_4.14.bb
<http://linux-yocto_4.14.bb>
@@ -19,7 +19,7 @@SRCREV_machine_qemux86?= "74f6cd2b6976e37491779fcb1bc4966d3a61492c"
SRCREV_machine_qemux86-64 ?=
"74f6cd2b6976e37491779fcb1bc4966d3a61492c"
SRCREV_machine_qemumips64?=
"9863b327e770b42b8c18da3e0cfaf06e8f99ae97"
SRCREV_machine?= "74f6cd2b6976e37491779fcb1bc4966d3a61492c"
-SRCREV_meta ?= "ea9330894eea727bd1655569b16f338976b72563" +SRCREV_meta ?= "53336e1b7d969f21d8214ec9ceeb48fba4f99372"Do not bump the SRCREV for meta in this series.
If your feature depends on something in the meta branch (which it does), wait until I've sent my next series before sending this.
Bruce
SRC_URI = "git://git.yoctoproject.org/linux-yocto.git;name=machine;branch=${KBRANCH} <http://git.yoctoproject.org/linux-yocto.git;name=machine;branch=$%7BKBRANCH%7D>; \ git://git.yoctoproject.org/yocto-kernel-cache;type=kmeta;name=meta;branch=yocto-4.14;destsuffix=${KMETA} <http://git.yoctoproject.org/yocto-kernel-cache;type=kmeta;name=meta;branch=yocto-4.14;destsuffix=$%7BKMETA%7D>" -- 2.7.4 -- _______________________________________________ Openembedded-core mailing list [email protected] <mailto:[email protected]> http://lists.openembedded.org/mailman/listinfo/openembedded-core <http://lists.openembedded.org/mailman/listinfo/openembedded-core>Signature · 1 line
"Thou shalt not follow the NULL pointer, for chaos and madness await thee at its end"
Quoted 7 lines · lei yang
hi dengke,
some of the kernel modules were rmmod-ed twice, some of them forget to be rmmod-ed when it fails,
please take a look.
Thanks, after bruce update the SRCREV for kernel meta, I will send v2.
Quoted 258 lines
Lei
Quoted 252 lines · Bruce Ashfield
On Wed, May 30, 2018 at 11:08 PM, Dengke Du <[email protected] <mailto:[email protected]>> wrote:
Signed-off-by Dengke Du <[email protected]<mailto:[email protected]>>
---
meta/recipes-kernel/linux/files/run-ptest | 138
++++++++++++++++++++++++++Nothing else in linux-yocto uses "files", and this shouldn't either.
We can't guarantee that these are version independent, so they need to be in a versioned kernel subdirectory.
meta/recipes-kernel/linux/linux-yocto.inc | 8 ++ meta/recipes-kernel/linux/linux-yocto_4.14.bb <http://linux-yocto_4.14.bb> | 2 +- 3 files changed, 147 insertions(+), 1 deletion(-) create mode 100644 meta/recipes-kernel/linux/files/run-ptest diff --git a/meta/recipes-kernel/linux/files/run-ptest b/meta/recipes-kernel/linux/files/run-ptest new file mode 100644 index 0000000..a3d9e14 --- /dev/null +++ b/meta/recipes-kernel/linux/files/run-ptest @@ -0,0 +1,138 @@ +#!/bin/bashThis script should have a license and proper header file.
Also, if the ptests are mainly trace/sample related, name the script to indicate that.
The kernel already has a significant number of selftests, which are likely better than these ptests. Is there any reason why they aren't being used instead ?
+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 + rmmod "$i" + else + echo "$i: FAILED" >> kernel.log + fi +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 + rmmod "$i" + else + echo "$i: FAILED" >> kernel.log + fi +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.inc b/meta/recipes-kernel/linux/linux-yocto.inc index 95ec2a2..7e1773e 100644 --- a/meta/recipes-kernel/linux/linux-yocto.inc +++ b/meta/recipes-kernel/linux/linux-yocto.inc @@ -67,3 +67,11 @@ do_install_append(){ addtask kernel_version_sanity_check after do_kernel_metadata do_kernel_checkout before do_compile addtask validate_branches before do_patch after do_kernel_checkout addtask kernel_configcheck after do_configure before do_compile + +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)}" diff --git a/meta/recipes-kernel/linux/linux-yocto_4.14.bb <http://linux-yocto_4.14.bb> b/meta/recipes-kernel/linux/linux-yocto_4.14.bb <http://linux-yocto_4.14.bb> index 16142f8..7002693 100644 --- a/meta/recipes-kernel/linux/linux-yocto_4.14.bb <http://linux-yocto_4.14.bb> +++ b/meta/recipes-kernel/linux/linux-yocto_4.14.bb <http://linux-yocto_4.14.bb> @@ -19,7 +19,7 @@ SRCREV_machine_qemux86 ?= "74f6cd2b6976e37491779fcb1bc4966d3a61492c" SRCREV_machine_qemux86-64 ?= "74f6cd2b6976e37491779fcb1bc4966d3a61492c" SRCREV_machine_qemumips64 ?= "9863b327e770b42b8c18da3e0cfaf06e8f99ae97" SRCREV_machine ?= "74f6cd2b6976e37491779fcb1bc4966d3a61492c" -SRCREV_meta ?= "ea9330894eea727bd1655569b16f338976b72563" +SRCREV_meta ?= "53336e1b7d969f21d8214ec9ceeb48fba4f99372"Do not bump the SRCREV for meta in this series.
If your feature depends on something in the meta branch (which it does), wait until I've sent my next series before sending this.
Bruce
SRC_URI = "git://git.yoctoproject.org/linux-yocto.git;name=machine;branch=${KBRANCH} <http://git.yoctoproject.org/linux-yocto.git;name=machine;branch=$%7BKBRANCH%7D>; \ git://git.yoctoproject.org/yocto-kernel-cache;type=kmeta;name=meta;branch=yocto-4.14;destsuffix=${KMETA} <http://git.yoctoproject.org/yocto-kernel-cache;type=kmeta;name=meta;branch=yocto-4.14;destsuffix=$%7BKMETA%7D>" -- 2.7.4 -- _______________________________________________ Openembedded-core mailing list [email protected] <mailto:[email protected]> http://lists.openembedded.org/mailman/listinfo/openembedded-core <http://lists.openembedded.org/mailman/listinfo/openembedded-core>Signature · 1 line
"Thou shalt not follow the NULL pointer, for chaos and madness await thee at its end"
Quoted 11 lines · Bruce Ashfield
On Wed, May 30, 2018 at 11:08 PM, Dengke Du <[email protected] <mailto:[email protected]>> wrote:
Signed-off-by Dengke Du <[email protected]<mailto:[email protected]>>
---
meta/recipes-kernel/linux/files/run-ptest | 138
++++++++++++++++++++++++++
Quoted 4 lines
Nothing else in linux-yocto uses "files", and this shouldn't either.
We can't guarantee that these are version independent, so they need to be in a versioned kernel subdirectory.
Ok, I will put it in versioned kernel subdirectory.
Quoted 17 lines
meta/recipes-kernel/linux/linux-yocto.inc | 8 ++
meta/recipes-kernel/linux/linux-yocto_4.14.bb
<http://linux-yocto_4.14.bb> | 2 +-
3 files changed, 147 insertions(+), 1 deletion(-)
create mode 100644 meta/recipes-kernel/linux/files/run-ptest
diff --git a/meta/recipes-kernel/linux/files/run-ptest
b/meta/recipes-kernel/linux/files/run-ptest
new file mode 100644
index 0000000..a3d9e14
--- /dev/null
+++ b/meta/recipes-kernel/linux/files/run-ptest
@@ -0,0 +1,138 @@
+#!/bin/bashQuoted 3 lines
This script should have a license and proper header file.
Also, if the ptests are mainly trace/sample related, name the script to indicate that.
Ok.
Quoted 3 lines
The kernel already has a significant number of selftests, which are likely better than these ptests. Is there any reason why they aren't being used instead ?
This is different to selftests, this ptest was based on kernel samples in sample directory, those samples were some tutorial modules, the modules that we can modify it and learn it(some basic kernel theory), in the end build it into our image to test and verification our thought easily.
Quoted 181 lines
+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
+ rmmod "$i"
+ else
+ echo "$i: FAILED" >> kernel.log
+ fi
+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
+ rmmod "$i"
+ else
+ echo "$i: FAILED" >> kernel.log
+ fi
+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.inc
b/meta/recipes-kernel/linux/linux-yocto.inc
index 95ec2a2..7e1773e 100644
--- a/meta/recipes-kernel/linux/linux-yocto.inc
+++ b/meta/recipes-kernel/linux/linux-yocto.inc
@@ -67,3 +67,11 @@ do_install_append(){
addtask kernel_version_sanity_check after do_kernel_metadata
do_kernel_checkout before do_compile
addtask validate_branches before do_patch after do_kernel_checkout
addtask kernel_configcheck after do_configure before do_compile
+
+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)}"
diff --git a/meta/recipes-kernel/linux/linux-yocto_4.14.bb
<http://linux-yocto_4.14.bb>
b/meta/recipes-kernel/linux/linux-yocto_4.14.bb
<http://linux-yocto_4.14.bb>
index 16142f8..7002693 100644
--- a/meta/recipes-kernel/linux/linux-yocto_4.14.bb
<http://linux-yocto_4.14.bb>
+++ b/meta/recipes-kernel/linux/linux-yocto_4.14.bb
<http://linux-yocto_4.14.bb>
@@ -19,7 +19,7 @@ SRCREV_machine_qemux86 ?=
"74f6cd2b6976e37491779fcb1bc4966d3a61492c"
SRCREV_machine_qemux86-64 ?=
"74f6cd2b6976e37491779fcb1bc4966d3a61492c"
SRCREV_machine_qemumips64 ?=
"9863b327e770b42b8c18da3e0cfaf06e8f99ae97"
SRCREV_machine ?= "74f6cd2b6976e37491779fcb1bc4966d3a61492c"
-SRCREV_meta ?= "ea9330894eea727bd1655569b16f338976b72563"
+SRCREV_meta ?= "53336e1b7d969f21d8214ec9ceeb48fba4f99372"Quoted 1 line
Do not bump the SRCREV for meta in this series.
Ok.
Quoted 29 lines
If your feature depends on something in the meta branch (which it does), wait until I've sent my next series before sending this.
Bruce
SRC_URI = "git://git.yoctoproject.org/linux-yocto.git;name=machine;branch=${KBRANCH} <http://git.yoctoproject.org/linux-yocto.git;name=machine;branch=$%7BKBRANCH%7D>; \ git://git.yoctoproject.org/yocto-kernel-cache;type=kmeta;name=meta;branch=yocto-4.14;destsuffix=${KMETA} <http://git.yoctoproject.org/yocto-kernel-cache;type=kmeta;name=meta;branch=yocto-4.14;destsuffix=$%7BKMETA%7D>" -- 2.7.4 -- _______________________________________________ Openembedded-core mailing list [email protected] <mailto:[email protected]> http://lists.openembedded.org/mailman/listinfo/openembedded-core <http://lists.openembedded.org/mailman/listinfo/openembedded-core>Signature · 1 line
"Thou shalt not follow the NULL pointer, for chaos and madness await thee at its end"
Quoted 12 lines · Dengke Du
Quoted 9 lines · Bruce Ashfield
Quoted 5 lines · Dengke Du
Signed-off-by Dengke Du <[email protected]>--- meta/recipes-kernel/linux/files/run-ptest | 138++++++++++++++++++++++++++
Quoted 8 lines
Quoted 6 lines
Nothing else in linux-yocto uses "files", and this shouldn't either.
We can't guarantee that these are version independent, so they need to be in a versioned
kernel subdirectory.Ok, I will put it in versioned kernel subdirectory.
It doesn't have to be versioned, it can be "linux-yocto" if it really isn't version specific. It really shouldn't be "files" though.
Cheers,
Richard