apps/odroid_vm/components/helloworld/linux_userlevel/build/vchan_code/sel4_vchan_testsuite.c
int vchantests_vm_burst(libvchan_t *ctrl) {
	int key, rsize, sleep_count, x, res = 0;
    int total_int_num;
	int buf[VM_BURST_VM_SZ];

    TDPRINTF(2, "vm-burst: start\n");

    for(x = 0; x < VM_BURST_NUM_SENDS; x++) {
        sleep_count = 0;
        res = libvchan_recv(ctrl, &key, sizeof(int));
        if(res < 0) {
            TERROR("vm-burst: failed to get key\n");
            return -1;
        }

        if(!valid_key(key, vm_burst_base_nums, sizeof(vm_burst_base_nums) / sizeof(int))) {
            TERROR("vm-burst: key MISMATCH (got: %x)\n", key);
            return -1;
        }

        TDPRINTF(2, "vm-burst: key = %x\n", key);
        rsize = VM_BURST_CHUNK_INTS * sizeof(int);
        total_int_num = 0;
        TDPRINTF(2, "vm-burst: going to read\n");

        while(rsize > 0) {
            if(sleep_count < VM_BURST_NUM_SLEEPS) {
                sleep_count++;
                sleep(VM_BURST_SLEEP_TIME);
            }

            TDPRINTF(4, "vm-burst: %d bytes remaining\n", rsize);
            int rval = MIN(rsize, sizeof(buf));
            res = libvchan_recv(ctrl, buf, rval);
            TDPRINTF(4, "vm-burst: returned with %d|%d bytes\n", res, rsize);
            if(res != rval) {
                TERROR("vm-burst: did not get correct ret\n");
                return -1;
            }

            rsize -= res;
            if(vchantests_vm_burst_verify(key + total_int_num, buf, (res / sizeof(int))) < 0) {
                TERROR("vm-burst: failed data check %d\n", total_int_num);
            	return -1;
            } else {
                TDPRINTF(2, "vm-burst: passed data check %d\n", total_int_num);
            }
            total_int_num += res / sizeof(int);
        }

        res = VM_BURST_CHECKSUM;
        libvchan_send(ctrl, &res, sizeof(int));
    }

	return 0;
}
/*
    vchantests_vm_burst:
		Recieve big chunks of data from the component, sleep intermittently
		Check that the chunks recieved are correct
*/
Recieve big chunks of data from the component, sleep intermittently
Check that the chunks recieved are correct
Recieve big chunks of data from the component sleep intermittently Check that the chunks recieved are correct
int vchantests_vm_burst(libvchan_t *ctrl) {
	int key, rsize, sleep_count, x, res = 0;
    int total_int_num;
	int buf[VM_BURST_VM_SZ];
    TDPRINTF(2, "vm-burst: start\n");
    for(x = 0; x < VM_BURST_NUM_SENDS; x++) {
        sleep_count = 0;
        res = libvchan_recv(ctrl, &key, sizeof(int));
        if(res < 0) {
            TERROR("vm-burst: failed to get key\n");
            return -1;
        }
        if(!valid_key(key, vm_burst_base_nums, sizeof(vm_burst_base_nums) / sizeof(int))) {
            TERROR("vm-burst: key MISMATCH (got: %x)\n", key);
            return -1;
        }
        TDPRINTF(2, "vm-burst: key = %x\n", key);
        rsize = VM_BURST_CHUNK_INTS * sizeof(int);
        total_int_num = 0;
        TDPRINTF(2, "vm-burst: going to read\n");
        while(rsize > 0) {
            if(sleep_count < VM_BURST_NUM_SLEEPS) {
                sleep_count++;
                sleep(VM_BURST_SLEEP_TIME);
            }
            TDPRINTF(4, "vm-burst: %d bytes remaining\n", rsize);
            int rval = MIN(rsize, sizeof(buf));
            res = libvchan_recv(ctrl, buf, rval);
            TDPRINTF(4, "vm-burst: returned with %d|%d bytes\n", res, rsize);
            if(res != rval) {
                TERROR("vm-burst: did not get correct ret\n");
                return -1;
            }
            rsize -= res;
            if(vchantests_vm_burst_verify(key + total_int_num, buf, (res / sizeof(int))) < 0) {
                TERROR("vm-burst: failed data check %d\n", total_int_num);
            	return -1;
            } else {
                TDPRINTF(2, "vm-burst: passed data check %d\n", total_int_num);
            }
            total_int_num += res / sizeof(int);
        }
        res = VM_BURST_CHECKSUM;
        libvchan_send(ctrl, &res, sizeof(int));
    }
	return 0;
}
int vchantests_vm_burst ( libvchan_t * ctrl ) { int key , rsize , sleep_count , x , res = 0 ; int total_int_num ; int buf [ VM_BURST_VM_SZ ] ; TDPRINTF ( 2 , " \n " ) ; for ( x = 0 ; x < VM_BURST_NUM_SENDS ; x ++ ) { sleep_count = 0 ; res = libvchan_recv ( ctrl , & key , sizeof ( int ) ) ; if ( res < 0 ) { TERROR ( " \n " ) ; return -1 ; } if ( ! valid_key ( key , vm_burst_base_nums , sizeof ( vm_burst_base_nums ) / sizeof ( int ) ) ) { TERROR ( " \n " , key ) ; return -1 ; } TDPRINTF ( 2 , " \n " , key ) ; rsize = VM_BURST_CHUNK_INTS * sizeof ( int ) ; total_int_num = 0 ; TDPRINTF ( 2 , " \n " ) ; while ( rsize > 0 ) { if ( sleep_count < VM_BURST_NUM_SLEEPS ) { sleep_count ++ ; sleep ( VM_BURST_SLEEP_TIME ) ; } TDPRINTF ( 4 , " \n " , rsize ) ; int rval = MIN ( rsize , sizeof ( buf ) ) ; res = libvchan_recv ( ctrl , buf , rval ) ; TDPRINTF ( 4 , " \n " , res , rsize ) ; if ( res != rval ) { TERROR ( " \n " ) ; return -1 ; } rsize -= res ; if ( vchantests_vm_burst_verify ( key + total_int_num , buf , ( res / sizeof ( int ) ) ) < 0 ) { TERROR ( " \n " , total_int_num ) ; return -1 ; } else { TDPRINTF ( 2 , " \n " , total_int_num ) ; } total_int_num += res / sizeof ( int ) ; } res = VM_BURST_CHECKSUM ; libvchan_send ( ctrl , & res , sizeof ( int ) ) ; } return 0 ; }
vchantests_vm_burst:
Recieve big chunks of data from the component, sleep intermittently
Check that the chunks recieved are correct
vchantests_vm_burst : Recieve big chunks of data from the component sleep intermittently Check that the chunks recieved are correct