Example #1
0
int
ndmca_test_data_get_state (struct ndm_session *sess, ndmp9_error expect_err)
{
	struct ndmconn *	conn = sess->plumb.data;
	int			rc;

	/* close previous test if there is one */
	ndmca_test_close (sess);

	rc = ndmca_data_get_state (sess);

	rc = ndmca_test_check_expect (conn, rc, expect_err);

	return rc;
}
Example #2
0
int
ndmca_monitor_get_states (struct ndm_session *sess)
{
	struct ndm_control_agent *ca = sess->control_acb;
	int rc = 0;

	if (ndmca_data_get_state (sess) < 0)
	    rc = -1;
	if (!ca->job.tape_tcp) {
	    if (ndmca_mover_get_state (sess) < 0)
		rc = -1;
	    ndmca_tape_get_state_no_tattle (sess);
	}

	return rc;
}
Example #3
0
int
ndmca_test_check_data_state  (struct ndm_session *sess,
  ndmp9_data_state expected, int reason)
{
	struct ndm_control_agent *	ca = sess->control_acb;
	ndmp9_data_get_state_reply *	ds = &ca->data_state;
	int				rc;
	char *				what;
	char				errbuf[100];
	char				tmpbuf[256];

	/* close previous test if there is one */
	ndmca_test_close (sess);

	/* open new test */
	ndmca_test_open (sess,
			 "data check",
			 ndmp9_data_state_to_str (expected));

	strcpy (errbuf, "???");

	what = "get_state";
	rc = ndmca_data_get_state (sess);
	if (rc) goto fail;

	what = "state self-consistent";
	/* make sure the sensed state is self consistent */
	switch (ds->state) {
	case NDMP9_DATA_STATE_IDLE:
	case NDMP9_DATA_STATE_ACTIVE:
	case NDMP9_DATA_STATE_LISTEN:
	case NDMP9_DATA_STATE_CONNECTED:
		if (ds->halt_reason != NDMP9_DATA_HALT_NA) {
			strcpy (errbuf, "reason != NA");
			goto fail;
		}
		break;

	case NDMP9_DATA_STATE_HALTED:
		break;

	default:
		strcpy (errbuf, "bogus state");
		goto fail;
	}

	what = "state";
	if (ds->state != expected) {
		sprintf (errbuf, "expected %s got %s",
			ndmp9_data_state_to_str (expected),
			ndmp9_data_state_to_str (ds->state));
		goto fail;
	}

	what = "reason";
	switch (ds->state) {
	case NDMP9_DATA_STATE_HALTED:
		if (ds->halt_reason != (ndmp9_data_halt_reason)reason) {
			sprintf (errbuf, "expected %s got %s",
			    ndmp9_data_halt_reason_to_str (reason),
			    ndmp9_data_halt_reason_to_str (ds->halt_reason));
			goto fail;
		}
		break;

	default:
		break;
	}

	/* test passed */
	ndmca_test_close (sess);

	return 0;

  fail:
	/* test failed */
	sprintf(tmpbuf, "%s: %s", what, errbuf);
	ndmca_test_fail(sess, tmpbuf);

	ndmca_test_close (sess);

	return -1;
}