Skip to content

Commit 45c4b48

Browse files
committed
Add: Qualcomm User Data Encryption test script & Document
- Checks for fscryptctl binary presence - Creates a random sw encryption key - Applies and verifies encryption policy - Confirms functionality with a test file - Added yaml config Signed-off-by: Bharani Bhuvanagiri <bbharani@qti.qualcomm.com>
1 parent 34562ed commit 45c4b48

File tree

3 files changed

+401
-0
lines changed

3 files changed

+401
-0
lines changed
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
2+
SPDX-License-Identifier: BSD-3-Clause-Clear
3+
4+
# Qualcomm UserDataEncryption Functionality Test Script
5+
## Overview
6+
7+
The `UserDataEncryption` test script verifies basic filesystem encryption functionality. It generates a 64-byte key, adds it to the system, applies an encryption policy to a mount directory, and confirms the setup by creating and reading a test file. This ensures that key management and encryption policies work as expected.
8+
9+
## Features
10+
11+
- **Dependency Check**: Verifies the presence of the `fscryptctl` binary.
12+
- **Key Management**: Generates a 64-byte key and adds it to the filesystem.
13+
- **Encryption Policy**: Applies and verifies encryption policy on a mount directory.
14+
- **Functional Validation**: Creates and reads a test file to confirm encryption functionality.
15+
- **Automated Result Logging**: Outputs test results to a `.res` file for automated result collection.
16+
17+
## Prerequisites
18+
19+
Ensure the following components are present on the target device:
20+
21+
- `fscryptctl` binary is available
22+
- Sufficient permissions to create and mount directories
23+
24+
## Directory Structure
25+
```
26+
Runner/
27+
├── suites/
28+
│ ├── Kernel/
29+
│ │ │ ├── baseport/
30+
│ │ │ │ ├── UserDataEncryption/
31+
│ │ │ │ │ ├── run.sh
32+
```
33+
## Usage
34+
35+
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 the ```/<user-defined-location>``` directory on the target device.
36+
37+
2. Verify Transfer: Ensure that the repo have been successfully copied to the ```/<user-defined-location>``` directory on the target device.
38+
39+
3. Run Scripts: Navigate to the ```/<user-defined-location>``` directory on the target device and execute the scripts as needed.
40+
41+
---
42+
Quick Example
43+
```
44+
git clone <this-repo>
45+
cd <this-repo>
46+
scp -r common Runner user@target_device_ip:/<user-defined-location>
47+
ssh user@target_device_ip
48+
cd /<user-defined-location>/Runner && ./run-test.sh UserDataEncryption
49+
50+
Sample output:
51+
sh-5.2# ./run-test.sh UserDataEncryption
52+
[Executing test case: UserDataEncryption] 2025-12-24 06:19:59 -
53+
[INFO] 2025-12-24 06:19:59 - Running as root. Continuing...
54+
[INFO] 2025-12-24 06:19:59 - -----------------------------------------------------------------------------------------
55+
[INFO] 2025-12-24 06:19:59 - -------------------Starting UserDataEncryption Testcase----------------------------
56+
[INFO] 2025-12-24 06:19:59 - === Test Initialization ===
57+
[PASS] 2025-12-24 06:20:00 - Kernel config CONFIG_FS_ENCRYPTION is enabled
58+
[INFO] 2025-12-24 06:20:00 - Checking if dependency binary is available
59+
[INFO] 2025-12-24 06:20:00 - Temporary key file created: /tmp/tmp.wZdZ0ladk0
60+
[INFO] 2025-12-24 06:20:00 - Generating 64-byte encryption key
61+
[INFO] 2025-12-24 06:20:00 - Using existing writable /mnt for mount directory base
62+
[INFO] 2025-12-24 06:20:00 - Creating unique mount folder under /mnt
63+
[INFO] 2025-12-24 06:20:00 - Created unique mount directory: /mnt/testing.jkttLK
64+
[INFO] 2025-12-24 06:20:00 - Derived filesystem mount point: /var
65+
[INFO] 2025-12-24 06:20:00 - Filesystem at /var: ext4
66+
[INFO] 2025-12-24 06:20:00 - Adding encryption key to the filesystem
67+
[INFO] 2025-12-24 06:20:00 - Key ID: 6acffc5b7e670c7f841ef20c37027b52
68+
[INFO] 2025-12-24 06:20:00 - Checking key status
69+
[INFO] 2025-12-24 06:20:00 - Key Status: Present (user_count=1, added_by_self)
70+
[INFO] 2025-12-24 06:20:00 - Setting encryption policy on /mnt/testing.jkttLK
71+
[INFO] 2025-12-24 06:20:00 - Verifying encryption policy
72+
[INFO] 2025-12-24 06:20:00 - Policy verification successful: Master key identifier matches key_id
73+
[INFO] 2025-12-24 06:20:00 - Creating test file in encrypted directory
74+
[INFO] 2025-12-24 06:20:00 - Reading test file
75+
[PASS] 2025-12-24 06:20:00 - UserDataEncryption : Test Passed
76+
[INFO] 2025-12-24 06:20:00 - Cleaning up mount directory: /mnt/testing.jkttLK
77+
[INFO] 2025-12-24 06:20:00 - No relevant, non-benign errors for modules [fscrypt] in recent dmesg.
78+
[PASS] 2025-12-24 06:20:00 - UserDataEncryption passed
79+
80+
[INFO] 2025-12-24 06:20:00 - ========== Test Summary ==========
81+
PASSED:
82+
UserDataEncryption
83+
84+
FAILED:
85+
None
86+
87+
SKIPPED:
88+
None
89+
[INFO] 2025-12-24 06:20:00 - ==================================
90+
4. Results will be available in the `/<user-defined-location>/Runner/suites/Kernel/baseport/UserDataEncryption/` directory.
91+
92+
## Notes
93+
94+
- The script uses /mnt as the base directory (with /UDE as a fallback) for all operations.
95+
- Temporary files such as the encryption key are cleaned up after the test.
96+
- If any test fails, the script logs the error and exits with a failure code.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
metadata:
2+
format: Lava-Test Test Definition 1.0
3+
name: UserDataEncryption
4+
description: "Validates fscrypt-based user data encryption on supported filesystems"
5+
maintainer:
6+
- bbharani@qti.qualcomm.com
7+
os:
8+
- openembedded
9+
scope:
10+
- functional
11+
devices:
12+
- rb3gen2
13+
- ridesx
14+
- lemans evk
15+
- monaco evk
16+
17+
run:
18+
steps:
19+
- cd Runner
20+
- $PWD/suites/Kernel/Baseport/UserDataEncryption/run.sh || true
21+
- $PWD/utils/send-to-lava.sh $PWD/suites/Kernel/Baseport/UserDataEncryption/UserDataEncryption.res || true

0 commit comments

Comments
 (0)