Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Testing Strategy

1. Testing Objective

The testing strategy for PsyDian is designed to verify that the operating-system prototype works correctly at the kernel, subsystem, communication, AI Bridge, and end-to-end levels.

The project follows an incremental testing approach because kernel failures can affect the entire system.

The primary goals are:

  • Verify that PsyDian boots reliably in QEMU.
  • Verify individual kernel subsystems.
  • Verify command parsing and execution.
  • Verify exception, interrupt, memory, and panic behavior.
  • Verify structured diagnostic generation.
  • Verify kernel-to-AI-Bridge communication.
  • Verify AI request and response processing.
  • Verify security and validation boundaries.
  • Verify graceful degradation when the AI service is unavailable.
  • Measure performance and reliability.
  • Provide evidence that the implemented MVP works as specified.

2. Testing Principles

  • Test each subsystem independently before integrating it.
  • Prefer deterministic and reproducible test cases.
  • Use controlled failure scenarios for kernel diagnostics.
  • Keep core kernel tests independent from external AI availability.
  • Treat external AI responses as untrusted test inputs.
  • Test both successful and failure paths.
  • Automate repeatable tests where practical.
  • Record test results and known limitations.
  • Do not consider a feature complete until its expected error paths have been tested.

3. Test Levels

PsyDian will use the following test levels:

  1. Unit Testing
  2. Kernel Subsystem Testing
  3. Integration Testing
  4. Communication/Protocol Testing
  5. AI Bridge Testing
  6. End-to-End Testing
  7. Security Testing
  8. Performance Testing
  9. Failure and Recovery Testing
  10. Manual Demonstration Testing

4. Unit Testing

Unit tests should verify isolated logic that can be tested without booting the complete kernel.

Potential unit-test targets include:

  • Command parser.
  • Command validation.
  • Argument parsing.
  • Diagnostic record creation.
  • Message serialization.
  • Message deserialization.
  • Protocol validation.
  • Risk classification.
  • AI response parsing.
  • AI response schema validation.
  • Configuration parsing.
  • Utility functions.

Example:

Input:
"meminfo"

Expected:
Command = meminfo
Arguments = []

Another example:

Input:
"unknown_command"

Expected:
Validation Error

5. Kernel Subsystem Testing

Kernel subsystems should be tested incrementally as they are implemented.

5.1 Boot Testing

Verify:

  • Kernel image builds successfully.
  • Bootloader successfully loads the kernel.
  • Kernel reaches its entry point.
  • Kernel initialization does not immediately panic.
  • Expected boot logs are produced.

Expected evidence:

Bootloader
    ↓
Kernel Entry
    ↓
[INFO] PsyDian kernel booted.

5.2 Serial Testing

Verify:

  • UART initializes successfully.
  • Single-byte transmission works.
  • String transmission works.
  • Multiple consecutive log messages work.
  • QEMU serial output is visible on the host.
  • Serial output remains usable during controlled failures.

5.3 Logger Testing

Verify:

  • INFO messages are emitted correctly.
  • WARN messages are emitted correctly.
  • ERROR messages are emitted correctly.
  • PANIC diagnostics are emitted correctly.
  • Log formatting remains consistent.
  • Shared serial access does not corrupt output.

Example:

[INFO] Kernel initialized
[WARN] Test warning
[ERROR] Test error

5.4 Keyboard Testing

Verify:

  • Key press events are received.
  • Supported keys are decoded correctly.
  • Character input reaches the shell.
  • Enter submits a command.
  • Backspace behaves correctly.
  • Supported modifier keys behave correctly.

5.5 Shell Testing

Verify:

  • Shell starts after kernel initialization.
  • Commands are parsed correctly.
  • Unknown commands are rejected.
  • Invalid arguments are rejected.
  • Valid commands execute correctly.
  • Command output is displayed.
  • Shell remains usable after command errors.

5.6 Memory Testing

Verify:

  • Boot memory information is read correctly.
  • Required paging structures are initialized.
  • Heap initialization succeeds.
  • Valid allocations succeed.
  • Deallocations behave correctly where implemented.
  • Allocation failures are handled safely.
  • Memory-related diagnostics are generated for controlled failures.

5.7 Exception Testing

Controlled test scenarios should be used for supported CPU exceptions.

Examples:

Divide-by-zero test
Invalid operation test
Page fault test

For each supported exception:

Exception
   ↓
Handler
   ↓
Diagnostic
   ↓
Log
   ↓
Controlled Failure / Recovery

The test must verify that the expected handler is invoked instead of producing an uncontrolled or unexplained failure.


5.8 Interrupt Testing

Verify:

  • Interrupt descriptor setup.
  • Hardware interrupt registration.
  • Keyboard interrupt handling.
  • Interrupt handler execution.
  • End-of-interrupt handling where applicable.
  • Normal kernel execution after handling supported interrupts.

6. Communication Protocol Testing

The communication protocol between the kernel and AI Bridge shall be tested independently of the external AI provider.

6.1 Valid Message

Example:

{
  "type": "diagnostic",
  "version": 1,
  "id": "diag-001",
  "payload": {
    "severity": "error",
    "subsystem": "memory",
    "message": "Heap allocation failed"
  }
}

Expected result:

Message accepted
→ Parsed
→ Validated
→ Processed

6.2 Invalid Message

Example:

{
  "type": "unknown",
  "payload": []
}

Expected result:

Message rejected
→ Controlled error
→ No execution

7. AI Bridge Testing

The AI Bridge should be testable without depending entirely on a live external AI service.

7.1 Request Construction

Verify:

  • Correct request type.
  • Correct diagnostic context.
  • Correct user query handling.
  • Input limits.
  • Provider-specific request formatting.

7.2 Response Parsing

Verify:

  • Valid AI response is parsed.
  • Missing required fields are detected.
  • Incorrect data types are rejected.
  • Oversized responses are rejected.
  • Unexpected fields are handled safely.

7.3 Response Validation

Verify:

  • Schema validation.
  • Safety validation.
  • Suggested-command validation.
  • Confirmation requirements.
  • Unsupported response handling.

7.4 Provider Failure

Test:

  • Authentication failure.
  • Rate limiting.
  • Timeout.
  • Network failure.
  • Server error.
  • Malformed provider response.

Expected result:

Provider Failure
    ↓
AI Bridge
    ↓
Controlled Error
    ↓
PsyDian
    ↓
User

Core kernel functionality should remain available.


8. AI / GenAI Evaluation

The GenAI component requires additional evaluation beyond conventional software tests.

The evaluation set should contain controlled diagnostic scenarios with known expected outcomes.

Each scenario may specify:

Input Diagnostic
Expected Facts
Expected Explanation
Acceptable Investigation Steps
Unsupported Claims
Safety Requirements

9. GenAI Evaluation Metrics

9.1 Groundedness

Determine whether the AI response stays consistent with the supplied diagnostic information.

9.2 Diagnostic Explanation Correctness

Determine whether the AI correctly explains the reported system condition.

9.3 Evidence Usage

Determine whether relevant supplied information is used appropriately.

9.4 Hallucination Rate

Measure unsupported technical claims.

9.5 Suggested-Step Quality

Evaluate whether suggested troubleshooting steps are technically reasonable and relevant.

9.6 Safety Compliance

Verify that the AI:

  • Does not bypass command validation.
  • Does not claim execution authority.
  • Does not automatically authorize privileged operations.
  • Does not invent system state.

9.7 Latency

Measure:

Request Creation
    ↓
Bridge Processing
    ↓
External AI
    ↓
Response Validation
    ↓
Return to PsyDian

9.8 Cost

When a provider is selected, record approximate AI cost per request using the provider’s current pricing.


10. Integration Testing

Integration testing verifies interactions between multiple subsystems.

Important integration paths include:

Kernel + Serial

Kernel
 ↓
Logger
 ↓
UART
 ↓
QEMU
 ↓
Host Terminal

Kernel + Shell

Keyboard
 ↓
Input Buffer
 ↓
Shell Parser
 ↓
Command Handler
 ↓
Output

Diagnostics + AI Bridge

Kernel Diagnostic
 ↓
Communication Protocol
 ↓
AI Bridge
 ↓
AI Processing
 ↓
Validated Response

11. End-to-End Testing

The complete AI-assisted flow shall be tested as one system.

11.1 Diagnostic Flow

System Failure
    ↓
Kernel Exception / Panic
    ↓
Diagnostic Generation
    ↓
Serial / Diagnostic Channel
    ↓
AI Bridge
    ↓
External AI Service
    ↓
AI Response
    ↓
Response Validation
    ↓
PsyDian
    ↓
Shell
    ↓
User

The test passes when the user receives a relevant, validated explanation without bypassing the system’s security controls.


12. AI Command Suggestion Testing

When the AI returns a command suggestion:

AI Suggestion
    ↓
Bridge
    ↓
PsyDian
    ↓
Shell Parser
    ↓
Command Validation
    ↓
Risk Classification
    ↓
Confirmation
    ↓
Execution / Rejection

Test cases should include:

  • Safe command.
  • Invalid command.
  • Unknown command.
  • Privileged command.
  • Destructive command.
  • Malformed command.
  • Command designed to bypass validation.

Expected behavior is that all suggestions still pass through normal validation.


13. Failure and Recovery Testing

PsyDian shall deliberately test important failure scenarios.

Examples:

  • Boot failure.
  • Kernel initialization failure.
  • Serial initialization failure.
  • Invalid command.
  • Unsupported command.
  • Memory allocation failure.
  • Page fault.
  • Keyboard input failure.
  • Communication failure.
  • AI timeout.
  • AI authentication failure.
  • AI provider outage.
  • Malformed AI response.
  • Invalid protocol message.

For each scenario:

Failure
  ↓
Detection
  ↓
Controlled Handling
  ↓
Diagnostic
  ↓
Safe State

14. Graceful Degradation Testing

The system must continue basic operation when optional external components fail.

AI Service Unavailable

Expected:

AI unavailable
    ↓
Controlled error
    ↓
Normal shell remains usable

Voice Unavailable

Expected:

Voice unavailable
    ↓
Keyboard/text interface remains usable

AI Bridge Unavailable

Expected:

AI Bridge unavailable
    ↓
AI assistance unavailable
    ↓
Core kernel/shell remains functional

15. Security Testing

Security testing shall verify the trust boundary.

15.1 Input Security

Test:

  • Oversized input.
  • Malformed messages.
  • Invalid command syntax.
  • Unexpected message types.
  • Unsupported protocol versions.

15.2 AI Security

Test:

  • Prompt injection text.
  • Unsafe AI response.
  • Malformed AI output.
  • Unsupported claims.
  • Arbitrary command suggestions.

15.3 Command Security

Test:

  • Privileged command.
  • Destructive command.
  • AI-generated privileged command.
  • Confirmation bypass attempts.

15.4 Secret Security

Verify that:

  • API keys are not committed.
  • API keys are not printed.
  • API keys are not included in kernel binaries.
  • Sensitive request content is not unnecessarily logged.

16. Performance Testing

Performance testing shall focus on both local kernel behavior and external AI latency.

16.1 Kernel Metrics

Measure:

  • Boot/initialization time.
  • Local command response time.
  • Serial logging overhead.
  • Keyboard response time.
  • Memory allocation performance where measurable.

16.2 AI Metrics

Measure:

  • AI request latency.
  • AI response latency.
  • End-to-end diagnostic latency.
  • Timeout frequency.
  • Retry frequency.

External AI latency shall be measured separately from local kernel processing.


17. Stress Testing

Where practical, run repeated operations such as:

  • Repeated shell commands.
  • Repeated keyboard input.
  • Repeated diagnostic generation.
  • Repeated AI requests.
  • Repeated communication messages.
  • Repeated allocations.

The goal is to detect:

  • Buffer overflows.
  • Memory leaks.
  • Deadlocks.
  • Output corruption.
  • State corruption.
  • Unbounded resource use.

18. Regression Testing

Every significant kernel change should be checked against previously validated functionality.

Minimum regression checks:

Boot
 ↓
Serial Output
 ↓
Kernel Initialization
 ↓
Shell
 ↓
Keyboard Input
 ↓
Existing Commands
 ↓
Diagnostics
 ↓
AI Bridge

A new subsystem must not silently break an earlier subsystem.


19. Test Environment

The primary test environment is:

Host Linux
    ↓
Rust nightly toolchain
    ↓
PsyDian kernel
    ↓
Bootloader
    ↓
QEMU

AI testing additionally requires:

Host Linux
    ↓
AI Bridge
    ↓
Network
    ↓
Configured AI Provider

The documented development environment should be used for reproducible testing.


20. Sample Test Cases

IDScenarioExpected ResultPriority
TEST-001Kernel bootPsyDian reaches kernel entry pointHigh
TEST-002Serial initializationKernel log appears in host terminalHigh
TEST-003Logger INFOINFO message formatted correctlyHigh
TEST-004Unknown shell commandControlled error displayedHigh
TEST-005Valid shell commandCorrect result displayedHigh
TEST-006Keyboard inputCharacters reach shell input bufferHigh
TEST-007Invalid command argumentsValidation error displayedHigh
TEST-008Controlled panicPanic diagnostic is generatedHigh
TEST-009Supported exceptionCorrect handler executesHigh
TEST-010Keyboard interruptInput event is processedHigh
TEST-011Heap allocationValid allocation succeedsHigh
TEST-012Allocation failureControlled diagnostic generatedHigh
TEST-013Valid diagnostic messageAI Bridge accepts messageHigh
TEST-014Malformed diagnosticMessage rejectedHigh
TEST-015AI requestValid provider request generatedHigh
TEST-016Valid AI responseResponse parsed and displayedHigh
TEST-017Malformed AI responseResponse rejected safelyHigh
TEST-018AI timeoutControlled error; core system remains availableHigh
TEST-019AI suggested safe commandCommand passes normal validationHigh
TEST-020AI suggested destructive commandConfirmation/validation requiredHigh
TEST-021Prompt injection inputTreated as untrusted dataHigh
TEST-022Missing AI credentialsControlled configuration errorHigh
TEST-023AI Bridge unavailableCore shell remains usableHigh
TEST-024Voice unavailableText interface remains usableMedium
TEST-025Repeated AI requestsResource limits prevent uncontrolled generationMedium

21. Test Evidence

Each completed test should have enough evidence to demonstrate the result.

Possible evidence includes:

  • Terminal output.
  • QEMU screenshots.
  • Kernel logs.
  • Test logs.
  • Error output.
  • AI request/response samples with secrets removed.
  • Recorded latency measurements.
  • Automated test results.
  • Git commit or build identifier.

For demonstration-critical features, screenshots or recordings should be retained where appropriate.


22. Test Result Format

A simple result format should be used:

Test ID: TEST-001
Scenario: Kernel boot
Status: PASS
Environment: QEMU / x86_64
Expected: Kernel reaches entry point
Actual: Kernel reached entry point
Evidence: Boot log

For failures:

Test ID: TEST-018
Scenario: AI timeout
Status: FAIL
Expected: Controlled timeout
Actual: Shell blocked indefinitely
Severity: High
Issue: AI request timeout missing

23. Definition of Done for Testing

A feature is considered test-complete when:

  • Expected functionality is implemented.
  • Positive cases pass.
  • Important failure cases are tested.
  • Security implications are reviewed.
  • Relevant performance behavior is measured where applicable.
  • Integration with dependent components is verified.
  • Evidence is recorded.
  • Known limitations are documented.

24. Testing Priority

Given the 8-week project timeline, testing priority shall be:

Priority 1 — Core System

  • Boot.
  • Serial.
  • Kernel initialization.
  • Memory foundation.
  • Interrupts/exceptions.
  • Keyboard.
  • Shell.

Priority 2 — Diagnostics

  • Logging.
  • Panic handling.
  • Structured diagnostics.

Priority 3 — AI Integration

  • AI Bridge.
  • Protocol.
  • External AI API.
  • Response validation.
  • AI-assisted diagnostics.

Priority 4 — Optional Features

  • Advanced shell features.
  • Voice integration.
  • Additional AI capabilities.

Optional features must not reduce the reliability of the core MVP.


25. Final End-to-End Validation

Before final demonstration, the complete project should pass the following sequence:

Build
  ↓
Boot in QEMU
  ↓
Kernel Initialization
  ↓
Serial / Logger
  ↓
Keyboard Input
  ↓
Shell
  ↓
Normal Command
  ↓
Controlled Diagnostic Failure
  ↓
Diagnostic Generation
  ↓
AI Bridge
  ↓
External AI
  ↓
Response Validation
  ↓
AI Explanation
  ↓
Display to User
  ↓
AI Failure Test
  ↓
Core Shell Still Works

This end-to-end scenario provides the strongest evidence that the PsyDian MVP works as an integrated system.