Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 731a3dc1 authored by Sungtak Lee's avatar Sungtak Lee Committed by Automerger Merge Worker
Browse files

Merge "C2 VTS: Add support to choose component/s to be tested" am: f77640ee

Original change: https://android-review.googlesource.com/c/platform/frameworks/av/+/1652569

Change-Id: I96c1b4c91352ba1e243e44ae580d771309afdf0e
parents 1fe11784 f77640ee
Loading
Loading
Loading
Loading
+1 −12
Original line number Diff line number Diff line
@@ -39,9 +39,6 @@ static std::vector<std::tuple<std::string, std::string, std::string, std::string

static std::vector<std::tuple<std::string, std::string, std::string>> kCsdFlushTestParameters;

// Resource directory
static std::string sResourceDir = "";

struct CompToURL {
    std::string mime;
    std::string mURL;
@@ -892,6 +889,7 @@ INSTANTIATE_TEST_SUITE_P(CsdInputs, Codec2AudioDecCsdInputTests,
}  // anonymous namespace

int main(int argc, char** argv) {
    parseArgs(argc, argv);
    kTestParameters = getTestParameters(C2Component::DOMAIN_AUDIO, C2Component::KIND_DECODER);
    for (auto params : kTestParameters) {
        kDecodeTestParameters.push_back(
@@ -909,15 +907,6 @@ int main(int argc, char** argv) {
                std::make_tuple(std::get<0>(params), std::get<1>(params), "false"));
    }

    // Set the resource directory based on command line args.
    // Test will fail to set up if the argument is not set.
    for (int i = 1; i < argc; i++) {
        if (strcmp(argv[i], "-P") == 0 && i < argc - 1) {
            sResourceDir = argv[i + 1];
            break;
        }
    }

    ::testing::InitGoogleTest(&argc, argv);
    return RUN_ALL_TESTS();
}
+1 −12
Original line number Diff line number Diff line
@@ -38,9 +38,6 @@ using android::C2AllocatorIon;
static std::vector<std::tuple<std::string, std::string, std::string, std::string>>
        kEncodeTestParameters;

// Resource directory
static std::string sResourceDir = "";

class LinearBuffer : public C2Buffer {
  public:
    explicit LinearBuffer(const std::shared_ptr<C2LinearBlock>& block)
@@ -797,6 +794,7 @@ INSTANTIATE_TEST_SUITE_P(EncodeTest, Codec2AudioEncEncodeTest,
}  // anonymous namespace

int main(int argc, char** argv) {
    parseArgs(argc, argv);
    kTestParameters = getTestParameters(C2Component::DOMAIN_AUDIO, C2Component::KIND_ENCODER);
    for (auto params : kTestParameters) {
        kEncodeTestParameters.push_back(
@@ -809,15 +807,6 @@ int main(int argc, char** argv) {
                std::make_tuple(std::get<0>(params), std::get<1>(params), "true", "2"));
    }

    // Set the resource directory based on command line args.
    // Test will fail to set up if the argument is not set.
    for (int i = 1; i < argc; i++) {
        if (strcmp(argv[i], "-P") == 0 && i < argc - 1) {
            sResourceDir = argv[i + 1];
            break;
        }
    }

    ::testing::InitGoogleTest(&argc, argv);
    return RUN_ALL_TESTS();
}
+50 −1
Original line number Diff line number Diff line
@@ -22,6 +22,48 @@

#include <android/hardware/media/c2/1.0/IComponentStore.h>

std::string sResourceDir = "";

std::string sComponentNamePrefix = "";

static constexpr struct option kArgOptions[] = {
    {"res", required_argument, 0, 'P'},
    {"prefix", required_argument, 0, 'p'},
    {"help", required_argument, 0, 'h'},
    {nullptr, 0, nullptr, 0},
};

void printUsage(char *me) {
    std::cerr << "VTS tests to test codec2 components \n";
    std::cerr << "Usage: " << me << " [options] \n";
    std::cerr << "\t -P,  --res:    Mandatory path to a folder that contains test resources \n";
    std::cerr << "\t -p,  --prefix: Optional prefix to select component/s to be tested \n";
    std::cerr << "\t                    All codecs are tested by default \n";
    std::cerr << "\t                    Eg: c2.android - test codecs starting with c2.android \n";
    std::cerr << "\t                    Eg: c2.android.aac.decoder - test a specific codec \n";
    std::cerr << "\t -h,  --help:   Print usage \n";
}

void parseArgs(int argc, char** argv) {
    int arg;
    int option_index;
    while ((arg = getopt_long(argc, argv, ":P:p:h", kArgOptions, &option_index)) != -1) {
        switch (arg) {
        case 'P':
            sResourceDir = optarg;
            break;
        case 'p':
            sComponentNamePrefix = optarg;
            break;
        case 'h':
            printUsage(argv[0]);
            break;
        default:
            break;
        }
    }
}

// Test the codecs for NullBuffer, Empty Input Buffer with(out) flags set
void testInputBuffer(const std::shared_ptr<android::Codec2Client::Component>& component,
                     std::mutex& queueLock, std::list<std::unique_ptr<C2Work>>& workQueue,
@@ -157,11 +199,18 @@ const std::vector<std::tuple<std::string, std::string>>& getTestParameters(
                (traits.domain != domain || traits.kind != kind)) {
                continue;
            }

            if (traits.name.rfind(sComponentNamePrefix, 0) != 0) {
                ALOGD("Skipping tests for %s. Prefix specified is %s", traits.name.c_str(),
                      sComponentNamePrefix.c_str());
                continue;
            }
            parameters.push_back(std::make_tuple(instance, traits.name));
        }
    }

    if (parameters.empty()) {
        ALOGE("No test parameters added. Verify component prefix passed to the test");
    }
    return parameters;
}

+8 −0
Original line number Diff line number Diff line
@@ -42,6 +42,12 @@ using namespace ::std::chrono;

static std::vector<std::tuple<std::string, std::string>> kTestParameters;

// Resource directory
extern std::string sResourceDir;

// Component name prefix
extern std::string sComponentNamePrefix;

struct FrameInfo {
    int bytesCount;
    uint32_t flags;
@@ -105,6 +111,8 @@ struct CodecListener : public android::Codec2Client::Listener {
    std::function<void(std::list<std::unique_ptr<C2Work>>& workItems)> callBack;
};

void parseArgs(int argc, char** argv);

// Return all test parameters, a list of tuple of <instance, component>.
const std::vector<std::tuple<std::string, std::string>>& getTestParameters();

+1 −0
Original line number Diff line number Diff line
@@ -360,6 +360,7 @@ INSTANTIATE_TEST_CASE_P(NonStdInputs, Codec2ComponentInputTests,
// TODO: Add test for Invalid work,
// TODO: Add test for Invalid states
int main(int argc, char** argv) {
    parseArgs(argc, argv);
    kTestParameters = getTestParameters();
    for (auto params : kTestParameters) {
        kInputTestParameters.push_back(
Loading