|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +# Linux Testing Script for kanata --list functionality |
| 4 | +# Run this on your Ubuntu machine after cloning the repo |
| 5 | + |
| 6 | +set -e # Exit on any error |
| 7 | + |
| 8 | +echo "🐧 Linux Testing Script for kanata --list" |
| 9 | +echo "========================================" |
| 10 | +echo |
| 11 | + |
| 12 | +# Colors for output |
| 13 | +RED='\033[0;31m' |
| 14 | +GREEN='\033[0;32m' |
| 15 | +YELLOW='\033[1;33m' |
| 16 | +BLUE='\033[0;34m' |
| 17 | +NC='\033[0m' # No Color |
| 18 | + |
| 19 | +print_step() { |
| 20 | + echo -e "${BLUE}📋 $1${NC}" |
| 21 | +} |
| 22 | + |
| 23 | +print_success() { |
| 24 | + echo -e "${GREEN}✅ $1${NC}" |
| 25 | +} |
| 26 | + |
| 27 | +print_warning() { |
| 28 | + echo -e "${YELLOW}⚠️ $1${NC}" |
| 29 | +} |
| 30 | + |
| 31 | +print_error() { |
| 32 | + echo -e "${RED}❌ $1${NC}" |
| 33 | +} |
| 34 | + |
| 35 | +# Test 1: Basic Build Test |
| 36 | +print_step "Test 1: Building kanata on Linux" |
| 37 | +echo "Building with default features..." |
| 38 | +cargo build --release |
| 39 | +if [ $? -eq 0 ]; then |
| 40 | + print_success "Build successful" |
| 41 | +else |
| 42 | + print_error "Build failed" |
| 43 | + exit 1 |
| 44 | +fi |
| 45 | +echo |
| 46 | + |
| 47 | +# Test 2: Help Output Test |
| 48 | +print_step "Test 2: Checking --list availability in help" |
| 49 | +echo "Running: cargo run --release -- --help" |
| 50 | +HELP_OUTPUT=$(cargo run --release -- --help 2>&1) |
| 51 | +if echo "$HELP_OUTPUT" | grep -q "\-l, \-\-list"; then |
| 52 | + print_success "--list option found in help output" |
| 53 | +else |
| 54 | + print_error "--list option NOT found in help output" |
| 55 | + echo "Help output:" |
| 56 | + echo "$HELP_OUTPUT" |
| 57 | + exit 1 |
| 58 | +fi |
| 59 | +echo |
| 60 | + |
| 61 | +# Test 3: List Devices Functionality |
| 62 | +print_step "Test 3: Testing --list functionality" |
| 63 | +echo "Running: cargo run --release -- --list" |
| 64 | +echo "Note: This may require permissions or show permission errors" |
| 65 | +echo |
| 66 | + |
| 67 | +LIST_OUTPUT=$(cargo run --release -- --list 2>&1) |
| 68 | +EXIT_CODE=$? |
| 69 | + |
| 70 | +echo "Exit code: $EXIT_CODE" |
| 71 | +echo "Output:" |
| 72 | +echo "$LIST_OUTPUT" |
| 73 | +echo |
| 74 | + |
| 75 | +if [ $EXIT_CODE -eq 0 ]; then |
| 76 | + print_success "--list executed successfully" |
| 77 | + |
| 78 | + # Check for expected output format |
| 79 | + if echo "$LIST_OUTPUT" | grep -q "Available keyboard devices:"; then |
| 80 | + print_success "Found expected header" |
| 81 | + else |
| 82 | + print_warning "Expected header not found" |
| 83 | + fi |
| 84 | + |
| 85 | + if echo "$LIST_OUTPUT" | grep -q "Configuration example:"; then |
| 86 | + print_success "Found configuration example" |
| 87 | + else |
| 88 | + print_warning "Configuration example not found" |
| 89 | + fi |
| 90 | + |
| 91 | +else |
| 92 | + print_warning "--list execution returned non-zero exit code" |
| 93 | + |
| 94 | + # Check if it's a permission issue |
| 95 | + if echo "$LIST_OUTPUT" | grep -q -i "permission"; then |
| 96 | + print_warning "Permission issue detected - this is expected on some systems" |
| 97 | + echo |
| 98 | + echo "💡 Try running with sudo or adding user to input group:" |
| 99 | + echo " sudo usermod -a -G input \$USER" |
| 100 | + echo " (then log out and back in)" |
| 101 | + else |
| 102 | + print_error "Unexpected error" |
| 103 | + fi |
| 104 | +fi |
| 105 | +echo |
| 106 | + |
| 107 | +# Test 4: System Information |
| 108 | +print_step "Test 4: System Information" |
| 109 | +echo "OS Information:" |
| 110 | +lsb_release -a 2>/dev/null || cat /etc/os-release |
| 111 | +echo |
| 112 | +echo "Available input devices in /dev/input/:" |
| 113 | +ls -la /dev/input/ | head -10 |
| 114 | +echo |
| 115 | +echo "Current user groups:" |
| 116 | +groups |
| 117 | +echo |
| 118 | +echo "Input group membership:" |
| 119 | +if groups | grep -q input; then |
| 120 | + print_success "User is in input group" |
| 121 | +else |
| 122 | + print_warning "User is NOT in input group" |
| 123 | + echo "💡 Add user to input group: sudo usermod -a -G input \$USER" |
| 124 | +fi |
| 125 | +echo |
| 126 | + |
| 127 | +# Test 5: Device Files Test |
| 128 | +print_step "Test 5: Input Device Files" |
| 129 | +echo "Checking for keyboard-like devices..." |
| 130 | +DEVICE_COUNT=$(ls /dev/input/event* 2>/dev/null | wc -l) |
| 131 | +echo "Found $DEVICE_COUNT event devices" |
| 132 | + |
| 133 | +if [ $DEVICE_COUNT -gt 0 ]; then |
| 134 | + print_success "Input devices found" |
| 135 | + echo "Device files:" |
| 136 | + ls -la /dev/input/event* 2>/dev/null | head -5 |
| 137 | +else |
| 138 | + print_warning "No input devices found" |
| 139 | +fi |
| 140 | +echo |
| 141 | + |
| 142 | +# Test 6: Dependencies Check |
| 143 | +print_step "Test 6: Dependencies Check" |
| 144 | +echo "Rust version:" |
| 145 | +rustc --version |
| 146 | +echo "Cargo version:" |
| 147 | +cargo --version |
| 148 | +echo |
| 149 | + |
| 150 | +print_step "Test 7: Feature Build Test" |
| 151 | +echo "Testing build without explicit features..." |
| 152 | +cargo clean |
| 153 | +cargo build --release --no-default-features |
| 154 | +if [ $? -eq 0 ]; then |
| 155 | + print_success "No-default-features build successful" |
| 156 | +else |
| 157 | + print_warning "No-default-features build failed" |
| 158 | +fi |
| 159 | +echo |
| 160 | + |
| 161 | +# Summary |
| 162 | +echo "🏁 Linux Testing Summary" |
| 163 | +echo "=======================" |
| 164 | +echo "✅ Build test" |
| 165 | +echo "✅ Help output test" |
| 166 | +echo "✅ --list functionality test" |
| 167 | +echo "✅ System information gathering" |
| 168 | +echo "✅ Dependencies check" |
| 169 | +echo |
| 170 | +echo "📋 Next Steps:" |
| 171 | +echo "1. If permission errors: Add user to input group and re-test" |
| 172 | +echo "2. If successful: Test with actual USB keyboard plugged in" |
| 173 | +echo "3. Test edge cases (no keyboards, multiple keyboards, etc.)" |
| 174 | +echo |
| 175 | +echo "🎯 Linux testing complete!" |
0 commit comments