apps/odroid_vm/components/helloworld/linux_userlevel/build/vchan_code/sel4_vchan_testsuite.c
int vchantests_funnel(libvchan_t *ctrl) {
	int res, count = 0;
	char *buffer;
	int sz = libvchan_buffer_space(ctrl);
	if(sz <= 0) {
		TERROR("funnel: invalid bspace precondition");
		return -1;
	}

	TDPRINTF(2, "funnel: starting with %d\n", sz);
	libvchan_write(ctrl, &sz, sizeof(int));

	if(sz > 0) {
		buffer = malloc(sz);
		char c = 0;
		while(count < sz) {
			res = libvchan_write(ctrl, &c, sizeof(char));
			if(res < 0)
				TERROR("funnel: failed to perform write");

			buffer[count] = c;
			count++;
			c++;
		}

		TDPRINTF(2, "funnel: waiting for writeback\n");
    	libvchan_recv(ctrl, buffer, sz);
    	if(vchantests_funnel_verify_buffer(buffer, sz) < 0) {
    		TERROR("funnel: failed on buffer getback stage!\n");
    		return -1;
    	}
	} else {
		TERROR("funnel: incorrect precondtion for funnel start\n");
	}

	TDPRINTF(2, "funnel: finished on clientside\n");

	return 0;
}
/*
    vchantests_funnel:
        Send an entire buffer in chunks
        Wait for that buffer to be sent back (sent back in chunks)
        Primarily testing correct blocking behaviour
*/
Send an entire buffer in chunks
Wait for that buffer to be sent back (sent back in chunks)
Primarily testing correct blocking behaviour
Send an entire buffer in chunks Wait for that buffer to be sent back ( sent back in chunks ) Primarily testing correct blocking behaviour
int vchantests_funnel(libvchan_t *ctrl) {
	int res, count = 0;
	char *buffer;
	int sz = libvchan_buffer_space(ctrl);
	if(sz <= 0) {
		TERROR("funnel: invalid bspace precondition");
		return -1;
	}
	TDPRINTF(2, "funnel: starting with %d\n", sz);
	libvchan_write(ctrl, &sz, sizeof(int));
	if(sz > 0) {
		buffer = malloc(sz);
		char c = 0;
		while(count < sz) {
			res = libvchan_write(ctrl, &c, sizeof(char));
			if(res < 0)
				TERROR("funnel: failed to perform write");
			buffer[count] = c;
			count++;
			c++;
		}
		TDPRINTF(2, "funnel: waiting for writeback\n");
    	libvchan_recv(ctrl, buffer, sz);
    	if(vchantests_funnel_verify_buffer(buffer, sz) < 0) {
    		TERROR("funnel: failed on buffer getback stage!\n");
    		return -1;
    	}
	} else {
		TERROR("funnel: incorrect precondtion for funnel start\n");
	}
	TDPRINTF(2, "funnel: finished on clientside\n");
	return 0;
}
int vchantests_funnel ( libvchan_t * ctrl ) { int res , count = 0 ; char * buffer ; int sz = libvchan_buffer_space ( ctrl ) ; if ( sz <= 0 ) { TERROR ( " " ) ; return -1 ; } TDPRINTF ( 2 , " \n " , sz ) ; libvchan_write ( ctrl , & sz , sizeof ( int ) ) ; if ( sz > 0 ) { buffer = malloc ( sz ) ; char c = 0 ; while ( count < sz ) { res = libvchan_write ( ctrl , & c , sizeof ( char ) ) ; if ( res < 0 ) TERROR ( " " ) ; buffer [ count ] = c ; count ++ ; c ++ ; } TDPRINTF ( 2 , " \n " ) ; libvchan_recv ( ctrl , buffer , sz ) ; if ( vchantests_funnel_verify_buffer ( buffer , sz ) < 0 ) { TERROR ( " \n " ) ; return -1 ; } } else { TERROR ( " \n " ) ; } TDPRINTF ( 2 , " \n " ) ; return 0 ; }
vchantests_funnel:
Send an entire buffer in chunks
Wait for that buffer to be sent back (sent back in chunks)
Primarily testing correct blocking behaviour
vchantests_funnel : Send an entire buffer in chunks Wait for that buffer to be sent back ( sent back in chunks ) Primarily testing correct blocking behaviour