예제 #1
0
int do_test_misc(const char *test_parm)
{
    (void) test_parm;

    char buf[BSIZE];
    int rc;

    test_check_eq(getpagesize(),4096);

    test_check_eq(personality(0xffffffff), 0);

    {
    struct utsname phantom_uname;
    test_check_eq(uname(&phantom_uname), 0);

    printf("uland: uname sys '%s'\n\tnode    %s\n\trel    %s\n\tver     %s\n\tmachine %s\n\tdomain  %s\n",
           phantom_uname.sysname,
           phantom_uname.nodename,
           phantom_uname.release,
           phantom_uname.version,
           phantom_uname.machine,
           phantom_uname.domainname
          );
    }

    rc = gethostname(buf, BSIZE);
    test_check_ge(rc,0);
    printf("uland: hostname %s\n", buf );


    return 0;
}
예제 #2
0
int do_test_sem(const char *test_parm)
{
    (void) test_parm;
    printf("Testing semaphores\n");

    hal_sem_init(&test_sem_0, "semTest");



    softirq = hal_alloc_softirq();
    if( softirq < 0 )
        test_fail_msg( 1, "Unable to get softirq" );

    hal_set_softirq_handler( softirq, sem_softirq, 0 );

    //int tid =
    hal_start_kernel_thread_arg( sem_rel, 0 );

    printf("sema wait 1\n");

    // Direct
    sem_released = 0;
    hal_sem_acquire( &test_sem_0 );
    test_check_eq(sem_released,1);

    hal_sleep_msec( 100 );

    printf("sema wait 2\n");

#if TEST_SOFTIRQ
    // Softirq
    sem_released = 0;
    hal_sem_acquire( &test_sem_0 );
    test_check_eq(sem_released,1);
#endif

    hal_sleep_msec( 100 );


    printf("sema timeout\n");
    sem_released = 0;
    hal_start_kernel_thread_arg( sem_etc, 0 );
    hal_sleep_msec( 100 );
    test_check_eq(sem_released,0);
    hal_sleep_msec( 120 );
    test_check_eq(sem_released,1);
    test_check_eq( rc, ETIMEDOUT);


    stop_sem_test = 1;

    printf("Done testing semaphores\n");
    return 0;

}
예제 #3
0
int do_test_rectangles(const char *test_parm)
{
    (void) test_parm;

    rect_t out1, out2, oldw, neww;

    oldw.x = 1;
    oldw.y = 1;
    oldw.xsize = 10;
    oldw.ysize = 10;

    neww.x = 2;
    neww.y = 2;
    neww.xsize = 10;
    neww.ysize = 10;

    //int o2 =
    rect_sub( &out1, &out2, &oldw, &neww );

    //rect_dump( &out1 );
    //rect_dump( &out2 );

    test_check_eq(out1.x,1);
    test_check_eq(out1.y,1);
    test_check_eq(out1.xsize,1);
    test_check_eq(out1.ysize,10);

    test_check_eq(out2.x,1);
    test_check_eq(out2.y,1);
    test_check_eq(out2.xsize,10);
    test_check_eq(out2.ysize,1);

    rect_t a, b;

    a.x     = 10; a.y     = 10;
    a.xsize = 10; a.ysize = 10;

    b.x     = 15; b.y     = 15;
    b.xsize = 10; b.ysize = 10;

    test_check_false( rect_includes( &a, &b ) );
    test_check_true( rect_intersects( &a, &b ) );

    b.xsize = 2;  b.ysize = 2;

    test_check_true( rect_includes( &a, &b ) );
    test_check_true( rect_intersects( &a, &b ) );

    b.x     = 35; b.y     = 35;

    test_check_false( rect_includes( &a, &b ) );
    test_check_false( rect_intersects( &a, &b ) );

    return 0;
}
예제 #4
0
int do_test_amap(const char *test_parm)
{
    (void) test_parm;
    //errno_t ret;
    int modified;

    amap_init( &map, 0, ~0, MAP_UNKNOWN );

    test_check_false(  amap_check_modify( &map, 10, 1, MAP_USED, &modified ) );
    test_check_false(  amap_check_modify( &map, 10, 1, MAP_USED, &modified ) );
    test_check_false( modified );

    test_check_false(  amap_check_modify( &map, 10, 1, MAP_FREE, &modified ) );
    test_check_true( modified );

    // Check if range has these attributes. Return 0 if it has.
    test_check_false( amap_check( &map, 10, 1, MAP_FREE ) );

    counter = 0;
    amap_iterate_flags( &map, count, 0, MAP_FREE );
    test_check_eq( counter, 1 );

    unsigned int i;

    for( i = 20; i < 50; i += 3 )
    {
        test_check_false( amap_check_modify( &map, i, 2, MAP_FREE, &modified ) );
    }

    for( i = 20; i < 50; i += 4 )
    {
        test_check_false( amap_check_modify( &map, i, 4, MAP_USED, &modified ) );
        test_check_true( modified );
    }

    for( i = 20; i < 100; i += 7 )
    {
        test_check_false( amap_check_modify( &map, i, 3, MAP_FREE, &modified ) );
    }


    amap_destroy( &map );
    return 0;
}
예제 #5
0
int do_test_userland(const char *test_parm)
{
    (void) test_parm;

    char testdata[5];
    int res;
    int32_t code;


    strcpy(testdata, "abcd");

    SHOW_INFO0( 0, "port_create()");
    uland_port = port_create(1,    "__regress_test_port");

    test_check_ge(uland_port,0);


    SHOW_INFO0( 0, "port_write()");
    res = port_write(uland_port, 1, &testdata, sizeof(testdata));
    test_check_eq(res,0);

    testdata[0] = 0;

    SHOW_INFO0( 0, "port_read()");
    res = port_read_etc(uland_port, &code, &testdata, sizeof(testdata), PORT_FLAG_TIMEOUT, 1000000);
    test_check_eq(res,5);
    test_check_eq(code,0xAA);

    test_check_eq( strcmp(testdata, "abcd"), 0);


    SHOW_INFO0( 0, "port_read() - wait for userland to finish");
    res = port_read_etc(uland_port, &code, &testdata, sizeof(testdata), PORT_FLAG_TIMEOUT, 1000000);
    test_check_ge(res,0);
    test_check_eq(code,0x55);


    SHOW_INFO0( 0, "close port");
    res = port_close(uland_port);
    test_check_ne(res,0);

#if 0
    SHOW_INFO0( 0, "delete port");
    res = port_delete(test_p2);
    test_check_eq(res,0);
#endif
    SHOW_INFO0( 0, "end test");

    return 0;
}
예제 #6
0
int do_test_timed_call(const char *test_parm)
{
    (void) test_parm;


    printf("Testing timed call undo, must be no echoes:\n");
    called = 0;

    phantom_request_timed_call( &t2, 0 );
    phantom_undo_timed_call(&t2);

    hal_sleep_msec(200); // Twice the time
    test_check_eq(called, 0);


#if DUMPQ
    //dump_timed_call_queue();
#endif


    called = 0;

    printf("Testing timed calls, wait for echoes:\n");

    phantom_request_timed_call( &t1, 0 );
    //test_check_false(called); // it is still possible for this test to fail with correct code!
    phantom_request_timed_call( &t2, 0 );
#if DUMPQ
    //dump_timed_call_queue();
#endif
    phantom_request_timed_call( &t3, 0 );
    phantom_request_timed_call( &t4, 0 );

    //TIMEDCALL_FLAG_AUTOFREE requires call to free from interrupt :(
    //phantom_request_timed_func( echo, msg, 5000, 0 );
    phantom_request_timed_call( &t5, 0 );

#if DUMPQ
    dump_timed_call_queue();
#endif

    // We check for >= (ge) because hal_sleep... can cleep for more than asked, and timed
    // calls are usually quite on time

    hal_sleep_msec(6);
    test_check_ge(called, 1);

    hal_sleep_msec(200); // Have lag of 106 msec, OK?
    test_check_ge(called, 2);

    hal_sleep_msec(2000-100); // Still have lag of 106 msec
    test_check_ge(called, 3);

    hal_sleep_msec(5000-2000); // Have lag of 206 msec
    test_check_ge(called, 4);

    hal_sleep_msec(2500+10000-5000-2000); // Strange - need quite big lag here...
    test_check_ge(called, 5);



    printf("Done testing timed calls\n");
    return 0;
}