OpenCores
URL https://opencores.org/ocsvn/plasma/plasma/trunk

Subversion Repositories plasma

[/] [plasma/] [trunk/] [kernel/] [rtos_test.c] - Diff between revs 416 and 425

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 416 Rev 425
Line 59... Line 59...
   rc = strcmp(s1, "Hello world!\n");
   rc = strcmp(s1, "Hello world!\n");
   assert(rc < 0);
   assert(rc < 0);
   rc = strncmp(s1, "Hellx", 4);
   rc = strncmp(s1, "Hellx", 4);
   assert(rc == 0);
   assert(rc == 0);
   ptr = strstr(s1, "orl");
   ptr = strstr(s1, "orl");
   assert(ptr[0] == 'o');
   assert(ptr && ptr[0] == 'o');
   rc = strlen(s1);
   rc = strlen(s1);
   assert(rc == 13);
   assert(rc == 13);
   memcpy(s2, s1, rc+1);
   memcpy(s2, s1, rc+1);
   rc = memcmp(s1, s2, 8);
   rc = memcmp(s1, s2, 8);
   assert(rc == 0);
   assert(rc == 0);
Line 96... Line 96...
   uint8 *ptrs[256], size[256], *ptr;
   uint8 *ptrs[256], size[256], *ptr;
   int i, j, k, value;
   int i, j, k, value;
 
 
   printf("TestHeap\n");
   printf("TestHeap\n");
   memset(ptrs, 0, sizeof(ptrs));
   memset(ptrs, 0, sizeof(ptrs));
 
   memset(size, 0, sizeof(size));
   for(i = 0; i < 1000; ++i)
   for(i = 0; i < 1000; ++i)
   {
   {
      j = rand() & 255;
      j = rand() & 255;
      if(ptrs[j])
      if(ptrs[j])
      {
      {
Line 162... Line 163...
   printf("TestThread\n");
   printf("TestThread\n");
   for(i = 0; i < 32; ++i)
   for(i = 0; i < 32; ++i)
   {
   {
      priority = 50 + i;
      priority = 50 + i;
      thread = OS_ThreadCreate("MyThread", MyThreadMain, (uint32*)i, priority, 0);
      thread = OS_ThreadCreate("MyThread", MyThreadMain, (uint32*)i, priority, 0);
 
      if(thread == NULL)
 
         return;
      OS_ThreadInfoSet(thread, 0, (void*)(0xabcd + i));
      OS_ThreadInfoSet(thread, 0, (void*)(0xabcd + i));
      //printf("Created thread 0x%x\n", thread);
      //printf("Created thread 0x%x\n", thread);
   }
   }
 
 
   thread = OS_ThreadSelf();
   thread = OS_ThreadSelf();
Line 261... Line 264...
static void TestMutex(void)
static void TestMutex(void)
{
{
   TestInfo_t info;
   TestInfo_t info;
   printf("TestMutex\n");
   printf("TestMutex\n");
   info.MyMutex = OS_MutexCreate("MyMutex");
   info.MyMutex = OS_MutexCreate("MyMutex");
 
   if(info.MyMutex == NULL)
 
      return;
   OS_MutexPend(info.MyMutex);
   OS_MutexPend(info.MyMutex);
   OS_MutexPend(info.MyMutex);
   OS_MutexPend(info.MyMutex);
   OS_MutexPend(info.MyMutex);
   OS_MutexPend(info.MyMutex);
   printf("Acquired mutexes\n");
   printf("Acquired mutexes\n");
 
 
Line 295... Line 300...
   char data[16];
   char data[16];
   int i, rc;
   int i, rc;
 
 
   printf("TestMQueue\n");
   printf("TestMQueue\n");
   mqueue = OS_MQueueCreate("MyMQueue", 10, 16);
   mqueue = OS_MQueueCreate("MyMQueue", 10, 16);
 
   if(mqueue == NULL)
 
      return;
   strcpy(data, "Test0");
   strcpy(data, "Test0");
   for(i = 0; i < 16; ++i)
   for(i = 0; i < 16; ++i)
   {
   {
      data[4] = (char)('0' + i);
      data[4] = (char)('0' + i);
      OS_MQueueSend(mqueue, data);
      OS_MQueueSend(mqueue, data);
Line 340... Line 347...
}
}
 
 
static void TestTimer(void)
static void TestTimer(void)
{
{
   int i;
   int i;
   TestInfo_t info;
   volatile TestInfo_t info;
 
 
   printf("TestTimer\n");
   printf("TestTimer\n");
   info.TimerDone = 0;
   info.TimerDone = 0;
   for(i = 0; i < TIMER_COUNT; ++i)
   for(i = 0; i < TIMER_COUNT; ++i)
   {
   {
      info.MyQueue[i] = OS_MQueueCreate("MyQueue", 10, 16);
      info.MyQueue[i] = OS_MQueueCreate("MyQueue", 10, 16);
      info.MyTimer[i] = OS_TimerCreate("MyTimer", info.MyQueue[i], i);
      info.MyTimer[i] = OS_TimerCreate("MyTimer", info.MyQueue[i], i);
      info.MyThread[i] = OS_ThreadCreate("TimerTest", TestTimerThread, &info, 50, 0);
      info.MyThread[i] = OS_ThreadCreate("TimerTest", TestTimerThread, (void*)&info, 50, 0);
      OS_ThreadInfoSet(info.MyThread[i], 0, (void*)i);
      OS_ThreadInfoSet(info.MyThread[i], 0, (void*)i);
      OS_TimerStart(info.MyTimer[i], 10+i*2, 220+i);
      OS_TimerStart(info.MyTimer[i], 10+i*2, 220+i);
   }
   }
 
 
   while(info.TimerDone < TIMER_COUNT)
   while(info.TimerDone < TIMER_COUNT)

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.