Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
metadata:
name: partition-postboot-validation
format: "Lava-Test Test Definition 1.0"
description: "Validate critical post-boot partitions and mount health on Qualcomm Linux platforms."
os:
- linux
scope:
- functional

params:
ALLOW_DEGRADED: "0"
SCAN_DMESG: "1"
MOUNT_MATRIX: "/:ext4,erofs,squashfs:0:0;/efi:autofs,vfat:0:1;/var/lib/tee:ext4:1:0"

run:
steps:
- REPO_PATH=$PWD
- cd Runner/suites/Kernel/Baseport/Storage/Partition_PostBoot_Validation/ || true
- ALLOW_DEGRADED="${ALLOW_DEGRADED}" SCAN_DMESG="${SCAN_DMESG}" MOUNT_MATRIX="${MOUNT_MATRIX}" ./run.sh || true
- $REPO_PATH/Runner/utils/send-to-lava.sh Partition_PostBoot_Validation.res
Original file line number Diff line number Diff line change
@@ -0,0 +1,242 @@
# Partition_PostBoot_Validation

## Overview

`Partition_PostBoot_Validation` validates that critical partitions and mount points are healthy after boot, before higher-level functional tests are executed.

This test is intended to act as an early post-boot gate and helps detect issues such as:

- missing required mounts
- wrong filesystem type on expected mount points
- partitions mounted read-only when read-write is expected
- autofs mount points that are not accessible
- storage or mount-related kernel errors after boot
- incomplete or degraded boot state due to filesystem or mount failures

The test is CI-friendly and writes a `.res` file with `PASS`, `FAIL`, or `SKIP`.

---

## What the test validates

The test performs the following checks:

1. Confirms required user-space tools are present.
2. Logs platform details.
3. Logs current mount inventory and block device inventory.
4. Verifies boot and mount readiness.
5. Validates expected mount points using a configurable mount matrix.
6. Optionally scans mount/storage-related kernel log errors.

This makes it useful as a post-boot storage sanity gate before running display, multimedia, networking, or application-level tests.

---

## Default validation matrix

By default, the test validates the following mount points:

- `/`
- allowed filesystems: `ext4`, `erofs`, `squashfs`
- read-write not required
- no trigger access required

- `/efi`
- allowed filesystems: `autofs`, `vfat`
- read-write not required
- trigger access required

- `/var/lib/tee`
- allowed filesystem: `ext4`
- read-write required
- no trigger access required

Default matrix:

```sh
/:ext4,erofs,squashfs:0:0;/efi:autofs,vfat:0:1;/var/lib/tee:ext4:1:0
```

---

## Mount matrix format

The mount matrix is provided through `MOUNT_MATRIX` using the format:

```sh
mountpoint:fstype1,fstype2:rw_required:trigger_access
```

Where:

- `mountpoint` = expected mount path
- `fstype1,fstype2` = allowed filesystem types
- `rw_required`
- `1` = mount must be writable
- `0` = writable check not required
- `trigger_access`
- `1` = access the path to trigger automount or autofs behavior
- `0` = no access trigger needed

Multiple entries are separated by `;`.

Example:

```sh
MOUNT_MATRIX='/:ext4,erofs,squashfs:0:0;/efi:autofs,vfat:0:1;/var/lib/tee:ext4:1:0'
```

---

## Dependencies

The test expects the following tools to be available:

- `findmnt`
- `mount`
- `awk`
- `grep`
- `sed`
- `dmesg`
- `systemctl`
- `lsblk`
- `blkid`

If required dependencies are missing, the test will report `SKIP`.

---

## Parameters

### `ALLOW_DEGRADED`

Controls whether a degraded boot state is acceptable.

Values:

- `0` = degraded boot state is treated as failure
- `1` = degraded boot state is allowed

Default:

```sh
ALLOW_DEGRADED=0
```

---

### `SCAN_DMESG`

Controls whether storage and mount-related kernel logs are scanned.

Values:

- `1` = enable dmesg scan
- `0` = disable dmesg scan

Default:

```sh
SCAN_DMESG=1
```

---

### `MOUNT_MATRIX`

Defines the expected mount points and validation rules.

Default:

```sh
MOUNT_MATRIX='/:ext4,erofs,squashfs:0:0;/efi:autofs,vfat:0:1;/var/lib/tee:ext4:1:0'
```

---

## Usage

Run with defaults:

```sh
./run.sh
```

Run while allowing degraded boot state:

```sh
ALLOW_DEGRADED=1 ./run.sh
```

Run without dmesg scanning:

```sh
SCAN_DMESG=0 ./run.sh
```

Run with a custom mount matrix:

```sh
MOUNT_MATRIX='/:ext4:0:0;/efi:autofs,vfat:0:1;/var/lib/tee:ext4:1:0;/persist:ext4:1:0' ./run.sh
```

---

## Result file

The test generates:

```sh
Partition_PostBoot_Validation.res
```

Possible results:

- `Partition_PostBoot_Validation PASS`
- `Partition_PostBoot_Validation FAIL`
- `Partition_PostBoot_Validation SKIP`

---

## Pass criteria

The test passes when:

- required tools are available
- boot state is acceptable
- all required mount points are present
- each validated mount has an allowed filesystem type
- writable mounts pass writeability checks when required
- autofs or trigger-access mounts are accessible
- no blocking mount/storage-related issues are detected

---

## Fail criteria

The test fails when any of the following occurs:

- boot state is not acceptable
- a required mount point is missing
- filesystem type does not match the expected matrix
- a mount expected to be writable is not writable
- automount or autofs path is inaccessible
- mount/storage validation detects blocking errors
- optional dmesg scan detects relevant storage or mount failures

---

## Skip criteria

The test is skipped when:

- one or more required dependencies are unavailable
- the environment does not support the required validation flow

---

## Notes

- `/efi` may appear as `autofs` before access and transition to a real backing mount after access.
- The test is intended to be lightweight and suitable as an early boot validation gate.
- For platform-specific layouts, adjust `MOUNT_MATRIX` rather than changing the test logic.
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
#!/bin/sh
# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
# SPDX-License-Identifier: BSD-3-Clause
#
# Post-boot partition validation:
# - logs current mount inventory
# - logs block device inventory
# - validates expected mountpoints from the mount matrix
# - triggers autofs mounts where needed
# - performs RW probe only where required
# - does not gate on systemd or unrelated service health

SCRIPT_DIR="$(
cd "$(dirname "$0")" || exit 1
pwd
)"
INIT_ENV=""
SEARCH="$SCRIPT_DIR"

while [ "$SEARCH" != "/" ]; do
if [ -f "$SEARCH/init_env" ]; then
INIT_ENV="$SEARCH/init_env"
break
fi
SEARCH=$(dirname "$SEARCH")
done

if [ -z "$INIT_ENV" ]; then
echo "[ERROR] Could not find init_env (starting at $SCRIPT_DIR)" >&2
exit 1
fi

if [ -z "${__INIT_ENV_LOADED:-}" ]; then
# shellcheck disable=SC1090
. "$INIT_ENV"
fi

# shellcheck disable=SC1090,SC1091
. "$TOOLS/functestlib.sh"

TESTNAME="Partition_PostBoot_Validation"
MOUNT_MATRIX="${MOUNT_MATRIX:-/:ext4,erofs,squashfs:0:0;/efi:autofs,vfat:0:1;/var/lib/tee:ext4:1:0}"

test_path="$(find_test_case_by_name "$TESTNAME")"
if [ -n "$test_path" ]; then
cd "$test_path" || exit 1
else
cd "$SCRIPT_DIR" || exit 1
fi

RES_FILE="./$TESTNAME.res"
rm -f "$RES_FILE"

if ! CHECK_DEPS_NO_EXIT=1 check_dependencies findmnt mount awk grep sed lsblk blkid; then
log_skip "$TESTNAME SKIP: missing dependencies"
echo "$TESTNAME SKIP" > "$RES_FILE"
exit 0
fi

log_info "--------------------------------------------------------------------------"
log_info "------------------- Starting $TESTNAME Testcase --------------------------"
log_info "Mount matrix, $MOUNT_MATRIX"

if command -v detect_platform >/dev/null 2>&1; then
detect_platform
fi

log_info "Platform Details: machine='${PLATFORM_MACHINE:-unknown}' target='${PLATFORM_TARGET:-unknown}' kernel='$(uname -r 2>/dev/null || echo unknown)' arch='$(uname -m 2>/dev/null || echo unknown)'"

partition_log_current_mounts
partition_log_block_devices

log_info "----- Partition mount validation -----"
if partition_validate_mount_matrix "$MOUNT_MATRIX"; then
log_info "----- End partition mount validation -----"
log_pass "$TESTNAME : PASS"
echo "$TESTNAME PASS" > "$RES_FILE"
exit 0
fi
log_info "----- End partition mount validation -----"

log_fail "$TESTNAME : FAIL"
echo "$TESTNAME FAIL" > "$RES_FILE"
exit 0
Loading
Loading