Skip to content

Commit c31d819

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 c31d819

File tree

2 files changed

+63
-109
lines changed

2 files changed

+63
-109
lines changed

Runner/suites/Kernel/FunctionalArea/baseport/shmbridge/README.md

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -5,55 +5,55 @@ SPDX-License-Identifier: BSD-3-Clause-Clear
55

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+
```

Runner/suites/Kernel/FunctionalArea/baseport/shmbridge/run.sh

Lines changed: 31 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -25,93 +25,47 @@ fi
2525

2626
# shellcheck disable=SC1090,SC1091
2727
. "$TOOLS/functestlib.sh"
28-
28+
2929
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-
30+
test_path=$(find_test_case_by_name "$TESTNAME")
3631
cd "$test_path" || exit 1
3732
res_file="./$TESTNAME.res"
38-
rm -f "$res_file"
39-
40-
log_info "--------------------------------------------------------------------------"
33+
34+
log_info "-----------------------------------------------------------------------------------------"
4135
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"
56-
echo "$TESTNAME FAIL" > "$res_file"
57-
exit 1
58-
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"
36+
log_info "=== Test Initialization ==="
37+
38+
log_info "Checking if required tools are available"
39+
check_dependencies zcat grep dmesg
40+
41+
log_info "Checking kernel config for QCOM_SCM support..."
42+
if ! check_kernel_config "CONFIG_QCOM_SCM"; then
43+
log_skip "$TESTNAME : CONFIG_QCOM_SCM not enabled, skipping test"
44+
echo "$TESTNAME SKIP" > "$res_file"
45+
exit 0
6546
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"
47+
48+
log_info "Checking dmesg logs for qcom_scm entries..."
49+
dmesg_output=$(dmesg | grep qcom_scm)
50+
51+
if [ -z "$dmesg_output" ]; then
52+
log_fail "$TESTNAME : No qcom_scm entries found in dmesg"
7053
echo "$TESTNAME FAIL" > "$res_file"
7154
exit 1
7255
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"
56+
57+
echo "$dmesg_output" | while read -r line; do
58+
log_info "$line"
59+
done
60+
61+
if echo "$dmesg_output" | grep -qi "probe failure"; then
62+
log_fail "$TESTNAME : Probe failure detected in dmesg logs"
10763
echo "$TESTNAME FAIL" > "$res_file"
108-
umount "$MOUNT_POINT"
10964
exit 1
11065
fi
111-
112-
umount "$MOUNT_POINT"
113-
log_info "Unmounted $MOUNT_POINT and cleaned up."
114-
66+
67+
log_pass "$TESTNAME : Test Passed (QCOM_SCM present and no probe failures)"
68+
echo "$TESTNAME PASS" > "$res_file"
69+
11570
log_info "-------------------Completed $TESTNAME Testcase----------------------------"
11671
exit 0
117-

0 commit comments

Comments
 (0)