apps/vm/components/helloworld/src/hello.c
/*
    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;
    char done = 1;
    int x, pnum;
    vchan_packet_t pak;
    DHELL("packet test...\n", pnum);
    libvchan_wait(ctrl);
    sz = libvchan_read(ctrl, &pnum, sizeof(int));
    assert(sz == sizeof(int));
    DHELL("number of packets to recieve = %d\n", pnum);
    for(x = 0; x < pnum; x++) {
        libvchan_wait(ctrl);
        assert(libvchan_data_ready(ctrl) != 0);
        assert(libvchan_buffer_space(ctrl) == FILE_DATAPORT_MAX_SIZE);
        sz = libvchan_read(ctrl, &pak, sizeof(pak));
        assert(sz == sizeof(pak));
        assert(pak.pnum == x);
        assert(vchantests_packet_verify(&pak) == 1);
        assert(pak.guard == PACKET_TEST_GUARD);
        if(x % 500 == 0)
            DHELL("comp.packet %d|%d\n", x, sizeof(pak));
    }
    sz = libvchan_write(ctrl, &done, sizeof(char));
    assert(sz == sizeof(char));
    return 0;
}
int vchantests_packet ( libvchan_t * ctrl ) { size_t sz ; char done = 1 ; int x , pnum ; vchan_packet_t pak ; DHELL ( " \n " , pnum ) ; libvchan_wait ( ctrl ) ; sz = libvchan_read ( ctrl , & pnum , sizeof ( int ) ) ; assert ( sz == sizeof ( int ) ) ; DHELL ( " \n " , pnum ) ; for ( x = 0 ; x < pnum ; x ++ ) { libvchan_wait ( ctrl ) ; assert ( libvchan_data_ready ( ctrl ) != 0 ) ; assert ( libvchan_buffer_space ( ctrl ) == FILE_DATAPORT_MAX_SIZE ) ; sz = libvchan_read ( ctrl , & pak , sizeof ( pak ) ) ; assert ( sz == sizeof ( pak ) ) ; assert ( pak . pnum == x ) ; assert ( vchantests_packet_verify ( & pak ) == 1 ) ; assert ( pak . guard == PACKET_TEST_GUARD ) ; if ( x % 500 == 0 ) DHELL ( " \n " , x , sizeof ( pak ) ) ; } sz = libvchan_write ( ctrl , & done , sizeof ( char ) ) ; assert ( sz == sizeof ( char ) ) ; 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
/* Buffer sanity checking */ /* Perform read operation */ /* See if the given packet is correct */