Subversion Repositories HelenOS-historic

Compare Revisions

Ignore whitespace Rev 1767 → Rev 1780

/kernel/trunk/test/synch/rwlock4/test.c
50,17 → 50,17
 
static waitq_t can_start;
 
__u32 seed = 0xdeadbeef;
uint32_t seed = 0xdeadbeef;
 
static __u32 random(__u32 max);
static uint32_t random(uint32_t max);
 
static void writer(void *arg);
static void reader(void *arg);
static void failed(void);
 
__u32 random(__u32 max)
uint32_t random(uint32_t max)
{
__u32 rc;
uint32_t rc;
 
spinlock_lock(&lock);
rc = seed % max;
121,7 → 121,7
void test(void)
{
context_t ctx;
__u32 i, k;
uint32_t i, k;
printf("Read/write locks test #4\n");
/kernel/trunk/test/synch/semaphore2/test.c
45,16 → 45,16
 
static waitq_t can_start;
 
__u32 seed = 0xdeadbeef;
uint32_t seed = 0xdeadbeef;
 
static __u32 random(__u32 max);
static uint32_t random(uint32_t max);
 
static void consumer(void *arg);
static void failed(void);
 
__u32 random(__u32 max)
uint32_t random(uint32_t max)
{
__u32 rc;
uint32_t rc;
 
spinlock_lock(&lock);
rc = seed % max;
95,7 → 95,7
 
void test(void)
{
__u32 i, k;
uint32_t i, k;
printf("Semaphore test #2\n");
/kernel/trunk/test/mm/falloc1/test.c
40,7 → 40,7
#define TEST_RUNS 2
 
void test(void) {
__address * frames = (__address *) malloc(MAX_FRAMES*sizeof(__address), 0);
uintptr_t * frames = (uintptr_t *) malloc(MAX_FRAMES*sizeof(uintptr_t), 0);
int results[MAX_ORDER+1];
int i, order, run;
54,7 → 54,7
printf("Allocating %d frames blocks ... ", 1 << order);
allocated = 0;
for (i = 0; i < MAX_FRAMES >> order; i++) {
frames[allocated] = (__address) frame_alloc(order, FRAME_ATOMIC | FRAME_KA);
frames[allocated] = (uintptr_t) frame_alloc(order, FRAME_ATOMIC | FRAME_KA);
if (ALIGN_UP(frames[allocated], FRAME_SIZE << order) != frames[allocated]) {
panic("Test failed. Block at address %p (size %dK) is not aligned\n", frames[allocated], (FRAME_SIZE << order) >> 10);
/kernel/trunk/test/mm/falloc2/test.c
52,10 → 52,10
void falloc(void * arg)
{
int order, run, allocated, i;
__u8 val = THREAD->tid % THREADS;
uint8_t val = THREAD->tid % THREADS;
index_t k;
__address * frames = (__address *) malloc(MAX_FRAMES * sizeof(__address), FRAME_ATOMIC);
uintptr_t * frames = (uintptr_t *) malloc(MAX_FRAMES * sizeof(uintptr_t), FRAME_ATOMIC);
ASSERT(frames != NULL);
thread_detach(THREAD);
65,7 → 65,7
printf("Thread #%d (cpu%d): Allocating %d frames blocks ... \n", THREAD->tid, CPU->id, 1 << order);
allocated = 0;
for (i = 0; i < (MAX_FRAMES >> order); i++) {
frames[allocated] = (__address)frame_alloc(order, FRAME_ATOMIC | FRAME_KA);
frames[allocated] = (uintptr_t)frame_alloc(order, FRAME_ATOMIC | FRAME_KA);
if (frames[allocated]) {
memsetb(frames[allocated], FRAME_SIZE << order, val);
allocated++;
78,7 → 78,7
printf("Thread #%d (cpu%d): Deallocating ... \n", THREAD->tid, CPU->id);
for (i = 0; i < allocated; i++) {
for (k = 0; k <= ((FRAME_SIZE << order) - 1); k++) {
if (((__u8 *) frames[i])[k] != val) {
if (((uint8_t *) frames[i])[k] != val) {
printf("Thread #%d (cpu%d): Unexpected data (%d) in block %p offset %#zx\n", THREAD->tid, CPU->id, ((char *) frames[i])[k], frames[i], k);
failed();
}
/kernel/trunk/test/mm/slab1/test.c
49,7 → 49,7
printf("Allocating %d items...", count);
for (i=0; i < count; i++) {
data[i] = slab_alloc(cache, 0);
memsetb((__address)data[i], size, 0);
memsetb((uintptr_t)data[i], size, 0);
}
printf("done.\n");
printf("Freeing %d items...", count);
61,7 → 61,7
printf("Allocating %d items...", count);
for (i=0; i < count; i++) {
data[i] = slab_alloc(cache, 0);
memsetb((__address)data[i], size, 0);
memsetb((uintptr_t)data[i], size, 0);
}
printf("done.\n");
 
74,7 → 74,7
printf("Allocating %d items...", count/2);
for (i=count/2; i < count; i++) {
data[i] = slab_alloc(cache, 0);
memsetb((__address)data[i], size, 0);
memsetb((uintptr_t)data[i], size, 0);
}
printf("done.\n");
printf("Freeing %d items...", count);
110,7 → 110,7
 
static void slabtest(void *data)
{
int offs = (int)(__native) data;
int offs = (int)(unative_t) data;
int i,j;
thread_detach(THREAD);
140,7 → 140,7
SLAB_CACHE_NOMAGAZINE);
semaphore_initialize(&thr_sem,0);
for (i=0; i<THREADS; i++) {
if (!(t = thread_create(slabtest, (void *)(__native)i, TASK, 0, "slabtest")))
if (!(t = thread_create(slabtest, (void *)(unative_t)i, TASK, 0, "slabtest")))
panic("could not create thread\n");
thread_ready(t);
}
/kernel/trunk/test/mm/purge1/test.c
37,7 → 37,7
 
 
extern void tlb_invalidate_all(void);
extern void tlb_invalidate_pages(asid_t asid, __address va, count_t cnt);
extern void tlb_invalidate_pages(asid_t asid, uintptr_t va, count_t cnt);
void test(void)
{
tlb_entry_t entryi;
/kernel/trunk/test/mm/slab2/test.c
67,8 → 67,8
slab_free(cache2,data2);
break;
}
memsetb((__address)data1, ITEM_SIZE, 0);
memsetb((__address)data2, ITEM_SIZE, 0);
memsetb((uintptr_t)data1, ITEM_SIZE, 0);
memsetb((uintptr_t)data2, ITEM_SIZE, 0);
*((void **)data1) = olddata1;
*((void **)data2) = olddata2;
olddata1 = data1;
90,7 → 90,7
if (!data1) {
panic("Incorrect memory size - use another test.");
}
memsetb((__address)data1, ITEM_SIZE, 0);
memsetb((uintptr_t)data1, ITEM_SIZE, 0);
*((void **)data1) = olddata1;
olddata1 = data1;
}
99,7 → 99,7
if (!data1) {
break;
}
memsetb((__address)data1, ITEM_SIZE, 0);
memsetb((uintptr_t)data1, ITEM_SIZE, 0);
*((void **)data1) = olddata1;
olddata1 = data1;
}
/kernel/trunk/test/mm/mapping1/test.c
42,8 → 42,8
 
void test(void)
{
__address frame0, frame1;
__u32 v0, v1;
uintptr_t frame0, frame1;
uint32_t v0, v1;
 
printf("Memory management test mapping #1\n");
 
51,9 → 51,9
frame1 = frame_alloc(ONE_FRAME, FRAME_KA);
 
printf("Writing %#x to physical address %p.\n", VALUE0, KA2PA(frame0));
*((__u32 *) frame0) = VALUE0;
*((uint32_t *) frame0) = VALUE0;
printf("Writing %#x to physical address %p.\n", VALUE1, KA2PA(frame1));
*((__u32 *) frame1) = VALUE1;
*((uint32_t *) frame1) = VALUE1;
printf("Mapping virtual address %p to physical address %p.\n", PAGE0, KA2PA(frame0));
page_mapping_insert(AS_KERNEL, PAGE0, KA2PA(frame0), PAGE_PRESENT | PAGE_WRITE);
60,22 → 60,22
printf("Mapping virtual address %p to physical address %p.\n", PAGE1, KA2PA(frame1));
page_mapping_insert(AS_KERNEL, PAGE1, KA2PA(frame1), PAGE_PRESENT | PAGE_WRITE);
printf("Value at virtual address %p is %#x.\n", PAGE0, v0 = *((__u32 *) PAGE0));
printf("Value at virtual address %p is %#x.\n", PAGE1, v1 = *((__u32 *) PAGE1));
printf("Value at virtual address %p is %#x.\n", PAGE0, v0 = *((uint32_t *) PAGE0));
printf("Value at virtual address %p is %#x.\n", PAGE1, v1 = *((uint32_t *) PAGE1));
ASSERT(v0 == VALUE0);
ASSERT(v1 == VALUE1);
 
printf("Writing %#x to virtual address %p.\n", 0, PAGE0);
*((__u32 *) PAGE0) = 0;
*((uint32_t *) PAGE0) = 0;
printf("Writing %#x to virtual address %p.\n", 0, PAGE1);
*((__u32 *) PAGE1) = 0;
*((uint32_t *) PAGE1) = 0;
 
v0 = *((__u32 *) PAGE0);
v1 = *((__u32 *) PAGE1);
v0 = *((uint32_t *) PAGE0);
v1 = *((uint32_t *) PAGE1);
printf("Value at virtual address %p is %#x.\n", PAGE0, *((__u32 *) PAGE0));
printf("Value at virtual address %p is %#x.\n", PAGE1, *((__u32 *) PAGE1));
printf("Value at virtual address %p is %#x.\n", PAGE0, *((uint32_t *) PAGE0));
printf("Value at virtual address %p is %#x.\n", PAGE1, *((uint32_t *) PAGE1));
 
ASSERT(v0 == 0);
ASSERT(v1 == 0);
/kernel/trunk/test/fpu/mips1/test.c
47,7 → 47,7
static void testit1(void *data)
{
int i;
int arg __attribute__((aligned(16))) = (int)((__native) data);
int arg __attribute__((aligned(16))) = (int)((unative_t) data);
int after_arg __attribute__((aligned(16)));
 
thread_detach(THREAD);
77,7 → 77,7
static void testit2(void *data)
{
int i;
int arg __attribute__((aligned(16))) = (int)((__native) data);
int arg __attribute__((aligned(16))) = (int)((unative_t) data);
int after_arg __attribute__((aligned(16)));
 
thread_detach(THREAD);
116,10 → 116,10
printf("Creating %d threads... ", THREADS);
 
for (i=0; i<THREADS/2; i++) {
if (!(t = thread_create(testit1, (void *)((__native)i*2), TASK, 0, "testit1")))
if (!(t = thread_create(testit1, (void *)((unative_t)i*2), TASK, 0, "testit1")))
panic("could not create thread\n");
thread_ready(t);
if (!(t = thread_create(testit2, (void *)((__native)i*2+1), TASK, 0, "testit2")))
if (!(t = thread_create(testit2, (void *)((unative_t)i*2+1), TASK, 0, "testit2")))
panic("could not create thread\n");
thread_ready(t);
}
/kernel/trunk/test/fpu/fpu1/test.c
95,10 → 95,10
}
 
if((int)(100000000*e)!=E_10e8)
panic("tid%d: e*10e8=%zd should be %zd\n", THREAD->tid, (__native) (100000000*e),(__native) E_10e8);
panic("tid%d: e*10e8=%zd should be %zd\n", THREAD->tid, (unative_t) (100000000*e),(unative_t) E_10e8);
}
 
printf("tid%d: e*10e8=%zd should be %zd\n", THREAD->tid, (__native) (100000000*e),(__native) E_10e8);
printf("tid%d: e*10e8=%zd should be %zd\n", THREAD->tid, (unative_t) (100000000*e),(unative_t) E_10e8);
atomic_inc(&threads_ok);
}
 
136,15 → 136,15
 
#ifdef __ia64_ARCH_H__
if((int)(1000000*pi)!=PI_10e8)
panic("tid%d: pi*10e8=%zd should be %zd\n", THREAD->tid, (__native) (1000000*pi),(__native) (PI_10e8/100));
panic("tid%d: pi*10e8=%zd should be %zd\n", THREAD->tid, (unative_t) (1000000*pi),(unative_t) (PI_10e8/100));
#else
if((int)(100000000*pi)!=PI_10e8)
panic("tid%d: pi*10e8=%zd should be %zd\n", THREAD->tid, (__native) (100000000*pi),(__native) PI_10e8);
panic("tid%d: pi*10e8=%zd should be %zd\n", THREAD->tid, (unative_t) (100000000*pi),(unative_t) PI_10e8);
#endif
 
}
 
printf("tid%d: pi*10e8=%zd should be %zd\n", THREAD->tid, (__native) (100000000*pi),(__native) PI_10e8);
printf("tid%d: pi*10e8=%zd should be %zd\n", THREAD->tid, (unative_t) (100000000*pi),(unative_t) PI_10e8);
atomic_inc(&threads_ok);
}
 
/kernel/trunk/test/fpu/sse1/test.c
47,7 → 47,7
static void testit1(void *data)
{
int i;
int arg __attribute__((aligned(16))) = (int)((__native) data);
int arg __attribute__((aligned(16))) = (int)((unative_t) data);
int after_arg __attribute__((aligned(16)));
 
thread_detach(THREAD);
77,7 → 77,7
static void testit2(void *data)
{
int i;
int arg __attribute__((aligned(16))) = (int)((__native) data);
int arg __attribute__((aligned(16))) = (int)((unative_t) data);
int after_arg __attribute__((aligned(16)));
 
thread_detach(THREAD);
116,10 → 116,10
printf("Creating %d threads... ", THREADS);
 
for (i=0; i<THREADS/2; i++) {
if (!(t = thread_create(testit1, (void *)((__native)i*2), TASK, 0, "testit1")))
if (!(t = thread_create(testit1, (void *)((unative_t)i*2), TASK, 0, "testit1")))
panic("could not create thread\n");
thread_ready(t);
if (!(t = thread_create(testit2, (void *)((__native)i*2+1), TASK, 0, "testit2")))
if (!(t = thread_create(testit2, (void *)((unative_t)i*2+1), TASK, 0, "testit2")))
panic("could not create thread\n");
thread_ready(t);
}
/kernel/trunk/test/sysinfo/test.c
33,9 → 33,9
#include <test.h>
#include <sysinfo/sysinfo.h>
/*
static __native counter(sysinfo_item_t *root)
static unative_t counter(sysinfo_item_t *root)
{
static __native i=0;
static unative_t i=0;
return i++;
}*/
 
/kernel/trunk/test/print/print1/test.c
33,7 → 33,7
void test(void)
{
int retval;
__native nat = 0x12345678u;
unative_t nat = 0x12345678u;
char buffer[BUFFER_SIZE];
49,7 → 49,7
printf(" -int: d '%d', 3.2d '%3.2d', -3.2d '%-3.2d', 2.3d '%2.3d', -2.3d '%-2.3d' \n",-1, -1, -1, -1, -1 );
printf(" 0xint: x '%#x', 5.3x '%#5.3x', -5.3x '%#-5.3x', 3.5x '%#3.5x', -3.5x '%#-3.5x' \n",17, 17, 17, 17, 17 );
 
printf("'%#llx' 64bit, '%#x' 32bit, '%#hhx' 8bit, '%#hx' 16bit, __native '%#zx'. '%#llx' 64bit and '%s' string.\n", 0x1234567887654321ll, 0x12345678, 0x12, 0x1234, nat, 0x1234567887654321ull, "Lovely string" );
printf("'%#llx' 64bit, '%#x' 32bit, '%#hhx' 8bit, '%#hx' 16bit, unative_t '%#zx'. '%#llx' 64bit and '%s' string.\n", 0x1234567887654321ll, 0x12345678, 0x12, 0x1234, nat, 0x1234567887654321ull, "Lovely string" );
printf(" Print to NULL '%s'\n",NULL);