apps/vm/components/helloworld/src/hello.c
/*
    vchantests_prod_cons:
        Simple buffer reading and writing test, similar to packet test
*/
Simple buffer reading and writing test, similar to packet test
Simple buffer reading and writing test similar to packet test
int vchantests_prod_cons(libvchan_t *ctrl) {
    int sz, x, i, failed, buf[PROD_CONS_CHUNK];
    for(x = 0; x < PROD_CONS_NUM; x++) {
        failed = 0;
        sz = libvchan_recv(ctrl, buf, PROD_CONS_CHUNK * sizeof(int));
        if(sz == PROD_CONS_CHUNK * sizeof(int)) {
            for(i = 0; i < PROD_CONS_CHUNK; i++) {
                if(i + x != buf[i]) {
                    DHELL("with: %d !packet_mismatch! got:%d:expected:%d\n", x, buf[i], i);
                    failed = 1;
                }
            }
        } else {
            DHELL("with: %d !incorrect size! got:%d:expected:%d\n", x, sz, PROD_CONS_CHUNK);
            failed = 1;
        }
        assert(failed == 0);
    }
    x = 1;
    libvchan_write(ctrl, &x, sizeof(x));
    return 0;
}
int vchantests_prod_cons ( libvchan_t * ctrl ) { int sz , x , i , failed , buf [ PROD_CONS_CHUNK ] ; for ( x = 0 ; x < PROD_CONS_NUM ; x ++ ) { failed = 0 ; sz = libvchan_recv ( ctrl , buf , PROD_CONS_CHUNK * sizeof ( int ) ) ; if ( sz == PROD_CONS_CHUNK * sizeof ( int ) ) { for ( i = 0 ; i < PROD_CONS_CHUNK ; i ++ ) { if ( i + x != buf [ i ] ) { DHELL ( " \n " , x , buf [ i ] , i ) ; failed = 1 ; } } } else { DHELL ( " \n " , x , sz , PROD_CONS_CHUNK ) ; failed = 1 ; } assert ( failed == 0 ) ; } x = 1 ; libvchan_write ( ctrl , & x , sizeof ( x ) ) ; return 0 ; }
vchantests_prod_cons:
Simple buffer reading and writing test, similar to packet test
vchantests_prod_cons : Simple buffer reading and writing test similar to packet test