diff --git a/Runner/suites/Kernel/Baseport/shmbridge/README.md b/Runner/suites/Kernel/Baseport/shmbridge/README.md index 3905e715..3128b6a3 100644 --- a/Runner/suites/Kernel/Baseport/shmbridge/README.md +++ b/Runner/suites/Kernel/Baseport/shmbridge/README.md @@ -1,59 +1,57 @@ Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. SPDX-License-Identifier: BSD-3-Clause-Clear -# shmbridge Validation Test +# shmbridge Validation test ## Overview -This test case validates the encryption and access functionality of the `shmbridge` partition by: +This test case validates the presence and initialization of the Qualcomm Secure Channel Manager (QCOM_SCM) interface on the device. It ensures that: -- Formatting the partition with ext4 and encryption options -- Mounting it with `inlinecrypt` -- Adding an encryption key using `fscryptctl` -- Setting and verifying an encryption policy -- Writing and reading a test file to confirm data integrity +- The kernel is configured with QCOM_SCM support +- The dmesg logs contain expected `qcom_scm` entries +- There are no "probe failure" messages in the logs ## Usage Instructions: -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. -2. Verify Transfer: Ensure that the repo have been successfully copied to any directory on the target device. -3. Run Scripts: Navigate to the directory where these files are copied on the target device and execute the scripts as needed. +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. +2. **Verify Transfer**: Ensure that the repo has been successfully copied to the target device. +3. **Run Scripts**: Navigate to the directory where these files are copied on the target device and execute the scripts as needed. -Run a Kernel Baseport shmbridge test using: +Run the SHM Bridge test using: --- #### Quick Example -``` +```sh git clone cd scp -r common Runner user@target_device_ip: ssh user@target_device_ip cd /Runner && ./run-test.sh shmbridge ``` - +--- ## Prerequisites -- `fscryptctl`, `mkfs.ext4` and `mount` must be available -- Root access is required -- Partition /dev/disk/by-partlabel/xbl_ramdump_a must exist and be accessible - -## Result Format - -Test result will be saved in shmbridge.res as: -#### Pass Criteria -- Partition is found and formatted -- Encryption key is added and policy is set -- Test file is written and read successfully -- `Test Passed` – if all validations succeed - -#### Fail Criteria -- Partition not found -- Encryption setup fails -- Test file cannot be read or content mismatch -- `Test Failed` – if any check fails - +1. zcat, grep, and dmesg must be available. +2. Root access may be required to write to read kernel logs. + --- + ## Result Format +Test result will be saved in `shmbridge.res` as: ## Output A .res file is generated in the same directory: -`PASS shmbridge` OR `FAIL shmbridge` +`shmbridge PASS` OR `shmbridge FAIL` +## Sample Log +``` +Output + +[INFO] 1970-01-01 01:10:01 - ----------------------------------------------------------------------------------------- +[INFO] 1970-01-01 01:10:01 - -------------------Starting shmbridge Testcase---------------------------- +[INFO] 1970-01-01 01:10:01 - ==== Test Initialization ==== +[INFO] 1970-01-01 01:10:01 - Checking if required tools are available +[INFO] 1970-01-01 01:10:01 - Checking kernel config for QCOM_SCM support... +[PASS] 1970-01-01 01:10:01 - Kernel config CONFIG_QCOM_SCM is enabled +[INFO] 1970-01-01 01:10:01 - Scanning dmesg logs for qcom_scm initialization +[PASS] 1970-01-01 01:10:01 - shmbridge : Test Passed (qcom_scm present and no probe failures) +[INFO] 1970-01-01 01:10:01 - -------------------Completed shmbridge Testcase---------------------------- +``` diff --git a/Runner/suites/Kernel/Baseport/shmbridge/run.sh b/Runner/suites/Kernel/Baseport/shmbridge/run.sh index ff4f7f32..9dd89f62 100755 --- a/Runner/suites/Kernel/Baseport/shmbridge/run.sh +++ b/Runner/suites/Kernel/Baseport/shmbridge/run.sh @@ -25,93 +25,43 @@ fi # shellcheck disable=SC1090,SC1091 . "$TOOLS/functestlib.sh" - + TESTNAME="shmbridge" -test_path=$(find_test_case_by_name "$TESTNAME") || { - log_fail "$TESTNAME : Test directory not found." - echo "$TESTNAME FAIL" > "./$TESTNAME.res" - exit 1 -} - +test_path=$(find_test_case_by_name "$TESTNAME") cd "$test_path" || exit 1 res_file="./$TESTNAME.res" -rm -f "$res_file" - -log_info "--------------------------------------------------------------------------" + +log_info "-----------------------------------------------------------------------------------------" log_info "-------------------Starting $TESTNAME Testcase----------------------------" - -check_dependencies fscryptctl mkfs.ext4 mount dd grep cat - -MOUNT_POINT="/mnt/overlay" -PARTITION="/dev/disk/by-partlabel/xbl_ramdump_a" -KEY_FILE="$MOUNT_POINT/stdkey" -TEST_DIR="$MOUNT_POINT/test" -TEST_FILE="$TEST_DIR/txt" - -log_info "Creating mount point at $MOUNT_POINT" -mkdir -p "$MOUNT_POINT" - -if [ ! -e "$PARTITION" ]; then - log_fail "Partition $PARTITION not found" - echo "$TESTNAME FAIL" > "$res_file" - exit 1 -fi - -if ! mount | grep -q "$PARTITION"; then - log_info "Formatting $PARTITION with ext4 (encrypt, stable_inodes)" - mkfs.ext4 -F -O encrypt,stable_inodes "$PARTITION" -else - log_warn "$PARTITION already mounted, skipping format" -fi - -log_info "Mounting $PARTITION to $MOUNT_POINT with inlinecrypt" -if ! mount "$PARTITION" -o inlinecrypt "$MOUNT_POINT"; then - log_fail "Failed to mount $PARTITION" +log_info "==== Test Initialization ====" + +log_info "Checking if required tools are available" +check_dependencies zcat grep dmesg + +log_info "Checking kernel config for QCOM_SCM support..." +if ! check_kernel_config "CONFIG_QCOM_SCM"; then + log_fail "$TESTNAME : CONFIG_QCOM_SCM not enabled, test failed" echo "$TESTNAME FAIL" > "$res_file" exit 1 fi -log_info "Generating 64-byte encryption key" -dd if=/dev/urandom bs=1 count=64 of="$KEY_FILE" status=none - -log_info "Adding encryption key with fscryptctl" -identifier=$(fscryptctl add_key "$MOUNT_POINT" < "$KEY_FILE") || { - log_fail "Failed to add key to $MOUNT_POINT" - echo "$TESTNAME FAIL" > "$res_file" - umount "$MOUNT_POINT" - exit 1 -} - -mkdir -p "$TEST_DIR" -log_info "Applying encryption policy to $TEST_DIR" -fscryptctl set_policy --iv-ino-lblk-64 "$identifier" "$TEST_DIR" || { - log_fail "Failed to set policy on $TEST_DIR" - echo "$TESTNAME FAIL" > "$res_file" - umount "$MOUNT_POINT" - exit 1 -} - -log_info "Verifying encryption policy" -fscryptctl get_policy "$TEST_DIR" - -log_info "Writing and reading test file" -echo "hello" > "$TEST_FILE" -sync -echo 3 > /proc/sys/vm/drop_caches - -if grep -q "hello" "$TEST_FILE"; then - log_pass "$TESTNAME : Test Passed" - echo "$TESTNAME PASS" > "$res_file" +log_info "Scanning dmesg logs for qcom_scm initialization" + +if dmesg | grep -q 'qcom_scm'; then + if ! dmesg | grep -q 'probe failure'; then + log_pass "$TESTNAME : Test Passed (qcom_scm present and no probe failures)" + echo "$TESTNAME PASS" > "$res_file" + else + echo "FAIL: 'probe failure' detected in dmesg." + echo "$TESTNAME FAIL" > "$res_file" + exit 1 + fi else - log_fail "$TESTNAME : Test Failed to verify data" + echo "FAIL: 'qcom_scm' not found in dmesg." echo "$TESTNAME FAIL" > "$res_file" - umount "$MOUNT_POINT" exit 1 fi - -umount "$MOUNT_POINT" -log_info "Unmounted $MOUNT_POINT and cleaned up." - + log_info "-------------------Completed $TESTNAME Testcase----------------------------" exit 0 - + \ No newline at end of file