sl@0: /*
sl@0: * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
sl@0: * All rights reserved.
sl@0: * This component and the accompanying materials are made available
sl@0: * under the terms of "Eclipse Public License v1.0"
sl@0: * which accompanies this distribution, and is available
sl@0: * at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0: *
sl@0: * Initial Contributors:
sl@0: * Nokia Corporation - initial contribution.
sl@0: *
sl@0: * Contributors:
sl@0: *
sl@0: * Description: 
sl@0: *
sl@0: */
sl@0: 
sl@0: 
sl@0: #include <liboil/liboil.h>
sl@0: #include <liboil/liboiltest.h>
sl@0: #include <liboil/liboilfunction.h>
sl@0: #include <stdio.h>
sl@0: #include <stdlib.h>
sl@0: 
sl@0: #include <liboil/globals.h>
sl@0: 
sl@0: #define LOG_FILE "c:\\logs\\testsuite_liboiltest_log.txt"
sl@0: #include "std_log_result.h"
sl@0: #define LOG_FILENAME_LINE __FILE__, __LINE__
sl@0: 
sl@0: #define SIZE    20
sl@0: 
sl@0: void create_xml(int result)
sl@0: {
sl@0:     if(result)
sl@0:         assert_failed = 1;
sl@0:     
sl@0:     testResultXml("testsuite_liboiltest");
sl@0:     close_log_file();
sl@0: }
sl@0: 
sl@0: void abs_f32_f32_test(float * dest, int dstr, const float * src, int sstr, int n)
sl@0:     {
sl@0:     int i = 0;
sl@0:     std_log(LOG_FILENAME_LINE,"abs_f32_f32_test is called");
sl@0:     assert_failed = 0;
sl@0:     
sl@0:     for(i=0; i<SIZE; i++)
sl@0:         dest[i] = 10;
sl@0:     }
sl@0: 
sl@0: void test()
sl@0:     {
sl@0:     OilTest *test;
sl@0:     OilParameter *p;
sl@0:     int16_t *data;
sl@0:     int n;
sl@0:     int footer;
sl@0:     int footer_increment = 10;
sl@0:     OilFunctionClass *klass;
sl@0:     OilFunctionImpl *impl;
sl@0:     
sl@0:     klass = oil_class_get("abs_f32_f32");
sl@0:     
sl@0:     if(klass != NULL)
sl@0:         {
sl@0:         test = (OilTest *)oil_test_new(klass); 
sl@0:         
sl@0:         if(test != NULL)
sl@0:             {
sl@0:             impl = (OilFunctionImpl*)calloc(sizeof(OilFunctionImpl), 0);
sl@0:             impl->func = (void*)abs_f32_f32_test;
sl@0:             impl->name = "abs_f32_f32_test";
sl@0:             impl->klass = klass;
sl@0:             
sl@0:             oil_test_set_impl(test, impl);
sl@0:             
sl@0:             if(test->impl != impl)
sl@0:                 {
sl@0:                 std_log(LOG_FILENAME_LINE,"oil_test_set_impl failed. errno = %d", errno);
sl@0:                 assert_failed = 1;
sl@0:                 }
sl@0:             
sl@0:             p = &test->params[1];
sl@0:             footer = p->test_footer;
sl@0:             oil_test_set_test_footer(test, p, OIL_TEST_FOOTER+footer_increment);
sl@0:             
sl@0:             if(p->test_footer != footer+footer_increment)
sl@0:                 {
sl@0:                 std_log(LOG_FILENAME_LINE,"oil_test_set_test_footer failed. errno = %d", errno);
sl@0:                 assert_failed = 1;
sl@0:                 }
sl@0:             
sl@0:             data = (int16_t *)oil_test_get_source_data (test, OIL_ARG_SRC1);
sl@0:             n = oil_test_get_arg_pre_n (test, OIL_ARG_SRC1);
sl@0:             
sl@0:             oil_test_cleanup(test);
sl@0:             oil_test_free(test);
sl@0:             }
sl@0:         else
sl@0:             {
sl@0:             std_log(LOG_FILENAME_LINE,"oil_test_new returned NULL. errno = %d", errno);
sl@0:             assert_failed = 1;
sl@0:             }
sl@0:         }
sl@0:     else
sl@0:         {
sl@0:         std_log(LOG_FILENAME_LINE,"oil_class_get returned NULL. errno = %d", errno);
sl@0:         assert_failed = 1;
sl@0:         }
sl@0:     }
sl@0: 
sl@0: int main (int argc, char *argv[])
sl@0: {
sl@0:     oil_init ();
sl@0:  
sl@0:     test();
sl@0:     
sl@0:     if(assert_failed)
sl@0:       std_log(LOG_FILENAME_LINE,"Test Failed");
sl@0:     else
sl@0:       std_log(LOG_FILENAME_LINE,"Test Successful");
sl@0:     
sl@0:     create_xml(0);
sl@0:     return 0;
sl@0: }
sl@0: