tests/cfg_yaml_ut.cpp
/* Test Fixture. */
/*************************************************************/
/**
 * Verify that the yaml_add_subsystem API
 * - fails with an invalid hwdesc directory pointer
 * - works with a good manifest file
 * - won't let you add the same subsystem twice
 * - allows multiple subsystems to be added
 ****************************************************************/
Test Fixture.
Verify that the yaml_add_subsystem API
- fails with an invalid hwdesc directory pointer
- works with a good manifest file
- won't let you add the same subsystem twice
- allows multiple subsystems to be added
Test Fixture . Verify that the yaml_add_subsystem API - fails with an invalid hwdesc directory pointer - works with a good manifest file - won ' t let you add the same subsystem twice - allows multiple subsystems to be added
TEST_F(CfgYamlTestSuite, cfg_001_yaml_add_subsystem) {
    char    cwd[1024];
    int     rc = 0;
    rc = snprintf(cwd, sizeof(cwd), "%s/%s", CFG_YAML_UT_FILE_DIR, "yaml_files");
    ASSERT_GT(rc, 0);
    printf("Create a new base SUBSYSTEM with invalid manifest directory.\n");
    rc = yaml_add_subsystem(cy_handle, "test_subsys", "junk_dir");
    ASSERT_NE(rc, 0);
    unlink_file(cwd, MANIFEST_FILE);
    link_file(cwd, GOOD_MANIFEST, MANIFEST_FILE);
    printf("Create a new base SUBSYSTEM with valid params.\n");
    rc = yaml_add_subsystem(cy_handle, BASE_SUBSYSTEM, cwd);
    ASSERT_EQ(rc, 0);
    printf("Re-create base SUBSYSTEM.\n");
    rc = yaml_add_subsystem(cy_handle, BASE_SUBSYSTEM, cwd);
    ASSERT_NE(rc, 0);
    printf("Create a new test-base SUBSYSTEM.\n");
    rc = yaml_add_subsystem(cy_handle, "test-base", cwd);
    ASSERT_EQ(rc, 0);
    unlink_file(cwd, MANIFEST_FILE);
}
TEST_F ( CfgYamlTestSuite , cfg_001_yaml_add_subsystem ) { char cwd [ 1024 ] ; int rc = 0 ; rc = snprintf ( cwd , sizeof ( cwd ) , " " , CFG_YAML_UT_FILE_DIR , " " ) ; ASSERT_GT ( rc , 0 ) ; printf ( " \n " ) ; rc = yaml_add_subsystem ( cy_handle , " " , " " ) ; ASSERT_NE ( 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_add_subsystem ( cy_handle , BASE_SUBSYSTEM , cwd ) ; ASSERT_NE ( rc , 0 ) ; printf ( " \n " ) ; rc = yaml_add_subsystem ( cy_handle , " " , cwd ) ; ASSERT_EQ ( rc , 0 ) ; unlink_file ( cwd , MANIFEST_FILE ) ; }
Test Fixture.
Test Fixture .
/* Test YAML files are stored in ./yaml_files dir. */ /* Try creating a subsystem with invalid directory.
     * The look up for manifest file should fail. */ /* Try creating a subsystem. It should PASS. */ /* Try re-creating a subsystem. It should FAIL. */ /* Try creating another subsystem. It should PASS. */