Skip to contentSkip to conversation

linux-yocto: add ptest support

PATCH Superseded Dengke Du 3 participants 5 messages Jun 14, 2018 – Jul 4, 2018

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Dengke Du

author
#0 lore raw

v2 cover linux-yocto: add ptest support

Changed in V2:
Put the run-ptest script in linux-yocto directory.

The following changes since commit ddbd7b0cd6580ee26e11aa87e426fb294b372d64:

meta-yocto-bsp: bump to the latest linux stable kernel for edgerouter/beaglebone (2018-06-12 23:34:40 +0100)

are available in the git repository at:

https://github.com/DengkeDu/openembedded-core.git kernel-ptest
https://github.com//tree/kernel-ptest

Dengke Du (1):
linux-yocto: add ptest support

 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
Signature · 1 line
2.7.4
author
#1 lore raw

PATCH v2 1/1 linux-yocto: add ptest support

---
 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
meta/recipes-kernel/linux/linux-yocto/run-ptest new file +138 -0
new file mode 100644
index 0000000..6db4d93
@@ -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
meta/recipes-kernel/linux/linux-yocto_4.14.bb +9 -0
index 0449213..9650ee2 100644
@@ -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)}"
Signature · 1 line
2.7.4
#2 lore raw
Quoted 21 lines · 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

meta/recipes-kernel/linux/linux-yocto/run-ptest new file +8 -0
new file mode 100644
index 0000000..6db4d93
@@ -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

meta/recipes-kernel/linux/linux-yocto/run-ptest line 18

Quoted 10 lines
meta/recipes-kernel/linux/linux-yocto/run-ptest new file +10 -0
+  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

meta/recipes-kernel/linux/linux-yocto/run-ptest line 27

Quoted 9 lines
meta/recipes-kernel/linux/linux-yocto/run-ptest new file +9 -0
+  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.

meta/recipes-kernel/linux/linux-yocto_4.14.bb

Quoted 115 lines
meta/recipes-kernel/linux/linux-yocto/run-ptest new file +111 -0
+  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
meta/recipes-kernel/linux/linux-yocto_4.14.bb +0 -0
index 0449213..9650ee2 100644

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

Quoted 13 lines
meta/recipes-kernel/linux/linux-yocto_4.14.bb +9 -0
@@ -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)}"
#3 lore raw
In reply to Dengke Du

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.

Quoted 14 lines · 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
meta/recipes-kernel/linux/linux-yocto/run-ptest new file +0 -0
new file mode 100644
index 0000000..6db4d93

meta/recipes-kernel/linux/linux-yocto/run-ptest line 10

Quoted 10 lines
meta/recipes-kernel/linux/linux-yocto/run-ptest new file +10 -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"

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

Quoted 148 lines
meta/recipes-kernel/linux/linux-yocto/run-ptest new file +128 -0
+  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
meta/recipes-kernel/linux/linux-yocto_4.14.bb +9 -1
index 0449213..9650ee2 100644
@@ -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

Signature · 2 lines
"Thou shalt not follow the NULL pointer, for chaos and madness await
thee at its end"
author
#4 lore raw
Quoted 6 lines · Bruce Ashfield

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.

Quoted 4 lines

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.

Quoted 6 lines

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.

Quoted 183 lines · Dengke Du
Quoted 13 lines
---
  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

meta/recipes-kernel/linux/linux-yocto/run-ptest new file +0 -0
new file mode 100644
index 0000000..6db4d93

meta/recipes-kernel/linux/linux-yocto/run-ptest line 10

Quoted 10 lines
meta/recipes-kernel/linux/linux-yocto/run-ptest new file +10 -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"

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

Quoted 148 lines
meta/recipes-kernel/linux/linux-yocto/run-ptest new file +128 -0
+  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
meta/recipes-kernel/linux/linux-yocto_4.14.bb +9 -1
index 0449213..9650ee2 100644
@@ -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