Navigation


Changeset 658:f198d16fa7f4 in freeDiameter for tests/tests.h


Ignore:
Timestamp:
Jan 14, 2011, 3:15:23 PM (13 years ago)
Author:
Sebastien Decugis <sdecugis@nict.go.jp>
Branch:
default
Phase:
public
Message:

Initial commit for 1.1.0:

  • Restructuring:
    • libfreeDiameter:
      • renamed folder & binary into libfdproto
      • renamed libfD.h into fdproto-internal.h
      • removed signals management (replaced by triggers in libfdcore)
  • freeDiameter split into:
    • libfdcore (most contents)
      • renamed fD.h into fdcore-internal.h
      • added core.c for framework init/shutdown.
      • new triggers mechanism in events.c.
  • freeDiameterd (main, command line parsing, signals management)
  • tests:
    • now in top-level directory tests.
  • other changes:
    • fd_dict_new now returns 0 on duplicate identical entries.
    • fixes in dict_legacy_xml
    • fixes in some dictionaries
    • moved FD_DEFAULT_CONF_FILENAME definition to freeDiameter-host.h
File:
1 moved

Legend:

Unmodified
Added
Removed
  • tests/tests.h

    r481 r658  
    4242#define _TESTS_H
    4343
    44 #include "libfD.h"
    45 #include "fD.h"
     44#include "fdproto-internal.h"
     45#include "fdcore-internal.h"
    4646
    4747#include <pthread.h>
     
    8282struct fd_config * fd_g_config = &conf;
    8383
    84 /* gcrypt functions to support posix threads */
    85 GCRY_THREAD_OPTION_PTHREAD_IMPL;
    86 
    8784/* Define the standard check routines */
    8885#define CHECK( _val, _assert ){                         \
     
    105102}
    106103
    107 /* Minimum inits */
    108 #define INIT_FD() {                                                             \
    109         memset(fd_g_config, 0, sizeof(struct fd_config));                       \
    110         CHECK( 0, fd_lib_init(1) );                                             \
    111         fd_log_threadname(basename(__FILE__));                                  \
    112         (void) gcry_control (GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread);    \
    113         (void) gcry_control (GCRYCTL_ENABLE_QUICK_RANDOM, 0);                   \
    114         CHECK( 0, gnutls_global_init());                                        \
    115         CHECK( 0, fd_conf_init() );                                             \
    116         CHECK( 0, fd_dict_base_protocol(fd_g_config->cnf_dict) );               \
    117         CHECK( 0, fd_sess_start() );                                            \
    118         parse_cmdline(argc, argv);                                              \
     104static pthread_t timeout_thr;
     105static void * timeout_catch(void * arg)
     106{
     107        int sig;
     108        sigset_t ss;
     109        fd_log_threadname ( "timeout catcher" );
     110       
     111        sigemptyset(&ss);
     112        sigaddset(&ss, SIGALRM);
     113       
     114        CHECK_POSIX_DO( sigwait(&ss, &sig),  );
     115       
     116        FAILTEST("The timeout (" _stringize(TEST_TIMEOUT) " sec) was reached. Use -n or change TEST_TIMEOUT if the test needs more time to execute.");
     117       
     118        return NULL;
    119119}
     120       
    120121
    121 static void test_timeout(int signal)
    122 {
    123         FAILTEST("The timeout (" _stringize(TEST_TIMEOUT) " sec) was reached. Use -n or change TEST_TIMEOUT if the test needs more time to execute.");
    124 }
     122GCRY_THREAD_OPTION_PTHREAD_IMPL;
    125123
    126124static inline void parse_cmdline(int argc, char * argv[]) {
     
    164162        if (!no_timeout) {
    165163                alarm(TEST_TIMEOUT);
    166                 fd_sig_register(SIGALRM, "Test.harness", test_timeout);
     164                CHECK( 0, pthread_create(&timeout_thr, NULL, timeout_catch, NULL) );
    167165        }
    168166}
    169167 
     168static inline void test_init(int argc, char * argv[])
     169{
     170        memset(fd_g_config, 0, sizeof(struct fd_config));
     171       
     172        CHECK( 0, fd_libproto_init() );
     173       
     174        fd_log_threadname(basename(__FILE__));
     175       
     176        /* Initialize gcrypt and gnutls */
     177        (void) gcry_control (GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread);
     178        (void) gcry_control (GCRYCTL_ENABLE_QUICK_RANDOM, 0);
     179        CHECK( 0, gnutls_global_init());
     180       
     181        /* Initialize the config */
     182        CHECK( 0, fd_conf_init() );
     183
     184        /* Add definitions of the base protocol */
     185        CHECK( 0, fd_dict_base_protocol(fd_g_config->cnf_dict) );
     186       
     187        /* Initialize only the sessions */
     188        CHECK( 0, fd_sess_start()  );
     189       
     190        /* Parse the command line */
     191        parse_cmdline(argc, argv);
     192       
     193        return;
     194}
     195#define INIT_FD()  test_init(argc, argv);
     196
    170197#endif /* _TESTS_H */
Note: See TracChangeset for help on using the changeset viewer.