os/ossrv/genericopenlibs/liboil/tsrc/testsuite/copy/src/copy.c
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     1 /*
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     8 *
     9 * Initial Contributors:
    10 * Nokia Corporation - initial contribution.
    11 *
    12 * Contributors:
    13 *
    14 * Description: 
    15 *
    16 */
    17 
    18 
    19 #ifdef HAVE_CONFIG_H
    20 #include "config.h"
    21 #endif
    22 
    23 #include <liboil/liboil.h>
    24 #include <liboil/liboilfunction.h>
    25 #include <stdio.h>
    26 #include <string.h>
    27 #include <liboil/globals.h>
    28 
    29 #define LOG_FILE "c:\\logs\\testsuite_copy_log.txt"
    30 #include "std_log_result.h"
    31 #define LOG_FILENAME_LINE __FILE__, __LINE__
    32 
    33 void create_xml(int result)
    34 {
    35     if(result)
    36         assert_failed = 1;
    37     
    38     testResultXml("testsuite_copy");
    39     close_log_file();
    40 }
    41 
    42 uint8_t dest[200];
    43 uint8_t src[200];
    44 
    45 
    46 void test(void)
    47 {
    48   int i;
    49 
    50   for(i=0;i<200;i++){
    51     dest[i]=0;
    52     src[i]=i;
    53   }
    54 
    55   oil_copy_u8 (dest + 8, src + 0, 64);
    56 
    57   for(i=0;i<100;i++){
    58       if(i<8 || i>71)
    59           assert_failed = (dest[i] == 0) ? assert_failed : 1; 
    60       else
    61           assert_failed = (dest[i] == (i-8)) ? assert_failed : 1;
    62       std_log(LOG_FILENAME_LINE,"%d\n",dest[i]);
    63   }
    64 }
    65 
    66 int main (int argc, char *argv[])
    67 {
    68   OilFunctionClass *klass;
    69   OilFunctionImpl *impl;
    70 
    71   std_log(LOG_FILENAME_LINE,"Test started testsuite_copy");
    72   oil_init ();
    73 
    74   klass = (OilFunctionClass *)oil_class_get ("copy_u8");
    75   oil_class_optimize(klass);
    76 
    77   oil_class_choose_by_name (klass, "copy_u8_altivec");
    78   impl = klass->chosen_impl;
    79   if (oil_impl_is_runnable (impl)) {
    80       std_log(LOG_FILENAME_LINE,"chosen=%p\n", impl);
    81     impl = klass->reference_impl;
    82     std_log(LOG_FILENAME_LINE,"ref=%p\n", impl);
    83     test();
    84   }
    85 
    86   if(assert_failed)
    87         std_log(LOG_FILENAME_LINE,"Test Fail");
    88   else
    89         std_log(LOG_FILENAME_LINE,"Test Successful");
    90   create_xml(0);
    91   return 0;
    92 }
    93