90 lines
2.9 KiB
Python
90 lines
2.9 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
Test script to verify WiFi adapter classification
|
|
"""
|
|
import sys
|
|
sys.path.insert(0, '/home/gilles/projects/serv_benchmark/backend')
|
|
|
|
from app.utils.device_classifier import DeviceClassifier
|
|
|
|
# Test data from the Realtek RTL8188GU WiFi adapter
|
|
test_content = """
|
|
Bus 003 Device 002: ID 0bda:b711 Realtek Semiconductor Corp. RTL8188GU 802.11n WLAN Adapter (After Modeswitch)
|
|
Negotiated speed: High Speed (480Mbps)
|
|
Device Descriptor:
|
|
bLength 18
|
|
bDescriptorType 1
|
|
bcdUSB 2.00
|
|
bDeviceClass 0 [unknown]
|
|
bDeviceSubClass 0 [unknown]
|
|
bDeviceProtocol 0
|
|
bMaxPacketSize0 64
|
|
idVendor 0x0bda Realtek Semiconductor Corp.
|
|
idProduct 0xb711 RTL8188GU 802.11n WLAN Adapter (After Modeswitch)
|
|
bcdDevice 2.00
|
|
iManufacturer 1 Realtek
|
|
iProduct 2 802.11n WLAN Adapter
|
|
iSerial 3 00E04CB82101
|
|
bNumConfigurations 1
|
|
Configuration Descriptor:
|
|
bLength 9
|
|
bDescriptorType 2
|
|
wTotalLength 0x003c
|
|
bNumInterfaces 1
|
|
bConfigurationValue 1
|
|
iConfiguration 0
|
|
bmAttributes 0x80
|
|
(Bus Powered)
|
|
MaxPower 500mA
|
|
Interface Descriptor:
|
|
bLength 9
|
|
bDescriptorType 4
|
|
bInterfaceNumber 0
|
|
bAlternateSetting 0
|
|
bNumEndpoints 6
|
|
bInterfaceClass 255 Vendor Specific Class
|
|
bInterfaceSubClass 255 Vendor Specific Subclass
|
|
bInterfaceProtocol 255 Vendor Specific Protocol
|
|
iInterface 2 802.11n WLAN Adapter
|
|
"""
|
|
|
|
device_info = {
|
|
"vendor_id": "0x0bda",
|
|
"product_id": "0xb711",
|
|
"manufacturer": "Realtek",
|
|
"product": "802.11n WLAN Adapter",
|
|
"interface_classes": [{"code": 255, "name": "Vendor Specific Class"}],
|
|
"device_class": "00"
|
|
}
|
|
|
|
print("=" * 60)
|
|
print("TEST: Realtek RTL8188GU WiFi Adapter Classification")
|
|
print("=" * 60)
|
|
|
|
# Test 1: Full classification
|
|
type_principal, sous_type = DeviceClassifier.classify_device(
|
|
cli_content=test_content,
|
|
synthese_content=None,
|
|
device_info=device_info
|
|
)
|
|
|
|
print(f"\n✓ Type principal: {type_principal}")
|
|
print(f"✓ Sous-type: {sous_type}")
|
|
|
|
# Test 2: Keyword detection
|
|
keyword_result = DeviceClassifier.detect_from_keywords(test_content)
|
|
print(f"\n✓ Keyword detection: {keyword_result}")
|
|
|
|
# Test 3: Network refinement
|
|
if type_principal == "USB" and sous_type == "Autre":
|
|
refined = DeviceClassifier.refine_usb_network_subtype(test_content)
|
|
print(f"\n✓ After refinement: USB / {refined}")
|
|
sous_type = refined
|
|
|
|
print("\n" + "=" * 60)
|
|
if type_principal == "USB" and sous_type == "Adaptateur WiFi":
|
|
print("✅ SUCCESS: Correctly identified as WiFi adapter!")
|
|
else:
|
|
print(f"❌ FAILED: Expected 'USB / Adaptateur WiFi', got '{type_principal} / {sous_type}'")
|
|
print("=" * 60)
|