Add C mock driver for RAIDGuard X GUI Server

This commit is contained in:
accusys
2026-03-29 14:46:28 +08:00
parent 27da85879f
commit c42b62b473
5 changed files with 860 additions and 0 deletions
@@ -0,0 +1,83 @@
/*
* test_mock_driver.c
*
* Test program for mock driver
*/
#include <stdio.h>
#include "mock_driver.h"
int main(int argc, char *argv[]) {
printf("=== Mock Driver Test ===\n\n");
// Enable verbose output
mock_set_verbose(true);
// Initialize mock driver
printf("\n--- Testing mock_init() ---\n");
mock_init();
// Print configuration
printf("\n--- Testing mock_print_config() ---\n");
mock_print_config();
// Test QuaryDTR
printf("\n--- Testing mock_QuaryDTR() ---\n");
UCHAR pageBuf[1024];
UCHAR heatsink;
CHAR result = mock_QuaryDTR(0, pageBuf, &heatsink);
printf("QuaryDTR result: %d\n", result);
printf("Serial Number: %.16s\n", pageBuf);
printf("Model Name: %.20s\n", pageBuf + 16);
printf("Firmware: %.8s\n", pageBuf + 64);
// Test GetCtlrEvent
printf("\n--- Testing mock_get_ctlr_event() ---\n");
EVENT_INFO evt;
result = mock_GetCtlrEvent(0, &evt);
printf("GetCtlrEvent result: 0x%02X\n", result);
printf("Event Status: %d\n", evt.bStatus);
if (evt.bStatus) {
printf("Event Data: ");
for (int i = 0; i < 16 && i < MAX_EDB_SZ; i++) {
printf("%02X ", evt.bEventBuf[i]);
}
printf("\n");
}
// Test pushing custom event
printf("\n--- Testing mock_push_event() ---\n");
UCHAR customEvent[] = {
0x03, 0x00, 0x00, 0x00, // Event Type: RAID Rebuild Start
0x00, 0x00, 0x00, 0x00, // Timestamp
0x00, 0x00, 0x00, 0x00, // RAID ID 0
0x00, 0x00, 0x00, 0x00
};
mock_push_event(customEvent, 16);
printf("Custom event pushed\n");
// Get the custom event
result = mock_GetCtlrEvent(0, &evt);
printf("GetCtlrEvent result: 0x%02X\n", result);
// Test configuration functions
printf("\n--- Testing configuration functions ---\n");
mock_set_controller_count(2);
mock_set_controller_serial(1, "MOCK00000002");
mock_set_controller_model(1, "Accusys GEN3");
mock_print_config();
// Test event generation
printf("\n--- Testing event generation ---\n");
mock_generate_disk_event(5, 0x01); // Disk 5 online
mock_generate_raid_event(0, 0x02); // RAID 0 rebuild
printf("Generated 2 events\n");
// Cleanup
printf("\n--- Testing mock_cleanup() ---\n");
mock_cleanup();
printf("\n=== All Tests Completed ===\n");
return 0;
}