diff options
| author | tobtoht <tob@featherwallet.org> | 2025-02-13 17:29:53 +0000 |
|---|---|---|
| committer | tobtoht <tob@featherwallet.org> | 2025-02-13 17:29:53 +0000 |
| commit | 632eceb172d2f2df907ec3ad019104ecb1cc9738 (patch) | |
| tree | 4c64a56dbd87136111d729c675b517469ef761b9 /tests/unit_tests | |
| parent | 563390612409b9c1815528705a9646853696866c (diff) | |
| parent | 87a8e0b2ced6cc478a70de728d66f261df20bc72 (diff) | |
| download | monzero-core-632eceb172d2f2df907ec3ad019104ecb1cc9738.tar.gz monzero-core-632eceb172d2f2df907ec3ad019104ecb1cc9738.tar.xz monzero-core-632eceb172d2f2df907ec3ad019104ecb1cc9738.zip | |
Merge pull request #9777
87a8e0b2c ci: development build backports [0.18] (tobtoht)
84e44dd01 tests: Fix tools::is_hdd unit tests (iamamyth)
Diffstat (limited to 'tests/unit_tests')
| -rw-r--r-- | tests/unit_tests/is_hdd.cpp | 37 |
1 files changed, 28 insertions, 9 deletions
diff --git a/tests/unit_tests/is_hdd.cpp b/tests/unit_tests/is_hdd.cpp index 040af4f47..55f759ed9 100644 --- a/tests/unit_tests/is_hdd.cpp +++ b/tests/unit_tests/is_hdd.cpp @@ -1,17 +1,36 @@ #include "common/util.h" +#include <cstdlib> #include <string> #include <gtest/gtest.h> +#include <boost/optional/optional_io.hpp> /* required to output boost::optional in assertions */ + +#ifndef GTEST_SKIP +#include <iostream> +#define SKIP_TEST(reason) do {std::cerr << "Skipping test: " << reason << std::endl; return;} while(0) +#else +#define SKIP_TEST(reason) GTEST_SKIP() << reason +#endif #if defined(__GLIBC__) -TEST(is_hdd, linux_os_root) -{ - std::string path = "/"; - EXPECT_TRUE(tools::is_hdd(path.c_str()) != boost::none); +TEST(is_hdd, rotational_drive) { + const char *hdd = std::getenv("MONERO_TEST_DEVICE_HDD"); + if (hdd == nullptr) + SKIP_TEST("No rotational disk device configured"); + EXPECT_EQ(tools::is_hdd(hdd), boost::optional<bool>(true)); } -#else -TEST(is_hdd, unknown_os) -{ - std::string path = ""; - EXPECT_FALSE(tools::is_hdd(path.c_str()) != boost::none); + +TEST(is_hdd, ssd) { + const char *ssd = std::getenv("MONERO_TEST_DEVICE_SSD"); + if (ssd == nullptr) + SKIP_TEST("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); } #endif +TEST(is_hdd, stability) +{ + EXPECT_NO_THROW(tools::is_hdd("")); +} |
