From bd2dadcf93abd0694d55a73071e753005680662d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Sommer?= Date: Wed, 28 Jun 2023 17:55:13 +0200 Subject: [PATCH] rt-tests: Add DURATION variable to control test duration Running the test for 12h is too long in some cases. It would be better if the duration of the test could be set from outside. With the new environment variable DURATION a user can control the value of the parameter `-D` of cyclictest and set the desired value. --- README.md | 10 +++++++--- rt-tests/rt-tests.sh | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 9f88452..5534ff2 100644 --- a/README.md +++ b/README.md @@ -47,7 +47,7 @@ $ docker run --rm -d --name stress-tests --privileged -v /dev:/dev -v /tmp:/tmp Check if the stress tests started successfully: ``` -$ docker logs stress-tests +$ docker logs stress-tests Setting up stress tests... RT stress tests started successfully! ``` @@ -61,7 +61,11 @@ Run the following command to execute the `rt-tests` container and start measurin $ docker run --rm -it --name rt-tests --cap-add=sys_nice --cap-add=ipc_lock --cap-add=sys_rawio --ulimit rtprio=99 --device-cgroup-rule='c 10:* rmw' -v /dev:/dev -v /tmp:/tmp torizon/rt-tests:$CT_TAG_RT_TESTS ``` -The tests will run for at most 12 hours, but can be interrupted at any time by pressing CTRL-C. +The tests will run for at most 12 hours, but can be interrupted at any time by +pressing CTRL-C. You can specify a different length of the test run in seconds +by passing the environment variable *DURATION* to the container (with +`-e DURATION=…`); for other units append `m` for minutes, `h` for hours and `d` +for days. After the tests are finished, stop the `stress-tests` container: @@ -111,4 +115,4 @@ So if you want to run the `rt-tests` container on a non-PREEMPT_RT version of To ``` sudo sh -c "echo 950000 > /sys/fs/cgroup/cpu,cpuacct/docker/cpu.rt_runtime_us" docker run --rm -it --name rt-tests --cpu-rt-runtime=950000 --cap-add=sys_nice --cap-add=ipc_lock --cap-add=sys_rawio --ulimit rtprio=99 --device-cgroup-rule='c 10:* rmw' -v /dev:/dev -v /tmp:/tmp torizon/rt-tests:$CT_TAG_RT_TESTS -``` \ No newline at end of file +``` diff --git a/rt-tests/rt-tests.sh b/rt-tests/rt-tests.sh index 305a223..9aabce8 100755 --- a/rt-tests/rt-tests.sh +++ b/rt-tests/rt-tests.sh @@ -1,7 +1,7 @@ #!/bin/bash # Run cyclictest -if ! cyclictest -S -p99 -i1000 -m -D12h -h400 -q >output; then +if ! cyclictest -S -p99 -i1000 -m -D${DURATION:-12h} -h400 -q >output; then echo "ERROR: cyclictest failed" >&2 exit 1 fi