summaryrefslogtreecommitdiffstats
path: root/yocto-poky/meta/recipes-rt
diff options
context:
space:
mode:
Diffstat (limited to 'yocto-poky/meta/recipes-rt')
-rw-r--r--yocto-poky/meta/recipes-rt/README13
-rw-r--r--yocto-poky/meta/recipes-rt/images/core-image-rt-sdk.bb12
-rw-r--r--yocto-poky/meta/recipes-rt/images/core-image-rt.bb9
-rw-r--r--yocto-poky/meta/recipes-rt/rt-tests/files/0001-rt-tests-Allow-for-user-specified-PYLIB.patch35
-rw-r--r--yocto-poky/meta/recipes-rt/rt-tests/files/0002-rt-tests-Break-out-install_hwlatdetect.patch68
-rw-r--r--yocto-poky/meta/recipes-rt/rt-tests/files/Makefile-fix-gzip-command.patch30
-rw-r--r--yocto-poky/meta/recipes-rt/rt-tests/files/fix-re-install-failure.patch48
-rw-r--r--yocto-poky/meta/recipes-rt/rt-tests/files/hackbench-fix-error-check.patch41
-rwxr-xr-xyocto-poky/meta/recipes-rt/rt-tests/files/rt_bmark.py412
-rw-r--r--yocto-poky/meta/recipes-rt/rt-tests/files/run-ptest3
-rw-r--r--yocto-poky/meta/recipes-rt/rt-tests/hwlatdetect_0.92.bb23
-rw-r--r--yocto-poky/meta/recipes-rt/rt-tests/rt-tests.inc19
-rw-r--r--yocto-poky/meta/recipes-rt/rt-tests/rt-tests_0.92.bb30
13 files changed, 743 insertions, 0 deletions
diff --git a/yocto-poky/meta/recipes-rt/README b/yocto-poky/meta/recipes-rt/README
new file mode 100644
index 000000000..7d7558de4
--- /dev/null
+++ b/yocto-poky/meta/recipes-rt/README
@@ -0,0 +1,13 @@
+The recipes-rt recipes provide package and image recipes for using and testing
+the PREEMPT_RT kernel. The core-image-rt*.bb images are minimal images with
+a couple extra packages, including rt-tests. In order to build the image with
+the linux-yocto-rt kernel, be sure to include the following line in your
+local.conf, bblayers.conf, or your $MACHINE.conf.
+
+PREFERRED_PROVIDER_virtual/kernel = "linux-yocto-rt"
+
+If you are creating a new BSP which should use linux-yocto-rt by default,
+use the line above in the $MACHINE.conf in your BSP layer, and specify the
+following in a linux-yocto-rt bbappend recipe:
+
+COMPATIBLE_MACHINE_$MACHINE = $MACHINE
diff --git a/yocto-poky/meta/recipes-rt/images/core-image-rt-sdk.bb b/yocto-poky/meta/recipes-rt/images/core-image-rt-sdk.bb
new file mode 100644
index 000000000..db7d58183
--- /dev/null
+++ b/yocto-poky/meta/recipes-rt/images/core-image-rt-sdk.bb
@@ -0,0 +1,12 @@
+require recipes-core/images/core-image-minimal.bb
+
+DESCRIPTION = "Small image capable of booting a device with a test suite and \
+tools for real-time use. It includes the full meta-toolchain, development \
+headers and libraries to form a standalone SDK."
+DEPENDS = "linux-yocto-rt"
+
+IMAGE_FEATURES += "dev-pkgs tools-sdk tools-debug eclipse-debug tools-profile tools-testapps debug-tweaks"
+
+IMAGE_INSTALL += "rt-tests hwlatdetect kernel-dev"
+
+LICENSE = "MIT"
diff --git a/yocto-poky/meta/recipes-rt/images/core-image-rt.bb b/yocto-poky/meta/recipes-rt/images/core-image-rt.bb
new file mode 100644
index 000000000..cab6f8b74
--- /dev/null
+++ b/yocto-poky/meta/recipes-rt/images/core-image-rt.bb
@@ -0,0 +1,9 @@
+require recipes-core/images/core-image-minimal.bb
+
+DESCRIPTION = "A small image just capable of allowing a device to boot plus a \
+real-time test suite and tools appropriate for real-time use."
+DEPENDS = "linux-yocto-rt"
+
+IMAGE_INSTALL += "rt-tests hwlatdetect"
+
+LICENSE = "MIT"
diff --git a/yocto-poky/meta/recipes-rt/rt-tests/files/0001-rt-tests-Allow-for-user-specified-PYLIB.patch b/yocto-poky/meta/recipes-rt/rt-tests/files/0001-rt-tests-Allow-for-user-specified-PYLIB.patch
new file mode 100644
index 000000000..8b493eb1f
--- /dev/null
+++ b/yocto-poky/meta/recipes-rt/rt-tests/files/0001-rt-tests-Allow-for-user-specified-PYLIB.patch
@@ -0,0 +1,35 @@
+From 66765522b634952346f1a3ab7d00c7222a1f9361 Mon Sep 17 00:00:00 2001
+Message-Id: <66765522b634952346f1a3ab7d00c7222a1f9361.1347419597.git.dvhart@linux.intel.com>
+From: Darren Hart <dvhart@linux.intel.com>
+Date: Tue, 11 Sep 2012 15:19:30 -0700
+Subject: [PATCH 1/2] rt-tests: Allow for user-specified PYLIB
+
+Upstream-Status: Submitted
+
+Allow users (build systems) to specify PYLIB. This allows for a
+cross-build-system to specify the target PYLIB rather than the host
+PYLIB.
+
+Signed-off-by: Darren Hart <dvhart@linux.intel.com>
+CC: Clark Williams <williams@redhat.com>
+CC: John Kacur <jkacur@redhat.com>
+---
+ Makefile | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/Makefile b/Makefile
+index 3a82407..61e2f9f 100644
+--- a/Makefile
++++ b/Makefile
+@@ -23,7 +23,7 @@ endif
+ CFLAGS ?= -D_GNU_SOURCE -Wall -Wno-nonnull -Isrc/include
+ LDFLAGS ?=
+
+-PYLIB := $(shell python -c 'import distutils.sysconfig; print distutils.sysconfig.get_python_lib()')
++PYLIB ?= $(shell python -c 'import distutils.sysconfig; print distutils.sysconfig.get_python_lib()')
+
+ ifndef DEBUG
+ CFLAGS += -O2
+--
+1.7.11.4
+
diff --git a/yocto-poky/meta/recipes-rt/rt-tests/files/0002-rt-tests-Break-out-install_hwlatdetect.patch b/yocto-poky/meta/recipes-rt/rt-tests/files/0002-rt-tests-Break-out-install_hwlatdetect.patch
new file mode 100644
index 000000000..bc6136f1d
--- /dev/null
+++ b/yocto-poky/meta/recipes-rt/rt-tests/files/0002-rt-tests-Break-out-install_hwlatdetect.patch
@@ -0,0 +1,68 @@
+From af93e580d005a2bba6ed36528003af4cf631adb8 Mon Sep 17 00:00:00 2001
+Message-Id: <af93e580d005a2bba6ed36528003af4cf631adb8.1347419597.git.dvhart@linux.intel.com>
+In-Reply-To: <66765522b634952346f1a3ab7d00c7222a1f9361.1347419597.git.dvhart@linux.intel.com>
+References: <66765522b634952346f1a3ab7d00c7222a1f9361.1347419597.git.dvhart@linux.intel.com>
+From: Darren Hart <dvhart@linux.intel.com>
+Date: Tue, 11 Sep 2012 14:51:10 -0700
+Subject: [PATCH 2/2] rt-tests: Break out install_hwlatdetect
+
+Upstream-Status: Submitted
+
+Allow hwlatdetect to be installed independently of the rest of the
+tests. This is convenient for build systems that package it separately
+due to the python dependency.
+
+Signed-off-by: Darren Hart <dvhart@linux.intel.com>
+CC: Clark Williams <williams@redhat.com>
+CC: John Kacur <jkacur@redhat.com>
+---
+ Makefile | 18 +++++++++++-------
+ 1 file changed, 11 insertions(+), 7 deletions(-)
+
+diff --git a/Makefile b/Makefile
+index 61e2f9f..636e63b 100644
+--- a/Makefile
++++ b/Makefile
+@@ -119,21 +119,15 @@ changelog:
+ git log >ChangeLog
+
+ .PHONY: install
+-install: all
++install: all install_hwlatdetect
+ mkdir -p "$(DESTDIR)$(bindir)" "$(DESTDIR)$(mandir)/man4"
+ mkdir -p "$(DESTDIR)$(srcdir)" "$(DESTDIR)$(mandir)/man8"
+ cp $(TARGETS) "$(DESTDIR)$(bindir)"
+- if test -n "$(PYLIB)" ; then \
+- install -D -m 755 src/hwlatdetect/hwlatdetect.py $(DESTDIR)$(PYLIB)/hwlatdetect.py ; \
+- rm -f "$(DESTDIR)$(bindir)/hwlatdetect" ; \
+- ln -s $(PYLIB)/hwlatdetect.py "$(DESTDIR)$(bindir)/hwlatdetect" ; \
+- fi
+ install -D -m 644 src/backfire/backfire.c "$(DESTDIR)$(srcdir)/backfire/backfire.c"
+ install -m 644 src/backfire/Makefile "$(DESTDIR)$(srcdir)/backfire/Makefile"
+ gzip src/backfire/backfire.4 -c >"$(DESTDIR)$(mandir)/man4/backfire.4.gz"
+ gzip src/cyclictest/cyclictest.8 -c >"$(DESTDIR)$(mandir)/man8/cyclictest.8.gz"
+ gzip src/pi_tests/pi_stress.8 -c >"$(DESTDIR)$(mandir)/man8/pi_stress.8.gz"
+- gzip src/hwlatdetect/hwlatdetect.8 -c >"$(DESTDIR)$(mandir)/man8/hwlatdetect.8.gz"
+ gzip src/ptsematest/ptsematest.8 -c >"$(DESTDIR)$(mandir)/man8/ptsematest.8.gz"
+ gzip src/sigwaittest/sigwaittest.8 -c >"$(DESTDIR)$(mandir)/man8/sigwaittest.8.gz"
+ gzip src/svsematest/svsematest.8 -c >"$(DESTDIR)$(mandir)/man8/svsematest.8.gz"
+@@ -141,6 +135,16 @@ install: all
+ gzip src/backfire/sendme.8 -c >"$(DESTDIR)$(mandir)/man8/sendme.8.gz"
+ gzip src/hackbench/hackbench.8 -c >"$(DESTDIR)$(mandir)/man8/hackbench.8.gz"
+
++.PHONY: install_hwlatdetect
++install_hwlatdetect: hwlatdetect
++ if test -n "$(PYLIB)" ; then \
++ mkdir -p "$(DESTDIR)$(bindir)" "$(DESTDIR)$(mandir)/man8" ; \
++ install -D -m 755 src/hwlatdetect/hwlatdetect.py $(DESTDIR)$(PYLIB)/hwlatdetect.py ; \
++ rm -f "$(DESTDIR)$(bindir)/hwlatdetect" ; \
++ ln -s $(PYLIB)/hwlatdetect.py "$(DESTDIR)$(bindir)/hwlatdetect" ; \
++ gzip src/hwlatdetect/hwlatdetect.8 -c >"$(DESTDIR)$(mandir)/man8/hwlatdetect.8.gz" ; \
++ fi
++
+ .PHONY: release
+ release: clean changelog
+ mkdir -p releases
+--
+1.7.11.4
+
diff --git a/yocto-poky/meta/recipes-rt/rt-tests/files/Makefile-fix-gzip-command.patch b/yocto-poky/meta/recipes-rt/rt-tests/files/Makefile-fix-gzip-command.patch
new file mode 100644
index 000000000..0a35ddc74
--- /dev/null
+++ b/yocto-poky/meta/recipes-rt/rt-tests/files/Makefile-fix-gzip-command.patch
@@ -0,0 +1,30 @@
+From 07b5ed42d7041ccc084889eaa96817aa097bf461 Mon Sep 17 00:00:00 2001
+From: Robert Yang <liezhi.yang@windriver.com>
+Date: Tue, 3 Feb 2015 03:10:25 +0000
+Subject: [PATCH] Makefile: fix gzip command
+
+The "-c" doesn't work in command "gzip file -c", need use "gzip -c file"
+
+Upstream-Status: Pending
+
+Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
+---
+ Makefile | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/Makefile b/Makefile
+index 219a591..c7d147a 100644
+--- a/Makefile
++++ b/Makefile
+@@ -144,7 +144,7 @@ install_hwlatdetect: hwlatdetect
+ install -D -m 755 src/hwlatdetect/hwlatdetect.py $(DESTDIR)$(PYLIB)/hwlatdetect.py ; \
+ rm -f "$(DESTDIR)$(bindir)/hwlatdetect" ; \
+ ln -s $(PYLIB)/hwlatdetect.py "$(DESTDIR)$(bindir)/hwlatdetect" ; \
+- gzip src/hwlatdetect/hwlatdetect.8 -c >"$(DESTDIR)$(mandir)/man8/hwlatdetect.8.gz" ; \
++ gzip -c src/hwlatdetect/hwlatdetect.8 >"$(DESTDIR)$(mandir)/man8/hwlatdetect.8.gz" ; \
+ fi
+
+ .PHONY: release
+--
+2.0.1
+
diff --git a/yocto-poky/meta/recipes-rt/rt-tests/files/fix-re-install-failure.patch b/yocto-poky/meta/recipes-rt/rt-tests/files/fix-re-install-failure.patch
new file mode 100644
index 000000000..e38ec92c0
--- /dev/null
+++ b/yocto-poky/meta/recipes-rt/rt-tests/files/fix-re-install-failure.patch
@@ -0,0 +1,48 @@
+Currently gzip on host is used. If host gzip is provided by pigz, it fails to
+redo install that pigz can't handle the option after file name. When run:
+
+gzip src/backfire/backfire.4 -c > OUTPUT_FILE
+
+File src/backfire/backfire.4 is zipped into backfire.4.gz but the OUTPUT_FILE
+is empty. When rerun do_install, it shows warning:
+
+| gzip: src/backfire/backfire.4 does not exist -- skipping
+
+and empty manual gzip files are created:
+
+$ file image/usr/share/man/man4/backfire.4.gz
+image/usr/share/man/man4/backfire.4.gz: empty
+
+Fix it by putting option '-c' before the file name.
+
+Upstream-Status: Pending
+
+Signed-off-by: Kai Kang <kai.kang@windriver.com>
+---
+--- git/Makefile.orig 2014-11-14 15:47:26.406638419 +0800
++++ git/Makefile 2014-11-14 15:46:53.890637533 +0800
+@@ -127,15 +127,15 @@
+ cp $(TARGETS) "$(DESTDIR)$(bindir)"
+ install -D -m 644 src/backfire/backfire.c "$(DESTDIR)$(srcdir)/backfire/backfire.c"
+ install -m 644 src/backfire/Makefile "$(DESTDIR)$(srcdir)/backfire/Makefile"
+- gzip src/backfire/backfire.4 -c >"$(DESTDIR)$(mandir)/man4/backfire.4.gz"
+- gzip src/cyclictest/cyclictest.8 -c >"$(DESTDIR)$(mandir)/man8/cyclictest.8.gz"
+- gzip src/pi_tests/pi_stress.8 -c >"$(DESTDIR)$(mandir)/man8/pi_stress.8.gz"
+- gzip src/ptsematest/ptsematest.8 -c >"$(DESTDIR)$(mandir)/man8/ptsematest.8.gz"
+- gzip src/sigwaittest/sigwaittest.8 -c >"$(DESTDIR)$(mandir)/man8/sigwaittest.8.gz"
+- gzip src/svsematest/svsematest.8 -c >"$(DESTDIR)$(mandir)/man8/svsematest.8.gz"
+- gzip src/pmqtest/pmqtest.8 -c >"$(DESTDIR)$(mandir)/man8/pmqtest.8.gz"
+- gzip src/backfire/sendme.8 -c >"$(DESTDIR)$(mandir)/man8/sendme.8.gz"
+- gzip src/hackbench/hackbench.8 -c >"$(DESTDIR)$(mandir)/man8/hackbench.8.gz"
++ gzip -c src/backfire/backfire.4 >"$(DESTDIR)$(mandir)/man4/backfire.4.gz"
++ gzip -c src/cyclictest/cyclictest.8 >"$(DESTDIR)$(mandir)/man8/cyclictest.8.gz"
++ gzip -c src/pi_tests/pi_stress.8 >"$(DESTDIR)$(mandir)/man8/pi_stress.8.gz"
++ gzip -c src/ptsematest/ptsematest.8 >"$(DESTDIR)$(mandir)/man8/ptsematest.8.gz"
++ gzip -c src/sigwaittest/sigwaittest.8 >"$(DESTDIR)$(mandir)/man8/sigwaittest.8.gz"
++ gzip -c src/svsematest/svsematest.8 >"$(DESTDIR)$(mandir)/man8/svsematest.8.gz"
++ gzip -c src/pmqtest/pmqtest.8 >"$(DESTDIR)$(mandir)/man8/pmqtest.8.gz"
++ gzip -c src/backfire/sendme.8 >"$(DESTDIR)$(mandir)/man8/sendme.8.gz"
++ gzip -c src/hackbench/hackbench.8 >"$(DESTDIR)$(mandir)/man8/hackbench.8.gz"
+
+ .PHONY: install_hwlatdetect
+ install_hwlatdetect: hwlatdetect
diff --git a/yocto-poky/meta/recipes-rt/rt-tests/files/hackbench-fix-error-check.patch b/yocto-poky/meta/recipes-rt/rt-tests/files/hackbench-fix-error-check.patch
new file mode 100644
index 000000000..d17fdff45
--- /dev/null
+++ b/yocto-poky/meta/recipes-rt/rt-tests/files/hackbench-fix-error-check.patch
@@ -0,0 +1,41 @@
+childinfo_t is a union that contains both signed (error) and unsigned
+(threadid) members. Thus a large threadid could appear as a negative error
+value, which will cause unexpected failures.
+
+childinfo_t should be changed to a struct, but it could potentially affect the
+performance. So we keep it as a union but only check error against -1. There is
+still a chance of false alarm but it's small.
+
+Upstream-Status: Pending
+
+Signed-off-by: Song.Li <Song.Li@windriver.com>
+Signed-off-by: Jesse Zhang <sen.zhang@windriver.com>
+---
+ src/hackbench/hackbench.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/src/hackbench/hackbench.c b/src/hackbench/hackbench.c
+index 8baeb23..dc0de8f 100644
+--- a/src/hackbench/hackbench.c
++++ b/src/hackbench/hackbench.c
+@@ -317,7 +317,7 @@ static unsigned int group(childinfo_t *child,
+ ctx->wakefd = wakefd;
+
+ child[tab_offset+i] = create_worker(ctx, (void *)(void *)receiver);
+- if( child[tab_offset+i].error < 0 ) {
++ if( child[tab_offset+i].error == -1 ) {
+ return (i > 0 ? i-1 : 0);
+ }
+ snd_ctx->out_fds[i] = fds[1];
+@@ -332,7 +332,7 @@ static unsigned int group(childinfo_t *child,
+ snd_ctx->num_fds = num_fds;
+
+ child[tab_offset+num_fds+i] = create_worker(snd_ctx, (void *)(void *)sender);
+- if( child[tab_offset+num_fds+i].error < 0 ) {
++ if( child[tab_offset+num_fds+i].error == -1 ) {
+ return (num_fds+i)-1;
+ }
+ }
+--
+1.7.9.5
+
diff --git a/yocto-poky/meta/recipes-rt/rt-tests/files/rt_bmark.py b/yocto-poky/meta/recipes-rt/rt-tests/files/rt_bmark.py
new file mode 100755
index 000000000..e2280e43e
--- /dev/null
+++ b/yocto-poky/meta/recipes-rt/rt-tests/files/rt_bmark.py
@@ -0,0 +1,412 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright (C) 2015 Enea Software AB
+# Author: Thomas Lundström <thomas.lundstrom@enea.com>
+
+# The script measures interrupt latency together with different types of
+# system load. This is done using the programs cyclictest and stress.
+#
+# The main output is:
+#
+# Best case (min) latency
+# This has very limited value, but is presented since it can be done
+# easily
+#
+# Average latency
+# This value is of interrest for throughput oriented systems. Limited
+# value for a real-time system. Also presented because it is easy to do.
+#
+# Worst case (max) latency
+# This is the interesting number for a real-time system. The number
+# presented is (of cource) the largest number observed. The challenge
+# is to know how the observed worst case relates to the actual worst case.
+#
+# To get an indication of the confidence, the following method is used:
+# 1) Instead of one long run, the measurement is made as a set of shorter
+# runs. The number of runs must be a power of 2 for reasons that will
+# shorlty be obvious
+#
+# 2) First, a list of the max values are created.
+#
+# 3) The smallest value in that list is recorded.
+#
+# 4) Then a new list is create by taking the max value of each pair of
+# values in the original list. In this list the smallest value is
+# recorded.
+#
+# 5) Step 3 is repeated until there is only one value in the list. See
+# example below:
+#
+# Samples:
+# | 44 | | | | |
+# | 77 | 77 | | | |
+# | 118 | | | | |
+# | 119 | 119 | 119 | | |
+# | 138 | | | | |
+# | 57 | 138 | | | |
+# | 175 | | | | |
+# | 130 | 175 | 175 | 175 | |
+# | 54 | | | | |
+# | 150 | 150 | | | |
+# | 47 | | | | |
+# | 59 | 59 | 150 | | |
+# | 199 | | | | |
+# | 115 | 199 | | | |
+# | 177 | | | | |
+# | 129 | 177 | 199 | 199 | 199 |
+#
+# Smallest value:
+# | 44 | 59 | 119 | 175 | 199 |
+#
+# 6) The generated list of smallest values is analyzed. In this case, it
+# can be observed that the values are increasing significantly through
+# the entire list, which leads to the conclusion that the number of
+# samples is too small.
+# If instead the list had been (167, 191, 196, 199, 199), there had
+# been a very small, or no, increase at the end of the list. We might
+# then suspect that the number of samples is probably large enough.
+# There is however no guarantee for that.
+#
+# Steps 1-2 are done in run_cyclictest_suite
+# Steps 3-5 are done in gen_minmax_list.
+# Step 6 needs to be done manually since there is (yet) no well defined
+# FAIL criterion and a theoretically solid PASS criterion may never be
+# available.
+
+import multiprocessing
+import os
+import re
+import signal
+import subprocess
+import time
+import traceback
+
+# See comment on the function set_hung_tmo
+has_hung_task_detection = True
+
+#-------------------------------------------------------------------------------
+
+class TestFail(Exception):
+ def __init__(self, msg):
+ self.msg = msg
+
+ def __str__(self):
+ return "Test failure: (" + self.msg + ")"
+
+#-------------------------------------------------------------------------------
+
+def tc_name(sub_name):
+ return "rt_bmark.intlat." + sub_name
+
+#-------------------------------------------------------------------------------
+# log() does the same job as print except that a '#' is added at the beginning
+# of each line. This causes TEFEL to ignore it
+
+def log(*msg):
+ tmp = "".join(map(str, msg)) # 'map(str, ...' allows numbers
+ for line in tmp.split("\n"):
+ print "#", line
+
+#-------------------------------------------------------------------------------
+# Like log(), but with a timestamp added
+
+def log_ts(*msg):
+ ts = time.localtime()
+ stamp = "%2d:%02d:%02d: " % (ts.tm_hour, ts.tm_min, ts.tm_sec)
+ log(stamp, *msg)
+
+#-------------------------------------------------------------------------------
+
+def log_test_header(seq_no, nr_of_tests, name):
+ log("=" * 78)
+ log()
+ log(" Test case (%d/%d): %s" % (seq_no, nr_of_tests, tc_name(name)))
+ log()
+ log("." * 78)
+ log()
+
+#-------------------------------------------------------------------------------
+
+def start_stress(*args):
+ stress_cmd = [ "stress" ]
+ added_stress_types = []
+ req_stress_types = set(args)
+ cpu_cnt = str(multiprocessing.cpu_count())
+
+ # The function cond_add_stress appends the options to the stress
+ # command if the stress type is in the set of requested stress types
+
+ def cond_add_stress(stress_type, options):
+ if stress_type in req_stress_types:
+ req_stress_types.remove(stress_type)
+ added_stress_types.append(stress_type)
+ stress_cmd.extend(options)
+
+ #----------
+
+ cond_add_stress("io", ["-i", cpu_cnt])
+ cond_add_stress("cpu", ["-c", cpu_cnt])
+ cond_add_stress("hdd", ["-d", cpu_cnt, "--hdd-bytes", "20M"])
+ cond_add_stress("vm", ["-m", cpu_cnt, "--vm-bytes", "10M"])
+
+ unknown = ", ".join(req_stress_types)
+ if unknown != "":
+ raise TestFail("Unknown stress type(s): %s" % unknown)
+
+ if not added_stress_types:
+ log("No stress requested")
+ return None
+
+ added = "+".join(added_stress_types)
+ stress_cmd_str = " ".join(stress_cmd)
+
+ log("Starting stress(", added, ")")
+ log(" Command: '", stress_cmd_str, "'")
+ log()
+
+ # preexec_fn=os.setsid causes stress to be executed in a separate
+ # session, => it gets a new process group (incl. children). It
+ # can then be terminated using os.killpg in end_stress without
+ # terminating this script.
+
+ p = subprocess.Popen(stress_cmd, preexec_fn=os.setsid)
+
+ return p
+
+#-------------------------------------------------------------------------------
+
+def end_stress(p):
+ if p is None:
+ # The value None indicates that no stress scenario was started
+ return
+
+ if p.poll() is not None:
+ raise TestFail("stress prematurely terminated.")
+
+ os.killpg(os.getpgid(p.pid), signal.SIGTERM)
+ log("Terminated stress")
+
+#-------------------------------------------------------------------------------
+
+def us2hms_str(us):
+ s = (us+500000) // 1000000 # Round microseconds to s
+ m = s//60
+ s -= 60*m;
+ h = m//60
+ m -= 60*h
+
+ return "%d:%02d:%02d" % (h, m, s)
+
+#-------------------------------------------------------------------------------
+# Sometime the hung task supervision is triggered during execution of
+# cyclictest (cyclictest starves stress). To avoid that, the supervision
+# is temporarily disabled
+
+def set_hung_tmo(new_tmo):
+ global has_hung_task_detection
+
+ tmo_file = "/proc/sys/kernel/hung_task_timeout_secs"
+
+ if not has_hung_task_detection:
+ return
+
+ if not os.access(tmo_file, os.W_OK):
+ log("Hung task detection not supported")
+ log(" (File ", tmo_file, " not found)")
+ has_hung_task_detection = False
+ return
+
+ orig_tmo = int(subprocess.check_output(["cat", tmo_file]).strip())
+ if new_tmo != orig_tmo:
+ cmd = ( "echo " + str(new_tmo) + " > " + tmo_file )
+ subprocess.check_output(cmd, shell=True)
+ log("Changed timeout for detection of hung tasks: ",
+ orig_tmo, " -> ", new_tmo)
+
+ return orig_tmo
+
+#-------------------------------------------------------------------------------
+
+def gen_minmax_list(max_list):
+ res = [min(max_list)]
+
+ while True:
+ tmp = max_list
+ max_list = []
+ while tmp:
+ max_list.append(max(tmp.pop(0), tmp.pop(0)))
+
+ res.append(min(max_list))
+
+ if len(max_list) < 2:
+ return res
+
+#-------------------------------------------------------------------------------
+# Parameters for cyclictest:
+#
+# On the -S option (from cyclictest.c):
+# -S implies options -a -t -n and same priority of all threads
+# -a: One thread per core
+# -n: use clock_nanosleep instead of posix interval timers
+# -t: (without argument) Set number of threads to the number
+# of cpus
+
+interval_core_0 = 100 # Timer interval on core 0 [us]
+interval_delta = 20 # Interval increment for each core [us]
+loop_count = 30000 # Number of loops (on core 0).
+
+cmd = ("cyclictest",
+ "-S", # Standard SMP testing. See below
+ "-p", "99", # RT priority 99
+ "-q", # Quiet mode, i.e. print only a summary
+ "-i", str(interval_core_0),
+ "-d", str(interval_delta),
+ "-l", str(loop_count)
+ )
+rex = re.compile("C:\s*(\d+).*Min:\s*(\d+).*Avg:\s*(\d+).*Max:\s*(\d+)")
+
+def run_cyclictest_once():
+ res = subprocess.check_output(cmd)
+
+ # minlist and maxlist are lists with the extremes for each core
+ # avg_cnt is the sum of cycles for all cores
+ # avg_sum is the sum of (cycle count*average) for each core
+ # Since cyclictest runs different number of cycles on
+ # different cores, avg_sum/avg_cnt gives a more accurate
+ # value of the overall average than just taking the average
+ # of each core's averages
+
+ minlist = []
+ maxlist = []
+ avg_sum = 0
+ avg_cnt = 0
+
+ for line in res.split("\n"):
+ m = rex.search(line)
+ if m is not None:
+ minlist.append(int(m.group(2)))
+ maxlist.append(int(m.group(4)))
+ n = int(m.group(1))
+ avg_sum += n * int(m.group(3))
+ avg_cnt += n
+
+ return min(minlist), [avg_sum, avg_cnt], max(maxlist)
+
+#-------------------------------------------------------------------------------
+# A precondition for the tracking of min-max values is that
+# the suite size os a power of 2.
+
+N = 5
+suite_size = 2**N
+
+est_exec_time_once = interval_core_0 * loop_count
+est_exec_time_suite = suite_size * est_exec_time_once
+
+def run_cyclictest_suite():
+ log("Starting cyclictest")
+ log(" Command : ", " ".join(cmd))
+ log(" Number of cycles : ", loop_count*suite_size,
+ " (", suite_size, " sets of ", loop_count, " cycles)")
+ log(" Exec. time (est) : ", us2hms_str(est_exec_time_suite))
+ log()
+
+ orig_tmo = set_hung_tmo(0) # 0 => Disable
+
+ # float('inf') emulates infinity. At least in the sense that it is
+ # guaranteed to be larger than any actual number.
+ ack_min = float('inf')
+ ack_avg = [0, 0]
+
+ log()
+ log_ts("Start of execution")
+ t = time.time()
+ max_list = []
+
+ for i in xrange(0, suite_size):
+ tmp_min, tmp_avg, tmp_max = run_cyclictest_once()
+
+ msg = "%2d/%2d:" % (i+1, suite_size)
+ msg += " min: %4d" % tmp_min
+ msg += " avg: %5.1f" % (float(tmp_avg[0])/tmp_avg[1])
+ msg += " max: %4d" % tmp_max
+ log_ts(msg)
+
+ # Track minimum value
+ if tmp_min < ack_min:
+ ack_min = tmp_min
+
+ # Track smallest max value
+ max_list.append(tmp_max)
+
+ ack_avg[0] += tmp_avg[0]
+ ack_avg[1] += tmp_avg[1]
+
+ t = time.time()-t
+ log_ts("Cyclictest completed. Actual execution time:",
+ us2hms_str(t*1000000))
+ log()
+ set_hung_tmo(orig_tmo)
+
+ return ack_min, float(ack_avg[0])/ack_avg[1], gen_minmax_list(max_list)
+
+#-------------------------------------------------------------------------------
+
+class cyclictest_runner:
+ def run_test(self, seq_no, nr_of_tests, name, stressparams):
+
+ try:
+ log_test_header(seq_no, nr_of_tests, name)
+
+ p = start_stress(*stressparams)
+
+ bm_min, bm_avg, bm_max_list = run_cyclictest_suite()
+
+ end_stress(p)
+
+ bm_max = bm_max_list[-1]
+
+ log()
+ log("Min: %d us" % bm_min)
+ log("Avg: %.1f us" % bm_avg)
+ log("Max: %d us" % bm_max)
+ log()
+ log("Max list: ", bm_max_list)
+ log()
+ log("PASS")
+
+ print
+ print tc_name(name), "[Min/us,Avg/us,Max/us]:",
+ print "%d,%.1f,%d" % (bm_min,bm_avg, bm_max)
+ print "PASS:", tc_name(name)
+ print
+
+ except Exception:
+ log()
+ log("Exception!")
+ log()
+ log("Traceback:", traceback.format_exc())
+ log()
+ log("WD: ", os.getcwd())
+ log()
+ log("FAIL")
+ print
+ print "FAIL:", tc_name(name)
+ print
+
+#-------------------------------------------------------------------------------
+
+runner = cyclictest_runner()
+
+tests = (("no_stress", []),
+ ("cpu", ["cpu"]),
+ ("hdd", ["hdd"]),
+ ("io", ["io"]),
+ ("vm", ["vm"]),
+ ("full", ["io", "cpu", "hdd", "vm"]),
+ )
+
+nr_of_tests = len(tests)
+for seq_no, params in enumerate(tests, start=1):
+ runner.run_test(seq_no, nr_of_tests, *params)
diff --git a/yocto-poky/meta/recipes-rt/rt-tests/files/run-ptest b/yocto-poky/meta/recipes-rt/rt-tests/files/run-ptest
new file mode 100644
index 000000000..8e6d3e358
--- /dev/null
+++ b/yocto-poky/meta/recipes-rt/rt-tests/files/run-ptest
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+python ./rt_bmark.py
diff --git a/yocto-poky/meta/recipes-rt/rt-tests/hwlatdetect_0.92.bb b/yocto-poky/meta/recipes-rt/rt-tests/hwlatdetect_0.92.bb
new file mode 100644
index 000000000..8319eb987
--- /dev/null
+++ b/yocto-poky/meta/recipes-rt/rt-tests/hwlatdetect_0.92.bb
@@ -0,0 +1,23 @@
+SUMMARY = "Hardware latency detector"
+DESCRIPTION = "Python utility for controlling the kernel hardware latency detection module (hwlat_detector.ko)."
+HOMEPAGE = "http://git.kernel.org/?p=linux/kernel/git/clrkwllms/rt-tests.git"
+SECTION = "tests"
+LICENSE = "GPLv2"
+LIC_FILES_CHKSUM = "file://COPYING;md5=751419260aa954499f7abaabaa882bbe"
+
+require rt-tests.inc
+
+EXTRA_OEMAKE += "PYLIB=${libdir}/python${PYTHON_BASEVERSION}/dist-packages"
+
+do_compile() {
+ oe_runmake hwlatdetect
+}
+
+do_install() {
+ oe_runmake install_hwlatdetect DESTDIR=${D} SBINDIR=${sbindir} \
+ MANDIR=${mandir} INCLUDEDIR=${includedir}
+}
+
+FILES_${PN} += "${libdir}/python${PYTHON_BASEVERSION}/dist-packages/hwlatdetect.py"
+RDEPENDS_${PN} = "python python-subprocess python-textutils"
+RRECOMMENDS_${PN} = "kernel-module-hwlat-detector"
diff --git a/yocto-poky/meta/recipes-rt/rt-tests/rt-tests.inc b/yocto-poky/meta/recipes-rt/rt-tests/rt-tests.inc
new file mode 100644
index 000000000..871db136c
--- /dev/null
+++ b/yocto-poky/meta/recipes-rt/rt-tests/rt-tests.inc
@@ -0,0 +1,19 @@
+# Version v0.92
+PV = "0.92"
+SRCREV = "5f9f1e3fe327440a9d405f4af8feb16ff7a909eb"
+
+SRC_URI = "git://git.kernel.org/pub/scm/linux/kernel/git/clrkwllms/rt-tests.git \
+ file://0001-rt-tests-Allow-for-user-specified-PYLIB.patch \
+ file://0002-rt-tests-Break-out-install_hwlatdetect.patch \
+ file://hackbench-fix-error-check.patch \
+ file://Makefile-fix-gzip-command.patch \
+ file://fix-re-install-failure.patch \
+"
+
+S = "${WORKDIR}/git"
+
+# need to append rt-tests' default CFLAGS to ours
+CFLAGS += "-I${S}/src/include -D_GNU_SOURCE -Wall -Wno-nonnull"
+
+# calling 'uname -m' is broken on crossbuilds
+EXTRA_OEMAKE = "NUMA=0"
diff --git a/yocto-poky/meta/recipes-rt/rt-tests/rt-tests_0.92.bb b/yocto-poky/meta/recipes-rt/rt-tests/rt-tests_0.92.bb
new file mode 100644
index 000000000..fbe2f669e
--- /dev/null
+++ b/yocto-poky/meta/recipes-rt/rt-tests/rt-tests_0.92.bb
@@ -0,0 +1,30 @@
+SUMMARY = "Real-Time preemption testcases"
+HOMEPAGE = "https://rt.wiki.kernel.org/index.php/Cyclictest"
+SECTION = "tests"
+DEPENDS = "linux-libc-headers virtual/libc"
+LICENSE = "GPLv2 & GPLv2+"
+LIC_FILES_CHKSUM = "file://COPYING;md5=751419260aa954499f7abaabaa882bbe \
+ file://src/cyclictest/cyclictest.c;beginline=7;endline=9;md5=e768b8da44555fe63f65e5c497844cb5 \
+ file://src/pi_tests/pi_stress.c;beginline=6;endline=19;md5=bd426a634a43ec612e9fbf125dfcc949"
+
+require rt-tests.inc
+inherit ptest
+
+SRC_URI += "file://run-ptest \
+ file://rt_bmark.py \
+ "
+# Do not install hwlatdetect
+EXTRA_OEMAKE += "PYLIB=''"
+
+do_install() {
+ oe_runmake install DESTDIR=${D} SBINDIR=${sbindir} MANDIR=${mandir} \
+ INCLUDEDIR=${includedir}
+}
+
+do_install_ptest() {
+ cp ${WORKDIR}/rt_bmark.py ${D}${PTEST_PATH}
+}
+
+RDEPENDS_${PN}-ptest += " stress python python-subprocess python-multiprocessing python-datetime python-re python-lang"
+
+FILES_${PN} += "${prefix}/src/backfire"
OpenPOWER on IntegriCloud