Commit Graph

3 Commits

Author SHA1 Message Date
anamehra
3b30127913
[multi-asic] Fixed systemd-sonic-generator for multi-asic (#7954)
Why I did it

systemd-sonic-generator limits multi-asic unit file instances to 10 (single digit instance number 0 - 10). This limitation needs to be removed to handle more than 10 asics.
MAX_NUM_TARGETS and MAX_NUM_INSTALL_LINES limits to 15 which is not sufficient for systems with more than 15 asics.
Inside get_unit_files(), strcmp produce incorrect results due to non null terminated string being compared.

 Added build UT support for systemd-sonic-generator
2021-07-07 17:14:21 -07:00
Guohan Lu
c7bc0f0fa2 Revert "[multi-asic] Fixed systemd-sonic-generator for multi-asic (#7633)"
This reverts commit 4f8dec9a6f.
2021-06-09 08:20:23 -07:00
anamehra
4f8dec9a6f
[multi-asic] Fixed systemd-sonic-generator for multi-asic (#7633)
* Fixed systemd-sonic-generator for multi-asic

    1. In function insert_instance_number instance_string was malloced for 2 char
       size which was limiting the instance number value in instance_name to 1 digit.
       Fixed insert_instance_number to use asprintf to generate instancd_name for
       any number of instances. Added _GNU_SOURCE to CFLAGS for asprintf.

    2. Fixed get_unit_files() to use calloc instead of malloc. Uninitialized memory
       was causing incorrect string mismatch error while comparing unit file name
       string.

    3. Increased MAX_NUM_TARGETS and MAX_NUM_INSTALL_LINES values to 48 to handle more
       asic instances.

    4. Added build UT support for systemd-sonic-generator:
        a. Refactor systemd-sonic-generator.c to be used with UT infra.
        b. Added UT infra to run build UT for systemd-sonic-generator
        c. Added functional level and program level UT class and test cases.

* Resolved review comments.

    1. Explicitly setting global pointers to NULL in definitions.
    2. Added a space before ": public" in class definitions to align style
       with SONiC C++ files.

* Merged strtok_r statements in single command.

Signed-off-by: Anand Mehra <anamehra@cisco.com>
2021-05-28 13:20:11 -07:00