genericopenlibs/liboil/tsrc/testsuite/liboiltest/src/liboiltest.c
changeset 59 09fa7c3c5079
equal deleted inserted replaced
52:bf6a71c50e42 59:09fa7c3c5079
       
     1 /*
       
     2 * Copyright (c) 2010 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 #include <liboil/liboil.h>
       
    20 #include <liboil/liboiltest.h>
       
    21 #include <liboil/liboilfunction.h>
       
    22 #include <stdio.h>
       
    23 #include <stdlib.h>
       
    24 
       
    25 #include <liboil/globals.h>
       
    26 
       
    27 #define LOG_FILE "c:\\logs\\testsuite_liboiltest_log.txt"
       
    28 #include "std_log_result.h"
       
    29 #define LOG_FILENAME_LINE __FILE__, __LINE__
       
    30 
       
    31 #define SIZE    20
       
    32 
       
    33 void create_xml(int result)
       
    34 {
       
    35     if(result)
       
    36         assert_failed = 1;
       
    37     
       
    38     testResultXml("testsuite_liboiltest");
       
    39     close_log_file();
       
    40 }
       
    41 
       
    42 void abs_f32_f32_test(float * dest, int dstr, const float * src, int sstr, int n)
       
    43     {
       
    44     int i = 0;
       
    45     std_log(LOG_FILENAME_LINE,"abs_f32_f32_test is called");
       
    46     assert_failed = 0;
       
    47     
       
    48     for(i=0; i<SIZE; i++)
       
    49         dest[i] = 10;
       
    50     }
       
    51 
       
    52 void test()
       
    53     {
       
    54     OilTest *test;
       
    55     OilParameter *p;
       
    56     int16_t *data;
       
    57     int n;
       
    58     int footer;
       
    59     int footer_increment = 10;
       
    60     OilFunctionClass *klass;
       
    61     OilFunctionImpl *impl;
       
    62     
       
    63     klass = oil_class_get("abs_f32_f32");
       
    64     
       
    65     if(klass != NULL)
       
    66         {
       
    67         test = (OilTest *)oil_test_new(klass); 
       
    68         
       
    69         if(test != NULL)
       
    70             {
       
    71             impl = (OilFunctionImpl*)calloc(sizeof(OilFunctionImpl), 0);
       
    72             impl->func = (void*)abs_f32_f32_test;
       
    73             impl->name = "abs_f32_f32_test";
       
    74             impl->klass = klass;
       
    75             
       
    76             oil_test_set_impl(test, impl);
       
    77             
       
    78             if(test->impl != impl)
       
    79                 {
       
    80                 std_log(LOG_FILENAME_LINE,"oil_test_set_impl failed. errno = %d", errno);
       
    81                 assert_failed = 1;
       
    82                 }
       
    83             
       
    84             p = &test->params[1];
       
    85             footer = p->test_footer;
       
    86             oil_test_set_test_footer(test, p, OIL_TEST_FOOTER+footer_increment);
       
    87             
       
    88             if(p->test_footer != footer+footer_increment)
       
    89                 {
       
    90                 std_log(LOG_FILENAME_LINE,"oil_test_set_test_footer failed. errno = %d", errno);
       
    91                 assert_failed = 1;
       
    92                 }
       
    93             
       
    94             data = (int16_t *)oil_test_get_source_data (test, OIL_ARG_SRC1);
       
    95             n = oil_test_get_arg_pre_n (test, OIL_ARG_SRC1);
       
    96             
       
    97             oil_test_cleanup(test);
       
    98             oil_test_free(test);
       
    99             }
       
   100         else
       
   101             {
       
   102             std_log(LOG_FILENAME_LINE,"oil_test_new returned NULL. errno = %d", errno);
       
   103             assert_failed = 1;
       
   104             }
       
   105         }
       
   106     else
       
   107         {
       
   108         std_log(LOG_FILENAME_LINE,"oil_class_get returned NULL. errno = %d", errno);
       
   109         assert_failed = 1;
       
   110         }
       
   111     }
       
   112 
       
   113 int main (int argc, char *argv[])
       
   114 {
       
   115     oil_init ();
       
   116  
       
   117     test();
       
   118     
       
   119     if(assert_failed)
       
   120       std_log(LOG_FILENAME_LINE,"Test Failed");
       
   121     else
       
   122       std_log(LOG_FILENAME_LINE,"Test Successful");
       
   123     
       
   124     create_xml(0);
       
   125     return 0;
       
   126 }
       
   127