Run partition scanning test in CLI mode
| 18 | |
| 19 | // Run partition scanning test in CLI mode |
| 20 | static int runPartitionScanTest() |
| 21 | { |
| 22 | std::cout << "=== EFI Partition Scanner Test ===" << std::endl; |
| 23 | std::cout << "Platform: " |
| 24 | #ifdef Q_OS_LINUX |
| 25 | << "Linux" |
| 26 | #elif defined(Q_OS_FREEBSD) |
| 27 | << "FreeBSD" |
| 28 | #elif defined(Q_OS_DARWIN) |
| 29 | << "macOS" |
| 30 | #elif defined(Q_OS_WIN) |
| 31 | << "Windows" |
| 32 | #else |
| 33 | << "Unknown" |
| 34 | #endif |
| 35 | << std::endl; |
| 36 | |
| 37 | // Check privileges |
| 38 | QEFIPartitionManager manager; |
| 39 | bool hasPrivileges = manager.hasPrivileges(); |
| 40 | std::cout << "Running with privileges: " << (hasPrivileges ? "YES" : "NO") << std::endl; |
| 41 | |
| 42 | if (!hasPrivileges) { |
| 43 | std::cerr << "WARNING: Not running with sufficient privileges" << std::endl; |
| 44 | std::cerr << "Partition scanning may fail or return incomplete results" << std::endl; |
| 45 | } |
| 46 | |
| 47 | std::cout << "\nScanning for partitions..." << std::endl; |
| 48 | |
| 49 | // Perform scan |
| 50 | QList<QEFIPartitionInfo> partitions; |
| 51 | try { |
| 52 | partitions = manager.scanPartitions(); |
| 53 | } catch (const std::exception &e) { |
| 54 | std::cerr << "ERROR: Exception during scanning: " << e.what() << std::endl; |
| 55 | return 1; |
| 56 | } catch (...) { |
| 57 | std::cerr << "ERROR: Unknown exception during scanning" << std::endl; |
| 58 | return 1; |
| 59 | } |
| 60 | |
| 61 | std::cout << "Scan completed successfully" << std::endl; |
| 62 | std::cout << "Found " << partitions.size() << " partition(s)" << std::endl; |
| 63 | |
| 64 | if (partitions.isEmpty()) { |
| 65 | std::cout << "\nNo partitions found (this may be expected in test environments)" << std::endl; |
| 66 | return 0; |
| 67 | } |
| 68 | |
| 69 | // Display partition information |
| 70 | std::cout << "\n=== Partition Details ===" << std::endl; |
| 71 | for (int i = 0; i < partitions.size(); ++i) { |
| 72 | const QEFIPartitionInfo &part = partitions[i]; |
| 73 | std::cout << "\nPartition #" << (i + 1) << ":" << std::endl; |
| 74 | std::cout << " Device Path: " << part.devicePath.toStdString() << std::endl; |
| 75 | std::cout << " Is EFI: " << (part.isEFI ? "YES" : "NO") << std::endl; |
| 76 | std::cout << " Partition #: " << part.partitionNumber << std::endl; |
| 77 | std::cout << " Size: " << (part.size / 1024 / 1024) << " MB" << std::endl; |
no test coverage detected