ofdbus/dbus-glib/dbus/dbus-gtest.c
changeset 0 e4d67989cc36
equal deleted inserted replaced
-1:000000000000 0:e4d67989cc36
       
     1 /* -*- mode: C; c-file-style: "gnu" -*- */
       
     2 /* dbus-test.c  Program to run all tests
       
     3  *
       
     4  * Copyright (C) 2002, 2003  Red Hat Inc.
       
     5  * Portion Copyright © 2008 Nokia Corporation and/or its subsidiary(-ies). All rights reserved.
       
     6  * Licensed under the Academic Free License version 2.1
       
     7  * 
       
     8  * This program is free software; you can redistribute it and/or modify
       
     9  * it under the terms of the GNU General Public License as published by
       
    10  * the Free Software Foundation; either version 2 of the License, or
       
    11  * (at your option) any later version.
       
    12  *
       
    13  * This program is distributed in the hope that it will be useful,
       
    14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
       
    16  * GNU General Public License for more details.
       
    17  * 
       
    18  * You should have received a copy of the GNU General Public License
       
    19  * along with this program; if not, write to the Free Software
       
    20  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
       
    21  *
       
    22  */
       
    23 
       
    24 #ifndef __SYMBIAN32__
       
    25 #include <config.h>
       
    26 #else
       
    27 #include "config.h"
       
    28 #endif //__SYMBIAN32__
       
    29 #include "dbus-gtest.h"
       
    30 #include <stdio.h>
       
    31 #include <stdlib.h>
       
    32 #include <glib.h>
       
    33 
       
    34 #ifdef __SYMBIAN32__
       
    35 #define LOG_FILE "c:\\logs\\dbus_gtest_main_log1.txt"
       
    36 #include "std_log_result.h"
       
    37 #define LOG_FILENAME_LINE __FILE__, __LINE__
       
    38 
       
    39 void create_xml(int result)
       
    40 	{
       
    41 	if(result)
       
    42 		assert_failed = 1;
       
    43 	
       
    44 	testResultXml("dbus_gtest_main");
       
    45     close_log_file();
       
    46 	}
       
    47 #endif
       
    48 
       
    49 
       
    50 #ifdef DBUS_BUILD_TESTS
       
    51 static void
       
    52 die (const char *failure)
       
    53 {
       
    54   fprintf (stderr, "Unit test failed: %s\n", failure);
       
    55   #ifdef __SYMBIAN32__
       
    56   std_log(LOG_FILENAME_LINE, "Unit test failed: %s\n", failure);
       
    57   create_xml(1);
       
    58   #endif
       
    59   exit (1);
       
    60 }
       
    61 #endif /* DBUS_BUILD_TESTS */
       
    62 
       
    63 /**
       
    64  * An exported symbol to be run in order to execute
       
    65  * unit tests. Should not be used by
       
    66  * any app other than our test app, this symbol
       
    67  * won't exist in some builds of the library.
       
    68  * (with --enable-tests=no)
       
    69  *
       
    70  * @param test_data_dir the directory with test data (test/data normally)
       
    71  */
       
    72  	#ifdef __SYMBIAN32__
       
    73 	EXPORT_C
       
    74 	#endif
       
    75 void
       
    76 dbus_glib_internal_do_not_use_run_tests (const char *test_data_dir)
       
    77 {
       
    78 #ifdef DBUS_BUILD_TESTS  
       
    79   if (test_data_dir == NULL)
       
    80     test_data_dir = g_getenv ("DBUS_TEST_DATA");
       
    81 
       
    82   if (test_data_dir != NULL)
       
    83   #ifdef __SYMBIAN32__
       
    84   {
       
    85   #endif
       
    86     printf ("Test data in %s\n", test_data_dir);
       
    87 	#ifdef __SYMBIAN32__
       
    88 	std_log(LOG_FILENAME_LINE, "Test data in %s\n", test_data_dir);
       
    89 	}
       
    90 	#endif
       
    91   else
       
    92   #ifdef __SYMBIAN32__
       
    93   {
       
    94   #endif
       
    95     printf ("No test data!\n");
       
    96 	#ifdef __SYMBIAN32__
       
    97 	std_log(LOG_FILENAME_LINE, "No test data!\n");
       
    98 	}
       
    99 	#endif
       
   100 
       
   101   g_type_init ();
       
   102 
       
   103   printf ("%s: running GValue util tests\n", "dbus-glib-test");
       
   104   #ifdef __SYMBIAN32__
       
   105   std_log(LOG_FILENAME_LINE, "%s: running GValue util tests\n", "dbus-glib-test");
       
   106   #endif
       
   107   if (!_dbus_gvalue_utils_test (test_data_dir))
       
   108     die ("gvalue utils");
       
   109 
       
   110   printf ("%s: running GValue tests\n", "dbus-glib-test");
       
   111   #ifdef __SYMBIAN32__
       
   112   std_log(LOG_FILENAME_LINE, "%s: running GValue tests\n", "dbus-glib-test");
       
   113   #endif
       
   114   if (!_dbus_gvalue_test (test_data_dir))
       
   115     die ("gvalue utils");
       
   116 
       
   117   printf ("%s: running glib tests\n", "dbus-glib-test");
       
   118   #ifdef __SYMBIAN32__
       
   119   std_log(LOG_FILENAME_LINE, "%s: running glib tests\n", "dbus-glib-test");
       
   120   #endif
       
   121   if (!_dbus_glib_test (test_data_dir))
       
   122     die ("glib");
       
   123   
       
   124   printf ("%s: running utils tests\n", "dbus-glib-test");
       
   125   #ifdef __SYMBIAN32__
       
   126   std_log(LOG_FILENAME_LINE, "%s: running utils tests\n", "dbus-glib-test");
       
   127   #endif
       
   128   if (!_dbus_gutils_test (test_data_dir))
       
   129     die ("gutils");
       
   130   
       
   131   printf ("%s: running mainloop integration tests\n", "dbus-glib-test");
       
   132   #ifdef __SYMBIAN32__
       
   133   std_log(LOG_FILENAME_LINE, "%s: running mainloop integration tests\n", "dbus-glib-test");
       
   134   #endif
       
   135   if (!_dbus_gmain_test (test_data_dir))
       
   136     die ("gmain");
       
   137 
       
   138   printf ("%s: running GObject tests\n", "dbus-glib-test");
       
   139   #ifdef __SYMBIAN32__
       
   140   std_log(LOG_FILENAME_LINE, "%s: running GObject tests\n", "dbus-glib-test");
       
   141   #endif
       
   142   if (!_dbus_gobject_test (test_data_dir))
       
   143     die ("gobject");
       
   144   
       
   145   printf ("%s: completed successfully\n", "dbus-glib-test");
       
   146   #ifdef __SYMBIAN32__
       
   147   std_log(LOG_FILENAME_LINE, "%s: completed successfully\n", "dbus-glib-test");
       
   148   
       
   149   create_xml(0);
       
   150   #endif
       
   151 #else
       
   152   printf ("Not compiled with unit tests, not running any\n");
       
   153   #ifdef __SYMBIAN32__
       
   154   std_log(LOG_FILENAME_LINE, "Not compiled with unit tests, not running any\n");
       
   155   #endif
       
   156 #endif
       
   157 }
       
   158 
       
   159