예제 #1
0
static void
my_send(int sock, const char *who, pid_t pid)
{
	u_char packet[PACKETLEN];
	ssize_t len;
	size_t totlen;
	int error;

	totlen = 0;
	packet_fill(packet);
	while (totlen < PACKETLEN) {
		len = send(sock, packet + totlen, PACKETLEN - totlen, 0);
		if (len < 0) {
			error = errno;
			(void)kill(pid, SIGTERM);
			errno = error;
			err(-1, "%s: send()", who);
		}
		if (len == 0) {
			(void)kill(pid, SIGTERM);
			errx(-1, "%s: send(): EOF", who);
		}
		totlen += len;
	}
}
예제 #2
0
static int test_ctlr (int ctlr, int index)
{
	int res = -1;
	char packet_send[MAX_PACKET_LENGTH];
	char packet_recv[MAX_PACKET_LENGTH];
	int length;
	int i;
	int l;

	ctlr_proc[ctlr].init (index);

	for (i = 0; i < TEST_NUM; i++) {
		for (l = MIN_PACKET_LENGTH; l <= MAX_PACKET_LENGTH; l++) {
			packet_fill (packet_send, l);

			ctlr_proc[ctlr].send (index, packet_send, l);

			length = ctlr_proc[ctlr].recv (index, packet_recv,
							MAX_PACKET_LENGTH);

			if (length != l || packet_check (packet_recv, length) < 0) {
				goto Done;
			}
		}
	}

	res = 0;

Done:

	ctlr_proc[ctlr].halt (index);

	/*
	 * SCC2 Ethernet parameter RAM space overlaps
	 * the SPI parameter RAM space. So we need to restore
	 * the SPI configuration after SCC2 ethernet test.
	 */
#if defined(CONFIG_SPI)
	if (ctlr == CTLR_SCC && index == 1) {
		spi_init_f ();
		spi_init_r ();
	}
#endif

	if (res != 0) {
		post_log ("ethernet %s%d test failed\n", ctlr_name[ctlr],
				  index + 1);
	}

	return res;
}