Skip to content

Commit 7e821eb

Browse files
authored
Merge pull request qualcomm-linux#37 from abbajaj806/OpenCV
Public CI OpenCV Shell Scripts
2 parents e49d314 + adfe76d commit 7e821eb

File tree

2 files changed

+778
-0
lines changed

2 files changed

+778
-0
lines changed
Lines changed: 336 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,336 @@
1+
# OpenCV Test/Perf Suite Runner — README
2+
*(Updated 2025-10-15 10:33:13Z)*
3+
4+
This README documents the **OpenCV-only** test/performance suite runner (`run.sh`) that auto-discovers
5+
OpenCV gtest binaries (`opencv_test_*`) and perf binaries (`opencv_perf_*`), runs them with a unified
6+
interface, and produces a single summary with correct exit codes. Camera tests are **not** included here.
7+
8+
---
9+
10+
## What’s new / enhancements
11+
12+
- **Auto-discovery** of `opencv_test_*` and `opencv_perf_*` from `--build-dir`, its `bin/`, and `$PATH`.
13+
- **Per-binary skip** when a test/perf binary isn’t installed—suite continues and overall result only fails when any test fails.
14+
- **Filter precedence**: `--filter` > `GTEST_FILTER` > `GTEST_FILTER_STRING` > `*` (default).
15+
- **OPENCV_TEST_DATA_PATH**: auto-exported if not set (tries common locations), or override via `--testdata`.
16+
- **Detailed logging**: start/end banners per test, exact binary path, **full arguments**, and log file path.
17+
- **Performance defaults** for `opencv_perf_*`:
18+
`--perf_impl=plain --perf_min_samples=1 --perf_force_samples=1 --perf_verify_sanity --skip_unstable=1`
19+
(override with `--perf-args "..."`).
20+
- **List mode** (`--list`): shows gtest test names for each binary without executing them.
21+
- **Robust summary**: per-binary PASS/FAIL/SKIP table, **Totals**, and overall result written to `opencv_suite.res`.
22+
- **Zero-tests treated as SKIP**: when a binary returns success but runs zero tests.
23+
- **Timeout** support per run (`--timeout <sec>`, requires `timeout` tool).
24+
25+
---
26+
27+
## Usage
28+
29+
```bash
30+
# Common env (optional)
31+
export OPENCV_TEST_DATA_PATH=/usr/share/opencv4/testdata
32+
export GTEST_FILTER_STRING='-tracking_GOTURN.GOTURN/*' # Global default filter
33+
34+
# Basic help
35+
./run.sh --help
36+
```
37+
38+
### Run a single binary
39+
```bash
40+
# Let the script locate it on $PATH/build-dir
41+
./run.sh --bin opencv_test_sfm
42+
43+
# With an explicit filter (overrides env)
44+
./run.sh --bin opencv_test_sfm --filter 'PoseEstimation*'
45+
46+
# With extra args passed through
47+
./run.sh --bin opencv_test_sfm --args '--gtest_also_run_disabled_tests'
48+
```
49+
50+
### Run full suites (auto-discovery)
51+
```bash
52+
# Accuracy only (opencv_test_*)
53+
./run.sh --suite accuracy
54+
55+
# Performance only (opencv_perf_*) with default perf args
56+
./run.sh --suite performance
57+
58+
# Everything
59+
./run.sh --suite all
60+
```
61+
62+
### Performance args
63+
```bash
64+
# Override the defaults (example: more samples)
65+
./run.sh --suite performance --perf-args '--perf_impl=plain --perf_min_samples=10 --perf_force_samples=10'
66+
```
67+
68+
### Test data path
69+
```bash
70+
# Explicit test data root (exported to children)
71+
./run.sh --testdata /usr/share/opencv4/testdata
72+
```
73+
74+
### Repeat / shuffle / seed
75+
```bash
76+
./run.sh --bin opencv_test_core --repeat 5 --shuffle --seed 123
77+
```
78+
79+
### List tests in a binary
80+
```bash
81+
./run.sh --bin opencv_test_imgproc --list
82+
```
83+
84+
### Timeout
85+
```bash
86+
./run.sh --suite accuracy --timeout 600
87+
```
88+
89+
### Working directory for execution
90+
```bash
91+
./run.sh --cwd /tmp
92+
```
93+
94+
---
95+
96+
## Environment variables honored
97+
98+
- `OPENCV_TEST_DATA_PATH` — path provided to OpenCV tests. Auto-discovered if not set; can be overridden by `--testdata`.
99+
- `GTEST_FILTER` — gtest filter (overridden by `--filter`).
100+
- `GTEST_FILTER_STRING` — alternate filter env (used if `--filter` and `GTEST_FILTER` are not set).
101+
102+
**Filter resolution order:** `--filter` > `GTEST_FILTER` > `GTEST_FILTER_STRING` > `*`.
103+
104+
Example:
105+
```bash
106+
export GTEST_FILTER_STRING='-tracking_GOTURN.GOTURN/*'
107+
./run.sh --suite accuracy
108+
```
109+
110+
---
111+
112+
## Logs, artifacts, and exit codes
113+
114+
- **Per-run logs**: logs are written under a logs directory (default: `./logs`) as `<binary>_<timestamp>.log`
115+
- **Summary table**: printed to stdout and written to `opencv_suite.summary`
116+
- **Result list**: per-binary results in `opencv_suite.reslist`
117+
- **Overall result**: `opencv_suite.res` contains `PASS`, `FAIL`, or `SKIP`
118+
119+
**Exit codes:**
120+
- `0` — At least one test ran and **all** executed tests passed
121+
- `1` — At least one test failed
122+
- `2` — No tests executed (all missing/empty) → suite considered **SKIP**
123+
124+
**Zero tests** (e.g., filtered out) are treated as **SKIP** for that binary.
125+
126+
---
127+
128+
## Example session
129+
130+
```text
131+
[INFO] 1970-01-01 02:36:14 - ========= Starting OpenCV Suite at 1970-01-01 02:36:14 =========
132+
[INFO] 1970-01-01 02:36:14 - ----- START opencv_test_sfm @ 1970-01-01 02:36:14 -----
133+
[INFO] 1970-01-01 02:36:14 - Running opencv_test_sfm
134+
[INFO] 1970-01-01 02:36:14 - Binary : /usr/bin/opencv_test_sfm
135+
[INFO] 1970-01-01 02:36:14 - OPENCV_TEST_DATA_PATH=/usr/share/opencv4/testdata
136+
[INFO] 1970-01-01 02:36:14 - GTEST_FILTER_STRING=-tracking_GOTURN.GOTURN/*
137+
[INFO] 1970-01-01 02:36:14 - Args : --gtest_color=yes --gtest_filter=-tracking_GOTURN.GOTURN/*
138+
[INFO] 1970-01-01 02:36:14 - Log : /var/Runner/suites/Multimedia/OpenCV/opencv_suite/logs/opencv_test_sfm_19700101-023614.log
139+
[PASS] 1970-01-01 02:36:14 - opencv_test_sfm : PASS
140+
[INFO] 1970-01-01 02:36:14 - ----- END opencv_test_sfm (rc=0, PASS) @ 1970-01-01 02:36:14 -----
141+
142+
========= OpenCV Suite Summary =========
143+
TEST RES LOG
144+
opencv_test_sfm PASS /var/Runner/suites/Multimedia/OpenCV/opencv_suite/logs/opencv_test_sfm_19700101-023614.log
145+
----------------------------------------
146+
Totals: PASS=1 FAIL=0 SKIP=0
147+
```
148+
149+
---
150+
151+
## Troubleshooting
152+
153+
- **Binary not found** → reported as `SKIP`; check that the package containing that `opencv_test_*`/`opencv_perf_*` is installed, or point `--build-dir` to your build root.
154+
- **No tests run** → verify `--filter`/`GTEST_FILTER(_STRING)` patterns; tests filtered out lead to `SKIP` for that binary.
155+
- **Test data missing** → set `--testdata` or `OPENCV_TEST_DATA_PATH` to your `opencv_extra/testdata` (or distro path like `/usr/share/opencv4/testdata`).
156+
- **Long perf runs** → adjust `--perf-args` (e.g., reduce `--perf_min_samples`) or use `--timeout`.
157+
158+
---
159+
160+
## Original README (verbatim, user-supplied)
161+
162+
> The content below is pasted verbatim from your uploaded README for reference.
163+
164+
---
165+
166+
# OpenCV Test/Perf Suite Runner (`run.sh`)
167+
168+
A single script that auto-discovers and runs all installed **OpenCV accuracy tests** (`opencv_test_*`) and **performance tests** (`opencv_perf_*`) on the target.
169+
It handles per-binary **PASS/FAIL/SKIP**, prints a **suite summary**, writes artifacts, and returns CI-friendly **exit codes**:
170+
171+
- **0 = PASS**, **1 = FAIL**, **2 = SKIP** (overall PASS unless any binary fails)
172+
173+
The script also exports helpful environment variables (e.g., `OPENCV_TEST_DATA_PATH`, `GTEST_FILTER_STRING`) and applies sane defaults for perf runs.
174+
175+
---
176+
177+
## Download
178+
179+
Pick one option and replace placeholders with your real path:
180+
181+
**Option A — from your GitHub repo (raw link):**
182+
```bash
183+
curl -fsSL https://raw.githubusercontent.com/<ORG>/<REPO>/<BRANCH>/path/to/run.sh -o run.sh
184+
chmod +x run.sh
185+
```
186+
187+
**Option B — from a hosted file URL:**
188+
```bash
189+
curl -fsSL https://<your-host>/artifacts/opencv/run.sh -o run.sh
190+
chmod +x run.sh
191+
```
192+
193+
> If your project uses this script in-tree, you can obviously skip the download step.
194+
195+
---
196+
197+
## Requirements
198+
199+
- POSIX shell (`/bin/sh`) and coreutils (`find`, `sort`, etc.)
200+
- Optional: `timeout` (GNU coreutils) for `--timeout` support
201+
- The script sources your existing environment helpers:
202+
- `init_env` (auto-located, walking up from the script directory)
203+
- `functestlib.sh` (via `$TOOLS/functestlib.sh`)
204+
- OpenCV gtest/perf binaries on the **PATH** or under your **build directory**:
205+
- Examples (from your target list):
206+
`opencv_test_core`, `opencv_test_imgproc`, `opencv_perf_imgproc`, …
207+
(auto-discovered; no static list required)
208+
209+
---
210+
211+
## Quick Start
212+
213+
Run **all** discovered accuracy + performance suites:
214+
```bash
215+
./run.sh
216+
```
217+
218+
Only **accuracy** tests:
219+
```bash
220+
./run.sh --suite accuracy
221+
```
222+
223+
Only **performance** tests:
224+
```bash
225+
./run.sh --suite performance
226+
```
227+
228+
Run a **single** binary:
229+
```bash
230+
./run.sh --bin opencv_test_sfm
231+
```
232+
233+
---
234+
235+
## Environment
236+
237+
- `OPENCV_TEST_DATA_PATH`
238+
Path to OpenCV test data (auto-detected if not provided: `/var/testdata`, `/usr/share/opencv4/testdata`, etc.).
239+
240+
- `GTEST_FILTER` or `GTEST_FILTER_STRING`
241+
Global GoogleTest filter applied to every run.
242+
Example (exclude GOTURN):
243+
```bash
244+
export GTEST_FILTER_STRING='-tracking_GOTURN.GOTURN/*'
245+
./run.sh
246+
```
247+
248+
> Precedence: `--filter` (CLI) → `GTEST_FILTER``GTEST_FILTER_STRING``*`
249+
250+
---
251+
252+
## Common Options
253+
254+
```text
255+
--suite <accuracy|performance|all> Defaults to all
256+
--bin <path|name> Run only one binary (e.g., opencv_test_core)
257+
--build-dir <path> Where to search for binaries (default . and ./bin)
258+
--cwd <path> Working directory for each run (default .)
259+
--testdata <path> Export OPENCV_TEST_DATA_PATH to this dir
260+
--filter <pattern> GoogleTest filter (e.g., "*", "-tracking_GOTURN.GOTURN/*")
261+
--repeat <N> GoogleTest repeat count
262+
--shuffle Enable GoogleTest shuffle
263+
--seed <N> GoogleTest random seed
264+
--args "<args>" Extra args passed to ALL binaries
265+
--perf-args "<args>" Extra args for perf binaries (defaults provided)
266+
--timeout <sec> Kill a run after N seconds (requires `timeout`)
267+
--list List tests (per-binary) and exit (treated as PASS)
268+
```
269+
270+
**Default perf args** (if not provided):
271+
`--perf_impl=plain --perf_min_samples=1 --perf_force_samples=1 --perf_verify_sanity --skip_unstable=1`
272+
273+
---
274+
275+
## Behavior & Exit Codes
276+
277+
- Each discovered binary is executed independently:
278+
- **Not found****SKIP**
279+
- **Runs but zero tests** (e.g., filter excludes everything) → **SKIP**
280+
- **Exit code 0****PASS**
281+
- **Non-zero / timeout****FAIL**
282+
- **Overall result**:
283+
- Any **FAIL** → overall **FAIL** (exit **1**)
284+
- Else if at least one **PASS** → overall **PASS** (exit **0**)
285+
- Else (only SKIPs) → overall **SKIP** (exit **2**)
286+
287+
---
288+
289+
## Artifacts
290+
291+
- Logs directory: `${LOG_DIR:-./logs}`
292+
Each binary writes `logs/<binary>_<timestamp>.log`
293+
- Suite summary: `./opencv_suite.summary` (table of results + log paths)
294+
- Result file: `./opencv_suite.res` with `PASS`/`FAIL`/`SKIP`
295+
296+
Example summary line:
297+
```
298+
opencv_test_sfm PASS logs/opencv_test_sfm_20250101-120000.log
299+
```
300+
301+
---
302+
303+
## Examples
304+
305+
Exclude GOTURN for all runs + custom testdata:
306+
```bash
307+
export OPENCV_TEST_DATA_PATH=/var/testdata
308+
export GTEST_FILTER_STRING='-tracking_GOTURN.GOTURN/*'
309+
./run.sh --suite all
310+
```
311+
312+
Run only performance with explicit args and timeout:
313+
```bash
314+
./run.sh --suite performance --perf-args "--perf_impl=plain --skip_unstable=1" --timeout 600
315+
```
316+
317+
Run one binary with extra args:
318+
```bash
319+
./run.sh --bin opencv_test_core --args "--gapi_backend=cpu"
320+
```
321+
322+
---
323+
324+
## Troubleshooting
325+
326+
- **No binaries discovered** → check `PATH` and `--build-dir`.
327+
- **Zero tests executed** → your `--filter` (or env filter) may exclude all tests.
328+
- **Missing testdata** → export `OPENCV_TEST_DATA_PATH` explicitly.
329+
- **Timeout fails** → ensure `timeout` is installed or drop `--timeout`.
330+
331+
---
332+
333+
## License
334+
335+
BSD-3-Clause-Clear (same as the script).
336+

0 commit comments

Comments
 (0)