Exemple #1
0
//
//  testing the raw interface
//
int    genericTest()
{
    register LsShm * p;
    const char * mapName = LSI_SHM_MAP_NAME;
   
    HttpLog::log(LSI_LOG_NOTICE, "Generic RAW LiterSpeed SHM TESTER\r\n");
    
    p = LsShm::get(mapName, LS_SHMSIZE);
    
    if (debugBase::checkStatus(mapName, mapName, p->status()))
        return -1;
    
    LsShmPool * sysPool;
    sysPool = LsShmPool::get(p, LSSHM_SYSPOOL);
    
    if (debugBase::checkStatus(LSSHM_SYSPOOL, LSSHM_SYSPOOL, sysPool->status()))
        return -1;
    
#if 0
    // testShmAlloc(p);
    testShmPool(p);
    fflush(debugBase::fp());
    
    testShmReg(p);
    fflush(debugBase::fp());
#endif
    
    testShmHash(p, sysPool);
    fflush(debugBase::fp());
    
#if 0
    fprintf(debugBase::fp(), "===============  REG  ==========\n");
    debugBase::dumpShmReg(p);
    fprintf(debugBase::fp(), "================================\n");
    fflush(debugBase::fp());
#endif
    return 0;
}    
Exemple #2
0
//
//  LiteSpeed SHM small memory tester!
//
void    testShmPool(LsShm * shm)
{
    if (shm->status() != LSSHM_READY)
    {
        fprintf(debugBase::fp(), "LsShm %p NOTREADY %d\n",
                shm,shm->status());
        return;
    }
        
    LsShmPool   *pool = LsShmPool::get(shm, LSI_SHM_POOL_NAME);
    if (pool->status() != LSSHM_READY )
    {
        fprintf(debugBase::fp(), "LsShmPool %p NOTREADY %d\n",
                shm,shm->status());
        return;
    }
    
    debugBase::dumpShm(pool, 0, NULL);
    debugBase::dumpShmPool(pool, 0, NULL);
    fflush(debugBase::fp());
    
    testPoolAlloc(pool, dArray, sizeof(dArray)/sizeof(testShm_t), 0);
}
Exemple #3
0
void    testShmAlloc(LsShm * shm)
{
    register testShm_t *   p;
    register int i;
    
    if (shm->status() != LSSHM_READY)
    {
        fprintf(debugBase::fp(), "LsShm %p NOTREADY %d\n",
                shm,shm->status());
        return;
    }
        
    LsShmPool   *pool = LsShmPool::get(shm, LSI_SHM_POOL_NAME);
    if (pool->status() != LSSHM_READY)
    {
        fprintf(debugBase::fp(), "LsShmPool %p NOTREADY %d\n",
                shm,shm->status());
        return;
    }
        
    p = tArray;
    for (i = 0; i < (int)(sizeof(tArray)/sizeof(testShm_t)); i++)
    {
        p->roundsize = debugBase::roundPageSize(pool, p->size),
        fprintf(debugBase::fp(), "\nALLOC TEST %d SIZE %X\n", i, p->roundsize);
        int remapped = 0;
        if (!(p->offset = pool->alloc2(p->size, remapped)))
        {
            fprintf( debugBase::fp(), "ABORT: NO MEORY alloc2 [%8X %8X]\n", 
                 p->size,
                 p->roundsize);
            abort();
        }
        fprintf( debugBase::fp(), "ALLOC %8X %8X -> %8X %8X %s\n", 
                 p->offset,
                 p->size,
                 p->expected,
                 p->roundsize,
                 (p->offset == p->expected) ? "GOOD" : "BAD "
               );
        p++;
        debugBase::dumpShm(pool, 0, NULL);
        fflush(debugBase::fp());
    }
    
    p = tArray;
    i = rand() % (int)((sizeof(tArray)/sizeof(testShm_t)));
    for (; i < (int)(sizeof(tArray)/sizeof(testShm_t)); )
    {
        if (i & 0x1)
        {
            fprintf(debugBase::fp(), "\nFREE TEST %d [%8X %8X] \n", 
                    i, p->offset, p->roundsize);
            pool->release2(p->offset, p->size);
            debugBase::dumpShm(pool, 0, NULL);
            fflush(debugBase::fp());
        }
        p++;
        i++;
    }
    
    p = tArray;
    
    i = rand() % (int)((sizeof(tArray)/sizeof(testShm_t)));
    for (; i < (int)(sizeof(tArray)/sizeof(testShm_t)); )
    {
        if (!(i & 0x1))
        {
            fprintf(debugBase::fp(), "\nFREE TEST %d [%8X %8X] \n", 
                    i, p->offset, p->roundsize);
            pool->release2(p->offset, p->size);
            debugBase::dumpShm(pool, 0, NULL);
            fflush(debugBase::fp());
        }
        p++;
        i++;
    }
    
    fflush(debugBase::fp());
}