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

Commit a53f554c authored by Frankie Lizcano's avatar Frankie Lizcano
Browse files

Improve Tuner VTS: Generate DVR Playback Combos

This CL allows the VTS to read a vendor's configuration file, determine
if the given devices could support the playback dataflow, and generate
all combinations of units (dvr, audio filter, video filter, section
filters) to run them on corresponding integration tests.

Additionally, began storing section filter id's and eliminated the check
to see if they were stored already by utilizing the TearDown() function
between integration tests.

Bug: b/182519645

Test: vts-tradefed run vts --module VtsHalTvTunerTargetTest. Manual
tests with different input configuration files.

Change-Id: I8e8be258dce9927e755f9c8bdb41441f367a196b
parent d58f4aaa
Loading
Loading
Loading
Loading
+18 −4
Original line number Diff line number Diff line
@@ -839,27 +839,41 @@ TEST_P(TunerFilterAidlTest, FilterDelayHintTest) {

TEST_P(TunerPlaybackAidlTest, PlaybackDataFlowWithTsSectionFilterTest) {
    description("Feed ts data from playback and configure Ts section filter to get output");
    if (!playback.support || playback.sectionFilterId.compare(emptyHardwareId) == 0) {
    if (!playback.support) {
        return;
    }
    vector<DvrPlaybackHardwareConnections> playback_configs = generatePlaybackConfigs();
    for (auto& configuration : playback_configs) {
        if (configuration.sectionFilterId.compare(emptyHardwareId) != 0) {
            playback = configuration;
            playbackSingleFilterTest(filterMap[playback.sectionFilterId], dvrMap[playback.dvrId]);
        }
    }
}

TEST_P(TunerPlaybackAidlTest, PlaybackDataFlowWithTsAudioFilterTest) {
    description("Feed ts data from playback and configure Ts audio filter to get output");
    if (!playback.support) {
        return;
    }
    vector<DvrPlaybackHardwareConnections> playback_configs = generatePlaybackConfigs();
    for (auto& configuration : playback_configs) {
        playback = configuration;
        playbackSingleFilterTest(filterMap[playback.audioFilterId], dvrMap[playback.dvrId]);
    }
}

TEST_P(TunerPlaybackAidlTest, PlaybackDataFlowWithTsVideoFilterTest) {
    description("Feed ts data from playback and configure Ts video filter to get output");
    if (!playback.support) {
        return;
    }
    vector<DvrPlaybackHardwareConnections> playback_configs = generatePlaybackConfigs();
    for (auto& configuration : playback_configs) {
        playback = configuration;
        playbackSingleFilterTest(filterMap[playback.videoFilterId], dvrMap[playback.dvrId]);
    }
}

TEST_P(TunerRecordAidlTest, RecordDataFlowWithTsRecordFilterTest) {
    description("Feed ts data from frontend to recording and test with ts record filter");
+1 −0
Original line number Diff line number Diff line
@@ -70,6 +70,7 @@ void clearIds() {
    videoFilterIds.clear();
    playbackDvrIds.clear();
    recordFilterIds.clear();
    sectionFilterIds.clear();
}

class TunerLnbAidlTest : public testing::TestWithParam<std::string> {
+98 −0
Original line number Diff line number Diff line
@@ -75,6 +75,104 @@ static LnbLiveHardwareConnections lnbLive;
static LnbRecordHardwareConnections lnbRecord;
static TimeFilterHardwareConnections timeFilter;

/*
 * This function takes in a 2d vector of device Id's
 * The n vectors correlate to the ids for n different devices (eg frontends, filters)
 * The resultant 2d vector is every combination of id's with 1 id from each vector
 */
inline vector<vector<string>> generateIdCombinations(vector<vector<string>>& ids) {
    vector<vector<string>> combinations;

    // The index of each vector in ids that will be used in the next combination
    // EG {0, 2} means combo {ids[0][0] ids[1][2]} will be next
    const int size = static_cast<int>(ids.size());
    vector<int> indexes_used_in_combination(size, 0);

    // The vector number from ids whose elements we will cycle through to make combinations.
    // First, start at the right most vector
    int cycled_vector = size - 1;

    while (cycled_vector >= 0) {
        // Make a combination (one at a time)
        vector<string> combo;
        for (size_t i = 0; i < indexes_used_in_combination.size(); ++i) {
            const int combo_index = indexes_used_in_combination[i];
            combo.push_back(ids[i][combo_index]);
        }
        combinations.push_back(combo);

        // Find the right most vector that still has space [elements left] to cycle through and
        // create a combination
        while (cycled_vector >= 0 &&
               indexes_used_in_combination[cycled_vector] == ids[cycled_vector].size() - 1) {
            cycled_vector--;
        }

        // Use this check to avoid segmentation faults
        if (cycled_vector >= 0) {
            // Once found, we have a vector we can cycle through, so increase to its next element
            indexes_used_in_combination[cycled_vector]++;

            // Reset the other vectors to the right to their first element so we can cycle through
            // them again with the new element from cycled vector
            for (size_t i = cycled_vector + 1; i < indexes_used_in_combination.size(); ++i) {
                indexes_used_in_combination[i] = 0;
            }

            // all the vectors to the right were reset, so we can cycle through them again
            // Start at the furthest right vector
            cycled_vector = size - 1;
        }
    }

    return combinations;
}

/*
 * index 0 - playback dvr
 * index 1 - audio filters
 * index 2 - video filters
 * index 3 - optional section filters
 */
static inline vector<DvrPlaybackHardwareConnections> generatePlaybackCombinations() {
    vector<DvrPlaybackHardwareConnections> combinations;
    vector<string> sectionFilterIds_optional = sectionFilterIds;
    sectionFilterIds_optional.push_back(emptyHardwareId);
    vector<vector<string>> deviceIds{playbackDvrIds, audioFilterIds, videoFilterIds,
                                     sectionFilterIds_optional};

    const int dvrIndex = 0;
    const int audioFilterIndex = 1;
    const int videoFilterIndex = 2;
    const int sectionFilterIndex = 3;

    auto idCombinations = generateIdCombinations(deviceIds);
    for (auto& combo : idCombinations) {
        DvrPlaybackHardwareConnections mPlayback;
        mPlayback.dvrId = combo[dvrIndex];
        mPlayback.audioFilterId = combo[audioFilterIndex];
        mPlayback.videoFilterId = combo[videoFilterIndex];
        mPlayback.sectionFilterId = combo[sectionFilterIndex];
        combinations.push_back(mPlayback);
    }

    return combinations;
}

static inline vector<DvrPlaybackHardwareConnections> generatePlaybackConfigs() {
    vector<DvrPlaybackHardwareConnections> playback_configs;
    if (configuredPlayback) {
        ALOGD("Using DVR playback configuration provided.");
        playback_configs = {playback};
    } else {
        ALOGD("Dvr playback not provided. Generating possible combinations. Consider adding it to "
              "the configuration file.");
        playback_configs = generatePlaybackCombinations();
    }

    return playback_configs;
}

/** Config all the frontends that would be used in the tests */
inline void initFrontendConfig() {
    // The test will use the internal default fe when default fe is connected to any data flow
+3 −0
Original line number Diff line number Diff line
@@ -83,6 +83,7 @@ static vector<string> recordDvrIds;
static vector<string> audioFilterIds;
static vector<string> videoFilterIds;
static vector<string> recordFilterIds;
static vector<string> sectionFilterIds;

#define PROVISION_STR                                      \
    "{                                                   " \
@@ -838,6 +839,8 @@ struct TunerTestingConfigAidlReader1_0 {
            videoFilterIds.push_back(filterConfig.getId());
        } else if (subType == FilterSubTypeEnum::RECORD) {
            recordFilterIds.push_back(filterConfig.getId());
        } else if (subType == FilterSubTypeEnum::SECTION) {
            sectionFilterIds.push_back(filterConfig.getId());
        }

        switch (mainType) {