mirror of
https://github.com/ashaduri/gsmartcontrol.git
synced 2026-09-25 21:35:33 +00:00
Fix ATA testing with when JSON parser is used.
This commit is contained in:
@@ -445,7 +445,7 @@ hz::ExpectedVoid<SelfTestExecutionError> SelfTest::update(const std::shared_ptr<
|
||||
// we use the "self-test status" capability.
|
||||
StorageProperty p;
|
||||
for (const auto& e : property_repo.get_properties()) {
|
||||
if (e.is_value_type<AtaStorageSelftestEntry>() || e.get_value<AtaStorageSelftestEntry>().test_num != 0
|
||||
if (!e.is_value_type<AtaStorageSelftestEntry>() || e.get_value<AtaStorageSelftestEntry>().test_num != 0
|
||||
|| e.generic_name != "ata_smart_data/self_test/status/_merged")
|
||||
continue;
|
||||
p = e;
|
||||
|
||||
@@ -498,7 +498,7 @@ hz::ExpectedVoid<SmartctlParserError> SmartctlJsonAtaParser::parse_section_capab
|
||||
}
|
||||
},
|
||||
|
||||
{"ata_smart_data/self_test/status/value/_decoded", _("Self-test execution status"),
|
||||
{"ata_smart_data/self_test/status/_merged", _("Self-test execution status"),
|
||||
[](const nlohmann::json& root_node, const std::string& key, const std::string& displayable_name)
|
||||
-> hz::ExpectedValue<StorageProperty, SmartctlParserError>
|
||||
{
|
||||
@@ -536,9 +536,19 @@ hz::ExpectedVoid<SmartctlParserError> SmartctlJsonAtaParser::parse_section_capab
|
||||
default: status = AtaStorageSelftestEntry::Status::Reserved; break;
|
||||
}
|
||||
|
||||
AtaStorageSelftestEntry sse;
|
||||
sse.test_num = 0; // capability uses 0
|
||||
sse.status_str = AtaStorageSelftestEntry::get_readable_status_name(status);
|
||||
sse.status = status;
|
||||
|
||||
sse.remaining_percent = -1; // unknown or n/a
|
||||
if (auto remaining_percent_val = get_node_data<int8_t>(root_node, "ata_smart_data/self_test/status/remaining_percent"); remaining_percent_val.has_value()) {
|
||||
sse.remaining_percent = remaining_percent_val.value();
|
||||
}
|
||||
|
||||
StorageProperty p;
|
||||
p.set_name(key, key, displayable_name);
|
||||
p.value = AtaStorageSelftestEntry::get_readable_status_name(status);
|
||||
p.value = sse;
|
||||
return p;
|
||||
}
|
||||
|
||||
|
||||
@@ -209,7 +209,7 @@ class AtaStorageSelftestEntry {
|
||||
std::int8_t remaining_percent = -1; ///< Remaining %. 0% for completed, 90% for started. -1 if n/a.
|
||||
std::uint32_t lifetime_hours = 0; ///< When the test happened (in lifetime hours). capability: unused.
|
||||
std::string lba_of_first_error; ///< LBA of the first error. "-" or value (format? usually hex). capability: unused.
|
||||
bool passed = false; ///< Test passed or not.
|
||||
bool passed = false; ///< Test passed or not. capability: unused.
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user