Skip to content

Commit b1f73e9

Browse files
committed
Added Shmbridgee Validation Test script and README
Introduced the Shmbridge Validation Test to verify QCOM_SCM support on target devices. This commit includes: - A shell script that checks kernel config and dmesg logs for QCOM_SCM presence and probe status. - A README with usage instructions, prerequisites, and result criteria. This enhances automated validation of Shmbridge functionality in the kernel test suite. Signed-off-by: Sai-teja573 <122cs0573@nitrkl.ac.in>
1 parent 6c0969a commit b1f73e9

File tree

2 files changed

+72
-117
lines changed

2 files changed

+72
-117
lines changed
Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,59 @@
1+
# Shmbridge Validation Test
2+
13
Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
24
SPDX-License-Identifier: BSD-3-Clause-Clear
35

4-
# shmbridge Validation Test
5-
66
## Overview
77

8-
This test case validates the encryption and access functionality of the `shmbridge` partition by:
8+
This test case validates the presence and initialization of the Qualcomm Secure Channel Manager (QCOM_SCM) interface on the device. It ensures that:
99

10-
- Formatting the partition with ext4 and encryption options
11-
- Mounting it with `inlinecrypt`
12-
- Adding an encryption key using `fscryptctl`
13-
- Setting and verifying an encryption policy
14-
- Writing and reading a test file to confirm data integrity
10+
- The kernel is configured with QCOM_SCM support
11+
- The dmesg logs contain expected `qcom_scm` entries
12+
- There are no "probe failure" messages in the logs
1513

1614
## Usage
1715

1816
Instructions:
1917

20-
1. Copy repo to Target Device: Use scp to transfer the scripts from the host to the target device. The scripts should be copied to any directory on the target device.
21-
2. Verify Transfer: Ensure that the repo have been successfully copied to any directory on the target device.
22-
3. Run Scripts: Navigate to the directory where these files are copied on the target device and execute the scripts as needed.
18+
1. **Copy repo to Target Device**: Use `scp` to transfer the scripts from the host to the target device. The scripts should be copied to any directory on the target device.
19+
2. **Verify Transfer**: Ensure that the repo has been successfully copied to the target device.
20+
3. **Run Scripts**: Navigate to the directory where these files are copied on the target device and execute the scripts as needed.
2321

24-
Run a Kernel Baseport shmbridge test using:
22+
Run the SHM Bridge test using:
2523
---
2624
#### Quick Example
27-
```
25+
```sh
2826
git clone <this-repo>
2927
cd <this-repo>
3028
scp -r common Runner user@target_device_ip:<Path in device>
3129
ssh user@target_device_ip
3230
cd <Path in device>/Runner && ./run-test.sh shmbridge
3331
```
34-
32+
---
3533
## Prerequisites
36-
- `fscryptctl`, `mkfs.ext4` and `mount` must be available
37-
- Root access is required
38-
- Partition /dev/disk/by-partlabel/xbl_ramdump_a must exist and be accessible
39-
40-
## Result Format
41-
42-
Test result will be saved in shmbridge.res as:
43-
#### Pass Criteria
44-
- Partition is found and formatted
45-
- Encryption key is added and policy is set
46-
- Test file is written and read successfully
47-
- `Test Passed` – if all validations succeed
48-
<!-- -->
49-
#### Fail Criteria
50-
- Partition not found
51-
- Encryption setup fails
52-
- Test file cannot be read or content mismatch
53-
- `Test Failed` – if any check fails
54-
34+
1. zcat, grep, and dmesg must be available.
35+
2. Root access may be required to write to read kernel logs.
36+
---
37+
## Result Format
38+
Test result will be saved in `shmbridge.res` as:
5539
## Output
5640
A .res file is generated in the same directory:
5741

58-
`PASS shmbridge` OR `FAIL shmbridge`
42+
`shmbridge PASS` OR `shmbridge FAIL`
5943

44+
## Sample Log
45+
```
46+
Output
47+
48+
[INFO] 1970-01-01 00:09:09 - -----------------------------------------------------------------------------------------
49+
[INFO] 1970-01-01 00:09:09 - -------------------Starting shmbridge Testcase----------------------------
50+
[INFO] 1970-01-01 00:09:09 - === Test Initialization ===
51+
[INFO] 1970-01-01 00:09:09 - Checking if required tools are available
52+
[INFO] 1970-01-01 00:09:09 - Checking kernel config for QCOM_SCM support...
53+
[INFO] 1970-01-01 00:09:09 - Checking dmesg logs for qcom_scm entries...
54+
[INFO] 1970-01-01 00:09:09 - [ 0.113484] qcom_scm: convention: smc arm 64
55+
[INFO] 1970-01-01 00:09:09 - [ 0.113727] qcom_scm firmware:scm: qseecom: found qseecom with version 0x1402000
56+
[INFO] 1970-01-01 00:09:09 - [ 0.113742] qcom_scm firmware:scm: qseecom: untested machine, skipping
57+
[PASS] 1970-01-01 00:09:09 - shmbridge : Test Passed (QCOM_SCM present and no probe failures)
58+
[INFO] 1970-01-01 00:09:09 - -------------------Completed shmbridge Testcase----------------------------
59+
```
Lines changed: 38 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#!/bin/sh
2-
2+
33
# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
44
# SPDX-License-Identifier: BSD-3-Clause-Clear
5-
6-
# Locate and source init_env
5+
6+
# Robustly find and source init_env
77
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
88
INIT_ENV=""
99
SEARCH="$SCRIPT_DIR"
@@ -14,104 +14,59 @@ while [ "$SEARCH" != "/" ]; do
1414
fi
1515
SEARCH=$(dirname "$SEARCH")
1616
done
17-
17+
1818
if [ -z "$INIT_ENV" ]; then
1919
echo "[ERROR] Could not find init_env (starting at $SCRIPT_DIR)" >&2
2020
exit 1
2121
fi
22-
23-
# shellcheck disable=SC1090
24-
. "$INIT_ENV"
25-
22+
23+
if [ -z "$__INIT_ENV_LOADED" ]; then
24+
# shellcheck disable=SC1090
25+
. "$INIT_ENV"
26+
fi
2627
# shellcheck disable=SC1090,SC1091
2728
. "$TOOLS/functestlib.sh"
28-
29+
2930
TESTNAME="shmbridge"
30-
test_path=$(find_test_case_by_name "$TESTNAME") || {
31-
log_fail "$TESTNAME : Test directory not found."
32-
echo "$TESTNAME FAIL" > "./$TESTNAME.res"
33-
exit 1
34-
}
35-
31+
test_path=$(find_test_case_by_name "$TESTNAME")
3632
cd "$test_path" || exit 1
3733
res_file="./$TESTNAME.res"
38-
rm -f "$res_file"
39-
40-
log_info "--------------------------------------------------------------------------"
34+
35+
log_info "-----------------------------------------------------------------------------------------"
4136
log_info "-------------------Starting $TESTNAME Testcase----------------------------"
42-
43-
check_dependencies fscryptctl mkfs.ext4 mount dd grep cat
44-
45-
MOUNT_POINT="/mnt/overlay"
46-
PARTITION="/dev/disk/by-partlabel/xbl_ramdump_a"
47-
KEY_FILE="$MOUNT_POINT/stdkey"
48-
TEST_DIR="$MOUNT_POINT/test"
49-
TEST_FILE="$TEST_DIR/txt"
50-
51-
log_info "Creating mount point at $MOUNT_POINT"
52-
mkdir -p "$MOUNT_POINT"
53-
54-
if [ ! -e "$PARTITION" ]; then
55-
log_fail "Partition $PARTITION not found"
37+
log_info "=== Test Initialization ==="
38+
39+
log_info "Checking if required tools are available"
40+
check_dependencies zcat grep dmesg
41+
42+
log_info "Checking kernel config for QCOM_SCM support..."
43+
if ! zcat /proc/config.gz | grep -q "CONFIG_QCOM_SCM"; then
44+
log_fail "$TESTNAME : CONFIG_QCOM_SCM not found in kernel config"
5645
echo "$TESTNAME FAIL" > "$res_file"
5746
exit 1
5847
fi
59-
60-
if ! mount | grep -q "$PARTITION"; then
61-
log_info "Formatting $PARTITION with ext4 (encrypt, stable_inodes)"
62-
mkfs.ext4 -F -O encrypt,stable_inodes "$PARTITION"
63-
else
64-
log_warn "$PARTITION already mounted, skipping format"
65-
fi
66-
67-
log_info "Mounting $PARTITION to $MOUNT_POINT with inlinecrypt"
68-
if ! mount "$PARTITION" -o inlinecrypt "$MOUNT_POINT"; then
69-
log_fail "Failed to mount $PARTITION"
48+
49+
log_info "Checking dmesg logs for qcom_scm entries..."
50+
dmesg_output=$(dmesg | grep qcom_scm)
51+
52+
if [ -z "$dmesg_output" ]; then
53+
log_fail "$TESTNAME : No qcom_scm entries found in dmesg"
7054
echo "$TESTNAME FAIL" > "$res_file"
7155
exit 1
7256
fi
73-
74-
log_info "Generating 64-byte encryption key"
75-
dd if=/dev/urandom bs=1 count=64 of="$KEY_FILE" status=none
76-
77-
log_info "Adding encryption key with fscryptctl"
78-
identifier=$(fscryptctl add_key "$MOUNT_POINT" < "$KEY_FILE") || {
79-
log_fail "Failed to add key to $MOUNT_POINT"
80-
echo "$TESTNAME FAIL" > "$res_file"
81-
umount "$MOUNT_POINT"
82-
exit 1
83-
}
84-
85-
mkdir -p "$TEST_DIR"
86-
log_info "Applying encryption policy to $TEST_DIR"
87-
fscryptctl set_policy --iv-ino-lblk-64 "$identifier" "$TEST_DIR" || {
88-
log_fail "Failed to set policy on $TEST_DIR"
89-
echo "$TESTNAME FAIL" > "$res_file"
90-
umount "$MOUNT_POINT"
91-
exit 1
92-
}
93-
94-
log_info "Verifying encryption policy"
95-
fscryptctl get_policy "$TEST_DIR"
96-
97-
log_info "Writing and reading test file"
98-
echo "hello" > "$TEST_FILE"
99-
sync
100-
echo 3 > /proc/sys/vm/drop_caches
101-
102-
if grep -q "hello" "$TEST_FILE"; then
103-
log_pass "$TESTNAME : Test Passed"
104-
echo "$TESTNAME PASS" > "$res_file"
105-
else
106-
log_fail "$TESTNAME : Test Failed to verify data"
57+
58+
echo "$dmesg_output" | while read -r line; do
59+
log_info "$line"
60+
done
61+
62+
if echo "$dmesg_output" | grep -qi "probe failure"; then
63+
log_fail "$TESTNAME : Probe failure detected in dmesg logs"
10764
echo "$TESTNAME FAIL" > "$res_file"
108-
umount "$MOUNT_POINT"
10965
exit 1
11066
fi
111-
112-
umount "$MOUNT_POINT"
113-
log_info "Unmounted $MOUNT_POINT and cleaned up."
114-
67+
68+
log_pass "$TESTNAME : Test Passed (QCOM_SCM present and no probe failures)"
69+
echo "$TESTNAME PASS" > "$res_file"
70+
11571
log_info "-------------------Completed $TESTNAME Testcase----------------------------"
11672
exit 0
117-

0 commit comments

Comments
 (0)