/usr/src/suites/os/smf/tests/libscf-low/lib/libscftest-templates.c
C | 2991 lines | 1854 code | 232 blank | 905 comment | 690 complexity | 0a99059235dab8ed405f6e7239b9ce63 MD5 | raw file
Possible License(s): MPL-2.0-no-copyleft-exception
Large files files are truncated, but you can click here to view the full file
- /*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License (the "License").
- * You may not use this file except in compliance with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
- /*
- *
- * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
- #pragma ident "%Z%%M% %I% %E% SMI"
- /*
- * libscftest-property:
- * A library of test routines used in the property tests
- * for the mid level libscf API.
- * All functions in this file and in the accompanying include file
- * (must) have names begin with the string "scftest_".
- */
- #include <errno.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <strings.h>
- #include <unistd.h>
- #include <libscf.h>
- #include <libscf_priv.h>
- #include <libscftest-tmpl.h>
- #include <libscftest-low.h>
- /*
- * =====================================================
- * TEMPLATE FUNCTIONS
- * =====================================================
- */
- /*
- * scftest_tmpl_get_by_pg
- * Purpose: Call scf_tmpl_get_by_pg()
- * Parameters:
- * input: scf_propertygroup_t *pg; a property group to get
- * the template for
- * scf_pg_tmpl_t *template; a property group template
- * int flags: scf_tmpl_get_by_pg flags
- * scf_error_t *exp_err: the expected scf error code
- * output: none
- * Returns: The result of the scf_tmpl_get_by_pg call with PASS
- * or FAIL in the exp_err pointer.
- */
- int
- scftest_tmpl_get_by_pg(scf_propertygroup_t *pg, scf_pg_tmpl_t *template,
- int flags, scf_error_t *exp_err) {
- scf_error_t scf_err = SCF_ERROR_NONE;
- int scf_ret;
- if (*exp_err != SCF_ERROR_NONE) {
- (void) fprintf(stdout, "--INFO: "
- "Call scf_tmpl_get_by_pg() and expect an error\n");
- } else {
- (void) fprintf(stdout, "--INFO: "
- "Call scf_tmpl_get_by_pg() and return the "
- "pg template\n");
- }
- scf_ret = scf_tmpl_get_by_pg(pg, template, flags);
- scf_err = scf_error();
- /*
- * Check the returned data and expected error.
- */
- if (*exp_err != SCF_ERROR_NONE && scf_ret == -1) {
- /*
- * An error was expected check that the error returned
- * matches the expected error and report anomalies as
- * well as success.
- */
- if (scf_err != *exp_err) {
- (void) fprintf(stdout, "--DIAG: "
- "scf_tmpl_get_by_pg() returned the "
- "wrong error\n\t"
- "EXPECTED: %u (%s)\n\t"
- "RETURNED: %u (%s)\n",
- (unsigned int)*exp_err, scf_strerror(*exp_err),
- (unsigned int)scf_err, scf_strerror(scf_err));
- *exp_err = FAIL;
- } else {
- (void) fprintf(stdout, "--INFO: "
- "scf_tmpl_get_by_pg() failed as expected %d\n",
- *exp_err);
- *exp_err = PASS;
- }
- } else if (*exp_err != SCF_ERROR_NONE && scf_ret != -1) {
- /*
- * An error was expected but the template came back as
- * non-null which it should not have, therefore report
- * the anomaly.
- */
- (void) fprintf(stdout, "--DIAG: "
- "scf_tmpl_get_by_pg() did not fail as expected\n"
- "\tRETURNED: %d\n"
- "\tSCF_ERROR: %s\n", scf_ret,
- scf_strerror(scf_error()));
- *exp_err = FAIL;
- } else if (scf_ret == -1) {
- /*
- * No error was expected, and template is still NULL
- * report the anomaly.
- */
- (void) fprintf(stdout, "--DIAG: "
- "scf_tmpl_get_by_pg() returned an error\n"
- "\tERROR: %u (%s)\n",
- (unsigned int)scf_err, scf_strerror(scf_err));
- *exp_err = FAIL;
- } else {
- *exp_err = PASS;
- }
- return (scf_ret);
- }
- /*
- * scftest_tmpl_get_by_pg_name
- * Purpose: Call scf_tmpl_get_by_pg_name()
- * Parameters:
- * input: scf_handle_t *h; a handle
- * const char *fmri: an instance
- * const char *snapshot: a snapshot name
- * const char *pg: a property group
- * int flags: scf_tmpl_get_by_pg flags
- * scf_error_t *exp_err: the expected scf error code
- * output: none
- * Returns: The result of the scf_tmpl_get_by_pg_name call with PASS
- * or FAIL in the exp_err pointer.
- */
- int
- scftest_tmpl_get_by_pg_name(const char *fmri, const char *snapshot,
- const char *pg_name, const char *pg_type, scf_pg_tmpl_t *template,
- int flags, scf_error_t *exp_err) {
- scf_error_t scf_err = SCF_ERROR_NONE;
- int scf_ret;
- if (*exp_err != SCF_ERROR_NONE) {
- (void) fprintf(stdout, "--INFO: "
- "Call scf_tmpl_get_by_pg_name() and expect an error\n");
- } else {
- (void) fprintf(stdout, "--INFO: "
- "Call scf_tmpl_get_by_pg_name() and return the "
- "pg template\n");
- }
- scf_ret = scf_tmpl_get_by_pg_name(fmri, snapshot, pg_name, pg_type,
- template, flags);
- scf_err = scf_error();
- /*
- * Check the returned data and expected error.
- */
- if (*exp_err != SCF_ERROR_NONE && scf_ret == -1) {
- /*
- * An error was expected check that the error returned
- * matches the expected error and report anomalies as
- * well as success.
- */
- if (scf_err != *exp_err) {
- (void) fprintf(stdout, "--DIAG: "
- "scf_tmpl_get_by_pg_name() returned the "
- "wrong error\n\t"
- "EXPECTED: %u (%s)\n\t"
- "RETURNED: %u (%s)\n",
- (unsigned int)*exp_err, scf_strerror(*exp_err),
- (unsigned int)scf_err, scf_strerror(scf_err));
- *exp_err = FAIL;
- } else {
- (void) fprintf(stdout, "--INFO: "
- "scf_tmpl_get_by_pg_name() failed as expected %d\n",
- *exp_err);
- *exp_err = PASS;
- }
- } else if (*exp_err != SCF_ERROR_NONE && scf_ret != -1) {
- /*
- * An error was expected but the template came back as
- * non-null which it should not have, therefore report
- * the anomaly.
- */
- (void) fprintf(stdout, "--DIAG: "
- "scf_tmpl_get_by_pg_name() did not fail as expected\n"
- "\tRETURNED: %d\n"
- "\tSCF_ERROR: %s\n", scf_ret,
- scf_strerror(scf_error()));
- *exp_err = FAIL;
- } else if (scf_ret == -1) {
- /*
- * No error was expected, and template is still NULL
- * report the anomaly.
- */
- (void) fprintf(stdout, "--DIAG: "
- "scf_tmpl_get_by_pg_name() returned an error\n"
- "\tERROR: %u (%s)\n",
- (unsigned int)scf_err, scf_strerror(scf_err));
- *exp_err = FAIL;
- } else {
- *exp_err = PASS;
- }
- return (scf_ret);
- }
- /*
- * scftest_tmpl_get_by_prop
- * Purpose: Call scf_tmpl_get_by_prop()
- * Parameters:
- * input: scf_handle_t *h; a handle
- * const char *fmri: an instance
- * const char *snapshot: a snapshot name
- * const char *pg: a property group
- * int flags: scf_tmpl_get_by_prop flags
- * scf_error_t *exp_err: the expected scf error code
- * output: none
- * Returns: The result of the scf_tmpl_get_by_prop call with PASS
- * or FAIL in the exp_err pointer.
- */
- int
- scftest_tmpl_get_by_prop(scf_pg_tmpl_t *t, const char *prop,
- scf_prop_tmpl_t *property, int flags, scf_error_t *exp_err) {
- scf_error_t scf_err = SCF_ERROR_NONE;
- int scf_ret;
- if (*exp_err != SCF_ERROR_NONE) {
- (void) fprintf(stdout, "--INFO: "
- "Call scf_tmpl_get_by_prop() and expect an error\n");
- } else {
- (void) fprintf(stdout, "--INFO: "
- "Call scf_tmpl_get_by_prop() and return the prop "
- "template\n");
- }
- scf_ret = scf_tmpl_get_by_prop(t, prop, property, flags);
- scf_err = scf_error();
- if (*exp_err != SCF_ERROR_NONE && scf_ret == -1) {
- /*
- * An error was expected check that the error returned
- * matches the expected error and report anomalies as
- * well as success.
- */
- if (scf_err != *exp_err) {
- (void) fprintf(stdout, "--DIAG: "
- "scf_tmpl_get_by_prop() returned the wrong "
- "error\n\t"
- "EXPECTED: %u (%s)\n\t"
- "RETURNED: %u (%s)\n",
- (unsigned int)*exp_err, scf_strerror(*exp_err),
- (unsigned int)scf_err, scf_strerror(scf_err));
- *exp_err = FAIL;
- } else {
- (void) fprintf(stdout, "--INFO: "
- "scf_tmpl_get_by_prop() failed as expected\n");
- *exp_err = PASS;
- }
- } else if (*exp_err != SCF_ERROR_NONE && scf_ret != -1) {
- /*
- * An error was expected but the template came back as
- * non-null which it should not have, therefore report
- * the anomaly.
- */
- (void) fprintf(stdout, "--DIAG: "
- "scf_tmpl_get_by_prop() did not fail as expected\n\t"
- "RETURNED: 0x%p\n", (void *)property);
- /* scf_prop_tmpl_free(template); */
- property = NULL;
- *exp_err = FAIL;
- } else if (scf_ret == -1) {
- /*
- * No error was expected, and template is still NULL
- * report the anomaly.
- */
- (void) fprintf(stdout, "--DIAG: "
- "scf_tmpl_get_by_prop() returned an error\n\t"
- "ERROR: %u (%s)\n",
- (unsigned int)scf_err, scf_strerror(scf_err));
- *exp_err = FAIL;
- } else {
- *exp_err = PASS;
- }
- return (scf_ret);
- }
- /*
- * scftest_tmpl_iter_pgs
- * Purpose: Call scf_tmpl_iter_pgs()
- * Parameters:
- * input: scf_pg_tmpl_t *t: current template pointer
- * const char *fmri: an instance
- * const char *snapshot: a snapshot name
- * const char *pg: a property group
- * int flags: scf_tmpl_iter_pgs flags
- * scf_error_t *exp_err: the expected scf error code
- * output: none
- * Returns: The result of the scf_tmpl_iter_pgs call with PASS
- * or FAIL in the exp_err pointer.
- */
- int
- scftest_tmpl_iter_pgs(scf_pg_tmpl_t *t, const char *fmri,
- const char *snapshot, const char *pg_type, int flags,
- scf_error_t *exp_err) {
- scf_error_t scf_err = SCF_ERROR_NONE;
- int scf_ret;
- if (*exp_err != SCF_ERROR_NONE) {
- (void) fprintf(stdout, "--INFO: "
- "Call scf_tmpl_iter_pgs() and expect an error\n");
- } else {
- (void) fprintf(stdout, "--INFO: "
- "Call scf_tmpl_iter_pgs() and return the pg template\n");
- }
- scf_ret = scf_tmpl_iter_pgs(t, fmri, snapshot, pg_type, flags);
- scf_err = scf_error();
- if (*exp_err != SCF_ERROR_NONE && scf_ret == -1) {
- /*
- * An error was expected check that the error returned
- * matches the expected error and report anomalies as
- * well as success.
- */
- if (scf_err != *exp_err) {
- (void) fprintf(stdout, "--DIAG: "
- "scf_tmpl_iter_pgs() returned the wrong error\n\t"
- "EXPECTED: %u (%s)\n\t"
- "RETURNED: %u (%s)\n",
- (unsigned int)*exp_err, scf_strerror(*exp_err),
- (unsigned int)scf_err, scf_strerror(scf_err));
- *exp_err = FAIL;
- } else {
- (void) fprintf(stdout, "--INFO: "
- "scf_tmpl_iter_pgs() failed as expected\n");
- *exp_err = PASS;
- }
- } else if (*exp_err != SCF_ERROR_NONE && scf_ret != -1) {
- /*
- * An error was expected but the template came back as
- * non-null which it should not have, therefore report
- * the anomaly.
- */
- (void) fprintf(stdout, "--DIAG: "
- "scf_tmpl_iter_pgs() did not fail as expected\n\t"
- "and returned a template\n\t"
- "RETURNED: %d\n", scf_ret);
- *exp_err = FAIL;
- } else if (scf_ret == -1) {
- /*
- * No error was expected, and template is still NULL
- * report the anomaly.
- */
- (void) fprintf(stdout, "--INFO: "
- "scf_tmpl_iter_pgs() returned an error, "
- "the end of property groups, %s\n",
- scf_strerror(scf_err));
- *exp_err = FAIL;
- } else {
- *exp_err = PASS;
- }
- return (scf_ret);
- }
- /*
- * scftest_tmpl_iter_props
- * Purpose: Call scf_tmpl_iter_props()
- * Parameters:
- * input: scf_pg_tmpl_t *t: current template pointer
- * scf_handle_t *h: a handle
- * const char *fmri: an instance
- * const char *snapshot: a snapshot name
- * const char *pg: a property group
- * int flags: scf_tmpl_iter_props flags
- * scf_error_t *exp_err: the expected scf error code
- * output: none
- * Returns: The result of the scf_tmpl_iter_props call with PASS
- * or FAIL in the exp_err pointer.
- */
- int
- scftest_tmpl_iter_props(scf_pg_tmpl_t *t, scf_prop_tmpl_t *p, int flags,
- scf_error_t *exp_err) {
- scf_error_t scf_err = SCF_ERROR_NONE;
- int scf_ret;
- if (*exp_err != SCF_ERROR_NONE) {
- (void) fprintf(stdout, "--INFO: "
- "Call scf_tmpl_iter_props() and expect an error\n");
- } else {
- (void) fprintf(stdout, "--INFO: Call scf_tmpl_iter_props() "
- "and return the prop template\n");
- }
- scf_ret = scf_tmpl_iter_props(t, p, flags);
- scf_err = scf_error();
- if (*exp_err != SCF_ERROR_NONE && scf_ret == -1) {
- /*
- * An error was expected check that the error returned
- * matches the expected error and report anomalies as
- * well as success.
- */
- if (scf_err != *exp_err) {
- (void) fprintf(stdout, "--DIAG: "
- "scf_tmpl_iter_pgs() returned the wrong error\n\t"
- "EXPECTED: %u (%s)\n\t"
- "RETURNED: %u (%s)\n",
- (unsigned int)*exp_err, scf_strerror(*exp_err),
- (unsigned int)scf_err, scf_strerror(scf_err));
- *exp_err = FAIL;
- } else {
- (void) fprintf(stdout, "--INFO: "
- "scf_tmpl_iter_pgs() failed as expected\n");
- *exp_err = PASS;
- }
- } else if (*exp_err != SCF_ERROR_NONE && scf_ret != -1) {
- /*
- * An error was expected but the template came back as
- * non-null which it should not have, therefore report
- * the anomaly.
- */
- (void) fprintf(stdout, "--DIAG: "
- "scf_tmpl_iter_pgs() did not fail as expected\n\t"
- "and returned a prop\n\t"
- "RETURNED: %d\n", scf_ret);
- *exp_err = FAIL;
- } else if (scf_ret == -1) {
- /*
- * No error was expected, and template is still NULL
- * report the anomaly.
- */
- (void) fprintf(stdout, "--INFO: "
- "scf_tmpl_iter_pgs() returned an error, "
- "the end of property groups %s\n",
- scf_strerror(scf_err));
- *exp_err = FAIL;
- } else {
- *exp_err = PASS;
- }
- return (scf_ret);
- }
- /*
- * scftest_tmpl_pg_name
- * Purpose: Call scf_tmpl_pg_name()
- * Parameters:
- * input: scf_pg_tmpl_t *t; a template
- * char **name: a pointer to the pointer for the name
- * scf_error_t *exp_err: the expected error
- * output: none
- * Returns: The result of the scf_tmpl_pg_name call with PASS
- * or FAIL in the exp_err pointer.
- */
- ssize_t
- scftest_tmpl_pg_name(scf_pg_tmpl_t *t, char **name, scf_error_t *exp_err) {
- scf_error_t scf_err = SCF_ERROR_NONE;
- ssize_t scf_ret;
- if (*exp_err != SCF_ERROR_NONE) {
- (void) fprintf(stdout, "--INFO: "
- "Call scf_tmpl_pg_name() and expect an error\n");
- } else {
- (void) fprintf(stdout, "--INFO: "
- "Call scf_tmpl_pg_name() and return the pg name\n");
- }
- scf_ret = scf_tmpl_pg_name(t, name);
- scf_err = scf_error();
- if (*exp_err != SCF_ERROR_NONE && scf_ret == -1) {
- /*
- * An error was expected check that the error returned
- * matches the expected error and report anomalies as
- * well as success.
- */
- if (scf_err != *exp_err) {
- (void) fprintf(stdout, "--DIAG: "
- "scf_tmpl_pg_name() returned the wrong error\n\t"
- "EXPECTED: %d \n\t"
- "RETURNED: %d \n",
- (unsigned int)*exp_err, scf_ret);
- *exp_err = FAIL;
- } else {
- (void) fprintf(stdout, "--INFO: "
- "scf_tmpl_pg_name() failed as expected\n");
- *exp_err = PASS;
- }
- } else if (*exp_err != SCF_ERROR_NONE && scf_ret != -1) {
- /*
- * An error was expected but the template came back as
- * non-null which it should not have, therefore report
- * the anomaly.
- */
- (void) fprintf(stdout, "--DIAG: "
- "scf_tmpl_pg_name() did not fail as expected\n\t"
- "RETURNED: 0x%p\n", (void *)*name);
- if (*name)
- free(*name);
- *exp_err = FAIL;
- } else if (scf_ret == -1) {
- /*
- * No error was expected, and template is still NULL
- * report the anomaly.
- */
- (void) fprintf(stdout, "--DIAG: "
- "scf_tmpl_pg_name() returned an error\n\t"
- "ERROR: %u (%s)\n",
- (unsigned int)scf_err, scf_strerror(scf_err));
- *exp_err = FAIL;
- } else if (*name == NULL) {
- (void) fprintf(stdout, "--DIAG: "
- "scf_tmpl_pg_name() did not fill in the cname pointer");
- *exp_err = FAIL;
- } else {
- *exp_err = PASS;
- }
- return (scf_ret);
- }
- /*
- * scftest_tmpl_pg_common_name
- * Purpose: Call scf_tmpl_pg_common_name()
- * Parameters:
- * input: scf_pg_tmpl_t *t; a template
- * char **cname: a pointer to the pointer for the common name
- * scf_error_t *exp_err: the expected error
- * output: none
- * Returns: The result of the scf_tmpl_pg_common_name call with PASS
- * or FAIL in the exp_err pointer.
- */
- ssize_t
- scftest_tmpl_pg_common_name(scf_pg_tmpl_t *t, const char *locale, char **cname,
- scf_error_t *exp_err) {
- scf_error_t scf_err = SCF_ERROR_NONE;
- ssize_t scf_ret;
- if (*exp_err != SCF_ERROR_NONE) {
- (void) fprintf(stdout, "--INFO: "
- "Call scf_tmpl_pg_common_name() and expect an error\n");
- } else {
- (void) fprintf(stdout, "--INFO: "
- "Call scf_tmpl_pg_common_name() and "
- "return the pg template\n");
- }
- scf_ret = scf_tmpl_pg_common_name(t, locale, cname);
- scf_err = scf_error();
- if (*exp_err != SCF_ERROR_NONE && scf_ret == -1) {
- /*
- * An error was expected check that the error returned
- * matches the expected error and report anomalies as
- * well as success.
- */
- if (scf_err != *exp_err) {
- (void) fprintf(stdout, "--DIAG: "
- "scf_tmpl_pg_common_name() "
- "returned the wrong error\n\t"
- "EXPECTED: %d \n\t"
- "RETURNED: %d \n",
- (unsigned int)*exp_err, scf_ret);
- *exp_err = FAIL;
- } else {
- (void) fprintf(stdout, "--INFO: "
- "scf_tmpl_pg_common_name() failed as expected\n");
- *exp_err = PASS;
- }
- } else if (*exp_err != SCF_ERROR_NONE && scf_ret != -1) {
- /*
- * An error was expected but the template came back as
- * non-null which it should not have, therefore report
- * the anomaly.
- */
- (void) fprintf(stdout, "--DIAG: "
- "scf_tmpl_pg_common_name() did not fail as expected\n\t"
- "RETURNED: 0x%p\n", (void *)*cname);
- if (*cname)
- free(*cname);
- *exp_err = FAIL;
- } else if (scf_ret == -1) {
- /*
- * No error was expected, and template is still NULL
- * report the anomaly.
- */
- (void) fprintf(stdout, "--DIAG: "
- "scf_tmpl_pg_common_name() returned an error\n\t"
- "ERROR: %u (%s)\n",
- (unsigned int)scf_err, scf_strerror(scf_err));
- *exp_err = FAIL;
- } else if (*cname == NULL) {
- (void) fprintf(stdout, "--DIAG: "
- "scf_tmpl_pg_common_name() did not "
- "fill in the cname pointer");
- *exp_err = FAIL;
- } else {
- *exp_err = PASS;
- }
- return (scf_ret);
- }
- /*
- * scftest_tmpl_pg_description
- * Purpose: Call scf_tmpl_pg_description()
- * Parameters:
- * input: scf_pg_tmpl_t *t; a template
- * char **description: a pointer to the pointer for the description
- * scf_error_t *exp_err: the expected error
- * output: none
- * Returns: The result of the scf_tmpl_pg_description call with PASS
- * or FAIL in the exp_err pointer.
- */
- ssize_t
- scftest_tmpl_pg_description(scf_pg_tmpl_t *t, const char *locale,
- char **description, scf_error_t *exp_err) {
- scf_error_t scf_err = SCF_ERROR_NONE;
- ssize_t scf_ret;
- if (*exp_err != SCF_ERROR_NONE) {
- (void) fprintf(stdout, "--INFO: "
- "Call scf_tmpl_pg_description() and expect an error\n");
- } else {
- (void) fprintf(stdout, "--INFO: "
- "Call scf_tmpl_pg_description() and "
- "return the pg template\n");
- }
- scf_ret = scf_tmpl_pg_description(t, locale, description);
- scf_err = scf_error();
- if (*exp_err != SCF_ERROR_NONE && scf_ret == -1) {
- /*
- * An error was expected check that the error returned
- * matches the expected error and report anomalies as
- * well as success.
- */
- if (scf_err != *exp_err) {
- (void) fprintf(stdout, "--DIAG: "
- "scf_tmpl_pg_description() "
- "returned the wrong error\n\t"
- "EXPECTED: %d \n\t"
- "RETURNED: %d \n",
- (unsigned int)*exp_err, scf_ret);
- *exp_err = FAIL;
- } else {
- (void) fprintf(stdout, "--INFO: "
- "scf_tmpl_pg_description() failed as expected\n");
- *exp_err = PASS;
- }
- } else if (*exp_err != SCF_ERROR_NONE && scf_ret != -1) {
- /*
- * An error was expected but the template came back as
- * non-null which it should not have, therefore report
- * the anomaly.
- */
- (void) fprintf(stdout, "--DIAG: "
- "scf_tmpl_pg_description() did not fail as expected\n\t"
- "RETURNED: 0x%p\n", (void *)*description);
- if (*description)
- free(*description);
- *exp_err = FAIL;
- } else if (scf_ret == -1) {
- /*
- * No error was expected, and template is still NULL
- * report the anomaly.
- */
- (void) fprintf(stdout, "--DIAG: "
- "scf_tmpl_pg_description() returned an error\n\t"
- "ERROR: %u (%s)\n",
- (unsigned int)scf_err, scf_strerror(scf_err));
- *exp_err = FAIL;
- } else if (*description == NULL) {
- (void) fprintf(stdout, "--DIAG: "
- "scf_tmpl_pg_description() did not "
- "fill in the description pointer");
- *exp_err = FAIL;
- } else {
- *exp_err = PASS;
- }
- return (scf_ret);
- }
- /*
- * scftest_tmpl_pg_type
- * Purpose: Call scf_tmpl_pg_type()
- * Parameters:
- * input: scf_pg_tmpl_t *t; a template
- * char **type: a pointer to the pointer for the type
- * scf_error_t *exp_err: the expected error
- * output: none
- * Returns: The result of the scf_tmpl_pg_type call with PASS
- * or FAIL in the exp_err pointer.
- */
- ssize_t
- scftest_tmpl_pg_type(scf_pg_tmpl_t *t, char **type, scf_error_t *exp_err) {
- scf_error_t scf_err = SCF_ERROR_NONE;
- ssize_t scf_ret;
- if (*exp_err != SCF_ERROR_NONE) {
- (void) fprintf(stdout, "--INFO: "
- "Call scf_tmpl_pg_type() and expect an error\n");
- } else {
- (void) fprintf(stdout, "--INFO: "
- "Call scf_tmpl_pg_type() and return the pg template\n");
- }
- scf_ret = scf_tmpl_pg_type(t, type);
- scf_err = scf_error();
- if (*exp_err != SCF_ERROR_NONE && scf_ret == -1) {
- /*
- * An error was expected check that the error returned
- * matches the expected error and report anomalies as
- * well as success.
- */
- if (scf_ret != *exp_err) {
- (void) fprintf(stdout, "--DIAG: "
- "scf_tmpl_pg_type() returned the wrong error\n\t"
- "EXPECTED: %d \n\t"
- "RETURNED: %d \n",
- (unsigned int)*exp_err, scf_ret);
- *exp_err = FAIL;
- } else {
- (void) fprintf(stdout, "--INFO: "
- "scf_tmpl_pg_type() failed as expected\n");
- *exp_err = PASS;
- }
- } else if (*exp_err != SCF_ERROR_NONE && scf_ret != -1) {
- /*
- * An error was expected but the template came back as
- * non-null which it should not have, therefore report
- * the anomaly.
- */
- (void) fprintf(stdout, "--DIAG: "
- "scf_tmpl_pg_type() did not fail as expected\n\t"
- "RETURNED: 0x%p\n", (void *)*type);
- if (*type)
- free(*type);
- *exp_err = FAIL;
- } else if (scf_ret == -1) {
- /*
- * No error was expected, and template is still NULL
- * report the anomaly.
- */
- (void) fprintf(stdout, "--DIAG: "
- "scf_tmpl_pg_type() returned an error\n\t"
- "ERROR: %u (%s)\n",
- (unsigned int)scf_err, scf_strerror(scf_err));
- *exp_err = FAIL;
- } else if (*type == NULL) {
- (void) fprintf(stdout, "--DIAG: "
- "scf_tmpl_pg_type() did not fill in the type pointer");
- *exp_err = FAIL;
- } else {
- *exp_err = PASS;
- }
- return (scf_ret);
- }
- /*
- * scftest_tmpl_pg_required
- * Purpose: Call scf_tmpl_pg_required()
- * Parameters:
- * input: scf_pg_tmpl_t *t; a template
- * uint8_t *required: a pointer to the required flag
- * scf_error_t *exp_err: the expected error
- * output: none
- * Returns: The result of the scf_tmpl_pg_required call with PASS
- * or FAIL in the exp_err pointer.
- */
- int
- scftest_tmpl_pg_required(scf_pg_tmpl_t *t, uint8_t *required,
- scf_error_t *exp_err) {
- scf_error_t scf_err = SCF_ERROR_NONE;
- int scf_ret;
- if (*exp_err != SCF_ERROR_NONE) {
- (void) fprintf(stdout, "--INFO: "
- "Call scf_tmpl_pg_required() and expect an error\n");
- } else {
- (void) fprintf(stdout, "--INFO: "
- "Call scf_tmpl_pg_required() and return the pg template\n");
- }
- scf_ret = scf_tmpl_pg_required(t, required);
- scf_err = scf_error();
- if (*exp_err != SCF_ERROR_NONE && scf_ret == -1) {
- /*
- * An error was expected check that the error returned
- * matches the expected error and report anomalies as
- * well as success.
- */
- if (scf_err != *exp_err) {
- (void) fprintf(stdout, "--DIAG: "
- "scf_tmpl_pg_required() "
- "returned the wrong error\n"
- "\tEXPECTED: %d \n"
- "\tRETURNED: %d \n"
- "\tSCF_ERROR: %s\n",
- (unsigned int)*exp_err, scf_err,
- scf_strerror(scf_error()));
- *exp_err = FAIL;
- } else {
- *exp_err = PASS;
- (void) fprintf(stdout, "--INFO: "
- "scf_tmpl_pg_required() failed as expected\n");
- }
- } else if (*exp_err != SCF_ERROR_NONE && scf_ret != -1) {
- /*
- * An error was expected but the template came back as
- * non-null which it should not have, therefore report
- * the anomaly.
- */
- (void) fprintf(stdout, "--DIAG: "
- "scf_tmpl_pg_required() did not fail as expected\n"
- "\tRETURNED : %d\n"
- "\trequired : %hu\n", scf_ret, (uint8_t)required);
- *exp_err = FAIL;
- } else if (scf_ret == -1) {
- /*
- * No error was expected, and template is still NULL
- * report the anomaly.
- */
- (void) fprintf(stdout, "--DIAG: "
- "scf_tmpl_pg_required() returned an error\n\t"
- "ERROR: %u (%s)\n",
- (unsigned int)scf_err, scf_strerror(scf_err));
- *exp_err = FAIL;
- } else {
- *exp_err = PASS;
- }
- return (scf_ret);
- }
- /*
- * scftest_tmpl_prop_name
- * Purpose: Call scf_tmpl_prop_name()
- * Parameters:
- * input: scf_prop_tmpl_t *t: a template property
- * char **name: a pointer to the pointer for the name
- * scf_error_t *exp_err: the expected error
- * output: none
- * Returns: The result of the scf_tmpl_prop_name call with PASS
- * or FAIL in the exp_err pointer.
- */
- int
- scftest_tmpl_prop_name(scf_prop_tmpl_t *p, char **name, scf_error_t *exp_err) {
- scf_error_t scf_err = SCF_ERROR_NONE;
- int scf_ret;
- if (*exp_err != SCF_ERROR_NONE) {
- (void) fprintf(stdout, "--INFO: "
- "Call scf_tmpl_prop_name() and expect an error\n");
- } else {
- (void) fprintf(stdout, "--INFO: "
- "Call scf_tmpl_prop_name() and return the property name\n");
- }
- scf_ret = scf_tmpl_prop_name(p, name);
- scf_err = scf_error();
- if (*exp_err != SCF_ERROR_NONE && scf_ret == -1) {
- /*
- * An error was expected check that the error returned
- * matches the expected error and report anomalies as
- * well as success.
- */
- if (scf_err != *exp_err) {
- (void) fprintf(stdout, "--DIAG: "
- "scf_tmpl_prop_name() returned the wrong error\n\t"
- "EXPECTED: %d \n\t"
- "RETURNED: %d \n",
- (unsigned int)*exp_err, scf_ret);
- *exp_err = FAIL;
- } else {
- (void) fprintf(stdout, "--INFO: "
- "scf_tmpl_prop_name() failed as expected\n");
- *exp_err = PASS;
- }
- } else if (*exp_err != SCF_ERROR_NONE && scf_ret != -1) {
- /*
- * An error was expected but the template came back as
- * non-null which it should not have, therefore report
- * the anomaly.
- */
- (void) fprintf(stdout, "--DIAG: "
- "scf_tmpl_prop_name() did not fail as expected\n\t"
- "RETURNED: 0x%p\n", (void *)*name);
- if (*name)
- free(*name);
- *exp_err = FAIL;
- } else if (scf_ret == -1) {
- /*
- * No error was expected, and template is still NULL
- * report the anomaly.
- */
- (void) fprintf(stdout, "--DIAG: "
- "scf_tmpl_prop_name() returned an error\n\t"
- "ERROR: %u (%s)\n",
- (unsigned int)scf_err, scf_strerror(scf_err));
- *exp_err = FAIL;
- } else if (*name == NULL) {
- (void) fprintf(stdout, "--DIAG: "
- "scf_tmpl_prop_name() did not fill in the name pointer");
- *exp_err = FAIL;
- } else {
- *exp_err = PASS;
- }
- return (scf_ret);
- }
- /*
- * scftest_tmpl_prop_type
- * Purpose: Call scf_tmpl_prop_type()
- * Parameters:
- * input: scf_pg_tmpl_t *p; a property
- * scf_type_t *type: a pointer to the pointer for the type
- * scf_error_t *exp_err: the expected error
- * output: none
- * Returns: The result of the scf_tmpl_prop_type call with PASS
- * or FAIL in the exp_err pointer.
- */
- int
- scftest_tmpl_prop_type(scf_prop_tmpl_t *p, scf_type_t *type,
- scf_error_t *exp_err) {
- scf_error_t scf_err = SCF_ERROR_NONE;
- int scf_ret;
- if (*exp_err != SCF_ERROR_NONE) {
- (void) fprintf(stdout, "--INFO: "
- "Call scf_tmpl_prop_type() and expect an error\n");
- } else {
- (void) fprintf(stdout, "--INFO: "
- "Call scf_tmpl_prop_type() and return the propety type\n");
- }
- scf_ret = scf_tmpl_prop_type(p, type);
- scf_err = scf_error();
- if (*exp_err != SCF_ERROR_NONE && scf_ret == -1) {
- /*
- * An error was expected check that the error returned
- * matches the expected error and report anomalies as
- * well as success.
- */
- if (scf_err != *exp_err) {
- (void) fprintf(stdout, "--DIAG: "
- "scf_tmpl_prop_type() returned the wrong error\n\t"
- "EXPECTED: %d \n\t"
- "RETURNED: %d \n",
- (unsigned int)*exp_err, scf_ret);
- *exp_err = FAIL;
- } else {
- (void) fprintf(stdout, "--INFO: "
- "scf_tmpl_prop_type() failed as expected\n");
- *exp_err = PASS;
- }
- } else if (*exp_err != SCF_ERROR_NONE && scf_ret != -1) {
- /*
- * An error was expected but the template came back as
- * non-null which it should not have, therefore report
- * the anomaly.
- */
- (void) fprintf(stdout, "--DIAG: "
- "scf_tmpl_prop_type() did not fail as expected\n\t"
- "RETURNED: 0x%p\n", (void *)*type);
- *exp_err = FAIL;
- } else if (scf_ret == -1) {
- /*
- * No error was expected, and template is still NULL
- * report the anomaly.
- */
- (void) fprintf(stdout, "--DIAG: "
- "scf_tmpl_prop_type() returned an error\n\t"
- "ERROR: %u (%s)\n",
- (unsigned int)scf_err, scf_strerror(scf_err));
- *exp_err = FAIL;
- } else if (*type == NULL) {
- (void) fprintf(stdout, "--DIAG: "
- "scf_tmpl_prop_type() did not fill in the type pointer");
- *exp_err = FAIL;
- } else {
- *exp_err = PASS;
- }
- return (scf_ret);
- }
- /*
- * scftest_tmpl_prop_required
- * Purpose: Call scf_tmpl_prop_required()
- * Parameters:
- * input: scf_prop_tmpl_t *p: a property
- * uint8_t *required: a pointer to the required flag
- * scf_error_t *exp_err: the expected error
- * output: none
- * Returns: The result of the scf_tmpl_prop_required call with PASS
- * or FAIL in the exp_err pointer.
- */
- int
- scftest_tmpl_prop_required(scf_prop_tmpl_t *p, uint8_t *required,
- scf_error_t *exp_err) {
- scf_error_t scf_err = SCF_ERROR_NONE;
- int scf_ret;
- if (*exp_err != SCF_ERROR_NONE) {
- (void) fprintf(stdout, "--INFO: "
- "Call scf_tmpl_prop_required() and expect an error\n");
- } else {
- (void) fprintf(stdout, "--INFO: "
- "Call scf_tmpl_prop_required() and "
- "return the required flag\n");
- }
- scf_ret = scf_tmpl_prop_required(p, required);
- scf_err = scf_error();
- if (*exp_err != SCF_ERROR_NONE && scf_ret == -1) {
- /*
- * An error was expected check that the error returned
- * matches the expected error and report anomalies as
- * well as success.
- */
- if (scf_err != *exp_err) {
- (void) fprintf(stdout, "--DIAG: "
- "scf_tmpl_prop_required() "
- "returned the wrong error\n\t"
- "EXPECTED: %d \n\t"
- "RETURNED: %d \n",
- (unsigned int)*exp_err, scf_ret);
- *exp_err = FAIL;
- } else {
- (void) fprintf(stdout, "--INFO: "
- "scf_tmpl_prop_required() failed as expected\n");
- *exp_err = PASS;
- }
- } else if (*exp_err != SCF_ERROR_NONE && scf_ret != -1) {
- /*
- * An error was expected but the template came back as
- * non-null which it should not have, therefore report
- * the anomaly.
- */
- (void) fprintf(stdout, "--DIAG: "
- "scf_tmpl_prop_required() did not fail as expected\n\t"
- "RETURNED: %u\n", (uint8_t)required);
- *exp_err = FAIL;
- } else if (scf_ret == -1) {
- /*
- * No error was expected, and template is still NULL
- * report the anomaly.
- */
- (void) fprintf(stdout, "--DIAG: "
- "scf_tmpl_prop_required() returned an error\n\t"
- "ERROR: %u (%s)\n",
- (unsigned int)scf_err, scf_strerror(scf_err));
- *exp_err = FAIL;
- } else {
- *exp_err = PASS;
- }
- return (scf_ret);
- }
- /*
- * scftest_tmpl_prop_common_name
- * Purpose: Call scf_tmpl_prop_common_name()
- * Parameters:
- * input: scf_prop_tmpl_t *p: a property
- * char **cname: a pointer to the pointer for the common name
- * scf_error_t *exp_err: the expected error
- * output: none
- * Returns: The result of the scf_tmpl_prop_common_name call with PASS
- * or FAIL in the exp_err pointer.
- */
- ssize_t
- scftest_tmpl_prop_common_name(scf_prop_tmpl_t *p, const char *locale,
- char **cname, scf_error_t *exp_err) {
- scf_error_t scf_err = SCF_ERROR_NONE;
- int scf_ret;
- if (*exp_err != SCF_ERROR_NONE) {
- (void) fprintf(stdout, "--INFO: "
- "Call scf_tmpl_prop_common_name() and "
- "expect an error\n");
- } else {
- (void) fprintf(stdout, "--INFO: "
- "Call scf_tmpl_prop_common_name() and "
- "return the pg template\n");
- }
- scf_ret = scf_tmpl_prop_common_name(p, locale, cname);
- scf_err = scf_error();
- if (*exp_err != SCF_ERROR_NONE && scf_ret == -1) {
- /*
- * An error was expected check that the error returned
- * matches the expected error and report anomalies as
- * well as success.
- */
- if (scf_err != *exp_err) {
- (void) fprintf(stdout, "--DIAG: "
- "scf_tmpl_prop_common_name() "
- "returned the wrong error\n\t"
- "EXPECTED: %d \n\t"
- "RETURNED: %d \n",
- (unsigned int)*exp_err, scf_ret);
- *exp_err = FAIL;
- } else {
- (void) fprintf(stdout, "--INFO: "
- "scf_tmpl_prop_common_name() failed as expected\n");
- *exp_err = PASS;
- }
- } else if (*exp_err != SCF_ERROR_NONE && scf_ret != -1) {
- /*
- * An error was expected but the template came back as
- * non-null which it should not have, therefore report
- * the anomaly.
- */
- (void) fprintf(stdout, "--DIAG: "
- "scf_tmpl_prop_common_name() did not fail as expected\n\t"
- "RETURNED: 0x%p\n", (void *)*cname);
- if (*cname)
- free(*cname);
- *exp_err = FAIL;
- } else if (scf_ret == -1) {
- /*
- * No error was expected, and template is still NULL
- * report the anomaly.
- */
- (void) fprintf(stdout, "--DIAG: "
- "scf_tmpl_prop_common_name() returned an error\n\t"
- "ERROR: %u (%s)\n",
- (unsigned int)scf_err, scf_strerror(scf_err));
- *exp_err = FAIL;
- } else if (*cname == NULL) {
- (void) fprintf(stdout, "--DIAG: "
- "scf_tmpl_prop_common_name() did not "
- "fill in the cname pointer");
- *exp_err = FAIL;
- } else {
- *exp_err = PASS;
- }
- return (scf_ret);
- }
- /*
- * scftest_tmpl_prop_description
- * Purpose: Call scf_tmpl_prop_description()
- * Parameters:
- * input: scf_prop_tmpl_t *p: a property
- * char **description: a pointer to the pointer for the description
- * scf_error_t *exp_err: the expected error
- * output: none
- * Returns: The result of the scf_tmpl_prop_description call with PASS
- * or FAIL in the exp_err pointer.
- */
- ssize_t
- scftest_tmpl_prop_description(scf_prop_tmpl_t *p, const char *locale,
- char **description, scf_error_t *exp_err) {
- scf_error_t scf_err = SCF_ERROR_NONE;
- int scf_ret;
- if (*exp_err != SCF_ERROR_NONE) {
- (void) fprintf(stdout, "--INFO: "
- "Call scf_tmpl_prop_description() and "
- "expect an error\n");
- } else {
- (void) fprintf(stdout, "--INFO: "
- "Call scf_tmpl_prop_description() and "
- "return the pg template\n");
- }
- scf_ret = scf_tmpl_prop_description(p, locale, description);
- scf_err = scf_error();
- if (*exp_err != SCF_ERROR_NONE && scf_ret == -1) {
- /*
- * An error was expected check that the error returned
- * matches the expected error and report anomalies as
- * well as success.
- */
- if (scf_err != *exp_err) {
- (void) fprintf(stdout, "--DIAG: "
- "scf_tmpl_prop_description() "
- "returned the wrong error\n\t"
- "EXPECTED: %d \n\t"
- "RETURNED: %d \n",
- (unsigned int)*exp_err, scf_err);
- *exp_err = FAIL;
- } else {
- (void) fprintf(stdout, "--INFO: "
- "scf_tmpl_prop_description() failed as expected\n");
- *exp_err = PASS;
- }
- } else if (*exp_err != SCF_ERROR_NONE && scf_ret != -1) {
- /*
- * An error was expected but the template came back as
- * non-null which it should not have, therefore report
- * the anomaly.
- */
- (void) fprintf(stdout, "--DIAG: "
- "scf_tmpl_prop_description() did not fail as expected\n\t"
- "RETURNED: 0x%p\n", (void *)*description);
- if (*description)
- free(*description);
- *exp_err = FAIL;
- } else if (scf_ret == -1) {
- /*
- * No error was expected, and template is still NULL
- * report the anomaly.
- */
- (void) fprintf(stdout, "--DIAG: "
- "scf_tmpl_prop_description() returned an error\n\t"
- "ERROR: %u (%s)\n",
- (unsigned int)scf_err, scf_strerror(scf_err));
- *exp_err = FAIL;
- } else if (*description == NULL) {
- (void) fprintf(stdout, "--DIAG: "
- "scf_tmpl_prop_description() did not "
- "fill in the description pointer");
- *exp_err = FAIL;
- } else {
- *exp_err = PASS;
- }
- return (scf_ret);
- }
- /*
- * scftest_tmpl_prop_units
- * Purpose: Call scf_tmpl_prop_units()
- * Parameters:
- * input: scf_pg_tmpl_t *p; a property
- * char **units: a pointer to the pointer for the units
- * scf_error_t *exp_err: the expected error
- * output: none
- * Returns: The result of the scf_tmpl_prop_units call with PASS
- * or FAIL in the exp_err pointer.
- */
- ssize_t
- scftest_tmpl_prop_units(scf_prop_tmpl_t *p, const char *locale, char **units,
- scf_error_t *exp_err) {
- scf_error_t scf_err = SCF_ERROR_NONE;
- int scf_ret;
- if (*exp_err != SCF_ERROR_NONE) {
- (void) fprintf(stdout, "--INFO: "
- "Call scf_tmpl_prop_units() and expect an error\n");
- } else {
- (void) fprintf(stdout, "--INFO: "
- "Call scf_tmpl_prop_units() and "
- "return the propety units\n");
- }
- scf_ret = scf_tmpl_prop_units(p, locale, units);
- scf_err = scf_error();
- if (*exp_err != SCF_ERROR_NONE && scf_ret == -1) {
- /*
- * An error was expected check that the error returned
- * matches the expected error and report anomalies as
- * well as success.
- */
- if (scf_err != *exp_err) {
- (void) fprintf(stdout, "--DIAG: "
- "scf_tmpl_prop_units() returned the wrong error\n\t"
- "EXPECTED: %d \n\t"
- "RETURNED: %d \n",
- (unsigned int)*exp_err, scf_ret);
- *exp_err = FAIL;
- } else {
- (void) fprintf(stdout, "--INFO: "
- "scf_tmpl_prop_units() failed as expected\n");
- *exp_err = PASS;
- }
- } else if (*exp_err != SCF_ERROR_NONE && scf_ret != -1) {
- /*
- * An error was expected but the template came back as
- * non-null which it should not have, therefore report
- * the anomaly.
- */
- (void) fprintf(stdout, "--DIAG: "
- "scf_tmpl_prop_units() did not fail as expected\n\t"
- "RETURNED: 0x%p\n", (void *)*units);
- if (*units)
- free(*units);
- *exp_err = FAIL;
- } else if (scf_ret == -1) {
- /*
- * No error was expected, and template is still NULL
- * report the anomaly.
- */
- (void) fprintf(stdout, "--DIAG: "
- "scf_tmpl_prop_units() returned an error\n\t"
- "ERROR: %u (%s)\n",
- (unsigned int)scf_err, scf_strerror(scf_err));
- *exp_err = FAIL;
- } else if (*units == NULL) {
- (void) fprintf(stdout, "--DIAG: "
- "scf_tmpl_prop_units() did not fill in the units pointer");
- *exp_err = FAIL;
- } else {
- *exp_err = PASS;
- }
- return (scf_ret);
- }
- /*
- * scftest_tmpl_prop_visibility
- * Purpose: Call scf_tmpl_prop_visibility()
- * Parameters:
- * input: scf_prop_tmpl_t *p: a property
- * uint8_t *visibility: a pointer to the visibility flag
- * scf_error_t *exp_err: the expected error
- * output: none
- * Returns: The result of the scf_tmpl_prop_visibility call with PASS
- * or FAIL in the exp_err pointer.
- */
- int
- scftest_tmpl_prop_visibility(scf_prop_tmpl_t *p, uint8_t *visibility,
- scf_error_t *exp_err) {
- scf_error_t scf_err = SCF_ERROR_NONE;
- int scf_ret;
- if (*exp_err != SCF_ERROR_NONE) {
- (void) fprintf(stdout, "--INFO: "
- "Call scf_tmpl_prop_visibility() and expect an error\n");
- } else {
- (void) fprintf(stdout, "--INFO: "
- "Call scf_tmpl_prop_visibility() and return the "
- "visibility flag\n");
- }
- scf_ret = scf_tmpl_prop_visibility(p, visibility);
- scf_err = scf_error();
- if (*exp_err != SCF_ERROR_NONE && scf_ret == -1) {
- /*
- * An error was expected check that the error returned
- * matches the expected error and report anomalies as
- * well as success.
- */
- if (scf_err != *exp_err) {
- (void) fprintf(stdout, "--DIAG: "
- "scf_tmpl_prop_visibility() "
- "returned the wrong error\n\t"
- "EXPECTED: %d \n\t"
- "RETURNED: %d \n",
- (unsigned int)*exp_err, scf_ret);
- *exp_err = FAIL;
- } else {
- (void) fprintf(stdout, "--INFO: "
- "scf_tmpl_prop_visibility() failed as expected\n");
- *exp_err = PASS;
- }
- } else if (*exp_err != SCF_ERROR_NONE && scf_ret != -1) {
- /*
- * An error was expected but the template came back as
- * non-null which it should not have, therefore report
- * the anomaly.
- */
- (void) fprintf(stdout, "--DIAG: "
- "scf_tmpl_prop_visibility() did not fail as expected\n\t"
- "RETURNED: %u\n", (uint8_t)visibility);
- *exp_err = FAIL;
- } else if (scf_ret == -1) {
- /*
- * No error was expected, and template is still NULL
- * report the anomaly.
- */
- (void) fprintf(stdout, "--DIAG: "
- "scf_tmpl_prop_visibility() returned an error\n\t"
- "ERROR: %u (%s)\n",
- (unsigned int)scf_err, scf_strerror(scf_err));
- *exp_err = FAIL;
- } else {
- *exp_err = PASS;
- }
- return (scf_ret);
- }
- /*
- * scftest_tmpl_prop_cardinality
- * Purpose: Call scf_tmpl_prop_cardinality()
- * Parameters:
- * input: scf_prop_tmpl_t *p: a property
- * uint64_t *min: a pointer to the min
- * uint64_t *max: a pointer to the max
- * scf_error_t *exp_err: the expected error
- * output: none
- * Returns: The result of the scf_tmpl_prop_cardinality call with PASS
- * or FAIL in the exp_err pointer.
- */
- int
- scftest_tmpl_prop_cardinality(scf_prop_tmpl_t *p, uint64_t *min,
- uint64_t *max, scf_error_t *exp_err) {
- scf_error_t scf_err = SCF_ERROR_NONE;
- int scf_ret;
- if (*exp_err != SCF_ERROR_NONE) {
- (void) fprintf(stdout, "--INFO: "
- "Call scf_tmpl_prop_cardinality() and expect an error\n");
- } else {
- (void) fprintf(stdout, "--INFO: "
- "Call scf_tmpl_prop_cardinality() and "
- "return the cardinality flag\n");
- }
- scf_ret = scf_tmpl_prop_cardinality(p, min, max);
- scf_err = scf_error();
- if (*exp_err != SCF_ERROR_NONE && scf_ret == -1) {
- /*
- * An error was expected check that the error returned
- * matches the expected error and report anomalies as
- * well as success.
- */
- if (scf_err != *exp_err) {
- (void) fprintf(stdout, "--DIAG: "
- "scf_tmpl_prop_cardinality() "
- "returned the wrong error\n\t"
- "EXPECTED: %d \n\t"
- "RETURNED: %d \n",
- (unsigned int)*exp_err, scf_ret);
- *exp_err = FAIL;
- } else {
- (void) fprintf(stdout, "--INFO: "
- "scf_tmpl_prop_cardinality() failed as expected\n");
- *exp_err = PASS;
- }
- } else if (*exp_err != SCF_ERROR_NONE && scf_ret != -1) {
- /*
- * An error was expected but the template came back as
- * non-null which it should not have, therefore report
- * the anomaly.
- */
- (void) fprintf(stdout, "--DIAG: "
- "scf_tmpl_prop_cardinality() did not fail as expected\n"
- "\tRETURNED: ");
- if (min)
- (void) fprintf(stdout, "min = %llu ", *min);
- else
- (void) fprintf(stdout, "min = NULL ");
- if (max)
- (void) fprintf(stdout, "max = %llu\n", *max);
- else
- (void) fprintf(stdout, "max = NULL\n");
- (void) fprintf(stdout, "\tSCF_ERROR: %s\n",
- scf_strerror(scf_error()));
- *exp_err = FAIL;
- } else if (scf_ret == -1) {
- /*
- * No error was expected, and template is still NULL
- * report the anomaly.
- */
- (void) fprintf(stdout, "--DIAG: "
- "scf_tmpl_prop_cardinality() returned an error\n\t"
- "ERROR: %u (%s)\n",
- (unsigned int)scf_err, scf_strerror(scf_err));
- *exp_err = FAIL;
- } else {
- *exp_err = PASS;
- }
- return (scf_ret);
- }
- /*
- * scftest_tmpl_prop_internal_seps
- * Purpose: Call scf_tmpl_prop_internal_seps()
- * Parameters:
- * input: scf_prop_tmpl_t *p: a property
- * char ***internal_seps: a pointer to a pointer
- * to an array of characters
- * scf_error_t *exp_err: the expected error
- * output: none
- * Returns: The result of the scf_tmpl_prop_internal_seps call with PASS
- * or FAIL in the exp_err pointer.
- */
- int
- scftest_tmpl_prop_internal_seps(scf_prop_tmpl_t *p, scf_values_t *seps,
- scf_error_t *exp_err) {
- scf_error_t scf_err = SCF_ERROR_NONE;
- int i, scf_ret;
- if (*exp_err != SCF_ERROR_NONE) {
- (void) fprintf(stdout, "--INFO: "
- "Call scf_tmpl_prop_internal_seps() and expect an error\n");
- } else {
- (void) fprintf(stdout, "--INFO: "
- "Call scf_tmpl_prop_internal_seps() and return the list of "
- "separators\n");
- }
- scf_ret = scf_tmpl_prop_internal_seps(p, seps);
- scf_err = scf_error();
- if (*exp_err != SCF_ERROR_NONE && scf_ret == -1) {
- /*
- * An error was expected check that the error returned
- * matches the expected error and report anomalies as
- * well as success.
- */
- if (scf_err != *exp_err) {
- (void) fprintf(stdout, "--DIAG: "
- "scf_tmpl_prop_internal_seps() "
- "returned the wrong error\n\t"
- "EXPECTED: %d \n\t"
- "RETURNED: %d \n",
- (unsigned int)*exp_err, scf_ret);
- *exp_err = FAIL;
- } else {
- (void) fprintf(stdout, "--INFO: "
- "scf_tmpl_prop_internal_seps() "
- "failed as expected\n");
- *exp_err = PASS;
- }
- } else if (*exp_err != SCF_ERROR_NONE && scf_ret != -1) {
- /*
- * An error was expected but the template came back as
- * non-null which it should not have, therefore report
- * the anomaly.
- */
- (void) fprintf(stdout, "--DIAG: "
- "scf_tmpl_prop_internal_seps() did not fail as expected\n\t"
- "RETURNED: ");
- for (i = 0; seps->values.v_astring[i]; i++) {
- (void) fprintf(stdout, "%c ",
- (char)seps->values.v_astring[i]);
- }
- (void) fprintf(stdout, "\n");
- *exp_err = FAIL;
- } else if (scf_ret == -1) {
- /*
- * No error was expected, and template is still NULL
- * report the anomaly.
- */
- (void) fprintf(stdout, "--DIAG: "
- "scf_tmpl_prop_internal_seps() returned an error\n\t"
- "ERROR: %u (%s)\n",
- (unsigned int)scf_err, scf_strerror(scf_err));
- *exp_err = FAIL;
- } else {
- *exp_err = PASS;
- }
- return (scf_ret);
- }
- /*
- * scftest_tmpl_value_name_constraints
- * Purpose: Call scf_tmpl_value_name_constraints()
- * Parameters:
- * input: scf_prop_tmpl_t *p : a property
- * scf_values_t *vals : pointer to the scf_values_t
- * scf_error_t *exp_err: the expected error
- * output: none
- * Returns: The result of the scf_tmpl_value_name_constraints call with PASS
- * or FAIL in the exp_err pointer.
- */
- int
- scftest_tmpl_value_name_constraints(scf_prop_tmpl_t *p, scf_values_t *vals,
- scf_error_t *exp_err) {
- scf_error_t scf_err = SCF_ERROR_NONE;
- int scf_ret;
- if (*exp_err != SCF_ERROR_NONE) {
- (void) fprintf(stdout, "--INFO: "
- "Call scf_tmpl_value_name_constraints() and "
- "expect an error\n");
- } else {
- (void) fprintf(stdout, "--INFO: "
- "Call scf_tmpl_value_name_constraints() and "
- "return the values\n");
- }
- scf_ret = scf_tmpl_value_name_constraints(p, vals);
- scf_err = scf_error();
- if (*exp_err != SCF_ERROR_NONE && scf_ret == -1) {
- /*
- * An error was expected check that the error returned
- * matches the expected error and report anomalies as
- * well as success.
- */
- if (scf_err != *exp_err) {
- (void) fprintf(stdout, "--DIAG: "
- "scf_tmpl_value_name_constraints() "
- "returned the wrong error\n\t"
- "EXPECTED: %d \n\t"
- "RETURNED: %d \n",
- (unsigned int)*exp_err, scf_ret);
- *exp_err = FAIL;
- } else {
- (void) fprintf(stdout, "--INFO: "
- "scf_tmpl_value_name_constraints() "
- "failed as expected\n");
- *exp_err = PASS;
- }
- } else if (*exp_err != SCF_ERROR_NONE && scf_ret != -1) {
- /*
- * An error was expected but the template came back as
- * non-null which it should not have, therefore report
- * the anomaly.
- */
- (void) fprintf(stdout, "--DIAG: "
- "scf_tmpl_value_name_constraints() did not "
- "fail as expected\n\t"
- "RETURNED: %s\n", (char *)vals->values.v_astring);
- *exp_err = FAIL;
- } else if (scf_ret == -1) {
- /*
- * No error was expected, and template is still NULL
- * report the anomaly.
- */
- (void) fprintf(stdout, "--DIAG: "
- "scf_tmpl_value_name_constraints() returned an error\n"
- "ERROR: %u (%s)\n",
- (unsigned int)scf_err, scf_strerror(scf_err));
- *exp_err = FAIL;
- } else {
- *exp_err = PASS;
- }
- return (scf_ret);
- }
- /*
- * scftest_tmpl_value_name_choices
- * Purpose: Call scf_tmpl_value_name_choices()
- * Parameters:
- * input: scf_prop_tmpl_t *p : a property
- * scf_values_t *vals : pointer to the scf_values_t
- * scf_error_t *exp_err: the expected error
- * output: none
- * Returns: The result of the scf_tmpl_value_name_choices call with PASS
- * or FAIL in the exp_err pointer.
- */
- int
- scftest_tmpl_value_name_choices(scf_prop_tmpl_t *p, scf_values_t *vals,
- scf_error_t *exp_err) {
- scf_error_t scf_err = SCF_ERROR_NONE;
- int scf_ret;
- if (*exp_err != SCF_ERROR_NONE) {
- (void) fprintf(stdout, "--INFO: "
- "Call scf_tmpl_value_name_choices() and "
- "expect an error\n");
- } else {
- (void) fprintf(stdout, "--INFO: "
- "Call scf_tmpl_value_name_choices() and "
- "return the values\n");
- }
- scf_ret = scf_tmpl_value_name_choices(p, vals);
- scf_err = scf_error();
- if (*exp_err != SCF_ERROR_NONE && scf_ret == -1) {
- /*
- * An error was expected check that the error returned
- * matches the expected error and report anomalies as
- * well as success.
- */
- if (scf_err != *exp_err) {
- (void) fprintf(stdout, "--DIAG: "
- "scf_tmpl_value_name_choices() "
- "returned the wrong error\n\t"
- "EXPECTED: %d \n\t"
- "RETURNED: %d \n",
- (unsigned int)*exp_err, scf_ret);
- *exp_err = FAIL;
- } else {
- (void) fprintf(stdout, "--INFO: "
- "scf_tmpl_value_name_choices() "
- "failed as expected\n");
- *exp_err = PASS;
- }
- } else if (*exp_err != SCF_ERROR_NONE && scf_ret != -1) {
- /*
- * An error was expected but the template came back as
- * non-null which it s…
Large files files are truncated, but you can click here to view the full file