Navigation


Changeset 615:8abafd66a617 in freeDiameter


Ignore:
Timestamp:
Dec 3, 2010, 1:31:41 PM (13 years ago)
Author:
Sebastien Decugis <sdecugis@nict.go.jp>
Branch:
default
Phase:
public
Message:

Adapt test for systems that cannot create many threads per process, such as OpenSUSE (bouuuuh)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • freeDiameter/tests/testfifo.c

    r494 r615  
    3535
    3636#include "tests.h"
     37#include <unistd.h>
    3738
    3839/* Structure for testing threshold function */
     
    203204                int                      count;
    204205                int                      i;
     206                int                      nbr_threads;
     207               
     208                nbr_threads = sysconf(_SC_THREAD_THREADS_MAX);
     209                if ((nbr_threads <= 0) || (nbr_threads > NBR_THREADS / 2)) {
     210                        nbr_threads = NBR_THREADS;
     211                } else {
     212                        /* The local limit is bellow NBR_THREADS */
     213                        nbr_threads = (nbr_threads / 2) - 1;
     214                        /* Ensure we create at least a few threads! */
     215                        CHECK( 1, nbr_threads >= 10 ? 1 : 0 );
     216                }
    205217               
    206218                /* Create the queue */
     
    208220               
    209221                /* Create the barrier */
    210                 CHECK( 0, pthread_barrier_init(&bar, NULL, NBR_THREADS * 2 + 1) );
     222                CHECK( 0, pthread_barrier_init(&bar, NULL, nbr_threads * 2 + 1) );
    211223               
    212224                /* Initialize the ts */
     
    216228                /* Create the messages */
    217229                CHECK( 0, fd_dict_search ( fd_g_config->cnf_dict, DICT_COMMAND, CMD_BY_NAME, "Device-Watchdog-Request",         &dwr_model, ENOENT ) );
    218                 for (i = 0; i < NBR_MSG * NBR_THREADS * 2; i++) {
     230                for (i = 0; i < NBR_MSG * nbr_threads * 2; i++) {
    219231                        CHECK( 0, fd_msg_new ( dwr_model, 0, &msgs[i] ) );
    220232                }
     
    231243               
    232244                /* Create the threads */
    233                 for (i=0; i < NBR_THREADS * 2; i++) {
     245                for (i=0; i < nbr_threads * 2; i++) {
    234246                        CHECK( 0, pthread_create( &thr[i], NULL, test_fct, (i & 1) ? &td_1 : &td_2 ) );
    235247                }
     
    246258               
    247259                /* Now post all the messages */
    248                 for (i=0; i < NBR_MSG * NBR_THREADS * 2; i++) {
     260                for (i=0; i < NBR_MSG * nbr_threads * 2; i++) {
    249261                        msg = msgs[i];
    250262                        CHECK( 0, fd_fifo_post(queue, &msg) );
     
    252264               
    253265                /* Join all threads. This blocks if messages are lost... */
    254                 for (i=0; i < NBR_THREADS * 2; i++) {
     266                for (i=0; i < nbr_threads * 2; i++) {
    255267                        CHECK( 0, pthread_join( thr[i], NULL ) );
    256268                }
     
    262274                /* Destroy this queue and the messages */
    263275                CHECK( 0, fd_fifo_del(&queue) );
    264                 for (i=0; i < NBR_MSG * NBR_THREADS * 2; i++) {
     276                for (i=0; i < NBR_MSG * nbr_threads * 2; i++) {
    265277                        CHECK( 0, fd_msg_free(  msgs[i] ) );
    266278                }
Note: See TracChangeset for help on using the changeset viewer.