feat(tests): rework tests in numerous ways (#3059)

This commit is contained in:
ns6089
2024-08-22 23:48:24 +03:00
committed by GitHub
parent 3088823ffc
commit 764ce03520
19 changed files with 316 additions and 446 deletions

View File

@@ -4,60 +4,45 @@
*/
#include <src/video.h>
#include <tests/conftest.cpp>
#include "../tests_common.h"
class EncoderTest: public virtual BaseTest, public PlatformInitBase, public ::testing::WithParamInterface<std::tuple<std::basic_string_view<char>, video::encoder_t *>> {
protected:
struct EncoderTest: PlatformTestSuite, testing::WithParamInterface<video::encoder_t *> {
void
SetUp() override {
BaseTest::SetUp();
PlatformInitBase::SetUp();
std::string_view p_name = std::get<0>(GetParam());
std::cout << "EncoderTest(" << p_name << "):: starting Fixture SetUp" << std::endl;
std::cout << "EncoderTest(" << p_name << "):: validating encoder" << std::endl;
video::encoder_t *encoder = std::get<1>(GetParam());
bool isEncoderValid;
isEncoderValid = video::validate_encoder(*encoder, false);
if (!isEncoderValid) {
// if encoder is software fail, otherwise skip
if (encoder == &video::software && std::string(TESTS_SOFTWARE_ENCODER_UNAVAILABLE) == "fail") {
FAIL() << "EncoderTest(" << p_name << "):: software encoder not available";
auto &encoder = *GetParam();
if (!video::validate_encoder(encoder, false)) {
// Encoder failed validation,
// if it's software - fail (unless overriden with compile definition), otherwise skip
if (encoder.name == "software" && std::string(TESTS_SOFTWARE_ENCODER_UNAVAILABLE) == "fail") {
FAIL() << "Software encoder not available";
}
else {
GTEST_SKIP_((std::string("EncoderTest(") + std::string(p_name) + "):: encoder not available").c_str());
GTEST_SKIP() << "Encoder not available";
}
}
else {
std::cout << "EncoderTest(" << p_name << "):: encoder available" << std::endl;
}
}
void
TearDown() override {
PlatformInitBase::TearDown();
BaseTest::TearDown();
}
};
INSTANTIATE_TEST_SUITE_P(
EncoderVariants,
EncoderTest,
::testing::Values(
testing::Values(
#if !defined(__APPLE__)
std::make_tuple(video::nvenc.name, &video::nvenc),
&video::nvenc,
#endif
#ifdef _WIN32
std::make_tuple(video::amdvce.name, &video::amdvce), std::make_tuple(video::quicksync.name, &video::quicksync),
&video::amdvce,
&video::quicksync,
#endif
#ifdef __linux__
std::make_tuple(video::vaapi.name, &video::vaapi),
&video::vaapi,
#endif
#ifdef __APPLE__
std::make_tuple(video::videotoolbox.name, &video::videotoolbox),
&video::videotoolbox,
#endif
std::make_tuple(video::software.name, &video::software)));
&video::software),
[](const auto &info) { return std::string(info.param->name); });
TEST_P(EncoderTest, ValidateEncoder) {
// todo:: test something besides fixture setup
}