Navigation


Changeset 729:5d8ac5da7092 in freeDiameter for tests/tests.h


Ignore:
Timestamp:
Feb 24, 2011, 5:19:14 PM (13 years ago)
Author:
Sebastien Decugis <sdecugis@nict.go.jp>
Branch:
default
Phase:
public
Message:

Fixed timeout handling + minor fixes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tests/tests.h

    r695 r729  
    7777        (void)fd_core_shutdown();                       \
    7878        (void)fd_core_wait_shutdown_complete();         \
    79         (void)fd_thr_term(&timeout_thr);                \
     79        (void)fd_thr_term(&signal_thr);                 \
    8080        exit(PASS);                                     \
    8181}
     
    105105}
    106106
    107 static pthread_t timeout_thr;
    108 static void * timeout_catch(void * arg)
     107static pthread_t signal_thr;
     108static void * signal_catch(void * arg)
    109109{
    110110        int sig;
    111111        sigset_t ss;
    112         fd_log_threadname ( "Test alarm catcher" );
     112        fd_log_threadname ( "Signal catcher" );
    113113       
    114114        sigemptyset(&ss);
     115       
     116        /* We use SIGALRM */
    115117        sigaddset(&ss, SIGALRM);
    116118       
     119        /* Unblock any other signal for this thread, so that default handler is enabled */
     120        CHECK_SYS_DO( pthread_sigmask( SIG_SETMASK, &ss, NULL ), );
     121       
     122        /* Now wait for sigwait or cancelation */
    117123        CHECK_POSIX_DO( sigwait(&ss, &sig),  );
    118        
    119124        FAILTEST("The timeout (" _stringize(TEST_TIMEOUT) " sec) was reached. Use -n or change TEST_TIMEOUT if the test needs more time to execute.");
    120125       
     
    165170        if (!no_timeout) {
    166171                alarm(TEST_TIMEOUT);
    167                 CHECK( 0, pthread_create(&timeout_thr, NULL, timeout_catch, NULL) );
    168172        }
     173        CHECK( 0, pthread_create(&signal_thr, NULL, signal_catch, NULL) );
    169174}
    170175 
    171176static inline void test_init(int argc, char * argv[], char *fname)
    172177{
     178        sigset_t sig_all;
     179        sigfillset(&sig_all);
     180       
     181        CHECK( 0, pthread_sigmask(SIG_BLOCK, &sig_all, NULL));
     182       
    173183        memset(fd_g_config, 0, sizeof(struct fd_config));
    174184       
     
    176186       
    177187        fd_log_threadname(basename(fname));
     188       
     189        /* Parse the command line */
     190        parse_cmdline(argc, argv);
    178191       
    179192        /* Initialize gcrypt and gnutls */
     
    194207        CHECK( 0, fd_sess_start()  );
    195208       
    196         /* Parse the command line */
    197         parse_cmdline(argc, argv);
    198        
    199209        return;
    200210}
Note: See TracChangeset for help on using the changeset viewer.