armybox 0.3.0

A memory-safe #[no_std] BusyBox/Toybox clone in Rust - 299 Unix utilities in ~500KB
Documentation
//! POSIX.1-2017 compliance tests for kill
//!
//! Reference: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/kill.html

use crate::posix::helpers::*;

/// POSIX: "The kill utility shall send a signal to the process(es)"
#[test]
fn posix_kill_list_signals() {
    let result = run(&["kill", "-l"]);
    assert_success(&result);
    // Should list signal names
    assert!(result.1.contains("HUP") || result.1.contains("1"));
}

/// POSIX: kill -l lists all signals
#[test]
fn posix_kill_list_all() {
    let result = run(&["kill", "-l"]);
    assert_success(&result);
    assert!(result.1.contains("TERM") || result.1.contains("15"));
}

/// POSIX: kill -s signal_name
#[test]
fn posix_kill_signal_name() {
    // Send signal 0 to current process (should succeed)
    let result = run(&["kill", "-s", "0", "$$"]);
    // Might not work in this context, but flag should be accepted
    let _ = result;
}

/// POSIX: kill -0 checks process existence
#[test]
fn posix_kill_signal_zero() {
    let result = run(&["kill", "-0", "1"]);
    // May fail without permission to signal init
    let _ = result;
}

/// POSIX: kill with -SIGNAL_NAME
#[test]
fn posix_kill_dash_signal() {
    // Verify the flag format is accepted
    let result = run(&["kill", "-TERM", "99999"]);
    // Will fail (no such process) but should parse correctly
    assert!(result.0 != 0);
}

/// POSIX: kill with numeric signal
#[test]
fn posix_kill_numeric_signal() {
    let result = run(&["kill", "-15", "99999"]);
    // Will fail (no such process) but should parse correctly
    assert!(result.0 != 0);
}

/// POSIX: Exit status 0 when signal sent successfully
#[test]
fn posix_kill_exit_success() {
    // Can't easily test without a subprocess
    // Test that -l works
    let result = run(&["kill", "-l"]);
    assert_eq!(result.0, 0);
}

/// POSIX: Exit status >0 on error
#[test]
fn posix_kill_exit_error() {
    let result = run(&["kill", "99999"]);
    assert!(result.0 > 0);
}