apps/odroid_vm/components/helloworld/linux_userlevel/build/vchan_code/sel4_vchan_testsuite.c
int vchantests_packet(libvchan_t *ctrl) {
	size_t sz;
	vchan_packet_t pak;
	int x, i, num_packets = PACKET_TEST_NUM_PACKETS;
	char fnack;

	TDPRINTF(2, "packets: start\n");
	/* Check that buffer data is correct */
	sz = libvchan_data_ready(ctrl);
	if(sz != 0) {
		TERROR("incorrect start packet buffer size (data ready) %d\n", (int) sz);
		return -1;
	}

	sz = libvchan_buffer_space(ctrl);
	if(sz != FILE_DATAPORT_MAX_SIZE) {
		TERROR("error: incorrect start packet buffer size (bspace) %d\n", (int) sz);
		return -1;
	}

	/* Start */
	sz = libvchan_send(ctrl, &num_packets, sizeof(int));
	if(sz < sizeof(int)) {
		TERROR("bad packet send size\n");
		return -1;
	}

	TDPRINTF(4, "packets: send packets\n");

	for(x = 0; x < num_packets; x++) {
		pak.pnum = x;
		for(i = 0; i < 4; i++) {
			pak.datah[i] = i + x;
		}
        pak.guard = PACKET_TEST_GUARD;

		sz = libvchan_send(ctrl, &pak, sizeof(pak));
		if(sz != sizeof(pak)) {
			TERROR("bad packet send size\n");
			return -1;
		}
	}

	TDPRINTF(4, "packets: waiting for ack..\n");

	libvchan_wait(ctrl);
	sz = libvchan_read(ctrl, &fnack, sizeof(char));
	if(sz < sizeof(char) || ! fnack) {
		TERROR("bad ack for packets %d\n", (int) fnack);
		return -1;
	}

	TDPRINTF(2, "packets: finished\n");
	return 0;
}
/*
    vchantests_packet:
		Send a number of packets to the test component, then wait for an ack
		test component checks for incorrect data
*/
Send a number of packets to the test component, then wait for an ack
test component checks for incorrect data
Send a number of packets to the test component then wait for an ack test component checks for incorrect data
int vchantests_packet(libvchan_t *ctrl) {
	size_t sz;
	vchan_packet_t pak;
	int x, i, num_packets = PACKET_TEST_NUM_PACKETS;
	char fnack;
	TDPRINTF(2, "packets: start\n");
	sz = libvchan_data_ready(ctrl);
	if(sz != 0) {
		TERROR("incorrect start packet buffer size (data ready) %d\n", (int) sz);
		return -1;
	}
	sz = libvchan_buffer_space(ctrl);
	if(sz != FILE_DATAPORT_MAX_SIZE) {
		TERROR("error: incorrect start packet buffer size (bspace) %d\n", (int) sz);
		return -1;
	}
	sz = libvchan_send(ctrl, &num_packets, sizeof(int));
	if(sz < sizeof(int)) {
		TERROR("bad packet send size\n");
		return -1;
	}
	TDPRINTF(4, "packets: send packets\n");
	for(x = 0; x < num_packets; x++) {
		pak.pnum = x;
		for(i = 0; i < 4; i++) {
			pak.datah[i] = i + x;
		}
        pak.guard = PACKET_TEST_GUARD;
		sz = libvchan_send(ctrl, &pak, sizeof(pak));
		if(sz != sizeof(pak)) {
			TERROR("bad packet send size\n");
			return -1;
		}
	}
	TDPRINTF(4, "packets: waiting for ack..\n");
	libvchan_wait(ctrl);
	sz = libvchan_read(ctrl, &fnack, sizeof(char));
	if(sz < sizeof(char) || ! fnack) {
		TERROR("bad ack for packets %d\n", (int) fnack);
		return -1;
	}
	TDPRINTF(2, "packets: finished\n");
	return 0;
}
int vchantests_packet ( libvchan_t * ctrl ) { size_t sz ; vchan_packet_t pak ; int x , i , num_packets = PACKET_TEST_NUM_PACKETS ; char fnack ; TDPRINTF ( 2 , " \n " ) ; sz = libvchan_data_ready ( ctrl ) ; if ( sz != 0 ) { TERROR ( " \n " , ( int ) sz ) ; return -1 ; } sz = libvchan_buffer_space ( ctrl ) ; if ( sz != FILE_DATAPORT_MAX_SIZE ) { TERROR ( " \n " , ( int ) sz ) ; return -1 ; } sz = libvchan_send ( ctrl , & num_packets , sizeof ( int ) ) ; if ( sz < sizeof ( int ) ) { TERROR ( " \n " ) ; return -1 ; } TDPRINTF ( 4 , " \n " ) ; for ( x = 0 ; x < num_packets ; x ++ ) { pak . pnum = x ; for ( i = 0 ; i < 4 ; i ++ ) { pak . datah [ i ] = i + x ; } pak . guard = PACKET_TEST_GUARD ; sz = libvchan_send ( ctrl , & pak , sizeof ( pak ) ) ; if ( sz != sizeof ( pak ) ) { TERROR ( " \n " ) ; return -1 ; } } TDPRINTF ( 4 , " \n " ) ; libvchan_wait ( ctrl ) ; sz = libvchan_read ( ctrl , & fnack , sizeof ( char ) ) ; if ( sz < sizeof ( char ) || ! fnack ) { TERROR ( " \n " , ( int ) fnack ) ; return -1 ; } TDPRINTF ( 2 , " \n " ) ; return 0 ; }
vchantests_packet:
Send a number of packets to the test component, then wait for an ack
test component checks for incorrect data
vchantests_packet : Send a number of packets to the test component then wait for an ack test component checks for incorrect data
/* Check that buffer data is correct */ /* Start */