2018-02-17 02:21:44 +00:00
|
|
|
//
|
|
|
|
|
// Copyright 2018 Ettus Research, a National Instruments Company
|
2019-11-18 09:09:12 +00:00
|
|
|
// Copyright 2019 Ettus Research, A National Instruments Brand
|
2018-02-17 02:21:44 +00:00
|
|
|
//
|
|
|
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
#include <uhd/config.hpp>
|
|
|
|
|
#include <uhd/exception.hpp>
|
|
|
|
|
#include <uhd/utils/paths.hpp>
|
|
|
|
|
#include <uhdlib/utils/paths.hpp>
|
|
|
|
|
#include <boost/filesystem/operations.hpp>
|
2019-01-14 18:35:25 +00:00
|
|
|
#include <boost/test/unit_test.hpp>
|
2018-02-17 02:21:44 +00:00
|
|
|
#include <iostream>
|
2019-01-14 18:35:25 +00:00
|
|
|
#include <vector>
|
2018-02-17 02:21:44 +00:00
|
|
|
|
2019-01-14 18:35:25 +00:00
|
|
|
BOOST_AUTO_TEST_CASE(test_paths_expandvars)
|
|
|
|
|
{
|
2018-02-17 02:21:44 +00:00
|
|
|
#ifdef UHD_PLATFORM_WIN32
|
2019-11-18 09:09:12 +00:00
|
|
|
const std::string path_to_expand("%programdata%/uhd/uhd.conf");
|
2018-02-17 02:21:44 +00:00
|
|
|
#else
|
|
|
|
|
const std::string path_to_expand("$HOME/.uhd/uhd.conf");
|
|
|
|
|
#endif
|
|
|
|
|
const std::string expanded_path = uhd::path_expandvars(path_to_expand);
|
|
|
|
|
|
2019-01-14 18:35:25 +00:00
|
|
|
std::cout << "Expanded path: " << path_to_expand << " -> " << expanded_path
|
|
|
|
|
<< std::endl;
|
2018-02-17 02:21:44 +00:00
|
|
|
BOOST_CHECK(path_to_expand != expanded_path);
|
|
|
|
|
|
|
|
|
|
#ifdef UHD_PLATFORM_WIN32
|
|
|
|
|
const std::string var_identifier = "%";
|
|
|
|
|
#else
|
|
|
|
|
const std::string var_identifier = "$";
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
BOOST_CHECK(expanded_path.find(var_identifier) == std::string::npos);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2019-01-14 18:35:25 +00:00
|
|
|
BOOST_AUTO_TEST_CASE(test_get_paths)
|
|
|
|
|
{
|
2018-02-17 02:21:44 +00:00
|
|
|
using namespace uhd;
|
|
|
|
|
|
2020-03-06 00:23:07 +00:00
|
|
|
std::cout << "tmp_path: " << get_tmp_path() << std::endl;
|
|
|
|
|
BOOST_CHECK(true);
|
|
|
|
|
std::cout << "pkg_path: " << get_pkg_path() << std::endl;
|
|
|
|
|
BOOST_CHECK(true);
|
|
|
|
|
std::cout << "cal_path: " << get_cal_data_path() << std::endl;
|
|
|
|
|
BOOST_CHECK(true);
|
2018-02-17 02:21:44 +00:00
|
|
|
|
2022-11-17 14:32:49 +00:00
|
|
|
const auto module_paths = get_module_paths();
|
2018-02-17 02:21:44 +00:00
|
|
|
for (const auto& module_path : module_paths) {
|
|
|
|
|
std::cout << "module path: " << module_path << std::endl;
|
|
|
|
|
}
|
2020-03-06 00:23:07 +00:00
|
|
|
BOOST_CHECK(true);
|
2018-02-17 02:21:44 +00:00
|
|
|
|
|
|
|
|
const std::string images_dir_search_path = "";
|
2020-04-15 22:05:16 +00:00
|
|
|
std::cout << "images_dir: " << get_images_dir(images_dir_search_path) << std::endl;
|
2018-02-17 02:21:44 +00:00
|
|
|
BOOST_REQUIRE_THROW(
|
2019-01-14 18:35:25 +00:00
|
|
|
find_image_path("this_device_does_not_exist.bit", ""), uhd::io_error);
|
2018-02-17 02:21:44 +00:00
|
|
|
|
2019-01-14 18:35:25 +00:00
|
|
|
const std::string utility_path = find_utility("uhd_images_downloader");
|
2018-02-17 02:21:44 +00:00
|
|
|
std::cout << "utility_path: " << utility_path << std::endl;
|
|
|
|
|
|
2019-01-14 18:35:25 +00:00
|
|
|
const std::string utility_error =
|
|
|
|
|
print_utility_error("uhd_images_downloader", "--help");
|
2020-03-04 23:23:28 +00:00
|
|
|
std::cout << "utility_error: " << utility_error << std::endl;
|
2018-02-17 02:21:44 +00:00
|
|
|
}
|