-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_installation.py
More file actions
163 lines (141 loc) · 5.13 KB
/
test_installation.py
File metadata and controls
163 lines (141 loc) · 5.13 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
#!/usr/bin/env python3
"""
Test script to verify the flash installation
"""
import sys
import importlib
import subprocess
import platform
def test_python_version():
"""Test Python version"""
print("Testing Python version...")
version = sys.version_info
if version.major >= 3 and version.minor >= 9:
print(f"✅ Python {version.major}.{version.minor}.{version.micro} - OK")
return True
else:
print(f"❌ Python {version.major}.{version.minor}.{version.micro} - Requires Python 3.9+")
return False
def test_package_import(package_name, display_name=None):
"""Test if a package can be imported"""
if display_name is None:
display_name = package_name
try:
module = importlib.import_module(package_name)
version = getattr(module, '__version__', 'Unknown')
print(f"✅ {display_name} {version} - OK")
return True
except ImportError as e:
print(f"❌ {display_name} - Import failed: {e}")
return False
def test_opencv():
"""Test OpenCV specifically"""
print("Testing OpenCV...")
try:
import cv2
version = cv2.__version__
print(f"✅ OpenCV {version} - OK")
# Test basic OpenCV functionality
import numpy as np
img = np.zeros((100, 100, 3), dtype=np.uint8)
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
print("✅ OpenCV basic functionality - OK")
return True
except ImportError as e:
print(f"❌ OpenCV - Import failed: {e}")
return False
except Exception as e:
print(f"❌ OpenCV - Functionality test failed: {e}")
return False
def test_platform_specific():
"""Test platform-specific packages"""
print("Testing platform-specific packages...")
system = platform.system().lower()
if system == "darwin": # macOS
print("Testing macOS-specific packages...")
# Add macOS-specific tests if needed
return True
elif system == "linux":
print("Testing Linux-specific packages...")
# Add Linux-specific tests if needed
return True
elif system == "windows":
print("Testing Windows-specific packages...")
# Add Windows-specific tests if needed
return True
else:
print(f"Unknown platform: {system}")
return False
def test_system_tools():
"""Test system tools"""
print("Testing system tools...")
tools = ['cmake', 'git', 'python3']
if platform.system().lower() == 'windows':
tools = ['cmake', 'git', 'python']
all_ok = True
for tool in tools:
try:
result = subprocess.run([tool, '--version'],
capture_output=True, text=True, timeout=10)
if result.returncode == 0:
version_line = result.stdout.split('\n')[0]
print(f"✅ {tool} - {version_line}")
else:
print(f"❌ {tool} - Command failed")
all_ok = False
except (subprocess.TimeoutExpired, FileNotFoundError):
print(f"❌ {tool} - Not found or timeout")
all_ok = False
return all_ok
def main():
"""Run all tests"""
print("=" * 50)
print("Flash Installation Test")
print("=" * 50)
print(f"Platform: {platform.system()} {platform.machine()}")
print(f"Python: {sys.executable}")
print("=" * 50)
tests = [
("Python Version", test_python_version),
("System Tools", test_system_tools),
("OpenCV", test_opencv),
("NumPy", lambda: test_package_import('numpy')),
("Matplotlib", lambda: test_package_import('matplotlib')),
("Pandas", lambda: test_package_import('pandas')),
("SciPy", lambda: test_package_import('scipy')),
("Scikit-learn", lambda: test_package_import('sklearn', 'scikit-learn')),
("Pygame", lambda: test_package_import('pygame')),
("PyOpenGL", lambda: test_package_import('OpenGL', 'PyOpenGL')),
("Numba", lambda: test_package_import('numba')),
("PySerial", lambda: test_package_import('serial', 'PySerial')),
("Platform Specific", test_platform_specific),
]
results = []
for test_name, test_func in tests:
print(f"\n{test_name}:")
try:
result = test_func()
results.append((test_name, result))
except Exception as e:
print(f"❌ {test_name} - Test failed with exception: {e}")
results.append((test_name, False))
print("\n" + "=" * 50)
print("Test Summary")
print("=" * 50)
passed = 0
total = len(results)
for test_name, result in results:
status = "✅ PASS" if result else "❌ FAIL"
print(f"{test_name}: {status}")
if result:
passed += 1
print("=" * 50)
print(f"Results: {passed}/{total} tests passed")
if passed == total:
print("🎉 All tests passed! Installation is successful.")
return 0
else:
print("⚠️ Some tests failed. Check the output above for details.")
return 1
if __name__ == "__main__":
sys.exit(main())