2018-08-25 14:16:01 +03:00
|
|
|
#include "common/util.h"
|
2025-01-17 12:48:48 +02:00
|
|
|
#include <cstdlib>
|
2018-08-25 14:16:01 +03:00
|
|
|
#include <string>
|
|
|
|
#include <gtest/gtest.h>
|
2025-01-17 12:48:48 +02:00
|
|
|
#include <boost/optional/optional_io.hpp> /* required to output boost::optional in assertions */
|
2018-08-25 14:16:01 +03:00
|
|
|
|
|
|
|
#if defined(__GLIBC__)
|
2025-01-17 12:48:48 +02:00
|
|
|
TEST(is_hdd, rotational_drive) {
|
|
|
|
const char *hdd = std::getenv("MONERO_TEST_DEVICE_HDD");
|
|
|
|
if (hdd == nullptr)
|
|
|
|
GTEST_SKIP() << "No rotational disk device configured";
|
|
|
|
EXPECT_EQ(tools::is_hdd(hdd), boost::optional<bool>(true));
|
2018-08-25 14:16:01 +03:00
|
|
|
}
|
2025-01-17 12:48:48 +02:00
|
|
|
|
|
|
|
TEST(is_hdd, ssd) {
|
|
|
|
const char *ssd = std::getenv("MONERO_TEST_DEVICE_SSD");
|
|
|
|
if (ssd == nullptr)
|
|
|
|
GTEST_SKIP() << "No SSD device configured";
|
|
|
|
EXPECT_EQ(tools::is_hdd(ssd), boost::optional<bool>(false));
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(is_hdd, unknown_attrs) {
|
|
|
|
EXPECT_EQ(tools::is_hdd("/dev/null"), boost::none);
|
2018-08-25 14:16:01 +03:00
|
|
|
}
|
|
|
|
#endif
|
2025-01-17 12:48:48 +02:00
|
|
|
TEST(is_hdd, stability)
|
|
|
|
{
|
|
|
|
EXPECT_NO_THROW(tools::is_hdd(""));
|
|
|
|
}
|