Navigation


Changeset 658:f198d16fa7f4 in freeDiameter for tests


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
Location:
tests
Files:
11 moved

Legend:

Unmodified
Added
Removed
  • tests/CMakeLists.txt

    r585 r658  
    11# Test directory
    2 PROJECT("libfreeDiameter tests" C)
     2PROJECT("freeDiameter tests" C)
    33
    44# give the possibility to configure the timeout duration for the tests
     
    2828ADD_DEFINITIONS(-DTRACE_LEVEL=NONE)
    2929
    30 INCLUDE_DIRECTORIES( ".." )
    31 INCLUDE_DIRECTORIES( "../../libfreeDiameter" )
    32 
    33 BISON_FILE(../fdd.y)
    34 FLEX_FILE(../fdd.l)
    35 
    36 SET(TEST_COMMON_SRC "")
    37 
    38 FOREACH( SRC_FILE ${FD_COMMON_SRC})
    39    SET(TEST_COMMON_SRC ${TEST_COMMON_SRC} "../${SRC_FILE}")
    40 ENDFOREACH(SRC_FILE)
    41 
    42 FOREACH( SRC_FILE ${FD_COMMON_GEN_SRC})
    43    SET(TEST_COMMON_SRC ${TEST_COMMON_SRC} "${CMAKE_CURRENT_BINARY_DIR}/../${SRC_FILE}")
    44 ENDFOREACH(SRC_FILE)
    45 
    46 FOREACH( SRC_FILE ${LFD_SRC})
    47    SET(TEST_COMMON_SRC ${TEST_COMMON_SRC} "../../libfreeDiameter/${SRC_FILE}")
    48 ENDFOREACH(SRC_FILE)
    49 
    50 # Create an archive with the daemon common files (all but main)
    51 ADD_LIBRARY(fDcore STATIC ${TEST_COMMON_SRC})
     30INCLUDE_DIRECTORIES( "../libfdproto" )
     31INCLUDE_DIRECTORIES( "../libfdcore" )
    5232
    5333
     
    7252
    7353                # List of source files, copied from the extension CMakeLists.
    74                 BISON_FILE(../../extensions/app_acct/acct_conf.y)
    75                 FLEX_FILE(../../extensions/app_acct/acct_conf.l)
     54                BISON_FILE(../extensions/app_acct/acct_conf.y)
     55                FLEX_FILE(../extensions/app_acct/acct_conf.l)
    7656                #SET_SOURCE_FILES_PROPERTIES(lex.acct_conf.c acct_conf.tab.c PROPERTIES COMPILE_FLAGS "-I ${CMAKE_CURRENT_SOURCE_DIR}")
    7757               
     
    8969
    9070                # The extension headers
    91                 INCLUDE_DIRECTORIES( "../../extensions/app_acct" )
     71                INCLUDE_DIRECTORIES( "../extensions/app_acct" )
    9272
    9373                SET(testappacct_ADDITIONAL "")
    9474
    9575                FOREACH( SRC_FILE ${APP_ACCT_SRC})
    96                    SET(testappacct_ADDITIONAL ${testappacct_ADDITIONAL} "../../extensions/app_acct/${SRC_FILE}")
     76                   SET(testappacct_ADDITIONAL ${testappacct_ADDITIONAL} "../extensions/app_acct/${SRC_FILE}")
    9777                ENDFOREACH(SRC_FILE)
    9878
    9979                FOREACH( SRC_FILE ${APP_ACCT_SRC_GEN})
    100                    SET(testappacct_ADDITIONAL ${testappacct_ADDITIONAL} "${CMAKE_CURRENT_BINARY_DIR}/../../extensions/app_acct/${SRC_FILE}")
     80                   SET(testappacct_ADDITIONAL ${testappacct_ADDITIONAL} "${CMAKE_CURRENT_BINARY_DIR}/../extensions/app_acct/${SRC_FILE}")
    10181                ENDFOREACH(SRC_FILE)
    10282
     
    10989FOREACH( TEST ${TEST_LIST} )
    11090   ADD_EXECUTABLE(${TEST} ${TEST}.c tests.h ${${TEST}_ADDITIONAL})
    111    TARGET_LINK_LIBRARIES(${TEST} fDcore ${FD_LIBS} ${LFD_LIBS} ${${TEST}_ADDITIONAL_LIB})
     91   TARGET_LINK_LIBRARIES(${TEST} libfdproto libfdcore ${${TEST}_ADDITIONAL_LIB})
    11292   ADD_TEST(${TEST} ${EXECUTABLE_OUTPUT_PATH}/${TEST})
    11393ENDFOREACH( TEST )
  • 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.