pmt: Improve libpartition_map and tests
- Change doFor*** function return types as bool. - Add catching of doFor*** function test results. - Use std::ios_base_failure for catch std::fstream errors on tests
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
#include <iostream>
|
||||
#include <libpartition_map/lib.hpp>
|
||||
#include <unistd.h>
|
||||
#include <pstl/glue_execution_defs.h>
|
||||
|
||||
int main() {
|
||||
if (getuid() != 0) return 2;
|
||||
@@ -64,9 +65,11 @@ int main() {
|
||||
std::ofstream f("parts.txt");
|
||||
f << "Partition: " << partition << ", size: " << props.size
|
||||
<< ", logical: " << props.isLogical;
|
||||
f.exceptions(std::ios_base::failbit | std::ios_base::badbit);
|
||||
return !f.fail();
|
||||
};
|
||||
MyMap.doForAllPartitions(func);
|
||||
if (!MyMap.doForAllPartitions(func))
|
||||
throw PartitionMap::Error("doForAllPartitions() progress failed");
|
||||
|
||||
std::cout << "Total partitions count: " << (int)MyMap << std::endl;
|
||||
std::cout << "Boot: " << MyMap.getRealLinkPathOf("boot") << std::endl;
|
||||
@@ -95,6 +98,9 @@ int main() {
|
||||
} catch (PartitionMap::Error &error) {
|
||||
std::cerr << error.what() << std::endl;
|
||||
return 1;
|
||||
} catch (std::ios_base::failure &error) {
|
||||
std::cerr << "fstream error: " << error.what() << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user