Skip to content

Commit 5f01771

Browse files
committed
Refactored shmbridge test
Refactored shmbridge test to validate the upstream qcm drivers and check the driver initialisation Signed-off-by: Vamsee Narapareddi <[email protected]>
1 parent 59365c8 commit 5f01771

File tree

2 files changed

+59
-111
lines changed

2 files changed

+59
-111
lines changed
Lines changed: 31 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,57 @@
11
Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
22
SPDX-License-Identifier: BSD-3-Clause-Clear
33

4-
# shmbridge Validation Test
4+
# shmbridge Validation test
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 01:10:01 - -----------------------------------------------------------------------------------------
49+
[INFO] 1970-01-01 01:10:01 - -------------------Starting shmbridge Testcase----------------------------
50+
[INFO] 1970-01-01 01:10:01 - ==== Test Initialization ====
51+
[INFO] 1970-01-01 01:10:01 - Checking if required tools are available
52+
[INFO] 1970-01-01 01:10:01 - Checking kernel config for QCOM_SCM support...
53+
[PASS] 1970-01-01 01:10:01 - Kernel config CONFIG_QCOM_SCM is enabled
54+
[INFO] 1970-01-01 01:10:01 - Scanning dmesg logs for qcom_scm initialization
55+
[PASS] 1970-01-01 01:10:01 - shmbridge : Test Passed (qcom_scm present and no probe failures)
56+
[INFO] 1970-01-01 01:10:01 - -------------------Completed shmbridge Testcase----------------------------
57+
```

Runner/suites/Kernel/Baseport/shmbridge/run.sh

Lines changed: 28 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -25,93 +25,43 @@ 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"
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"
70-
echo "$TESTNAME FAIL" > "$res_file"
71-
exit 1
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_fail "$TESTNAME : CONFIG_QCOM_SCM not enabled, test Skipped"
44+
echo "$TESTNAME SKIP" > "$res_file"
45+
exit 0
7246
fi
7347

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"
48+
log_info "Scanning dmesg logs for qcom_scm initialization"
49+
50+
if dmesg | grep -q 'qcom_scm'; then
51+
if ! scan_dmesg_errors . "" ""; then
52+
log_pass "$TESTNAME : Test Passed (qcom_scm present and no probe failures)"
53+
echo "$TESTNAME PASS" > "$res_file"
54+
else
55+
echo "FAIL: 'probe failure' detected in dmesg."
56+
echo "$TESTNAME FAIL" > "$res_file"
57+
exit 1
58+
fi
10559
else
106-
log_fail "$TESTNAME : Test Failed to verify data"
60+
echo "FAIL: 'qcom_scm' not found in dmesg."
10761
echo "$TESTNAME FAIL" > "$res_file"
108-
umount "$MOUNT_POINT"
10962
exit 1
11063
fi
111-
112-
umount "$MOUNT_POINT"
113-
log_info "Unmounted $MOUNT_POINT and cleaned up."
114-
64+
11565
log_info "-------------------Completed $TESTNAME Testcase----------------------------"
11666
exit 0
117-
67+

0 commit comments

Comments
 (0)