Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 64 additions & 0 deletions Runner/suites/Multimedia/Display/igt-gpu-tools/dmabuf/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# dmabuf Test

## Overview
The dmabuf test is an IGT (Intel GPU Tools) test that validates DMA-BUF (Direct Memory Access Buffer) functionality in the display subsystem. This test verifies the kernel's ability to handle DMA-BUF operations for graphics memory sharing.

## Test Description
This test validates:
- DMA-BUF allocation and management
- Memory sharing between different subsystems
- Buffer import/export operations
- Kernel selftests for DMA-BUF functionality

## Prerequisites
- IGT GPU tools must be installed on the target device
- Display hardware must be available
- Weston compositor will be stopped during test execution

## Usage

### Basic Usage (Default)
```bash
./run-test.sh dmabuf
```
The test will automatically use the binary at `/usr/libexec/igt-gpu-tools/dmabuf`

### With Custom Binary Path
```bash
./run-test.sh dmabuf --dmabuf-path /custom/path/to/dmabuf
```

Or:
```bash
./run-test.sh dmabuf /custom/path/to/dmabuf
```

### Help
```bash
cd Runner/suites/Multimedia/Display/igt-gpu-tools/dmabuf
./run.sh --help
```

## Test Results
The test generates:
- **Result file**: `dmabuf.res` - Contains PASS/FAIL/SKIP status
- **Log file**: `dmabuf_log.txt` - Contains detailed test output

## Expected Behavior
- **PASS**: All subtests succeed or some subtests succeed with others skipped
- **SKIP**: All subtests are skipped (e.g., when kernel selftests are not available)
- **FAIL**: One or more subtests fail or the test exits with a non-zero code

## Common Issues
1. **Test Skipped**: If the test shows "SKIP", it typically means the required kernel selftests are not available on the system. This is not necessarily an error - it indicates the test requirements are not met.

2. **Binary Not Found**: Ensure IGT GPU tools are installed:
```bash
# Check if binary exists
ls -l /usr/libexec/igt-gpu-tools/dmabuf
```

## Notes
- The test automatically stops Weston before execution
- Exit code 77 indicates a SKIP condition (standard IGT behavior)
- Test output is parsed for SUCCESS, FAIL, and SKIP counts
20 changes: 20 additions & 0 deletions Runner/suites/Multimedia/Display/igt-gpu-tools/dmabuf/dmabuf.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
metadata:
name: dmabuf
format: "Lava-Test Test Definition 1.0"
description: "Validates DMA-BUF buffer sharing between DRM/KMS and other kernel subsystems using the IGT dmabuf test suite. Stops any active Weston compositor before running and restores it afterwards."
os:
- linux
scope:
- functional

params:
DMABUF_PATH: "/usr/libexec/igt-gpu-tools/dmabuf"
IGT_TIMEOUT: "300"

run:
steps:
- REPO_PATH=$PWD
- cd Runner/suites/Multimedia/Display/igt-gpu-tools/dmabuf
- export IGT_TIMEOUT="${IGT_TIMEOUT}"
- ./run.sh --dmabuf-path "${DMABUF_PATH}" || true
- $REPO_PATH/Runner/utils/send-to-lava.sh dmabuf.res || true
176 changes: 176 additions & 0 deletions Runner/suites/Multimedia/Display/igt-gpu-tools/dmabuf/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
#!/bin/sh
# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
# SPDX-License-Identifier: BSD-3-Clause-Clear

SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"

# ---- Source init_env & tools ----
INIT_ENV=""
SEARCH="$SCRIPT_DIR"
while [ "$SEARCH" != "/" ]; do
if [ -f "$SEARCH/init_env" ]; then INIT_ENV="$SEARCH/init_env"; break; fi
SEARCH="$(dirname "$SEARCH")"
done
if [ -z "$INIT_ENV" ]; then
echo "[ERROR] Could not find init_env (starting at $SCRIPT_DIR)" >&2
exit 1
fi

# Only source if not already loaded (idempotent)
if [ -z "$__INIT_ENV_LOADED" ]; then
# shellcheck disable=SC1090
. "$INIT_ENV"
fi
# Always source functestlib.sh, using $TOOLS exported by init_env
# shellcheck disable=SC1090,SC1091
. "$TOOLS/functestlib.sh"
# Source display helpers: Weston/Wayland lifecycle, DRM utilities, weston_restore_runtime
. "$TOOLS/lib_display.sh"

# EXIT trap: safety-net cleanup when the script exits normally (PIDs already cleared).
# Signal traps: kill the IGT child, restore Weston, then record an interrupted FAIL.
weston_stopped_by_test=0
trap 'if [ "$weston_stopped_by_test" -eq 1 ]; then if managed_timeout_cancel_bounded 5; then log_info "Restarting Weston after test completion"; weston_restore_runtime || true; else log_warn "IGT child may still hold DRM ownership; skipping Weston restore to avoid conflict"; fi; weston_stopped_by_test=0; else managed_timeout_cancel_bounded 5 || true; fi' EXIT
trap 'if [ "$weston_stopped_by_test" -eq 1 ]; then if managed_timeout_cancel_bounded 5; then log_info "Restarting Weston after signal interruption"; weston_restore_runtime || true; else log_warn "IGT child may still hold DRM ownership; skipping Weston restore to avoid conflict"; fi; weston_stopped_by_test=0; else managed_timeout_cancel_bounded 5 || true; fi; test_result_finish "FAIL" "test interrupted by signal"' INT TERM HUP

TESTNAME="dmabuf"
RES_FILE="$SCRIPT_DIR/${TESTNAME}.res"
Comment thread
vsalipal marked this conversation as resolved.
Resolved
test_result_init "$TESTNAME" "$RES_FILE"
# Default IGT test binary location
DEFAULT_IGT_PATH="/usr/libexec/igt-gpu-tools"
DMABUF_CMD="$DEFAULT_IGT_PATH/$TESTNAME"
# Configurable timeout in seconds for the IGT invocation
IGT_TIMEOUT="${IGT_TIMEOUT:-300}"

test_path="$(find_test_case_by_name "$TESTNAME" 2>/dev/null)"
if [ -z "$test_path" ] || [ ! -d "$test_path" ]; then
test_path="$SCRIPT_DIR"
fi

if [ ! -w "$test_path" ]; then
log_error "Cannot write to test directory: $test_path"
test_result_finish "FAIL" "Cannot write to test directory: $test_path"
fi

while [ $# -gt 0 ]; do
case "$1" in
--dmabuf-path)
shift
if [ -n "${1:-}" ]; then
DMABUF_CMD="$1"
else
log_error "Missing value for --dmabuf-path parameter"
test_result_finish "FAIL" "Missing value for --dmabuf-path parameter"
fi
;;
--help|-h)
log_info "Usage: $0 [--dmabuf-path BINARY_PATH] | [BINARY_PATH]"
log_info "Default binary path: $DEFAULT_IGT_PATH/$TESTNAME"
exit 0
;;
-*)
log_warn "Unknown argument: $1"
;;
*)
DMABUF_CMD="$1"
;;
esac
shift
done

if ! cd "$test_path"; then
log_error "cd failed: $test_path"
test_result_finish "FAIL" "cd failed: $test_path"
fi

log_info "-------------------Starting $TESTNAME Testcase-----------------------------"

# Check if the binary exists and is executable
if [ ! -x "$DMABUF_CMD" ]; then
log_skip "$TESTNAME: dmabuf binary not found or not executable at: $DMABUF_CMD"
log_skip "Please ensure IGT GPU tools are installed or specify the binary path with --dmabuf-path"
test_result_finish "SKIP" "dmabuf binary not found or not executable"
fi

log_info "Using dmabuf binary at: $DMABUF_CMD"

# Validate IGT_TIMEOUT is a positive integer before stopping Weston
case "$IGT_TIMEOUT" in
''|*[!0-9]*|0)
log_error "IGT_TIMEOUT must be a positive integer, got: '${IGT_TIMEOUT}'"
test_result_finish "FAIL" "invalid IGT_TIMEOUT: ${IGT_TIMEOUT}"
;;
esac

if weston_is_running; then
if ! weston_stop; then
log_error "Failed to stop Weston"
test_result_finish "FAIL" "Failed to stop Weston before test"
fi
weston_stopped_by_test=1
fi

log_file="$test_path/${TESTNAME}_log.txt"
log_info "Running $TESTNAME (timeout: ${IGT_TIMEOUT}s)"
Comment thread
vsalipal marked this conversation as resolved.
Resolved
run_with_managed_timeout "$IGT_TIMEOUT" "$test_path" "$TESTNAME" "$DMABUF_CMD" > "$log_file" 2>&1
RC=$?

log_info "Logs written to: $log_file"

success_count=$(grep -c "SUCCESS" "$log_file" 2>/dev/null || echo "0")
fail_count=$(grep -c "FAIL" "$log_file" 2>/dev/null || echo "0")
skip_count=$(grep -c "SKIP" "$log_file" 2>/dev/null || echo "0")

success_count=${success_count:-0}
fail_count=${fail_count:-0}
skip_count=${skip_count:-0}

case "$success_count" in ''|*[!0-9]*) success_count=0 ;; esac
case "$fail_count" in ''|*[!0-9]*) fail_count=0 ;; esac
case "$skip_count" in ''|*[!0-9]*) skip_count=0 ;; esac

total_subtests=$((success_count + fail_count + skip_count))

# Restore Weston before writing the final result; report FAIL if recovery fails
if [ "$weston_stopped_by_test" -eq 1 ]; then
log_info "Restarting Weston after test completion"
if ! weston_restore_runtime; then
log_fail "$TESTNAME: Weston failed to restart after test"
test_result_finish "FAIL" "Weston failed to restart after test"
fi
weston_stopped_by_test=0
fi

log_info "Subtest Results: SUCCESS=$success_count, FAIL=$fail_count, SKIP=$skip_count, TOTAL=$total_subtests"
log_info "results will be written to \"$RES_FILE\""
log_info "-------------------Completed $TESTNAME Testcase----------------------------"

if [ "$RC" -eq 143 ] || [ "$RC" -eq 124 ]; then
log_fail "$TESTNAME : Test Failed (timeout after ${IGT_TIMEOUT}s)"
test_result_finish "FAIL" "timeout after ${IGT_TIMEOUT}s"
elif [ "$RC" -eq 77 ]; then
log_skip "$TESTNAME : Test Skipped (IGT exit code 77)"
test_result_finish "SKIP" "IGT exit code 77"
elif [ "$RC" -ne 0 ]; then
log_fail "$TESTNAME : Test Failed (exit code: $RC)"
test_result_finish "FAIL" "exit code: $RC"
elif [ "$fail_count" -gt 0 ]; then
log_fail "$TESTNAME : Test Failed - $fail_count subtest(s) failed out of $total_subtests"
test_result_finish "FAIL" "$fail_count subtest(s) failed out of $total_subtests"
elif [ "$skip_count" -gt 0 ] && [ "$success_count" -eq 0 ]; then
log_skip "$TESTNAME : Test Skipped - All $skip_count subtest(s) were skipped"
test_result_finish "SKIP" "all $skip_count subtest(s) were skipped"
else
if [ "$success_count" -gt 0 ]; then
if [ "$skip_count" -gt 0 ]; then
log_pass "$TESTNAME : Test Passed - $success_count subtest(s) succeeded, $skip_count skipped"
test_result_finish "PASS" "$success_count subtest(s) succeeded, $skip_count skipped"
else
log_pass "$TESTNAME : Test Passed - All $success_count subtest(s) succeeded"
test_result_finish "PASS" "all $success_count subtest(s) succeeded"
fi
else
log_pass "$TESTNAME : Test Passed (return code $RC)"
test_result_finish "PASS" "return code $RC"
fi
fi
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# kms_setmode Test

## Overview
The kms_setmode test is an IGT (Intel GPU Tools) test that validates mode setting functionality in the KMS (Kernel Mode Setting) display subsystem. This test verifies the kernel's ability to set and switch between different display modes.

## Test Description
This test validates:
- Display mode setting operations
- Mode switching between different resolutions and refresh rates
- Multi-monitor mode configuration
- Display pipeline configuration
- CRTC (Cathode Ray Tube Controller) and connector management
- Mode validation and compatibility checking

## Prerequisites
- IGT GPU tools must be installed on the target device
- Display hardware must be available and connected
- Weston compositor will be stopped during test execution

## Usage

### Basic Usage (Default)
```bash
./run-test.sh kms_setmode
```
The test will automatically use the binary at `/usr/libexec/igt-gpu-tools/kms_setmode`

### With Custom Binary Path
```bash
./run-test.sh kms_setmode --kms-setmode-path /custom/path/to/kms_setmode
```

Or:
```bash
./run-test.sh kms_setmode /custom/path/to/kms_setmode
```

### Help
```bash
cd Runner/suites/Multimedia/Display/igt-gpu-tools/kms_setmode
./run.sh --help
```

## Test Results
The test generates:
- **Result file**: `kms_setmode.res` - Contains PASS/FAIL/SKIP status
- **Log file**: `kms_setmode_log.txt` - Contains detailed test output

## Expected Behavior
- **PASS**: All subtests succeed or some subtests succeed with others skipped
- **SKIP**: All subtests are skipped (e.g., when display hardware is not available)
- **FAIL**: One or more subtests fail or the test exits with a non-zero code

## Common Issues
1. **No Display Connected**: The test requires an active display connection. Ensure a monitor is connected.

2. **Mode Not Supported**: Some display modes may not be supported by the hardware or monitor. This will result in test skips for those specific modes.

3. **Display Flicker**: During mode switching tests, you may observe brief display flicker or blanking. This is expected behavior.

4. **Binary Not Found**: Ensure IGT GPU tools are installed:
```bash
# Check if binary exists
ls -l /usr/libexec/igt-gpu-tools/kms_setmode
```

## Test Coverage
The test typically covers:
- Single display mode setting
- Multiple display configurations
- Mode switching sequences
- Invalid mode rejection
- Display pipeline state validation

## Notes
- The test automatically stops Weston before execution
- Mode setting tests may cause brief display disruptions
- Test output is parsed for SUCCESS, FAIL, and SKIP counts
- The test validates both successful mode sets and proper error handling for invalid modes
- Results may vary based on display hardware capabilities and connected monitors
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
metadata:
name: kms-setmode
format: "Lava-Test Test Definition 1.0"
description: "Validates KMS mode-setting across all connected DRM connectors using the IGT kms_setmode test suite. Stops any active Weston compositor before running and restores it afterwards."
os:
- linux
scope:
- functional

params:
KMS_SETMODE_PATH: "/usr/libexec/igt-gpu-tools/kms_setmode"
IGT_TIMEOUT: "300"

run:
steps:
- REPO_PATH=$PWD
- cd Runner/suites/Multimedia/Display/igt-gpu-tools/kms_setmode
- export IGT_TIMEOUT="${IGT_TIMEOUT}"
- ./run.sh --kms-setmode-path "${KMS_SETMODE_PATH}" || true
- $REPO_PATH/Runner/utils/send-to-lava.sh kms_setmode.res || true
Loading