-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_service_dependency.py
More file actions
78 lines (62 loc) · 2.54 KB
/
Copy pathtest_service_dependency.py
File metadata and controls
78 lines (62 loc) · 2.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/usr/bin/env python3
"""Test script to verify user service functionality."""
import asyncio
import subprocess
import sys
import time
def run_command(cmd, check=True):
"""Run a command and return the result."""
try:
result = subprocess.run(cmd, shell=True, capture_output=True, text=True, check=check)
return result.returncode == 0, result.stdout, result.stderr
except subprocess.CalledProcessError as e:
return False, e.stdout, e.stderr
def test_user_service():
"""Test that the user service can start and stop properly."""
print("Testing user service functionality...")
# Check if user service is installed
success, stdout, stderr = run_command("systemctl --user is-enabled huion-keydial-mini-user.service", check=False)
if not success:
print("❌ User service not found. Please install it first:")
print(" sudo make install-systemd")
return False
print("✅ User service is installed")
# Stop service to start fresh
print("Stopping user service...")
run_command("systemctl --user stop huion-keydial-mini-user.service", check=False)
time.sleep(2)
# Check initial state
user_active, _, _ = run_command("systemctl --user is-active --quiet huion-keydial-mini-user.service", check=False)
print(f"Initial state - User service: {'active' if user_active else 'inactive'}")
# Start user service
print("Starting user service...")
success, stdout, stderr = run_command("systemctl --user start huion-keydial-mini-user.service")
if not success:
print(f"❌ Failed to start user service: {stderr}")
return False
# Wait a moment for service to start
time.sleep(3)
# Check final state
user_active, _, _ = run_command("systemctl --user is-active --quiet huion-keydial-mini-user.service", check=False)
print(f"Final state - User service: {'active' if user_active else 'inactive'}")
if user_active:
print("✅ Success! User service started successfully")
return True
else:
print("❌ Failed! User service did not start")
return False
def main():
"""Main test function."""
print("Huion Keydial Mini User Service Test")
print("=" * 50)
success = test_user_service()
print("\n" + "=" * 50)
if success:
print("✅ All tests passed!")
print("The user service is working correctly.")
else:
print("❌ Tests failed!")
print("Please check the service configuration.")
return 0 if success else 1
if __name__ == "__main__":
sys.exit(main())