Skip to content

Commit a0cba29

Browse files
authored
Merge pull request #213 from vsalipal/support-for-IGT-core-auth-tests
Add Display IGT Core Auth test suite
2 parents fc99736 + 042dce6 commit a0cba29

File tree

2 files changed

+299
-0
lines changed

2 files changed

+299
-0
lines changed
Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
# License
2+
Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
3+
SPDX-License-Identifier: BSD-3-Clause-Clear
4+
5+
# IGT Core Auth Test Script
6+
7+
## Overview
8+
9+
This script automates the validation of authentication mechanisms within the IGT Core framework. It performs a series of tests to ensure that the authentication processes are functioning correctly and securely. The script captures detailed logs and provides a comprehensive summary of the test results with subtest-level analysis.
10+
11+
## Features
12+
13+
- Comprehensive IGT authentication tests
14+
- Environment setup for required dependencies
15+
- Detailed logging of test processes and results
16+
- Color-coded pass/fail summaries
17+
- Output stored in structured results directory
18+
- Auto-check for required libraries and dependencies
19+
- Compatible with various Linux distributions
20+
- Help system with usage information
21+
22+
## Prerequisites
23+
24+
Ensure the following components are present in the target environment:
25+
26+
- Core authentication binary (core_auth) - must be executable
27+
- Required authentication libraries and dependencies
28+
- Write access to the filesystem (for environment setup and logging)
29+
30+
## Directory Structure
31+
```bash
32+
Runner/
33+
├──suites/
34+
├ ├── Multimedia/
35+
│ ├ ├── Display/
36+
│ ├ ├ ├── igt_gpu_tools/
37+
│ ├ ├ ├ ├── core_auth/
38+
│ ├ ├ ├ ├ ├── run.sh
39+
├ ├ ├ ├ ├ └── Display_IGT_Core_Auth_TestValidation_Readme.md
40+
```
41+
42+
## Usage
43+
44+
1. Copy the script to your target system and make it executable:
45+
46+
```bash
47+
chmod +x run.sh
48+
```
49+
50+
2. Run the script using one of the following methods:
51+
52+
**Method 1: Positional argument**
53+
```bash
54+
./run.sh <core_auth_bin_path>
55+
```
56+
57+
**Method 2: Named argument**
58+
```bash
59+
./run.sh --core-auth-path <core_auth_bin_path>
60+
```
61+
62+
**Method 3: Get help**
63+
```bash
64+
./run.sh --help
65+
./run.sh -h
66+
```
67+
68+
Examples:
69+
```bash
70+
./run.sh /usr/libexec/igt-gpu-tools/core_auth
71+
./run.sh --core-auth-path /usr/libexec/igt-gpu-tools/core_auth
72+
```
73+
74+
3. Logs and test results will be available in the test directory:
75+
- `core_auth_log.txt` - Detailed test execution log with subtest results
76+
- `core_auth.res` - Test result (PASS/FAIL/SKIP)
77+
78+
## Output
79+
80+
- **Console Output**: Real-time display of test execution and results with structured logging
81+
- **Log File**: `core_auth_log.txt` - Contains detailed output from the core_auth binary including all subtests
82+
- **Result File**: `core_auth.res` - Contains final test status (PASS/FAIL/SKIP)
83+
- **Subtest Analysis**: Detailed parsing and counting of individual subtest results
84+
- **Test Status Determination**:
85+
- **FAIL**: Return code ≠ 0 OR any subtest failed (fail_count > 0)
86+
- **SKIP**: Return code = 0 AND all subtests skipped (skip_count > 0, success_count = 0)
87+
- **PASS**: Return code = 0 AND no failures (success_count > 0 OR mixed results with no failures)
88+
89+
## Notes
90+
91+
- The script requires the path to the core_auth binary (via positional or named argument).
92+
- Enhanced argument validation includes checking for missing values in named parameters.
93+
- Comprehensive validation ensures the core_auth binary exists and is executable.
94+
- Automatic Weston compositor management using the `weston_stop` function from functestlib.sh.
95+
- Built-in help system provides usage information with improved syntax display.
96+
- Robust error handling with appropriate exit codes and result file generation.
97+
- Test results are determined by both return codes and log content analysis.
98+
99+
## Maintenance
100+
101+
- Ensure the authentication libraries remain compatible with your system.
102+
- Update test cases as per new authentication requirements or updates in the IGT Core framework.
103+
104+
## Run test using:
105+
```bash
106+
git clone <this-repo>
107+
cd <this-repo>
108+
scp -r Runner user@target_device_ip:<Path in device>
109+
ssh user@target_device_ip
110+
```
111+
112+
- **Using Unified Runner**
113+
```bash
114+
cd <Path in device>/Runner
115+
```
116+
117+
- **Run Core_auth testcase**
118+
```bash
119+
./run-test.sh core_auth <core_auth_bin_path>
120+
```
121+
122+
Example:
123+
```bash
124+
./run-test.sh core_auth /usr/libexec/igt-gpu-tools/core_auth
125+
```
126+
127+
## EXAMPLE OUTPUT
128+
129+
[Executing test case: core_auth] 2025-05-31 17:39:52 -
130+
[INFO] 2025-05-31 17:39:52 - -------------------Starting core_auth Testcase-----------------------------
131+
[INFO] 2025-05-31 17:39:52 - Using core_auth binary at: /usr/libexec/igt-gpu-tools/core_auth
132+
[INFO] 2025-05-31 17:39:52 - Weston is not running.
133+
[INFO] 2025-05-31 17:39:52 - Logs written to: /var/qcom-linux-testkit/Runner/suites/Multimedia/Display/core_auth/core_auth_log.txt
134+
[INFO] 2025-05-31 17:39:52 - Subtest Results: SUCCESS=4, FAIL=0, SKIP=0, TOTAL=4
135+
[INFO] 2025-05-31 17:39:52 - results will be written to "./core_auth.res"
136+
[INFO] 2025-05-31 17:39:52 - -------------------Completed core_auth Testcase----------------------------
137+
[PASS] 2025-05-31 17:39:52 - core_auth : Test Passed - All 4 subtest(s) succeeded
138+
[PASS] 2025-05-31 17:39:52 - core_auth passed
139+
140+
[INFO] 2025-05-31 17:39:52 - ========== Test Summary ==========
141+
PASSED:
142+
core_auth
143+
144+
FAILED:
145+
None
146+
147+
SKIPPED:
148+
None
149+
[INFO] 2025-05-31 17:39:52 - =================================
Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
#!/bin/sh
2+
# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
3+
# SPDX-License-Identifier: BSD-3-Clause-Clear
4+
5+
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
6+
7+
# ---- Source init_env & tools ----
8+
INIT_ENV=""
9+
SEARCH="$SCRIPT_DIR"
10+
while [ "$SEARCH" != "/" ]; do
11+
if [ -f "$SEARCH/init_env" ]; then INIT_ENV="$SEARCH/init_env"; break; fi
12+
SEARCH="$(dirname "$SEARCH")"
13+
done
14+
if [ -z "$INIT_ENV" ]; then
15+
echo "[ERROR] Could not find init_env (starting at $SCRIPT_DIR)" >&2
16+
exit 1
17+
fi
18+
19+
# Only source if not already loaded (idempotent)
20+
if [ -z "$__INIT_ENV_LOADED" ]; then
21+
# shellcheck disable=SC1090
22+
. "$INIT_ENV"
23+
fi
24+
# Always source functestlib.sh, using $TOOLS exported by init_env
25+
# shellcheck disable=SC1090,SC1091
26+
. "$TOOLS/functestlib.sh"
27+
28+
TESTNAME="core_auth"
29+
result_file="./${TESTNAME}.res"
30+
CORE_AUTH_CMD=""
31+
32+
test_path="$(find_test_case_by_name "$TESTNAME" 2>/dev/null)"
33+
if [ -z "$test_path" ] || [ ! -d "$test_path" ]; then
34+
test_path="$SCRIPT_DIR"
35+
fi
36+
37+
if [ ! -w "$test_path" ]; then
38+
log_error "Cannot write to test directory: $test_path"
39+
echo "$TESTNAME FAIL" >"$result_file"
40+
exit 1
41+
fi
42+
43+
while [ $# -gt 0 ]; do
44+
case "$1" in
45+
--core-auth-path)
46+
shift
47+
if [ -n "${1:-}" ]; then
48+
CORE_AUTH_CMD="$1"
49+
else
50+
log_error "Missing value for --core-auth-path parameter"
51+
echo "$TESTNAME FAIL" >"$result_file"
52+
exit 1
53+
fi
54+
;;
55+
--help|-h)
56+
log_info "Usage: $0 [--core-auth-path BINARY_PATH] | [BINARY_PATH]"
57+
exit 0
58+
;;
59+
-*)
60+
log_warn "Unknown argument: $1"
61+
;;
62+
*)
63+
if [ -z "$CORE_AUTH_CMD" ]; then
64+
CORE_AUTH_CMD="$1"
65+
else
66+
log_warn "Multiple paths specified, ignoring: $1"
67+
fi
68+
;;
69+
esac
70+
shift
71+
done
72+
73+
if ! cd "$test_path"; then
74+
log_error "cd failed: $test_path"
75+
echo "$TESTNAME FAIL" >"$result_file"
76+
exit 1
77+
fi
78+
79+
log_info "-------------------Starting $TESTNAME Testcase-----------------------------"
80+
81+
if [ -z "$CORE_AUTH_CMD" ]; then
82+
log_error "core_auth binary not specified"
83+
echo "$TESTNAME FAIL" > "$result_file"
84+
exit 1
85+
fi
86+
87+
if [ ! -x "$CORE_AUTH_CMD" ]; then
88+
log_error "FAIL: core_auth binary not found or not executable at: $CORE_AUTH_CMD"
89+
echo "$TESTNAME FAIL" > "$result_file"
90+
exit 1
91+
fi
92+
93+
log_info "Using core_auth binary at: $CORE_AUTH_CMD"
94+
95+
if ! weston_stop; then
96+
log_error "Failed to stop Weston"
97+
echo "$TESTNAME FAIL" > "$result_file"
98+
exit 1
99+
fi
100+
101+
log_file="$test_path/core_auth_log.txt"
102+
"$CORE_AUTH_CMD" > "$log_file" 2>&1
103+
RC="$?"
104+
105+
log_info "Logs written to: $log_file"
106+
107+
success_count=$(grep -c "SUCCESS" "$log_file" 2>/dev/null || echo "0")
108+
fail_count=$(grep -c "FAIL" "$log_file" 2>/dev/null || echo "0")
109+
skip_count=$(grep -c "SKIP" "$log_file" 2>/dev/null || echo "0")
110+
111+
# Ensure we have valid numbers
112+
success_count=${success_count:-0}
113+
fail_count=${fail_count:-0}
114+
skip_count=${skip_count:-0}
115+
116+
case "$success_count" in ''|*[!0-9]*) success_count=0 ;; esac
117+
case "$fail_count" in ''|*[!0-9]*) fail_count=0 ;; esac
118+
case "$skip_count" in ''|*[!0-9]*) skip_count=0 ;; esac
119+
120+
total_subtests=$((success_count + fail_count + skip_count))
121+
122+
log_info "Subtest Results: SUCCESS=$success_count, FAIL=$fail_count, SKIP=$skip_count, TOTAL=$total_subtests"
123+
log_info "results will be written to \"$result_file\""
124+
log_info "-------------------Completed $TESTNAME Testcase----------------------------"
125+
126+
if [ "$RC" -ne 0 ]; then
127+
log_fail "$TESTNAME : Test Failed (exit code: $RC)"
128+
echo "$TESTNAME FAIL" > "$result_file"
129+
exit 1
130+
elif [ "$fail_count" -gt 0 ]; then
131+
log_fail "$TESTNAME : Test Failed - $fail_count subtest(s) failed out of $total_subtests"
132+
echo "$TESTNAME FAIL" > "$result_file"
133+
exit 1
134+
elif [ "$skip_count" -gt 0 ] && [ "$success_count" -eq 0 ]; then
135+
log_skip "$TESTNAME : Test Skipped - All $skip_count subtest(s) were skipped"
136+
echo "$TESTNAME SKIP" > "$result_file"
137+
exit 0
138+
else
139+
if [ "$success_count" -gt 0 ]; then
140+
if [ "$skip_count" -gt 0 ]; then
141+
log_pass "$TESTNAME : Test Passed - $success_count subtest(s) succeeded, $skip_count skipped"
142+
else
143+
log_pass "$TESTNAME : Test Passed - All $success_count subtest(s) succeeded"
144+
fi
145+
else
146+
log_pass "$TESTNAME : Test Passed (return code $RC)"
147+
fi
148+
echo "$TESTNAME PASS" > "$result_file"
149+
exit 0
150+
fi

0 commit comments

Comments
 (0)