Skip to content

Commit 2c2289e

Browse files
committed
stressapptest: add validation run.sh and README
- Support for common CLI arguments and safe/dry-run modes - Dynamic resource detection (CPUs, memory, disk, network) - Strict mode checking for OOM, panics, I/O errors - Default localhost fallback if no IP is detected - Added README.md with install instructions, examples, and usage Signed-off-by: Srikanth Muppandam <[email protected]>
1 parent a1ee177 commit 2c2289e

File tree

2 files changed

+800
-0
lines changed

2 files changed

+800
-0
lines changed
Lines changed: 231 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,231 @@
1+
# Stressapptest Validation
2+
3+
This test validates system stability using [stressapptest](https://github.com/stressapptest/stressapptest).
4+
5+
## Overview
6+
7+
`stressapptest` is a stress-testing tool for CPU, memory, disk and networking, widely used in reliability testing for servers and embedded systems.
8+
9+
This wrapper script adds:
10+
11+
- **Cgroup-aware** memory sizing with safety guards
12+
- **Safe** and **Strict** modes
13+
- Post-run **dmesg** scanning (toggleable)
14+
- Auto detection for CPUs / memory / mounts / IP
15+
- Optional **auto** setup for disk and network tests
16+
- Looping with per-loop and aggregate **JSON** summaries
17+
- CPU pinning via **taskset** (if available) or **cpuset cgroups** (root, when supported)
18+
19+
## Prerequisites
20+
21+
- `stressapptest` must be installed and available in `PATH`.
22+
23+
Optional tools (the wrapper works without them, but features degrade gracefully):
24+
25+
- `taskset` (if present, used for CPU pinning)
26+
- Writable **cpuset** cgroups (kernel feature; used for pinning when `taskset` is absent)
27+
- `df` (for auto disk selection), `ip`/`hostname` (for auto network)
28+
- `getconf`/**`nproc`** (or `/proc/cpuinfo`) for CPU counting
29+
30+
Build from source (typical host):
31+
```bash
32+
git clone https://github.com/stressapptest/stressapptest.git
33+
cd stressapptest
34+
./configure
35+
make
36+
sudo make install
37+
38+
Yocto image:
39+
40+
IMAGE_INSTALL:append = " stressapptest"
41+
42+
Side-load:
43+
44+
scp stressapptest user@target:/usr/local/bin/
45+
46+
Usage
47+
48+
./run.sh [options]
49+
50+
Options forwarded to stressapptest
51+
52+
(These map 1:1 to stressapptest flags.)
53+
54+
-M <MB> : Memory to test (default: auto; see memory sizing below)
55+
56+
-s <seconds> : Duration (default: 300; safe mode: 120)
57+
58+
-m <threads> : Memory copy threads (default: online CPUs; safe: ~half, up to 4)
59+
60+
-W : More CPU-stressful memory copy
61+
62+
-n <ipaddr> : Network client thread to <ipaddr>
63+
64+
--listen : Listen thread (for networking)
65+
66+
-f <filename> : Disk thread using <filename>
67+
68+
-F : Use libc memcpy
69+
70+
-l <logfile> : Log file (default: ./Stressapptest.log)
71+
72+
-v <level> : Verbosity 0–20 (default: 8)
73+
74+
75+
Wrapper-specific options
76+
77+
--safe : Conservative sizing and CPU subset
78+
79+
--dry-run : Print the command that would run and exit
80+
81+
--strict : Fail run if severe dmesg issues are detected
82+
83+
--no-dmesg : Disable dmesg scanning
84+
85+
--auto-net[=primary|loopback] : Start local listener and set -n automatically
86+
(default mode: primary; falls back to loopback if no primary IP)
87+
88+
--auto-disk : Pick a writable mount and create a tempfile for -f
89+
90+
--auto : Shorthand for --auto-net --auto-disk
91+
92+
93+
Memory sizing knobs (cgroup-aware)
94+
95+
--mem-pct=<P> : Percent of available RAM to use (default 60; safe: 35)
96+
97+
--mem-headroom-mb=<MB> : Keep this many MB free (default 256; safe: 512)
98+
99+
--mem-cap-mb=<MB> : Hard upper cap on -M
100+
101+
--require-mem-mb=<MB> : Refuse to run if computed target < MB
102+
103+
104+
Control & reporting
105+
106+
--loops=<N> : Repeat test N times (default 1)
107+
108+
--loop-delay=<S> : Sleep S seconds between loops (default 0)
109+
110+
--json=<file> : Write line-delimited JSON per loop + final aggregate
111+
112+
113+
> You can also supply most of these via environment variables (e.g. SAFE=1, MEM_CAP_MB=256, JSON_OUT=summary.json, LOOPS=3).
114+
115+
116+
117+
Examples
118+
119+
Run for 60s using auto sizing:
120+
121+
./run.sh -s 60
122+
123+
Safer profile (shorter, fewer threads, more headroom):
124+
125+
./run.sh --safe
126+
127+
Low-memory guard (refuse to run < 512 MB):
128+
129+
./run.sh --require-mem-mb=512
130+
131+
Cap memory and add extra headroom:
132+
133+
./run.sh --mem-cap-mb=256 --mem-headroom-mb=512
134+
135+
Multiple loops with JSON summary (and strict dmesg checks):
136+
137+
./run.sh --loops=5 --loop-delay=10 --json=summary.json --strict
138+
139+
Auto network + auto disk:
140+
141+
./run.sh --auto
142+
143+
Dry run (show exact command that would execute):
144+
145+
./run.sh --dry-run
146+
147+
CPU usage & pinning
148+
149+
The wrapper starts one stressapptest process with -m <threads> (defaults to online CPUs).
150+
Those workers are threads—not separate processes—so ps typically shows a single process.
151+
152+
Pinning behavior:
153+
154+
1. If taskset exists → the process is pinned to the CPU list (logged as CPU pinning method: taskset (...)).
155+
156+
157+
2. Else, if cpuset cgroups are available (and writable) → the wrapper confines the process to that CPU list
158+
(logged as CPU pinning method: cgroup cpuset (...)).
159+
160+
161+
3. Else → runs unpinned (logged as CPU pinning method: none).
162+
163+
164+
165+
166+
How to verify
167+
168+
Count threads:
169+
170+
PID=$(pidof stressapptest)
171+
grep '^Threads:' /proc/$PID/status
172+
# or
173+
ls -1 /proc/$PID/task | wc -l
174+
175+
See allowed CPUs:
176+
177+
PID=$(pidof stressapptest)
178+
awk '/Cpus_allowed_list/ {print $2}' /proc/$PID/status
179+
180+
Check cpuset cgroup (if used):
181+
182+
cat /proc/$(pidof stressapptest)/cgroup
183+
# then inspect matching cpuset.cpus file under /sys/fs/cgroup/...
184+
185+
Memory sizing (how it’s computed)
186+
187+
1. Determine available memory (prefer cgroup limit/usage if present; otherwise MemAvailable).
188+
189+
190+
2. Take available * mem_pct (default 60%; --safe uses 35%).
191+
192+
193+
3. Reserve headroom (--mem-headroom-mb; default 256 MB; safe: 512 MB).
194+
195+
196+
4. Apply hard cap (--mem-cap-mb) if set.
197+
198+
199+
5. Clamp to sane floor (≥ 16 MB) and not above “available minus headroom”.
200+
201+
202+
6. If --require-mem-mb=N and computed < N, the run aborts.
203+
204+
205+
The final value is passed to stressapptest as -M.
206+
207+
Output
208+
209+
Result: ./Stressapptest.res → PASS or FAIL
210+
211+
Log file: ./Stressapptest.log
212+
213+
If --json is used: line-delimited JSON entries per loop and a final aggregate.
214+
215+
216+
Notes
217+
218+
By default you’ll see one stressapptest process; workers are threads (use /proc/$PID/task to list them).
219+
220+
Dmesg scanning can be disabled (--no-dmesg) or made strict (--strict).
221+
222+
Auto disk selection avoids RO/system mounts and picks the largest free writable mount for -f.
223+
224+
Auto network starts a local listen thread and chooses a primary IP (falling back to loopback).
225+
226+
---
227+
228+
License
229+
230+
The test runner: BSD-3-Clause-Clear (Qualcomm Technologies, Inc. and/or its subsidiaries).
231+
stressapptest is licensed by its upstream author; see its repository for details.

0 commit comments

Comments
 (0)