rdkcentral / ut-core

Unit Test - Core Framework
Apache License 2.0
4 stars 0 forks source link

i78: ut-core: upgrade core to support multiple profile inputs that get merged into a single lookup #78

Open Ulrond opened 4 months ago

Ulrond commented 4 months ago

Consideration

it would be good if we can support

./hdmi_cec -p hdmiProfile.yaml -p platformTestProfile.yaml

And all the profiles get merged together, in a single entry. I realise this means that instead of supporting file based kvp, in the backend we would need to support adding a new function to kvp. Since we have open - which opens the first file, we can introduce read which basically appends to the current ut_kvp_instance_t with extra data..

or we change the basic configuration for open, to always append to the already open data..

Ulrond commented 2 months ago
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

#define MAX_FILES 10 // Maximum number of files to handle

int main(int argc, char *argv[]) {
    int opt;
    char *filenames[MAX_FILES];  
    int fileCount = 0;
    const char *optString = "f:"; 

    while ((opt = getopt(argc, argv, optString)) != -1) {
        switch (opt) {
            case 'f':
                if (fileCount < MAX_FILES) {
                    filenames[fileCount++] = optarg;
                } else {
                    fprintf(stderr, "Error: Maximum number of files reached.\n");
                    exit(EXIT_FAILURE);
                }
                break;
            default: 
                fprintf(stderr, "Usage: %s [-f filename]...\n", argv[0]); // Notice the "..."
                exit(EXIT_FAILURE);
        }
    }

    printf("Processing %d files:\n", fileCount);
    for (int i = 0; i < fileCount; i++) {
        printf("  - %s\n", filenames[i]);
        // Do something with each file (e.g., call your process_node function)
    }

    return 0;
}

Yaml file

./your_program -f file1.yaml -f file2.json -f http://example.com/config.yaml
Ulrond commented 2 months ago

we should be able to support this via changing the input file to ut-control-kvp-open to something like this !include <file>, which appends the included file into the instance. or !include <http://url>