genericopenlibs/liboil/tsrc/testsuite/copy/src/copy_ptr.c
changeset 59 09fa7c3c5079
equal deleted inserted replaced
52:bf6a71c50e42 59:09fa7c3c5079
       
     1 // Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 
       
    17 
       
    18 #ifdef HAVE_CONFIG_H
       
    19 #include "config.h"
       
    20 #endif
       
    21 
       
    22 #include <liboil/liboil.h>
       
    23 #include <liboil/liboilfunction.h>
       
    24 #include <stdio.h>
       
    25 #include <string.h>
       
    26 #include <globals.h>
       
    27 
       
    28 #define LOG_FILE "c:\\logs\\testsuite_copyptr_log.txt"
       
    29 #include "std_log_result.h"
       
    30 #define LOG_FILENAME_LINE __FILE__, __LINE__
       
    31 #define MAX_SIZE 64
       
    32 #define RES_SIZE 1
       
    33 #define SIZE 10
       
    34 
       
    35 
       
    36 uint8_t src1[MAX_SIZE], src2[MAX_SIZE];
       
    37 
       
    38 void create_xml(int result)
       
    39 {
       
    40     if(result)
       
    41         assert_failed = 1;
       
    42     
       
    43     testResultXml("testsuite_copyptr");
       
    44     close_log_file();
       
    45 }
       
    46 
       
    47 
       
    48 void test_copy_u8()
       
    49 {
       
    50   uint8_t src[SIZE],dest[SIZE],check[SIZE]={0,0,0,1,2,3,4,5,0,0};  
       
    51   int i;
       
    52 
       
    53   for(i=0;i<SIZE;i++)
       
    54   {
       
    55     dest[i]=0;
       
    56     src[i]=i;
       
    57   }
       
    58 
       
    59   oil_copy_u8 (dest+3,src+1,5);
       
    60 
       
    61   for(i=0;i<SIZE;i++)
       
    62       if(dest[i]==check[i])
       
    63        {
       
    64        std_log(LOG_FILENAME_LINE,"oil_copy_u8 successful, dest[%d]=%d",i,dest[i]);
       
    65        }
       
    66       else
       
    67        {
       
    68        assert_failed=1;
       
    69        std_log(LOG_FILENAME_LINE,"oil_copy_u8 unsuccessful,Expected =%d,Actual =%d",check[i],dest[i]);
       
    70        }
       
    71 }
       
    72 
       
    73 void test_copy8x8_u8()
       
    74 {   
       
    75     uint8_t dest[MAX_SIZE];
       
    76     uint8_t check[MAX_SIZE] = {0,2,4,6,8,10,12,14,15,16,17,18,19,20,21,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
       
    77     int i;
       
    78     
       
    79     for(i=0;i<MAX_SIZE;i++)
       
    80     {
       
    81       src1[i]=i;
       
    82       dest[i]=0;
       
    83       std_log(LOG_FILENAME_LINE,"src1[%d]=%d",i,src1[i]);
       
    84     }
       
    85 
       
    86     oil_copy8x8_u8(dest,1,src1,2);
       
    87     
       
    88     for (i=0;i<MAX_SIZE;i++)
       
    89         if(check[i] == dest[i])
       
    90           {
       
    91           std_log(LOG_FILENAME_LINE,"oil_copy8x8_u8 successful,dest[%d]=%d",i,dest[i]);
       
    92           }
       
    93         else
       
    94          {
       
    95          assert_failed = 1;
       
    96          std_log(LOG_FILENAME_LINE,"oil_copy8x8_u8 unsuccessful,Expected =%d,Actual =%d",check[i],dest[i]);
       
    97          } 
       
    98 }
       
    99 
       
   100 
       
   101 void test_compare_u8()
       
   102 {  
       
   103   uint32_t dest1[RES_SIZE]={0},check[RES_SIZE]={10};
       
   104   int i;
       
   105 
       
   106   for(i=0;i<MAX_SIZE;i++)
       
   107   {
       
   108     src1[i]=i;
       
   109     src2[i]=i;
       
   110   }
       
   111 
       
   112   src1[10]=20;
       
   113   src2[20]=10;
       
   114   
       
   115   oil_compare_u8(dest1,src1,src2,MAX_SIZE);
       
   116 
       
   117   if(dest1[0] == check[0])
       
   118    {
       
   119     std_log(LOG_FILENAME_LINE,"oil_compare_u8 successful");
       
   120    }
       
   121   else
       
   122    {
       
   123    assert_failed = 1; 
       
   124    std_log(LOG_FILENAME_LINE,"oil_compare_u8 unsuccessful,Expected =%d,Actual =%d",check[0],dest1[0]);
       
   125    }
       
   126 }
       
   127 
       
   128 
       
   129 void test_testzero_u8()
       
   130 {
       
   131     uint32_t dest1[RES_SIZE]={0},check[RES_SIZE]={15};
       
   132     int i;
       
   133 
       
   134     for(i=0;i<MAX_SIZE;i++)
       
   135     {
       
   136       src1[i]=i+1;
       
   137       std_log(LOG_FILENAME_LINE,"src1[%d]=%d",i,src1[i]);
       
   138     }
       
   139     
       
   140     src1[15]=0;
       
   141     
       
   142     oil_testzero_u8(dest1,src1,MAX_SIZE);
       
   143     
       
   144     if(dest1[0] == check[0])
       
   145      {
       
   146      std_log(LOG_FILENAME_LINE,"oil_testzero_u8 successful");
       
   147      }
       
   148     else
       
   149      {
       
   150       assert_failed = 1;
       
   151       std_log(LOG_FILENAME_LINE,"oil_testzero_u8 unsuccessful,Expected =%d,Actual =%d",check[0],dest1[0]);
       
   152      }
       
   153 }
       
   154 
       
   155 int main (void)
       
   156 {
       
   157   std_log(LOG_FILENAME_LINE,"Test started testsuite_copyptr");
       
   158   oil_init ();
       
   159 
       
   160   std_log(LOG_FILENAME_LINE,"COPY");
       
   161   test_copy_u8();
       
   162 
       
   163   std_log(LOG_FILENAME_LINE,"COPY8X8");
       
   164   test_copy8x8_u8();
       
   165 
       
   166   std_log(LOG_FILENAME_LINE,"COMPARE TEST");
       
   167   test_compare_u8();
       
   168   
       
   169   std_log(LOG_FILENAME_LINE,"TESTZERO");
       
   170   test_testzero_u8();
       
   171   
       
   172   if(assert_failed)
       
   173         std_log(LOG_FILENAME_LINE,"Test Fail");
       
   174   else
       
   175         std_log(LOG_FILENAME_LINE,"Test Successful");
       
   176   create_xml(0);
       
   177   return 0;
       
   178 }
       
   179