aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Fleming <matt.fleming@intel.com>2014-05-29 16:17:26 +0100
committerMatt Fleming <matt.fleming@intel.com>2014-05-30 08:38:00 +0100
commitf2526b7e5c57b422fe3615aaeb637700cc0221f7 (patch)
tree7828e9068a8116acec631044f33fe96a694de56c
parent4d23279438d9135b4947f237129c0c39a7ff260c (diff)
downloadlinux-cqm/pj.tar.gz
tools/testing: Add cacheqos selftestscqm/pj
Signed-off-by: Matt Fleming <matt.fleming@intel.com>
-rw-r--r--tools/testing/selftests/cacheqos/Makefile6
-rw-r--r--tools/testing/selftests/cacheqos/cacheqos.sh63
2 files changed, 69 insertions, 0 deletions
diff --git a/tools/testing/selftests/cacheqos/Makefile b/tools/testing/selftests/cacheqos/Makefile
new file mode 100644
index 0000000000000..d887cee39e3de
--- /dev/null
+++ b/tools/testing/selftests/cacheqos/Makefile
@@ -0,0 +1,6 @@
+all:
+
+run_tests:
+ @/bin/bash ./cacheqos.sh || echo "cacheqos selftests: [FAIL]"
+
+clean:
diff --git a/tools/testing/selftests/cacheqos/cacheqos.sh b/tools/testing/selftests/cacheqos/cacheqos.sh
new file mode 100644
index 0000000000000..8ffea2bf8c961
--- /dev/null
+++ b/tools/testing/selftests/cacheqos/cacheqos.sh
@@ -0,0 +1,63 @@
+#!/bin/bash
+
+sysfs_dir="/sys/fs/cgroup/cacheqos/"
+NR_RMIDS=`dmesg | grep max_rmid | sed -e 's/.*max_rmid=//'`
+
+test1_setup() {
+ for i in $(seq 0 1); do
+
+ # RMID 0 is reserved for *all* tasks
+ for j in $(seq 1 $NR_RMIDS); do
+ mkdir t$i-$j
+ done
+ done
+
+}
+
+test1_cleanup() {
+ for i in $(seq 0 1); do
+ for j in $(seq 1 $NR_RMIDS); do
+ for t in `cat t$i-$j/tasks`; do
+ kill -s SIGCONT $t
+ wait $t
+ done
+ done
+ done
+
+ # Wait for every child process to catch SIGCONT and exit
+ wait
+ rmdir t0-* t1-*
+}
+
+#
+# test1:
+# Ensure that we can create more tasks than we have RMIDs if not all the
+# tasks are running at once.
+#
+# Essentially, fork 2 * NR_RMID tasks and put the first NR_RMID tasks
+# to sleep. NR_RMID+1..2 * NR_RMID should run.
+#
+test1() {
+ test1_setup
+
+ # Create permanently stopped tasks
+ for j in $(seq 1 $NR_RMIDS); do
+ sleep 10&
+ kill -s SIGSTOP $!
+ echo $! > t0-$j/tasks
+ echo 1 > t0-$j/cacheqos.monitor_cache
+ done
+
+ # Create periodically running tasks
+ for j in $(seq 1 $NR_RMIDS); do
+ ( trap "exit 0" SIGCONT ; while :; do sleep 1; done ) &
+ echo $! > t1-$j/tasks
+ echo 1 > t1-$j/cacheqos.monitor_cache
+ done
+
+ test1_cleanup
+}
+
+cd $sysfs_dir
+
+test1