4f8dec9a6f
* 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>
36 lines
1.1 KiB
C
36 lines
1.1 KiB
C
/*------------------------------------------------------------------
|
|
* systemd-sonic-generator.h - Header file
|
|
*
|
|
* Initial: Apr 2021
|
|
*
|
|
* Copyright (c) 2021 by Cisco Systems, Inc.
|
|
*------------------------------------------------------------------
|
|
*/
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
/* expose global vars for testing purpose */
|
|
extern const char* UNIT_FILE_PREFIX;
|
|
extern const char* CONFIG_FILE;
|
|
extern const char* MACHINE_CONF_FILE;
|
|
extern const char* ASIC_CONF_FORMAT;
|
|
extern const char* g_unit_file_prefix;
|
|
extern const char* g_config_file;
|
|
extern const char* g_machine_config_file;
|
|
extern const char* g_asic_conf_format;
|
|
|
|
/* C-functions under test */
|
|
extern const char* get_unit_file_prefix();
|
|
extern const char* get_config_file();
|
|
extern const char* get_machine_config_file();
|
|
extern const char* get_asic_conf_format();
|
|
extern char* insert_instance_number(char* unit_file, int instance);
|
|
extern int ssg_main(int argc, char** argv);
|
|
extern int get_num_of_asic();
|
|
extern int get_install_targets(char* unit_file, char* targets[]);
|
|
extern int get_unit_files(char* unit_files[]);
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|