43 lines
1.1 KiB
C++
43 lines
1.1 KiB
C++
#pragma once
|
|
|
|
#include <cerrno>
|
|
#include <filesystem>
|
|
#include <string>
|
|
#include <string_view>
|
|
|
|
#include <sys/wait.h>
|
|
#include <unistd.h>
|
|
|
|
#include <boost/test/unit_test.hpp>
|
|
|
|
#include <modulus/types.hpp>
|
|
|
|
|
|
namespace vamp_test {
|
|
|
|
inline auto part_filename(std::string_view part) -> std::string {
|
|
auto result = std::string{part};
|
|
result.front() = static_cast<std::char_t>(result.front() - 'A' + 'a');
|
|
return result + ".json";
|
|
}
|
|
|
|
inline auto build_catalogue(std::filesystem::path const &assets, std::filesystem::path const &database) -> std::bool_t {
|
|
auto source = assets.string();
|
|
auto destination = database.string();
|
|
auto child = ::fork();
|
|
BOOST_REQUIRE(child >= 0);
|
|
if (child == 0) {
|
|
::execl(VAMP_TEST_PYTHON, VAMP_TEST_PYTHON, VAMP_TEST_SOURCE_DIR "/generator/catalogue.py", source.c_str(), destination.c_str(), nullptr);
|
|
::_exit(127);
|
|
}
|
|
auto status = std::int32_t{};
|
|
auto waited = ::waitpid(child, &status, 0);
|
|
while (waited < 0 && errno == EINTR) {
|
|
waited = ::waitpid(child, &status, 0);
|
|
}
|
|
BOOST_REQUIRE(waited == child);
|
|
return WIFEXITED(status) && WEXITSTATUS(status) == 0;
|
|
}
|
|
|
|
}
|