tests/cfg_yaml_ut.cpp
/* Test Fixture. */
/*************************************************************/
/**
 * Verify that the yaml_init_devices API
 * - calls i2c_execute with the correct # of op cmds
 * -   note: no actual i2c calls are made.
 ****************************************************************/
Test Fixture.
Verify that the yaml_init_devices API
- calls i2c_execute with the correct # of op cmds
-   note: no actual i2c calls are made.
Test Fixture . Verify that the yaml_init_devices API - calls i2c_execute with the correct # of op cmds - note : no actual i2c calls are made .
TEST_F(CfgYamlTestSuite, cfg_004_yaml_init_devices) {
    char    cwd[1024];
    int     rc = 0;
    rc = snprintf(cwd, sizeof(cwd), "%s/%s", CFG_YAML_UT_FILE_DIR, "yaml_files");
    ASSERT_GT(rc, 0);
    unlink_file(cwd, MANIFEST_FILE);
    link_file(cwd, GOOD_MANIFEST, MANIFEST_FILE);
    printf("Create a new base SUBSYSTEM.\n");
    rc = yaml_add_subsystem(cy_handle, BASE_SUBSYSTEM, cwd);
    ASSERT_EQ(rc, 0);
    printf("Parse devices with valid subsystem.\n");
    rc = yaml_parse_devices(cy_handle, BASE_SUBSYSTEM);
    ASSERT_EQ(rc, 0);
    printf("Initialize the devices.\n");
    ops_cnt = 0;
    rc = yaml_init_devices(cy_handle, BASE_SUBSYSTEM);
    ASSERT_EQ(rc, 0);
    ASSERT_EQ(ops_cnt, 3);
    ops_cnt = 0;
    unlink_file(cwd, MANIFEST_FILE);
}
TEST_F ( CfgYamlTestSuite , cfg_004_yaml_init_devices ) { char cwd [ 1024 ] ; int rc = 0 ; rc = snprintf ( cwd , sizeof ( cwd ) , " " , CFG_YAML_UT_FILE_DIR , " " ) ; ASSERT_GT ( rc , 0 ) ; unlink_file ( cwd , MANIFEST_FILE ) ; link_file ( cwd , GOOD_MANIFEST , MANIFEST_FILE ) ; printf ( " \n " ) ; rc = yaml_add_subsystem ( cy_handle , BASE_SUBSYSTEM , cwd ) ; ASSERT_EQ ( rc , 0 ) ; printf ( " \n " ) ; rc = yaml_parse_devices ( cy_handle , BASE_SUBSYSTEM ) ; ASSERT_EQ ( rc , 0 ) ; printf ( " \n " ) ; ops_cnt = 0 ; rc = yaml_init_devices ( cy_handle , BASE_SUBSYSTEM ) ; ASSERT_EQ ( rc , 0 ) ; ASSERT_EQ ( ops_cnt , 3 ) ; ops_cnt = 0 ; unlink_file ( cwd , MANIFEST_FILE ) ; }
Test Fixture.
Test Fixture .
/* Test YAML files are stored in ./yaml_files dir. */ /* Try creating a subsystem. It should PASS. */ /* Call yaml_parse_devices() with valid subsystem,
     * and valid directory. The call should pass */ /* Call yaml_init_devices() to fake the init of the devices */ /* There should be 3 devices each with 1 command counted in ops_cnt */