aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/linux/sched.h1
-rw-r--r--kernel/Makefile1
-rw-r--r--kernel/rtmutex-tester.c436
-rw-r--r--kernel/rtmutex.c3
-rw-r--r--kernel/rtmutex_common.h22
-rw-r--r--lib/Kconfig.debug7
-rw-r--r--scripts/rt-tester/check-all.sh21
-rw-r--r--scripts/rt-tester/rt-tester.py222
-rw-r--r--scripts/rt-tester/t2-l1-2rt-sameprio.tst101
-rw-r--r--scripts/rt-tester/t2-l1-pi.tst84
-rw-r--r--scripts/rt-tester/t2-l1-signal.tst79
-rw-r--r--scripts/rt-tester/t2-l2-2rt-deadlock.tst91
-rw-r--r--scripts/rt-tester/t3-l1-pi-1rt.tst95
-rw-r--r--scripts/rt-tester/t3-l1-pi-2rt.tst96
-rw-r--r--scripts/rt-tester/t3-l1-pi-3rt.tst95
-rw-r--r--scripts/rt-tester/t3-l1-pi-signal.tst101
-rw-r--r--scripts/rt-tester/t3-l1-pi-steal.tst99
-rw-r--r--scripts/rt-tester/t3-l2-pi.tst95
-rw-r--r--scripts/rt-tester/t4-l2-pi-deboost.tst127
-rw-r--r--scripts/rt-tester/t5-l4-pi-boost-deboost.tst148
20 files changed, 1923 insertions, 1 deletions
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 6ea23c9af413..edadd13cf53f 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -982,6 +982,7 @@ static inline void put_task_struct(struct task_struct *t)
982#define PF_SPREAD_PAGE 0x01000000 /* Spread page cache over cpuset */ 982#define PF_SPREAD_PAGE 0x01000000 /* Spread page cache over cpuset */
983#define PF_SPREAD_SLAB 0x02000000 /* Spread some slab caches over cpuset */ 983#define PF_SPREAD_SLAB 0x02000000 /* Spread some slab caches over cpuset */
984#define PF_MEMPOLICY 0x10000000 /* Non-default NUMA mempolicy */ 984#define PF_MEMPOLICY 0x10000000 /* Non-default NUMA mempolicy */
985#define PF_MUTEX_TESTER 0x20000000 /* Thread belongs to the rt mutex tester */
985 986
986/* 987/*
987 * Only the _current_ task can read/write to tsk->flags, but other 988 * Only the _current_ task can read/write to tsk->flags, but other
diff --git a/kernel/Makefile b/kernel/Makefile
index f9c92d34cde5..82fb182f6f61 100644
--- a/kernel/Makefile
+++ b/kernel/Makefile
@@ -18,6 +18,7 @@ obj-$(CONFIG_FUTEX) += futex_compat.o
18endif 18endif
19obj-$(CONFIG_RT_MUTEXES) += rtmutex.o 19obj-$(CONFIG_RT_MUTEXES) += rtmutex.o
20obj-$(CONFIG_DEBUG_RT_MUTEXES) += rtmutex-debug.o 20obj-$(CONFIG_DEBUG_RT_MUTEXES) += rtmutex-debug.o
21obj-$(CONFIG_RT_MUTEX_TESTER) += rtmutex-tester.o
21obj-$(CONFIG_GENERIC_ISA_DMA) += dma.o 22obj-$(CONFIG_GENERIC_ISA_DMA) += dma.o
22obj-$(CONFIG_SMP) += cpu.o spinlock.o 23obj-$(CONFIG_SMP) += cpu.o spinlock.o
23obj-$(CONFIG_DEBUG_SPINLOCK) += spinlock.o 24obj-$(CONFIG_DEBUG_SPINLOCK) += spinlock.o
diff --git a/kernel/rtmutex-tester.c b/kernel/rtmutex-tester.c
new file mode 100644
index 000000000000..fe211ba3a5b5
--- /dev/null
+++ b/kernel/rtmutex-tester.c
@@ -0,0 +1,436 @@
1/*
2 * RT-Mutex-tester: scriptable tester for rt mutexes
3 *
4 * started by Thomas Gleixner:
5 *
6 * Copyright (C) 2006, Timesys Corp., Thomas Gleixner <tglx@timesys.com>
7 *
8 */
9#include <linux/config.h>
10#include <linux/kthread.h>
11#include <linux/module.h>
12#include <linux/sched.h>
13#include <linux/smp_lock.h>
14#include <linux/spinlock.h>
15#include <linux/sysdev.h>
16#include <linux/timer.h>
17
18#include "rtmutex.h"
19
20#define MAX_RT_TEST_THREADS 8
21#define MAX_RT_TEST_MUTEXES 8
22
23static spinlock_t rttest_lock;
24static atomic_t rttest_event;
25
26struct test_thread_data {
27 int opcode;
28 int opdata;
29 int mutexes[MAX_RT_TEST_MUTEXES];
30 int bkl;
31 int event;
32 struct sys_device sysdev;
33};
34
35static struct test_thread_data thread_data[MAX_RT_TEST_THREADS];
36static task_t *threads[MAX_RT_TEST_THREADS];
37static struct rt_mutex mutexes[MAX_RT_TEST_MUTEXES];
38
39enum test_opcodes {
40 RTTEST_NOP = 0,
41 RTTEST_SCHEDOT, /* 1 Sched other, data = nice */
42 RTTEST_SCHEDRT, /* 2 Sched fifo, data = prio */
43 RTTEST_LOCK, /* 3 Lock uninterruptible, data = lockindex */
44 RTTEST_LOCKNOWAIT, /* 4 Lock uninterruptible no wait in wakeup, data = lockindex */
45 RTTEST_LOCKINT, /* 5 Lock interruptible, data = lockindex */
46 RTTEST_LOCKINTNOWAIT, /* 6 Lock interruptible no wait in wakeup, data = lockindex */
47 RTTEST_LOCKCONT, /* 7 Continue locking after the wakeup delay */
48 RTTEST_UNLOCK, /* 8 Unlock, data = lockindex */
49 RTTEST_LOCKBKL, /* 9 Lock BKL */
50 RTTEST_UNLOCKBKL, /* 10 Unlock BKL */
51 RTTEST_SIGNAL, /* 11 Signal other test thread, data = thread id */
52 RTTEST_RESETEVENT = 98, /* 98 Reset event counter */
53 RTTEST_RESET = 99, /* 99 Reset all pending operations */
54};
55
56static int handle_op(struct test_thread_data *td, int lockwakeup)
57{
58 struct sched_param schedpar;
59 int i, id, ret = -EINVAL;
60
61 switch(td->opcode) {
62
63 case RTTEST_NOP:
64 return 0;
65
66 case RTTEST_SCHEDOT:
67 schedpar.sched_priority = 0;
68 ret = sched_setscheduler(current, SCHED_NORMAL, &schedpar);
69 if (!ret)
70 set_user_nice(current, 0);
71 return ret;
72
73 case RTTEST_SCHEDRT:
74 schedpar.sched_priority = td->opdata;
75 return sched_setscheduler(current, SCHED_FIFO, &schedpar);
76
77 case RTTEST_LOCKCONT:
78 td->mutexes[td->opdata] = 1;
79 td->event = atomic_add_return(1, &rttest_event);
80 return 0;
81
82 case RTTEST_RESET:
83 for (i = 0; i < MAX_RT_TEST_MUTEXES; i++) {
84 if (td->mutexes[i] == 4) {
85 rt_mutex_unlock(&mutexes[i]);
86 td->mutexes[i] = 0;
87 }
88 }
89
90 if (!lockwakeup && td->bkl == 4) {
91 unlock_kernel();
92 td->bkl = 0;
93 }
94 return 0;
95
96 case RTTEST_RESETEVENT:
97 atomic_set(&rttest_event, 0);
98 return 0;
99
100 default:
101 if (lockwakeup)
102 return ret;
103 }
104
105 switch(td->opcode) {
106
107 case RTTEST_LOCK:
108 case RTTEST_LOCKNOWAIT:
109 id = td->opdata;
110 if (id < 0 || id >= MAX_RT_TEST_MUTEXES)
111 return ret;
112
113 td->mutexes[id] = 1;
114 td->event = atomic_add_return(1, &rttest_event);
115 rt_mutex_lock(&mutexes[id]);
116 td->event = atomic_add_return(1, &rttest_event);
117 td->mutexes[id] = 4;
118 return 0;
119
120 case RTTEST_LOCKINT:
121 case RTTEST_LOCKINTNOWAIT:
122 id = td->opdata;
123 if (id < 0 || id >= MAX_RT_TEST_MUTEXES)
124 return ret;
125
126 td->mutexes[id] = 1;
127 td->event = atomic_add_return(1, &rttest_event);
128 ret = rt_mutex_lock_interruptible(&mutexes[id], 0);
129 td->event = atomic_add_return(1, &rttest_event);
130 td->mutexes[id] = ret ? 0 : 4;
131 return ret ? -EINTR : 0;
132
133 case RTTEST_UNLOCK:
134 id = td->opdata;
135 if (id < 0 || id >= MAX_RT_TEST_MUTEXES || td->mutexes[id] != 4)
136 return ret;
137
138 td->event = atomic_add_return(1, &rttest_event);
139 rt_mutex_unlock(&mutexes[id]);
140 td->event = atomic_add_return(1, &rttest_event);
141 td->mutexes[id] = 0;
142 return 0;
143
144 case RTTEST_LOCKBKL:
145 if (td->bkl)
146 return 0;
147 td->bkl = 1;
148 lock_kernel();
149 td->bkl = 4;
150 return 0;
151
152 case RTTEST_UNLOCKBKL:
153 if (td->bkl != 4)
154 break;
155 unlock_kernel();
156 td->bkl = 0;
157 return 0;
158
159 default:
160 break;
161 }
162 return ret;
163}
164
165/*
166 * Schedule replacement for rtsem_down(). Only called for threads with
167 * PF_MUTEX_TESTER set.
168 *
169 * This allows us to have finegrained control over the event flow.
170 *
171 */
172void schedule_rt_mutex_test(struct rt_mutex *mutex)
173{
174 int tid, op, dat;
175 struct test_thread_data *td;
176
177 /* We have to lookup the task */
178 for (tid = 0; tid < MAX_RT_TEST_THREADS; tid++) {
179 if (threads[tid] == current)
180 break;
181 }
182
183 BUG_ON(tid == MAX_RT_TEST_THREADS);
184
185 td = &thread_data[tid];
186
187 op = td->opcode;
188 dat = td->opdata;
189
190 switch (op) {
191 case RTTEST_LOCK:
192 case RTTEST_LOCKINT:
193 case RTTEST_LOCKNOWAIT:
194 case RTTEST_LOCKINTNOWAIT:
195 if (mutex != &mutexes[dat])
196 break;
197
198 if (td->mutexes[dat] != 1)
199 break;
200
201 td->mutexes[dat] = 2;
202 td->event = atomic_add_return(1, &rttest_event);
203 break;
204
205 case RTTEST_LOCKBKL:
206 default:
207 break;
208 }
209
210 schedule();
211
212
213 switch (op) {
214 case RTTEST_LOCK:
215 case RTTEST_LOCKINT:
216 if (mutex != &mutexes[dat])
217 return;
218
219 if (td->mutexes[dat] != 2)
220 return;
221
222 td->mutexes[dat] = 3;
223 td->event = atomic_add_return(1, &rttest_event);
224 break;
225
226 case RTTEST_LOCKNOWAIT:
227 case RTTEST_LOCKINTNOWAIT:
228 if (mutex != &mutexes[dat])
229 return;
230
231 if (td->mutexes[dat] != 2)
232 return;
233
234 td->mutexes[dat] = 1;
235 td->event = atomic_add_return(1, &rttest_event);
236 return;
237
238 case RTTEST_LOCKBKL:
239 return;
240 default:
241 return;
242 }
243
244 td->opcode = 0;
245
246 for (;;) {
247 set_current_state(TASK_INTERRUPTIBLE);
248
249 if (td->opcode > 0) {
250 int ret;
251
252 set_current_state(TASK_RUNNING);
253 ret = handle_op(td, 1);
254 set_current_state(TASK_INTERRUPTIBLE);
255 if (td->opcode == RTTEST_LOCKCONT)
256 break;
257 td->opcode = ret;
258 }
259
260 /* Wait for the next command to be executed */
261 schedule();
262 }
263
264 /* Restore previous command and data */
265 td->opcode = op;
266 td->opdata = dat;
267}
268
269static int test_func(void *data)
270{
271 struct test_thread_data *td = data;
272 int ret;
273
274 current->flags |= PF_MUTEX_TESTER;
275 allow_signal(SIGHUP);
276
277 for(;;) {
278
279 set_current_state(TASK_INTERRUPTIBLE);
280
281 if (td->opcode > 0) {
282 set_current_state(TASK_RUNNING);
283 ret = handle_op(td, 0);
284 set_current_state(TASK_INTERRUPTIBLE);
285 td->opcode = ret;
286 }
287
288 /* Wait for the next command to be executed */
289 schedule();
290
291 if (signal_pending(current))
292 flush_signals(current);
293
294 if(kthread_should_stop())
295 break;
296 }
297 return 0;
298}
299
300/**
301 * sysfs_test_command - interface for test commands
302 * @dev: thread reference
303 * @buf: command for actual step
304 * @count: length of buffer
305 *
306 * command syntax:
307 *
308 * opcode:data
309 */
310static ssize_t sysfs_test_command(struct sys_device *dev, const char *buf,
311 size_t count)
312{
313 struct test_thread_data *td;
314 char cmdbuf[32];
315 int op, dat, tid;
316
317 td = container_of(dev, struct test_thread_data, sysdev);
318 tid = td->sysdev.id;
319
320 /* strings from sysfs write are not 0 terminated! */
321 if (count >= sizeof(cmdbuf))
322 return -EINVAL;
323
324 /* strip of \n: */
325 if (buf[count-1] == '\n')
326 count--;
327 if (count < 1)
328 return -EINVAL;
329
330 memcpy(cmdbuf, buf, count);
331 cmdbuf[count] = 0;
332
333 if (sscanf(cmdbuf, "%d:%d", &op, &dat) != 2)
334 return -EINVAL;
335
336 switch (op) {
337 case RTTEST_SIGNAL:
338 send_sig(SIGHUP, threads[tid], 0);
339 break;
340
341 default:
342 if (td->opcode > 0)
343 return -EBUSY;
344 td->opdata = dat;
345 td->opcode = op;
346 wake_up_process(threads[tid]);
347 }
348
349 return count;
350}
351
352/**
353 * sysfs_test_status - sysfs interface for rt tester
354 * @dev: thread to query
355 * @buf: char buffer to be filled with thread status info
356 */
357static ssize_t sysfs_test_status(struct sys_device *dev, char *buf)
358{
359 struct test_thread_data *td;
360 char *curr = buf;
361 task_t *tsk;
362 int i;
363
364 td = container_of(dev, struct test_thread_data, sysdev);
365 tsk = threads[td->sysdev.id];
366
367 spin_lock(&rttest_lock);
368
369 curr += sprintf(curr,
370 "O: %4d, E:%8d, S: 0x%08lx, P: %4d, N: %4d, B: %p, K: %d, M:",
371 td->opcode, td->event, tsk->state,
372 (MAX_RT_PRIO - 1) - tsk->prio,
373 (MAX_RT_PRIO - 1) - tsk->normal_prio,
374 tsk->pi_blocked_on, td->bkl);
375
376 for (i = MAX_RT_TEST_MUTEXES - 1; i >=0 ; i--)
377 curr += sprintf(curr, "%d", td->mutexes[i]);
378
379 spin_unlock(&rttest_lock);
380
381 curr += sprintf(curr, ", T: %p, R: %p\n", tsk,
382 mutexes[td->sysdev.id].owner);
383
384 return curr - buf;
385}
386
387static SYSDEV_ATTR(status, 0600, sysfs_test_status, NULL);
388static SYSDEV_ATTR(command, 0600, NULL, sysfs_test_command);
389
390static struct sysdev_class rttest_sysclass = {
391 set_kset_name("rttest"),
392};
393
394static int init_test_thread(int id)
395{
396 thread_data[id].sysdev.cls = &rttest_sysclass;
397 thread_data[id].sysdev.id = id;
398
399 threads[id] = kthread_run(test_func, &thread_data[id], "rt-test-%d", id);
400 if (IS_ERR(threads[id]))
401 return PTR_ERR(threads[id]);
402
403 return sysdev_register(&thread_data[id].sysdev);
404}
405
406static int init_rttest(void)
407{
408 int ret, i;
409
410 spin_lock_init(&rttest_lock);
411
412 for (i = 0; i < MAX_RT_TEST_MUTEXES; i++)
413 rt_mutex_init(&mutexes[i]);
414
415 ret = sysdev_class_register(&rttest_sysclass);
416 if (ret)
417 return ret;
418
419 for (i = 0; i < MAX_RT_TEST_THREADS; i++) {
420 ret = init_test_thread(i);
421 if (ret)
422 break;
423 ret = sysdev_create_file(&thread_data[i].sysdev, &attr_status);
424 if (ret)
425 break;
426 ret = sysdev_create_file(&thread_data[i].sysdev, &attr_command);
427 if (ret)
428 break;
429 }
430
431 printk("Initializing RT-Tester: %s\n", ret ? "Failed" : "OK" );
432
433 return ret;
434}
435
436device_initcall(init_rttest);
diff --git a/kernel/rtmutex.c b/kernel/rtmutex.c
index 937a474fae94..39c8ca0cf526 100644
--- a/kernel/rtmutex.c
+++ b/kernel/rtmutex.c
@@ -640,7 +640,8 @@ rt_mutex_slowlock(struct rt_mutex *lock, int state,
640 640
641 debug_rt_mutex_print_deadlock(&waiter); 641 debug_rt_mutex_print_deadlock(&waiter);
642 642
643 schedule(); 643 if (waiter.task)
644 schedule_rt_mutex(lock);
644 645
645 spin_lock(&lock->wait_lock); 646 spin_lock(&lock->wait_lock);
646 set_current_state(state); 647 set_current_state(state);
diff --git a/kernel/rtmutex_common.h b/kernel/rtmutex_common.h
index 50eed60eb085..e068024eeffc 100644
--- a/kernel/rtmutex_common.h
+++ b/kernel/rtmutex_common.h
@@ -15,6 +15,28 @@
15#include <linux/rtmutex.h> 15#include <linux/rtmutex.h>
16 16
17/* 17/*
18 * The rtmutex in kernel tester is independent of rtmutex debugging. We
19 * call schedule_rt_mutex_test() instead of schedule() for the tasks which
20 * belong to the tester. That way we can delay the wakeup path of those
21 * threads to provoke lock stealing and testing of complex boosting scenarios.
22 */
23#ifdef CONFIG_RT_MUTEX_TESTER
24
25extern void schedule_rt_mutex_test(struct rt_mutex *lock);
26
27#define schedule_rt_mutex(_lock) \
28 do { \
29 if (!(current->flags & PF_MUTEX_TESTER)) \
30 schedule(); \
31 else \
32 schedule_rt_mutex_test(_lock); \
33 } while (0)
34
35#else
36# define schedule_rt_mutex(_lock) schedule()
37#endif
38
39/*
18 * This is the control structure for tasks blocked on a rt_mutex, 40 * This is the control structure for tasks blocked on a rt_mutex,
19 * which is allocated on the kernel stack on of the blocked task. 41 * which is allocated on the kernel stack on of the blocked task.
20 * 42 *
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index 06d3ea1133c9..6afe0af0a19b 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -120,6 +120,13 @@ config DEBUG_PI_LIST
120 default y 120 default y
121 depends on DEBUG_RT_MUTEXES 121 depends on DEBUG_RT_MUTEXES
122 122
123config RT_MUTEX_TESTER
124 bool "Built-in scriptable tester for rt-mutexes"
125 depends on RT_MUTEXES
126 default n
127 help
128 This option enables a rt-mutex tester.
129
123config DEBUG_SPINLOCK 130config DEBUG_SPINLOCK
124 bool "Spinlock debugging" 131 bool "Spinlock debugging"
125 depends on DEBUG_KERNEL 132 depends on DEBUG_KERNEL
diff --git a/scripts/rt-tester/check-all.sh b/scripts/rt-tester/check-all.sh
new file mode 100644
index 000000000000..ac45c3e65a35
--- /dev/null
+++ b/scripts/rt-tester/check-all.sh
@@ -0,0 +1,21 @@
1
2
3function testit ()
4{
5 printf "%-30s: " $1
6 ./rt-tester.py $1 | grep Pass
7}
8
9testit t2-l1-2rt-sameprio.tst
10testit t2-l1-pi.tst
11testit t2-l1-signal.tst
12#testit t2-l2-2rt-deadlock.tst
13testit t3-l1-pi-1rt.tst
14testit t3-l1-pi-2rt.tst
15testit t3-l1-pi-3rt.tst
16testit t3-l1-pi-signal.tst
17testit t3-l1-pi-steal.tst
18testit t3-l2-pi.tst
19testit t4-l2-pi-deboost.tst
20testit t5-l4-pi-boost-deboost.tst
21
diff --git a/scripts/rt-tester/rt-tester.py b/scripts/rt-tester/rt-tester.py
new file mode 100644
index 000000000000..4c79660793cf
--- /dev/null
+++ b/scripts/rt-tester/rt-tester.py
@@ -0,0 +1,222 @@
1#!/usr/bin/env python
2#
3# rt-mutex tester
4#
5# (C) 2006 Thomas Gleixner <tglx@linutronix.de>
6#
7# This program is free software; you can redistribute it and/or modify
8# it under the terms of the GNU General Public License version 2 as
9# published by the Free Software Foundation.
10#
11import os
12import sys
13import getopt
14import shutil
15import string
16
17# Globals
18quiet = 0
19test = 0
20comments = 0
21
22sysfsprefix = "/sys/devices/system/rttest/rttest"
23statusfile = "/status"
24commandfile = "/command"
25
26# Command opcodes
27cmd_opcodes = {
28 "schedother" : "1",
29 "schedfifo" : "2",
30 "lock" : "3",
31 "locknowait" : "4",
32 "lockint" : "5",
33 "lockintnowait" : "6",
34 "lockcont" : "7",
35 "unlock" : "8",
36 "lockbkl" : "9",
37 "unlockbkl" : "10",
38 "signal" : "11",
39 "resetevent" : "98",
40 "reset" : "99",
41 }
42
43test_opcodes = {
44 "prioeq" : ["P" , "eq" , None],
45 "priolt" : ["P" , "lt" , None],
46 "priogt" : ["P" , "gt" , None],
47 "nprioeq" : ["N" , "eq" , None],
48 "npriolt" : ["N" , "lt" , None],
49 "npriogt" : ["N" , "gt" , None],
50 "unlocked" : ["M" , "eq" , 0],
51 "trylock" : ["M" , "eq" , 1],
52 "blocked" : ["M" , "eq" , 2],
53 "blockedwake" : ["M" , "eq" , 3],
54 "locked" : ["M" , "eq" , 4],
55 "opcodeeq" : ["O" , "eq" , None],
56 "opcodelt" : ["O" , "lt" , None],
57 "opcodegt" : ["O" , "gt" , None],
58 "eventeq" : ["E" , "eq" , None],
59 "eventlt" : ["E" , "lt" , None],
60 "eventgt" : ["E" , "gt" , None],
61 }
62
63# Print usage information
64def usage():
65 print "rt-tester.py <-c -h -q -t> <testfile>"
66 print " -c display comments after first command"
67 print " -h help"
68 print " -q quiet mode"
69 print " -t test mode (syntax check)"
70 print " testfile: read test specification from testfile"
71 print " otherwise from stdin"
72 return
73
74# Print progress when not in quiet mode
75def progress(str):
76 if not quiet:
77 print str
78
79# Analyse a status value
80def analyse(val, top, arg):
81
82 intval = int(val)
83
84 if top[0] == "M":
85 intval = intval / (10 ** int(arg))
86 intval = intval % 10
87 argval = top[2]
88 elif top[0] == "O":
89 argval = int(cmd_opcodes.get(arg, arg))
90 else:
91 argval = int(arg)
92
93 # progress("%d %s %d" %(intval, top[1], argval))
94
95 if top[1] == "eq" and intval == argval:
96 return 1
97 if top[1] == "lt" and intval < argval:
98 return 1
99 if top[1] == "gt" and intval > argval:
100 return 1
101 return 0
102
103# Parse the commandline
104try:
105 (options, arguments) = getopt.getopt(sys.argv[1:],'chqt')
106except getopt.GetoptError, ex:
107 usage()
108 sys.exit(1)
109
110# Parse commandline options
111for option, value in options:
112 if option == "-c":
113 comments = 1
114 elif option == "-q":
115 quiet = 1
116 elif option == "-t":
117 test = 1
118 elif option == '-h':
119 usage()
120 sys.exit(0)
121
122# Select the input source
123if arguments:
124 try:
125 fd = open(arguments[0])
126 except Exception,ex:
127 sys.stderr.write("File not found %s\n" %(arguments[0]))
128 sys.exit(1)
129else:
130 fd = sys.stdin
131
132linenr = 0
133
134# Read the test patterns
135while 1:
136
137 linenr = linenr + 1
138 line = fd.readline()
139 if not len(line):
140 break
141
142 line = line.strip()
143 parts = line.split(":")
144
145 if not parts or len(parts) < 1:
146 continue
147
148 if len(parts[0]) == 0:
149 continue
150
151 if parts[0].startswith("#"):
152 if comments > 1:
153 progress(line)
154 continue
155
156 if comments == 1:
157 comments = 2
158
159 progress(line)
160
161 cmd = parts[0].strip().lower()
162 opc = parts[1].strip().lower()
163 tid = parts[2].strip()
164 dat = parts[3].strip()
165
166 try:
167 # Test or wait for a status value
168 if cmd == "t" or cmd == "w":
169 testop = test_opcodes[opc]
170
171 fname = "%s%s%s" %(sysfsprefix, tid, statusfile)
172 if test:
173 print fname
174 continue
175
176 while 1:
177 query = 1
178 fsta = open(fname, 'r')
179 status = fsta.readline().strip()
180 fsta.close()
181 stat = status.split(",")
182 for s in stat:
183 s = s.strip()
184 if s.startswith(testop[0]):
185 # Seperate status value
186 val = s[2:].strip()
187 query = analyse(val, testop, dat)
188 break
189 if query or cmd == "t":
190 break
191
192 progress(" " + status)
193
194 if not query:
195 sys.stderr.write("Test failed in line %d\n" %(linenr))
196 sys.exit(1)
197
198 # Issue a command to the tester
199 elif cmd == "c":
200 cmdnr = cmd_opcodes[opc]
201 # Build command string and sys filename
202 cmdstr = "%s:%s" %(cmdnr, dat)
203 fname = "%s%s%s" %(sysfsprefix, tid, commandfile)
204 if test:
205 print fname
206 continue
207 fcmd = open(fname, 'w')
208 fcmd.write(cmdstr)
209 fcmd.close()
210
211 except Exception,ex:
212 sys.stderr.write(str(ex))
213 sys.stderr.write("\nSyntax error in line %d\n" %(linenr))
214 if not test:
215 fd.close()
216 sys.exit(1)
217
218# Normal exit pass
219print "Pass"
220sys.exit(0)
221
222
diff --git a/scripts/rt-tester/t2-l1-2rt-sameprio.tst b/scripts/rt-tester/t2-l1-2rt-sameprio.tst
new file mode 100644
index 000000000000..a2b6f2aae755
--- /dev/null
+++ b/scripts/rt-tester/t2-l1-2rt-sameprio.tst
@@ -0,0 +1,101 @@
1#
2# RT-Mutex test
3#
4# Op: C(ommand)/T(est)/W(ait)
5# | opcode
6# | | threadid: 0-7
7# | | | opcode argument
8# | | | |
9# C: lock: 0: 0
10#
11# Commands
12#
13# opcode opcode argument
14# schedother nice value
15# schedfifo priority
16# lock lock nr (0-7)
17# locknowait lock nr (0-7)
18# lockint lock nr (0-7)
19# lockintnowait lock nr (0-7)
20# lockcont lock nr (0-7)
21# unlock lock nr (0-7)
22# lockbkl lock nr (0-7)
23# unlockbkl lock nr (0-7)
24# signal 0
25# reset 0
26# resetevent 0
27#
28# Tests / Wait
29#
30# opcode opcode argument
31#
32# prioeq priority
33# priolt priority
34# priogt priority
35# nprioeq normal priority
36# npriolt normal priority
37# npriogt normal priority
38# locked lock nr (0-7)
39# blocked lock nr (0-7)
40# blockedwake lock nr (0-7)
41# unlocked lock nr (0-7)
42# lockedbkl dont care
43# blockedbkl dont care
44# unlockedbkl dont care
45# opcodeeq command opcode or number
46# opcodelt number
47# opcodegt number
48# eventeq number
49# eventgt number
50# eventlt number
51
52#
53# 2 threads 1 lock
54#
55C: resetevent: 0: 0
56W: opcodeeq: 0: 0
57
58# Set schedulers
59C: schedfifo: 0: 80
60W: opcodeeq: 0: 0
61C: schedfifo: 1: 80
62W: opcodeeq: 1: 0
63
64# T0 lock L0
65C: locknowait: 0: 0
66C: locknowait: 1: 0
67W: locked: 0: 0
68W: blocked: 1: 0
69T: prioeq: 0: 80
70
71# T0 unlock L0
72C: unlock: 0: 0
73W: locked: 1: 0
74
75# Verify T0
76W: unlocked: 0: 0
77T: prioeq: 0: 80
78
79# Unlock
80C: unlock: 1: 0
81W: unlocked: 1: 0
82
83# T1,T0 lock L0
84C: locknowait: 1: 0
85C: locknowait: 0: 0
86W: locked: 1: 0
87W: blocked: 0: 0
88T: prioeq: 1: 80
89
90# T1 unlock L0
91C: unlock: 1: 0
92W: locked: 0: 0
93
94# Verify T1
95W: unlocked: 1: 0
96T: prioeq: 1: 80
97
98# Unlock and exit
99C: unlock: 0: 0
100W: unlocked: 0: 0
101
diff --git a/scripts/rt-tester/t2-l1-pi.tst b/scripts/rt-tester/t2-l1-pi.tst
new file mode 100644
index 000000000000..aa4c8940acd6
--- /dev/null
+++ b/scripts/rt-tester/t2-l1-pi.tst
@@ -0,0 +1,84 @@
1#
2# RT-Mutex test
3#
4# Op: C(ommand)/T(est)/W(ait)
5# | opcode
6# | | threadid: 0-7
7# | | | opcode argument
8# | | | |
9# C: lock: 0: 0
10#
11# Commands
12#
13# opcode opcode argument
14# schedother nice value
15# schedfifo priority
16# lock lock nr (0-7)
17# locknowait lock nr (0-7)
18# lockint lock nr (0-7)
19# lockintnowait lock nr (0-7)
20# lockcont lock nr (0-7)
21# unlock lock nr (0-7)
22# lockbkl lock nr (0-7)
23# unlockbkl lock nr (0-7)
24# signal 0
25# reset 0
26# resetevent 0
27#
28# Tests / Wait
29#
30# opcode opcode argument
31#
32# prioeq priority
33# priolt priority
34# priogt priority
35# nprioeq normal priority
36# npriolt normal priority
37# npriogt normal priority
38# locked lock nr (0-7)
39# blocked lock nr (0-7)
40# blockedwake lock nr (0-7)
41# unlocked lock nr (0-7)
42# lockedbkl dont care
43# blockedbkl dont care
44# unlockedbkl dont care
45# opcodeeq command opcode or number
46# opcodelt number
47# opcodegt number
48# eventeq number
49# eventgt number
50# eventlt number
51
52#
53# 2 threads 1 lock with priority inversion
54#
55C: resetevent: 0: 0
56W: opcodeeq: 0: 0
57
58# Set schedulers
59C: schedother: 0: 0
60W: opcodeeq: 0: 0
61C: schedfifo: 1: 80
62W: opcodeeq: 1: 0
63
64# T0 lock L0
65C: locknowait: 0: 0
66W: locked: 0: 0
67
68# T1 lock L0
69C: locknowait: 1: 0
70W: blocked: 1: 0
71T: prioeq: 0: 80
72
73# T0 unlock L0
74C: unlock: 0: 0
75W: locked: 1: 0
76
77# Verify T1
78W: unlocked: 0: 0
79T: priolt: 0: 1
80
81# Unlock and exit
82C: unlock: 1: 0
83W: unlocked: 1: 0
84
diff --git a/scripts/rt-tester/t2-l1-signal.tst b/scripts/rt-tester/t2-l1-signal.tst
new file mode 100644
index 000000000000..c47ba06af209
--- /dev/null
+++ b/scripts/rt-tester/t2-l1-signal.tst
@@ -0,0 +1,79 @@
1#
2# RT-Mutex test
3#
4# Op: C(ommand)/T(est)/W(ait)
5# | opcode
6# | | threadid: 0-7
7# | | | opcode argument
8# | | | |
9# C: lock: 0: 0
10#
11# Commands
12#
13# opcode opcode argument
14# schedother nice value
15# schedfifo priority
16# lock lock nr (0-7)
17# locknowait lock nr (0-7)
18# lockint lock nr (0-7)
19# lockintnowait lock nr (0-7)
20# lockcont lock nr (0-7)
21# unlock lock nr (0-7)
22# lockbkl lock nr (0-7)
23# unlockbkl lock nr (0-7)
24# signal 0
25# reset 0
26# resetevent 0
27#
28# Tests / Wait
29#
30# opcode opcode argument
31#
32# prioeq priority
33# priolt priority
34# priogt priority
35# nprioeq normal priority
36# npriolt normal priority
37# npriogt normal priority
38# locked lock nr (0-7)
39# blocked lock nr (0-7)
40# blockedwake lock nr (0-7)
41# unlocked lock nr (0-7)
42# lockedbkl dont care
43# blockedbkl dont care
44# unlockedbkl dont care
45# opcodeeq command opcode or number
46# opcodelt number
47# opcodegt number
48# eventeq number
49# eventgt number
50# eventlt number
51
52#
53# 2 threads 1 lock with priority inversion
54#
55C: resetevent: 0: 0
56W: opcodeeq: 0: 0
57
58# Set schedulers
59C: schedother: 0: 0
60W: opcodeeq: 0: 0
61C: schedother: 1: 0
62W: opcodeeq: 1: 0
63
64# T0 lock L0
65C: locknowait: 0: 0
66W: locked: 0: 0
67
68# T1 lock L0
69C: lockintnowait: 1: 0
70W: blocked: 1: 0
71
72# Interrupt T1
73C: signal: 1: 0
74W: unlocked: 1: 0
75T: opcodeeq: 1: -4
76
77# Unlock and exit
78C: unlock: 0: 0
79W: unlocked: 0: 0
diff --git a/scripts/rt-tester/t2-l2-2rt-deadlock.tst b/scripts/rt-tester/t2-l2-2rt-deadlock.tst
new file mode 100644
index 000000000000..0cee476b206e
--- /dev/null
+++ b/scripts/rt-tester/t2-l2-2rt-deadlock.tst
@@ -0,0 +1,91 @@
1#
2# RT-Mutex test
3#
4# Op: C(ommand)/T(est)/W(ait)
5# | opcode
6# | | threadid: 0-7
7# | | | opcode argument
8# | | | |
9# C: lock: 0: 0
10#
11# Commands
12#
13# opcode opcode argument
14# schedother nice value
15# schedfifo priority
16# lock lock nr (0-7)
17# locknowait lock nr (0-7)
18# lockint lock nr (0-7)
19# lockintnowait lock nr (0-7)
20# lockcont lock nr (0-7)
21# unlock lock nr (0-7)
22# lockbkl lock nr (0-7)
23# unlockbkl lock nr (0-7)
24# signal 0
25# reset 0
26# resetevent 0
27#
28# Tests / Wait
29#
30# opcode opcode argument
31#
32# prioeq priority
33# priolt priority
34# priogt priority
35# nprioeq normal priority
36# npriolt normal priority
37# npriogt normal priority
38# locked lock nr (0-7)
39# blocked lock nr (0-7)
40# blockedwake lock nr (0-7)
41# unlocked lock nr (0-7)
42# lockedbkl dont care
43# blockedbkl dont care
44# unlockedbkl dont care
45# opcodeeq command opcode or number
46# opcodelt number
47# opcodegt number
48# eventeq number
49# eventgt number
50# eventlt number
51
52#
53# 2 threads 2 lock
54#
55C: resetevent: 0: 0
56W: opcodeeq: 0: 0
57
58# Set schedulers
59C: schedfifo: 0: 80
60W: opcodeeq: 0: 0
61C: schedfifo: 1: 80
62W: opcodeeq: 1: 0
63
64# T0 lock L0
65C: locknowait: 0: 0
66W: locked: 0: 0
67
68# T1 lock L1
69C: locknowait: 1: 1
70W: locked: 1: 1
71
72# T0 lock L1
73C: lockintnowait: 0: 1
74W: blocked: 0: 1
75
76# T1 lock L0
77C: lockintnowait: 1: 0
78W: blocked: 1: 0
79
80# Make deadlock go away
81C: signal: 1: 0
82W: unlocked: 1: 0
83C: signal: 0: 0
84W: unlocked: 0: 1
85
86# Unlock and exit
87C: unlock: 0: 0
88W: unlocked: 0: 0
89C: unlock: 1: 1
90W: unlocked: 1: 1
91
diff --git a/scripts/rt-tester/t3-l1-pi-1rt.tst b/scripts/rt-tester/t3-l1-pi-1rt.tst
new file mode 100644
index 000000000000..a5eaf7ed5d54
--- /dev/null
+++ b/scripts/rt-tester/t3-l1-pi-1rt.tst
@@ -0,0 +1,95 @@
1#
2# rt-mutex test
3#
4# Op: C(ommand)/T(est)/W(ait)
5# | opcode
6# | | threadid: 0-7
7# | | | opcode argument
8# | | | |
9# C: lock: 0: 0
10#
11# Commands
12#
13# opcode opcode argument
14# schedother nice value
15# schedfifo priority
16# lock lock nr (0-7)
17# locknowait lock nr (0-7)
18# lockint lock nr (0-7)
19# lockintnowait lock nr (0-7)
20# lockcont lock nr (0-7)
21# unlock lock nr (0-7)
22# lockbkl lock nr (0-7)
23# unlockbkl lock nr (0-7)
24# signal thread to signal (0-7)
25# reset 0
26# resetevent 0
27#
28# Tests / Wait
29#
30# opcode opcode argument
31#
32# prioeq priority
33# priolt priority
34# priogt priority
35# nprioeq normal priority
36# npriolt normal priority
37# npriogt normal priority
38# locked lock nr (0-7)
39# blocked lock nr (0-7)
40# blockedwake lock nr (0-7)
41# unlocked lock nr (0-7)
42# lockedbkl dont care
43# blockedbkl dont care
44# unlockedbkl dont care
45# opcodeeq command opcode or number
46# opcodelt number
47# opcodegt number
48# eventeq number
49# eventgt number
50# eventlt number
51
52#
53# 3 threads 1 lock PI
54#
55C: resetevent: 0: 0
56W: opcodeeq: 0: 0
57
58# Set schedulers
59C: schedother: 0: 0
60W: opcodeeq: 0: 0
61C: schedother: 1: 0
62W: opcodeeq: 1: 0
63C: schedfifo: 2: 82
64W: opcodeeq: 2: 0
65
66# T0 lock L0
67C: locknowait: 0: 0
68W: locked: 0: 0
69
70# T1 lock L0
71C: locknowait: 1: 0
72W: blocked: 1: 0
73T: priolt: 0: 1
74
75# T2 lock L0
76C: locknowait: 2: 0
77W: blocked: 2: 0
78T: prioeq: 0: 82
79
80# T0 unlock L0
81C: unlock: 0: 0
82
83# Wait until T2 got the lock
84W: locked: 2: 0
85W: unlocked: 0: 0
86T: priolt: 0: 1
87
88# T2 unlock L0
89C: unlock: 2: 0
90
91W: unlocked: 2: 0
92W: locked: 1: 0
93
94C: unlock: 1: 0
95W: unlocked: 1: 0
diff --git a/scripts/rt-tester/t3-l1-pi-2rt.tst b/scripts/rt-tester/t3-l1-pi-2rt.tst
new file mode 100644
index 000000000000..c622391a8afe
--- /dev/null
+++ b/scripts/rt-tester/t3-l1-pi-2rt.tst
@@ -0,0 +1,96 @@
1#
2# rt-mutex test
3#
4# Op: C(ommand)/T(est)/W(ait)
5# | opcode
6# | | threadid: 0-7
7# | | | opcode argument
8# | | | |
9# C: lock: 0: 0
10#
11# Commands
12#
13# opcode opcode argument
14# schedother nice value
15# schedfifo priority
16# lock lock nr (0-7)
17# locknowait lock nr (0-7)
18# lockint lock nr (0-7)
19# lockintnowait lock nr (0-7)
20# lockcont lock nr (0-7)
21# unlock lock nr (0-7)
22# lockbkl lock nr (0-7)
23# unlockbkl lock nr (0-7)
24# signal thread to signal (0-7)
25# reset 0
26# resetevent 0
27#
28# Tests / Wait
29#
30# opcode opcode argument
31#
32# prioeq priority
33# priolt priority
34# priogt priority
35# nprioeq normal priority
36# npriolt normal priority
37# npriogt normal priority
38# locked lock nr (0-7)
39# blocked lock nr (0-7)
40# blockedwake lock nr (0-7)
41# unlocked lock nr (0-7)
42# lockedbkl dont care
43# blockedbkl dont care
44# unlockedbkl dont care
45# opcodeeq command opcode or number
46# opcodelt number
47# opcodegt number
48# eventeq number
49# eventgt number
50# eventlt number
51
52#
53# 3 threads 1 lock PI
54#
55C: resetevent: 0: 0
56W: opcodeeq: 0: 0
57
58# Set schedulers
59C: schedother: 0: 0
60W: opcodeeq: 0: 0
61C: schedfifo: 1: 81
62W: opcodeeq: 1: 0
63C: schedfifo: 2: 82
64W: opcodeeq: 2: 0
65
66# T0 lock L0
67C: locknowait: 0: 0
68W: locked: 0: 0
69
70# T1 lock L0
71C: locknowait: 1: 0
72W: blocked: 1: 0
73T: prioeq: 0: 81
74
75# T2 lock L0
76C: locknowait: 2: 0
77W: blocked: 2: 0
78T: prioeq: 0: 82
79T: prioeq: 1: 81
80
81# T0 unlock L0
82C: unlock: 0: 0
83
84# Wait until T2 got the lock
85W: locked: 2: 0
86W: unlocked: 0: 0
87T: priolt: 0: 1
88
89# T2 unlock L0
90C: unlock: 2: 0
91
92W: unlocked: 2: 0
93W: locked: 1: 0
94
95C: unlock: 1: 0
96W: unlocked: 1: 0
diff --git a/scripts/rt-tester/t3-l1-pi-3rt.tst b/scripts/rt-tester/t3-l1-pi-3rt.tst
new file mode 100644
index 000000000000..b5057fb13e09
--- /dev/null
+++ b/scripts/rt-tester/t3-l1-pi-3rt.tst
@@ -0,0 +1,95 @@
1#
2# rt-mutex test
3#
4# Op: C(ommand)/T(est)/W(ait)
5# | opcode
6# | | threadid: 0-7
7# | | | opcode argument
8# | | | |
9# C: lock: 0: 0
10#
11# Commands
12#
13# opcode opcode argument
14# schedother nice value
15# schedfifo priority
16# lock lock nr (0-7)
17# locknowait lock nr (0-7)
18# lockint lock nr (0-7)
19# lockintnowait lock nr (0-7)
20# lockcont lock nr (0-7)
21# unlock lock nr (0-7)
22# lockbkl lock nr (0-7)
23# unlockbkl lock nr (0-7)
24# signal thread to signal (0-7)
25# reset 0
26# resetevent 0
27#
28# Tests / Wait
29#
30# opcode opcode argument
31#
32# prioeq priority
33# priolt priority
34# priogt priority
35# nprioeq normal priority
36# npriolt normal priority
37# npriogt normal priority
38# locked lock nr (0-7)
39# blocked lock nr (0-7)
40# blockedwake lock nr (0-7)
41# unlocked lock nr (0-7)
42# lockedbkl dont care
43# blockedbkl dont care
44# unlockedbkl dont care
45# opcodeeq command opcode or number
46# opcodelt number
47# opcodegt number
48# eventeq number
49# eventgt number
50# eventlt number
51
52#
53# 3 threads 1 lock PI
54#
55C: resetevent: 0: 0
56W: opcodeeq: 0: 0
57
58# Set schedulers
59C: schedfifo: 0: 80
60W: opcodeeq: 0: 0
61C: schedfifo: 1: 81
62W: opcodeeq: 1: 0
63C: schedfifo: 2: 82
64W: opcodeeq: 2: 0
65
66# T0 lock L0
67C: locknowait: 0: 0
68W: locked: 0: 0
69
70# T1 lock L0
71C: locknowait: 1: 0
72W: blocked: 1: 0
73T: prioeq: 0: 81
74
75# T2 lock L0
76C: locknowait: 2: 0
77W: blocked: 2: 0
78T: prioeq: 0: 82
79
80# T0 unlock L0
81C: unlock: 0: 0
82
83# Wait until T2 got the lock
84W: locked: 2: 0
85W: unlocked: 0: 0
86T: prioeq: 0: 80
87
88# T2 unlock L0
89C: unlock: 2: 0
90
91W: locked: 1: 0
92W: unlocked: 2: 0
93
94C: unlock: 1: 0
95W: unlocked: 1: 0
diff --git a/scripts/rt-tester/t3-l1-pi-signal.tst b/scripts/rt-tester/t3-l1-pi-signal.tst
new file mode 100644
index 000000000000..3e427daa33ff
--- /dev/null
+++ b/scripts/rt-tester/t3-l1-pi-signal.tst
@@ -0,0 +1,101 @@
1#
2# rt-mutex test
3#
4# Op: C(ommand)/T(est)/W(ait)
5# | opcode
6# | | threadid: 0-7
7# | | | opcode argument
8# | | | |
9# C: lock: 0: 0
10#
11# Commands
12#
13# opcode opcode argument
14# schedother nice value
15# schedfifo priority
16# lock lock nr (0-7)
17# locknowait lock nr (0-7)
18# lockint lock nr (0-7)
19# lockintnowait lock nr (0-7)
20# lockcont lock nr (0-7)
21# unlock lock nr (0-7)
22# lockbkl lock nr (0-7)
23# unlockbkl lock nr (0-7)
24# signal thread to signal (0-7)
25# reset 0
26# resetevent 0
27#
28# Tests / Wait
29#
30# opcode opcode argument
31#
32# prioeq priority
33# priolt priority
34# priogt priority
35# nprioeq normal priority
36# npriolt normal priority
37# npriogt normal priority
38# locked lock nr (0-7)
39# blocked lock nr (0-7)
40# blockedwake lock nr (0-7)
41# unlocked lock nr (0-7)
42# lockedbkl dont care
43# blockedbkl dont care
44# unlockedbkl dont care
45# opcodeeq command opcode or number
46# opcodelt number
47# opcodegt number
48# eventeq number
49# eventgt number
50# eventlt number
51
52# Reset event counter
53C: resetevent: 0: 0
54W: opcodeeq: 0: 0
55
56# Set priorities
57C: schedother: 0: 0
58W: opcodeeq: 0: 0
59C: schedfifo: 1: 80
60W: opcodeeq: 1: 0
61C: schedfifo: 2: 81
62W: opcodeeq: 2: 0
63
64# T0 lock L0
65C: lock: 0: 0
66W: locked: 0: 0
67
68# T1 lock L0, no wait in the wakeup path
69C: locknowait: 1: 0
70W: blocked: 1: 0
71T: prioeq: 0: 80
72T: prioeq: 1: 80
73
74# T2 lock L0 interruptible, no wait in the wakeup path
75C: lockintnowait: 2: 0
76W: blocked: 2: 0
77T: prioeq: 0: 81
78T: prioeq: 1: 80
79
80# Interrupt T2
81C: signal: 2: 2
82W: unlocked: 2: 0
83T: prioeq: 1: 80
84T: prioeq: 0: 80
85
86T: locked: 0: 0
87T: blocked: 1: 0
88
89# T0 unlock L0
90C: unlock: 0: 0
91
92# Wait until T1 has locked L0 and exit
93W: locked: 1: 0
94W: unlocked: 0: 0
95T: priolt: 0: 1
96
97C: unlock: 1: 0
98W: unlocked: 1: 0
99
100
101
diff --git a/scripts/rt-tester/t3-l1-pi-steal.tst b/scripts/rt-tester/t3-l1-pi-steal.tst
new file mode 100644
index 000000000000..72c24a9e4be4
--- /dev/null
+++ b/scripts/rt-tester/t3-l1-pi-steal.tst
@@ -0,0 +1,99 @@
1#
2# rt-mutex test
3#
4# Op: C(ommand)/T(est)/W(ait)
5# | opcode
6# | | threadid: 0-7
7# | | | opcode argument
8# | | | |
9# C: lock: 0: 0
10#
11# Commands
12#
13# opcode opcode argument
14# schedother nice value
15# schedfifo priority
16# lock lock nr (0-7)
17# locknowait lock nr (0-7)
18# lockint lock nr (0-7)
19# lockintnowait lock nr (0-7)
20# lockcont lock nr (0-7)
21# unlock lock nr (0-7)
22# lockbkl lock nr (0-7)
23# unlockbkl lock nr (0-7)
24# signal thread to signal (0-7)
25# reset 0
26# resetevent 0
27#
28# Tests / Wait
29#
30# opcode opcode argument
31#
32# prioeq priority
33# priolt priority
34# priogt priority
35# nprioeq normal priority
36# npriolt normal priority
37# npriogt normal priority
38# locked lock nr (0-7)
39# blocked lock nr (0-7)
40# blockedwake lock nr (0-7)
41# unlocked lock nr (0-7)
42# lockedbkl dont care
43# blockedbkl dont care
44# unlockedbkl dont care
45# opcodeeq command opcode or number
46# opcodelt number
47# opcodegt number
48# eventeq number
49# eventgt number
50# eventlt number
51
52#
53# 3 threads 1 lock PI steal pending ownership
54#
55C: resetevent: 0: 0
56W: opcodeeq: 0: 0
57
58# Set schedulers
59C: schedother: 0: 0
60W: opcodeeq: 0: 0
61C: schedfifo: 1: 80
62W: opcodeeq: 1: 0
63C: schedfifo: 2: 81
64W: opcodeeq: 2: 0
65
66# T0 lock L0
67C: lock: 0: 0
68W: locked: 0: 0
69
70# T1 lock L0
71C: lock: 1: 0
72W: blocked: 1: 0
73T: prioeq: 0: 80
74
75# T0 unlock L0
76C: unlock: 0: 0
77
78# Wait until T1 is in the wakeup loop
79W: blockedwake: 1: 0
80T: priolt: 0: 1
81
82# T2 lock L0
83C: lock: 2: 0
84# T1 leave wakeup loop
85C: lockcont: 1: 0
86
87# T2 must have the lock and T1 must be blocked
88W: locked: 2: 0
89W: blocked: 1: 0
90
91# T2 unlock L0
92C: unlock: 2: 0
93
94# Wait until T1 is in the wakeup loop and let it run
95W: blockedwake: 1: 0
96C: lockcont: 1: 0
97W: locked: 1: 0
98C: unlock: 1: 0
99W: unlocked: 1: 0
diff --git a/scripts/rt-tester/t3-l2-pi.tst b/scripts/rt-tester/t3-l2-pi.tst
new file mode 100644
index 000000000000..2ba0dced48fa
--- /dev/null
+++ b/scripts/rt-tester/t3-l2-pi.tst
@@ -0,0 +1,95 @@
1#
2# rt-mutex test
3#
4# Op: C(ommand)/T(est)/W(ait)
5# | opcode
6# | | threadid: 0-7
7# | | | opcode argument
8# | | | |
9# C: lock: 0: 0
10#
11# Commands
12#
13# opcode opcode argument
14# schedother nice value
15# schedfifo priority
16# lock lock nr (0-7)
17# locknowait lock nr (0-7)
18# lockint lock nr (0-7)
19# lockintnowait lock nr (0-7)
20# lockcont lock nr (0-7)
21# unlock lock nr (0-7)
22# lockbkl lock nr (0-7)
23# unlockbkl lock nr (0-7)
24# signal thread to signal (0-7)
25# reset 0
26# resetevent 0
27#
28# Tests / Wait
29#
30# opcode opcode argument
31#
32# prioeq priority
33# priolt priority
34# priogt priority
35# nprioeq normal priority
36# npriolt normal priority
37# npriogt normal priority
38# locked lock nr (0-7)
39# blocked lock nr (0-7)
40# blockedwake lock nr (0-7)
41# unlocked lock nr (0-7)
42# lockedbkl dont care
43# blockedbkl dont care
44# unlockedbkl dont care
45# opcodeeq command opcode or number
46# opcodelt number
47# opcodegt number
48# eventeq number
49# eventgt number
50# eventlt number
51
52#
53# 3 threads 2 lock PI
54#
55C: resetevent: 0: 0
56W: opcodeeq: 0: 0
57
58# Set schedulers
59C: schedother: 0: 0
60W: opcodeeq: 0: 0
61C: schedother: 1: 0
62W: opcodeeq: 1: 0
63C: schedfifo: 2: 82
64W: opcodeeq: 2: 0
65
66# T0 lock L0
67C: locknowait: 0: 0
68W: locked: 0: 0
69
70# T1 lock L0
71C: locknowait: 1: 0
72W: blocked: 1: 0
73T: priolt: 0: 1
74
75# T2 lock L0
76C: locknowait: 2: 0
77W: blocked: 2: 0
78T: prioeq: 0: 82
79
80# T0 unlock L0
81C: unlock: 0: 0
82
83# Wait until T2 got the lock
84W: locked: 2: 0
85W: unlocked: 0: 0
86T: priolt: 0: 1
87
88# T2 unlock L0
89C: unlock: 2: 0
90
91W: unlocked: 2: 0
92W: locked: 1: 0
93
94C: unlock: 1: 0
95W: unlocked: 1: 0
diff --git a/scripts/rt-tester/t4-l2-pi-deboost.tst b/scripts/rt-tester/t4-l2-pi-deboost.tst
new file mode 100644
index 000000000000..01f1a80fa02a
--- /dev/null
+++ b/scripts/rt-tester/t4-l2-pi-deboost.tst
@@ -0,0 +1,127 @@
1#
2# rt-mutex test
3#
4# Op: C(ommand)/T(est)/W(ait)
5# | opcode
6# | | threadid: 0-7
7# | | | opcode argument
8# | | | |
9# C: lock: 0: 0
10#
11# Commands
12#
13# opcode opcode argument
14# schedother nice value
15# schedfifo priority
16# lock lock nr (0-7)
17# locknowait lock nr (0-7)
18# lockint lock nr (0-7)
19# lockintnowait lock nr (0-7)
20# lockcont lock nr (0-7)
21# unlock lock nr (0-7)
22# lockbkl lock nr (0-7)
23# unlockbkl lock nr (0-7)
24# signal thread to signal (0-7)
25# reset 0
26# resetevent 0
27#
28# Tests / Wait
29#
30# opcode opcode argument
31#
32# prioeq priority
33# priolt priority
34# priogt priority
35# nprioeq normal priority
36# npriolt normal priority
37# npriogt normal priority
38# locked lock nr (0-7)
39# blocked lock nr (0-7)
40# blockedwake lock nr (0-7)
41# unlocked lock nr (0-7)
42# lockedbkl dont care
43# blockedbkl dont care
44# unlockedbkl dont care
45# opcodeeq command opcode or number
46# opcodelt number
47# opcodegt number
48# eventeq number
49# eventgt number
50# eventlt number
51
52#
53# 4 threads 2 lock PI
54#
55C: resetevent: 0: 0
56W: opcodeeq: 0: 0
57
58# Set schedulers
59C: schedother: 0: 0
60W: opcodeeq: 0: 0
61C: schedother: 1: 0
62W: opcodeeq: 1: 0
63C: schedfifo: 2: 82
64W: opcodeeq: 2: 0
65C: schedfifo: 3: 83
66W: opcodeeq: 3: 0
67
68# T0 lock L0
69C: locknowait: 0: 0
70W: locked: 0: 0
71
72# T1 lock L1
73C: locknowait: 1: 1
74W: locked: 1: 1
75
76# T3 lock L0
77C: lockintnowait: 3: 0
78W: blocked: 3: 0
79T: prioeq: 0: 83
80
81# T0 lock L1
82C: lock: 0: 1
83W: blocked: 0: 1
84T: prioeq: 1: 83
85
86# T1 unlock L1
87C: unlock: 1: 1
88
89# Wait until T0 is in the wakeup code
90W: blockedwake: 0: 1
91
92# Verify that T1 is unboosted
93W: unlocked: 1: 1
94T: priolt: 1: 1
95
96# T2 lock L1 (T0 is boosted and pending owner !)
97C: locknowait: 2: 1
98W: blocked: 2: 1
99T: prioeq: 0: 83
100
101# Interrupt T3 and wait until T3 returned
102C: signal: 3: 0
103W: unlocked: 3: 0
104
105# Verify prio of T0 (still pending owner,
106# but T2 is enqueued due to the previous boost by T3
107T: prioeq: 0: 82
108
109# Let T0 continue
110C: lockcont: 0: 1
111W: locked: 0: 1
112
113# Unlock L1 and let T2 get L1
114C: unlock: 0: 1
115W: locked: 2: 1
116
117# Verify that T0 is unboosted
118W: unlocked: 0: 1
119T: priolt: 0: 1
120
121# Unlock everything and exit
122C: unlock: 2: 1
123W: unlocked: 2: 1
124
125C: unlock: 0: 0
126W: unlocked: 0: 0
127
diff --git a/scripts/rt-tester/t5-l4-pi-boost-deboost.tst b/scripts/rt-tester/t5-l4-pi-boost-deboost.tst
new file mode 100644
index 000000000000..efa0788c1189
--- /dev/null
+++ b/scripts/rt-tester/t5-l4-pi-boost-deboost.tst
@@ -0,0 +1,148 @@
1#
2# rt-mutex test
3#
4# Op: C(ommand)/T(est)/W(ait)
5# | opcode
6# | | threadid: 0-7
7# | | | opcode argument
8# | | | |
9# C: lock: 0: 0
10#
11# Commands
12#
13# opcode opcode argument
14# schedother nice value
15# schedfifo priority
16# lock lock nr (0-7)
17# locknowait lock nr (0-7)
18# lockint lock nr (0-7)
19# lockintnowait lock nr (0-7)
20# lockcont lock nr (0-7)
21# unlock lock nr (0-7)
22# lockbkl lock nr (0-7)
23# unlockbkl lock nr (0-7)
24# signal thread to signal (0-7)
25# reset 0
26# resetevent 0
27#
28# Tests / Wait
29#
30# opcode opcode argument
31#
32# prioeq priority
33# priolt priority
34# priogt priority
35# nprioeq normal priority
36# npriolt normal priority
37# npriogt normal priority
38# locked lock nr (0-7)
39# blocked lock nr (0-7)
40# blockedwake lock nr (0-7)
41# unlocked lock nr (0-7)
42# lockedbkl dont care
43# blockedbkl dont care
44# unlockedbkl dont care
45# opcodeeq command opcode or number
46# opcodelt number
47# opcodegt number
48# eventeq number
49# eventgt number
50# eventlt number
51
52#
53# 5 threads 4 lock PI
54#
55C: resetevent: 0: 0
56W: opcodeeq: 0: 0
57
58# Set schedulers
59C: schedother: 0: 0
60W: opcodeeq: 0: 0
61C: schedfifo: 1: 81
62W: opcodeeq: 1: 0
63C: schedfifo: 2: 82
64W: opcodeeq: 2: 0
65C: schedfifo: 3: 83
66W: opcodeeq: 3: 0
67C: schedfifo: 4: 84
68W: opcodeeq: 4: 0
69
70# T0 lock L0
71C: locknowait: 0: 0
72W: locked: 0: 0
73
74# T1 lock L1
75C: locknowait: 1: 1
76W: locked: 1: 1
77
78# T1 lock L0
79C: lockintnowait: 1: 0
80W: blocked: 1: 0
81T: prioeq: 0: 81
82
83# T2 lock L2
84C: locknowait: 2: 2
85W: locked: 2: 2
86
87# T2 lock L1
88C: lockintnowait: 2: 1
89W: blocked: 2: 1
90T: prioeq: 0: 82
91T: prioeq: 1: 82
92
93# T3 lock L3
94C: locknowait: 3: 3
95W: locked: 3: 3
96
97# T3 lock L2
98C: lockintnowait: 3: 2
99W: blocked: 3: 2
100T: prioeq: 0: 83
101T: prioeq: 1: 83
102T: prioeq: 2: 83
103
104# T4 lock L3
105C: lockintnowait: 4: 3
106W: blocked: 4: 3
107T: prioeq: 0: 84
108T: prioeq: 1: 84
109T: prioeq: 2: 84
110T: prioeq: 3: 84
111
112# Signal T4
113C: signal: 4: 0
114W: unlocked: 4: 3
115T: prioeq: 0: 83
116T: prioeq: 1: 83
117T: prioeq: 2: 83
118T: prioeq: 3: 83
119
120# Signal T3
121C: signal: 3: 0
122W: unlocked: 3: 2
123T: prioeq: 0: 82
124T: prioeq: 1: 82
125T: prioeq: 2: 82
126
127# Signal T2
128C: signal: 2: 0
129W: unlocked: 2: 1
130T: prioeq: 0: 81
131T: prioeq: 1: 81
132
133# Signal T1
134C: signal: 1: 0
135W: unlocked: 1: 0
136T: priolt: 0: 1
137
138# Unlock and exit
139C: unlock: 3: 3
140C: unlock: 2: 2
141C: unlock: 1: 1
142C: unlock: 0: 0
143
144W: unlocked: 3: 3
145W: unlocked: 2: 2
146W: unlocked: 1: 1
147W: unlocked: 0: 0
148