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; }
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; }
int do_test_physmem(const char *test_parm) { (void) test_parm; #if !defined(ARCH_arm) void *va; physaddr_t pa; char buf[MSIZE]; hal_pv_alloc( &pa, &va, MSIZE ); test_check_true( va != 0 ); test_check_true( pa != 0 ); memset( va, 0, MSIZE ); memcpy_p2v( buf, pa, MSIZE ); if( memnotchar( buf, 0, MSIZE ) ) test_fail_msg( EINVAL, "not 0"); memset( buf, 0xFF, MSIZE ); memcpy_v2p( pa, buf, MSIZE ); if( memnotchar( va, 0xFF, MSIZE ) ) test_fail_msg( EINVAL, "not 1"); memset( va, 0, MSIZE ); memcpy_v2p( pa, "AAA", 3 ); if( memnotchar( va, 'A', 3 ) ) test_fail_msg( EINVAL, "not A"); if( memnotchar( va+3, 0, MSIZE-3 ) ) test_fail_msg( EINVAL, "not A0"); memset( va, 0, MSIZE ); memcpy_v2p( pa+10, "BBB", 3 ); if( memnotchar( va+10, 'B', 3 ) ) test_fail_msg( EINVAL, "not B"); if( memnotchar( va, 0, 10 ) ) test_fail_msg( EINVAL, "not B0-"); if( memnotchar( va+13, 0, MSIZE-13 ) ) test_fail_msg( EINVAL, "not B0+"); // Cross page memset( va, 0, MSIZE ); #define SH (4096-4) memcpy_v2p( pa+SH, "EEEEEEEE", 8 ); if( memnotchar( va+SH, 'E', 8 ) ) test_fail_msg( EINVAL, "not E"); if( memnotchar( va, 0, SH ) ) test_fail_msg( EINVAL, "not E0-"); if( memnotchar( va+SH+8, 0, MSIZE-SH-8 ) ) test_fail_msg( EINVAL, "not E0+"); #if 0 // not impl memset( va, 0, MSIZE ); memset( va+20, 'C', 3 ); memcpy_p2v( buf, pa+20, 3 ); if( memnotchar( buf, 'C', 3 ) ) test_fail_msg( EINVAL, "not C"); #endif hal_pv_free( pa, va, MSIZE ); #endif //!defined(ARCH_arm) return 0; }