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
* 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>