os/ossrv/genericopenlibs/liboil/tsrc/testsuite/liboiltest/src/liboiltest.c
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/ossrv/genericopenlibs/liboil/tsrc/testsuite/liboiltest/src/liboiltest.c	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,127 @@
     1.4 +/*
     1.5 +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
     1.6 +* All rights reserved.
     1.7 +* This component and the accompanying materials are made available
     1.8 +* under the terms of "Eclipse Public License v1.0"
     1.9 +* which accompanies this distribution, and is available
    1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.11 +*
    1.12 +* Initial Contributors:
    1.13 +* Nokia Corporation - initial contribution.
    1.14 +*
    1.15 +* Contributors:
    1.16 +*
    1.17 +* Description: 
    1.18 +*
    1.19 +*/
    1.20 +
    1.21 +
    1.22 +#include <liboil/liboil.h>
    1.23 +#include <liboil/liboiltest.h>
    1.24 +#include <liboil/liboilfunction.h>
    1.25 +#include <stdio.h>
    1.26 +#include <stdlib.h>
    1.27 +
    1.28 +#include <liboil/globals.h>
    1.29 +
    1.30 +#define LOG_FILE "c:\\logs\\testsuite_liboiltest_log.txt"
    1.31 +#include "std_log_result.h"
    1.32 +#define LOG_FILENAME_LINE __FILE__, __LINE__
    1.33 +
    1.34 +#define SIZE    20
    1.35 +
    1.36 +void create_xml(int result)
    1.37 +{
    1.38 +    if(result)
    1.39 +        assert_failed = 1;
    1.40 +    
    1.41 +    testResultXml("testsuite_liboiltest");
    1.42 +    close_log_file();
    1.43 +}
    1.44 +
    1.45 +void abs_f32_f32_test(float * dest, int dstr, const float * src, int sstr, int n)
    1.46 +    {
    1.47 +    int i = 0;
    1.48 +    std_log(LOG_FILENAME_LINE,"abs_f32_f32_test is called");
    1.49 +    assert_failed = 0;
    1.50 +    
    1.51 +    for(i=0; i<SIZE; i++)
    1.52 +        dest[i] = 10;
    1.53 +    }
    1.54 +
    1.55 +void test()
    1.56 +    {
    1.57 +    OilTest *test;
    1.58 +    OilParameter *p;
    1.59 +    int16_t *data;
    1.60 +    int n;
    1.61 +    int footer;
    1.62 +    int footer_increment = 10;
    1.63 +    OilFunctionClass *klass;
    1.64 +    OilFunctionImpl *impl;
    1.65 +    
    1.66 +    klass = oil_class_get("abs_f32_f32");
    1.67 +    
    1.68 +    if(klass != NULL)
    1.69 +        {
    1.70 +        test = (OilTest *)oil_test_new(klass); 
    1.71 +        
    1.72 +        if(test != NULL)
    1.73 +            {
    1.74 +            impl = (OilFunctionImpl*)calloc(sizeof(OilFunctionImpl), 0);
    1.75 +            impl->func = (void*)abs_f32_f32_test;
    1.76 +            impl->name = "abs_f32_f32_test";
    1.77 +            impl->klass = klass;
    1.78 +            
    1.79 +            oil_test_set_impl(test, impl);
    1.80 +            
    1.81 +            if(test->impl != impl)
    1.82 +                {
    1.83 +                std_log(LOG_FILENAME_LINE,"oil_test_set_impl failed. errno = %d", errno);
    1.84 +                assert_failed = 1;
    1.85 +                }
    1.86 +            
    1.87 +            p = &test->params[1];
    1.88 +            footer = p->test_footer;
    1.89 +            oil_test_set_test_footer(test, p, OIL_TEST_FOOTER+footer_increment);
    1.90 +            
    1.91 +            if(p->test_footer != footer+footer_increment)
    1.92 +                {
    1.93 +                std_log(LOG_FILENAME_LINE,"oil_test_set_test_footer failed. errno = %d", errno);
    1.94 +                assert_failed = 1;
    1.95 +                }
    1.96 +            
    1.97 +            data = (int16_t *)oil_test_get_source_data (test, OIL_ARG_SRC1);
    1.98 +            n = oil_test_get_arg_pre_n (test, OIL_ARG_SRC1);
    1.99 +            
   1.100 +            oil_test_cleanup(test);
   1.101 +            oil_test_free(test);
   1.102 +            }
   1.103 +        else
   1.104 +            {
   1.105 +            std_log(LOG_FILENAME_LINE,"oil_test_new returned NULL. errno = %d", errno);
   1.106 +            assert_failed = 1;
   1.107 +            }
   1.108 +        }
   1.109 +    else
   1.110 +        {
   1.111 +        std_log(LOG_FILENAME_LINE,"oil_class_get returned NULL. errno = %d", errno);
   1.112 +        assert_failed = 1;
   1.113 +        }
   1.114 +    }
   1.115 +
   1.116 +int main (int argc, char *argv[])
   1.117 +{
   1.118 +    oil_init ();
   1.119 + 
   1.120 +    test();
   1.121 +    
   1.122 +    if(assert_failed)
   1.123 +      std_log(LOG_FILENAME_LINE,"Test Failed");
   1.124 +    else
   1.125 +      std_log(LOG_FILENAME_LINE,"Test Successful");
   1.126 +    
   1.127 +    create_xml(0);
   1.128 +    return 0;
   1.129 +}
   1.130 +