static void TestTimeout()
{
    Monitor monitor;
    HTTPConnector httpConnector(&monitor);
    WSMANExportClient client(&httpConnector,&monitor);
    const int TIMEOUT_MILLISECONDS =
        PEGASUS_DEFAULT_CLIENT_TIMEOUT_MILLISECONDS * 2;

    PEGASUS_TEST_ASSERT(client.getTimeout() ==
                        PEGASUS_DEFAULT_CLIENT_TIMEOUT_MILLISECONDS);
    client.setTimeout(TIMEOUT_MILLISECONDS);
    PEGASUS_TEST_ASSERT(client.getTimeout() == Uint32(TIMEOUT_MILLISECONDS));
    client.setTimeout(PEGASUS_DEFAULT_CLIENT_TIMEOUT_MILLISECONDS);
    PEGASUS_TEST_ASSERT(client.getTimeout() ==
                        PEGASUS_DEFAULT_CLIENT_TIMEOUT_MILLISECONDS);

    //
    //  Test setTimeout while connected
    //
    Uint32 port =
        System::lookupPort(WBEM_HTTP_SERVICE_NAME, WBEM_DEFAULT_HTTP_PORT);
    client.connect("localhost", port);
    PEGASUS_TEST_ASSERT(client.getTimeout() ==
                        PEGASUS_DEFAULT_CLIENT_TIMEOUT_MILLISECONDS);
    client.setTimeout(TIMEOUT_MILLISECONDS);
    PEGASUS_TEST_ASSERT(client.getTimeout() == Uint32(TIMEOUT_MILLISECONDS));
    client.setTimeout(PEGASUS_DEFAULT_CLIENT_TIMEOUT_MILLISECONDS);
    PEGASUS_TEST_ASSERT(client.getTimeout() ==
                        PEGASUS_DEFAULT_CLIENT_TIMEOUT_MILLISECONDS);
}
Beispiel #2
0
void Space::RefreshBackground()
{
	const SystemPath &path = m_starSystem->GetPath();
	Uint32 _init[5] = { path.systemIndex, Uint32(path.sectorX), Uint32(path.sectorY), Uint32(path.sectorZ), UNIVERSE_SEED };
	Random rand(_init, 5);
	m_background.reset(new Background::Container(Pi::renderer, rand));
}
Beispiel #3
0
void GetSysPolitStarSystem(const StarSystem *s, const fixed human_infestedness, SysPolit &outSysPolit)
{
	SystemPath path = s->GetPath();
	const Uint32 _init[5] = { Uint32(path.sectorX), Uint32(path.sectorY), Uint32(path.sectorZ), path.systemIndex, POLIT_SEED };
	Random rand(_init, 5);

	const Sector* sec = Sector::cache.GetCached(path);

	GovType a = GOV_INVALID;

	/* from custom system definition */
	if (sec->m_systems[path.systemIndex].customSys) {
		Polit::GovType t = sec->m_systems[path.systemIndex].customSys->govType;
		a = t;
	}
	if (a == GOV_INVALID) {
		if (path == SystemPath(0,0,0,0)) {
			a = Polit::GOV_EARTHDEMOC;
		} else if (human_infestedness > 0) {
			// attempt to get the government type from the faction
			a = s->GetFaction()->PickGovType(rand);

			// if that fails, either no faction or a faction with no gov types, then pick something at random
			if (a == GOV_INVALID) {
				a = static_cast<GovType>(rand.Int32(GOV_RAND_MIN, GOV_RAND_MAX));
			}
		} else {
			a = GOV_NONE;
		}
	}

	outSysPolit.govType = a;
	outSysPolit.lawlessness = s_govDesc[a].baseLawlessness * rand.Fixed();
}
Beispiel #4
0
bool IsCommodityLegal(const StarSystem *s, const Equip::Type t)
{
	SystemPath path = s->GetPath();
	const Uint32 _init[5] = { Uint32(path.sectorX), Uint32(path.sectorY), Uint32(path.sectorZ), path.systemIndex, POLIT_SALT };
	Random rand(_init, 5);

	Polit::GovType a = s->GetSysPolit().govType;
	if (a == GOV_NONE) return true;

	if(s->GetFaction()->idx != Faction::BAD_FACTION_IDX ) {
		Faction::EquipProbMap::const_iterator iter = s->GetFaction()->equip_legality.find(t);
		if( iter != s->GetFaction()->equip_legality.end() ) {
			const Uint32 per = (*iter).second;
			return (rand.Int32(100) >= per);
		}
	}
	else
	{
		// this is a non-faction system - do some hardcoded test
		switch (t) {
			case Equip::HAND_WEAPONS:
				return rand.Int32(2) == 0;
			case Equip::BATTLE_WEAPONS:
				return rand.Int32(3) == 0;
			case Equip::NERVE_GAS:
				return rand.Int32(10) == 0;
			case Equip::NARCOTICS:
				return rand.Int32(2) == 0;
			case Equip::SLAVES:
				return rand.Int32(16) == 0;
			default: return true;
		}
	}
	return true;
}
Beispiel #5
0
void GetSysPolitStarSystem(const StarSystem *s, const fixed human_infestedness, SysPolit &outSysPolit)
{
	SystemPath path = s->GetPath();
	const unsigned long _init[5] = { Uint32(path.sectorX), Uint32(path.sectorY), Uint32(path.sectorZ), path.systemIndex, POLIT_SEED };
	MTRand rand(_init, 5);

	Sector sec(path.sectorX, path.sectorY, path.sectorZ);

	GovType a = GOV_INVALID;

	/* from custom system definition */
	if (sec.m_systems[path.systemIndex].customSys) {
		Polit::GovType t = sec.m_systems[path.systemIndex].customSys->govType;
		a = t;
	}
	if (a == GOV_INVALID) {
		if (path == SystemPath(0,0,0,0)) {
			a = Polit::GOV_EARTHDEMOC;
		} else if (human_infestedness > 0) {
			a = static_cast<GovType>(rand.Int32(GOV_RAND_MIN, GOV_RAND_MAX));
		} else {
			a = GOV_NONE;
		}
	}

	outSysPolit.govType = a;
	outSysPolit.lawlessness = s_govDesc[a].baseLawlessness * rand.Fixed();
}
Beispiel #6
0
Space::Space(Game *game, RefCountedPtr<Galaxy> galaxy, const SystemPath &path, Space* oldSpace)
	: m_starSystemCache(oldSpace ? oldSpace->m_starSystemCache : galaxy->NewStarSystemSlaveCache())
	, m_game(game)
	, m_frameIndexValid(false)
	, m_bodyIndexValid(false)
	, m_sbodyIndexValid(false)
	, m_bodyNearFinder(this)
#ifndef NDEBUG
	, m_processingFinalizationQueue(false)
#endif
{
	m_starSystem = galaxy->GetStarSystem(path);

	Uint32 _init[5] = { path.systemIndex, Uint32(path.sectorX), Uint32(path.sectorY), Uint32(path.sectorZ), UNIVERSE_SEED };
	Random rand(_init, 5);
	m_background.reset(new Background::Container(Pi::renderer, rand));

	CityOnPlanet::SetCityModelPatterns(m_starSystem->GetPath());

	// XXX set radius in constructor
	m_rootFrame.reset(new Frame(0, Lang::SYSTEM));
	m_rootFrame->SetRadius(FLT_MAX);

	GenBody(m_game->GetTime(), m_starSystem->GetRootBody().Get(), m_rootFrame.get());
	m_rootFrame->UpdateOrbitRails(m_game->GetTime(), m_game->GetTimeStep());

	GenSectorCache(galaxy, &path);

	//DebugDumpFrames();
}
Beispiel #7
0
TextEntry *TextEntry::SetText(const std::string &text)
{
    bool atEnd = m_label->GetText().size() == m_cursor;
    m_label->SetText(text);
    m_cursor = atEnd ? Uint32(text.size()) : Clamp(m_cursor, Uint32(0), Uint32(text.size()));
    GetContext()->RequestLayout();
    return this;
}
Beispiel #8
0
static MessageLoaderParms _formPartialMessage(Uint32 code, Uint32 line)
{
    String dftMsg = _xmlMessages[Uint32(code) - 1];
    const char* key = _xmlKeys[Uint32(code) - 1];

    dftMsg.append(": on line $0");

    return MessageLoaderParms(key, dftMsg.getCString(), line);
}
Beispiel #9
0
void callMethod(const CIMName& methodName)
{
    try
    {
        CIMClient client;
        client.connectLocal();

        Array<CIMParamValue> inParams;
        Array<CIMParamValue> outParams;

        CIMObjectPath instName =
            CIMObjectPath("Test_MethodProviderClass.Id=1");

        inParams.append(CIMParamValue("InParam1", Uint32(1)));
        inParams.append(CIMParamValue("InParam2", Uint32(2)));

        CIMValue returnValue = client.invokeMethod(
            NAMESPACE,
            instName,
            methodName,
            inParams,
            outParams);

        Uint32 rc;
        returnValue.get(rc);
        PEGASUS_TEST_ASSERT(rc == 10);

        PEGASUS_TEST_ASSERT(outParams.size() == 2);

        Uint32 outParam1 = 0;
        Uint32 outParam2 = 0;

        for (Uint32 i = 0; i < 2; i++)
        {
            if (outParams[i].getParameterName() == "OutParam1")
            {
                outParams[i].getValue().get(outParam1);
            }
            else if (outParams[i].getParameterName() == "OutParam2")
            {
                outParams[i].getValue().get(outParam2);
            }
            else
            {
                PEGASUS_TEST_ASSERT(0);
            }
        }
        PEGASUS_TEST_ASSERT(outParam1 == 21);
        PEGASUS_TEST_ASSERT(outParam2 == 32);
    }
    catch (Exception& e)
    {
        cerr << "Error: " << e.getMessage() << endl;
        exit(1);
    }
}
Beispiel #10
0
RefCountedPtr<Sector> GalaxyGenerator::GenerateSector(RefCountedPtr<Galaxy> galaxy, const SystemPath &path, SectorCache *cache)
{
	const Uint32 _init[4] = { Uint32(path.sectorX), Uint32(path.sectorY), Uint32(path.sectorZ), UNIVERSE_SEED };
	Random rng(_init, 4);
	SectorConfig config;
	RefCountedPtr<Sector> sector(new Sector(galaxy, path, cache));
	for (SectorGeneratorStage *secgen : m_sectorStage)
		if (!secgen->Apply(rng, galaxy, sector, &config))
			break;
	return sector;
}
Beispiel #11
0
extern "C" void* NdbThreadFuncUpdate(void* pArg)
{
    myRandom48Init((long int)NdbTick_CurrentMillisecond());
    unsigned nSucc = 0;
    unsigned nFail = 0;
    Ndb* pNdb = NULL ;
    pNdb = new Ndb("TEST_DB");
    VerifyMethodInt(pNdb, init());
    VerifyMethodInt(pNdb, waitUntilReady());

    while(NdbMutex_Trylock(g_pNdbMutex)) {
        Uint32 nWarehouse = myRandom48(g_nWarehouseCount);
        NdbConnection* pNdbConnection = NULL ;
        VerifyMethodPtr(pNdbConnection, pNdb, startTransaction());
        CHK_TR(pNdbConnection) ; // epaulsa
        NdbOperation* pNdbOperationW = NULL ;
        VerifyMethodPtr(pNdbOperationW, pNdbConnection, getNdbOperation(c_szWarehouse));
        VerifyMethodInt(pNdbOperationW, interpretedUpdateTuple());
        VerifyMethodInt(pNdbOperationW, equal(c_szWarehouseNumber, nWarehouse));
        VerifyMethodInt(pNdbOperationW, incValue(c_szWarehouseCount, Uint32(1)));
        Uint32 nWarehouseSum = 0;
        for(Uint32 nDistrict=0; nDistrict<g_nDistrictPerWarehouse; ++nDistrict) {
            NdbOperation* pNdbOperationD = NULL ;
            VerifyMethodPtr(pNdbOperationD, pNdbConnection, getNdbOperation(c_szDistrict));
            VerifyMethodInt(pNdbOperationD, interpretedUpdateTuple());
            VerifyMethodInt(pNdbOperationD, equal(c_szDistrictWarehouseNumber, nWarehouse));
            VerifyMethodInt(pNdbOperationD, equal(c_szDistrictNumber, nDistrict));
            VerifyMethodInt(pNdbOperationD, incValue(c_szDistrictCount, Uint32(1)));
            Uint32 nDistrictSum = myRandom48(100);
            nWarehouseSum += nDistrictSum;
            VerifyMethodInt(pNdbOperationD, setValue(c_szDistrictSum, nDistrictSum));
        }
        VerifyMethodInt(pNdbOperationW, setValue(c_szWarehouseSum, nWarehouseSum));
        int iExec = pNdbConnection->execute(Commit);
        int iError = pNdbConnection->getNdbError().code;

        if(iExec<0 && iError!=0 && iError!=266 && iError!=626) {
            ReportMethodInt(iExec, pNdbConnection, "pNdbConnection", "execute(Commit)", __FILE__, __LINE__);
        }
        if(iExec==0) {
            ++nSucc;
        } else {
            ++nFail;
        }
        VerifyMethodVoid(pNdb, closeTransaction(pNdbConnection));
    }
    ndbout << "update: " << nSucc << " succeeded, " << nFail << " failed " << endl;
    NdbMutex_Unlock(g_pNdbMutex);
    delete pNdb;
    pNdb = NULL ;
    return NULL;
}
Beispiel #12
0
void TestCreateInstance5()
{
  if (verbose) cout << ProgName << "-TestCreateInstance5()" << endl;
    // -- Create an instance of each class:

    CIMInstance inst0(CIMName ("SuperClass"));
    inst0.addProperty(CIMProperty(CIMName ("key"), Uint32(11111)));
    r->createInstance(NS, inst0);

    CIMInstance inst1(CIMName ("SubClass"));
    inst1.addProperty(CIMProperty(CIMName ("key"), Uint32(22222)));
    r->createInstance(NS, inst1);
}
/**
   getTotalVirtualMemorySize method for SunOS implementation of OS Provider

   Gets information from swapinfo -q command (techically not swap
   space, it's paging).  Same as the information returned for
   TotalSwapSpace.

  */
Boolean OSTestClient::goodTotalVirtualMemorySize(
    const Uint64 &totalvmem,
    Boolean verbose)
{
   if (verbose)
      cout<<"Checking TotalVirtualMemorySize "<<Uint32(totalvmem)<<endl;

   Uint64 totalVMem = _totalVM();

   if (verbose)
      cout<<" Should be " << Uint32(totalVMem) << endl;

   return (totalvmem == totalVMem);  // will return false if totalVMem=0
}
Beispiel #14
0
void TestCreateClass()
{

  if (verbose) cout << ProgName << "-TestCreateClass()" << endl;
    CIMClass c1(CIMName ("SuperClass"));
    c1.addQualifier(d);
    c1.addProperty(
        CIMProperty(CIMName ("key"), Uint32(0))
        .addQualifier(CIMQualifier(CIMName("key"), true, CIMFlavor::DEFAULTS)));

    c1.addProperty(CIMProperty(CIMName ("ratio"), Real32(1.5)));
    c1.addProperty(CIMProperty(CIMName ("message"), String("Hello World")));

    // -- Create the class (get it back and compare):
    r->createClass(NS, c1);
    CIMConstClass cc1;
    cc1 = r->getClass(NS, CIMName("SuperClass"), true, true, false);
    PEGASUS_TEST_ASSERT(c1.identical(cc1));
    PEGASUS_TEST_ASSERT(cc1.identical(c1));

    // -- Now create a sub class (get it back and compare):
    // c22 has one additional property than c1 (junk)

    CIMClass c2(CIMName ("SubClass"), CIMName ("SuperClass"));
    // Add new qualifier that will be local
    CIMQualifier j(
        CIMName("junk"), String("TestQualifier"), CIMFlavor::DEFAULTS);
    c2.addQualifier(j);

    c2.addProperty(CIMProperty(CIMName ("junk"), Real32(66.66)));
    r->createClass(NS, c2);
    CIMConstClass cc2;
    cc2 = r->getClass(NS, CIMName("SubClass"), true, true, false);
    //XmlWriter::printClassElement(c2);
    //XmlWriter::printClassElement(cc2);

    PEGASUS_TEST_ASSERT(c2.identical(cc2));
    PEGASUS_TEST_ASSERT(cc2.identical(c2));

    // -- Modify "SubClass" (add new property)

    c2.addProperty(CIMProperty(CIMName ("newProperty"), Uint32(888)));
    r->modifyClass(NS, c2);
    cc2 = r->getClass(NS, CIMName ("SubClass"), true, true, false);
    PEGASUS_TEST_ASSERT(c2.identical(cc2));
    PEGASUS_TEST_ASSERT(cc2.identical(c2));
    // should test for this new property on "SubClass" also.

}
Beispiel #15
0
RefCountedPtr<StarSystem> GalaxyGenerator::GenerateStarSystem(RefCountedPtr<Galaxy> galaxy, const SystemPath &path, StarSystemCache *cache)
{
	RefCountedPtr<const Sector> sec = galaxy->GetSector(path);
	assert(path.systemIndex >= 0 && path.systemIndex < sec->m_systems.size());
	Uint32 seed = sec->m_systems[path.systemIndex].GetSeed();
	std::string name = sec->m_systems[path.systemIndex].GetName();
	Uint32 _init[6] = { path.systemIndex, Uint32(path.sectorX), Uint32(path.sectorY), Uint32(path.sectorZ), UNIVERSE_SEED, Uint32(seed) };
	Random rng(_init, 6);
	StarSystemConfig config;
	RefCountedPtr<StarSystem::GeneratorAPI> system(new StarSystem::GeneratorAPI(path, galaxy, cache, rng));
	for (StarSystemGeneratorStage *sysgen : m_starSystemStage)
		if (!sysgen->Apply(rng, galaxy, system, &config))
			break;
	return system;
}
Beispiel #16
0
void GameLog::DrawHudMessages(Graphics::Renderer *r)
{
	Graphics::Renderer::StateTicket ticket(r);
	Graphics::RenderStateDesc rsd;
	rsd.depthTest  = false;
	rsd.depthWrite = false;
	Graphics::RenderState *prsd = r->CreateRenderState(rsd);

	//I'd rather render this as one string, but then we can't
	//have per-line fade - markup doesn't support alpha
	r->SetOrthographicProjection(0, m_screenSize.x, m_screenSize.y, 0, -1, 1);
	r->SetTransform(matrix4x4f::Identity());
	r->SetRenderState(prsd);

	const Color &c = Color::WHITE;

	float y = 0;
	for (auto it = m_messages.rbegin(); it != m_messages.rend(); ++it) {
		float alpha = 1.f;
		if (it->time > FADE_AFTER) {
			alpha = 1.0f - (float(it->time - FADE_AFTER) / float(FADE_TIME));
		}
		const Color textColour(c.r, c.g, c.b, Clamp(Uint32(alpha*255), 0U, 255U));
		m_font->RenderString(it->msg.c_str(), m_offset.x, m_offset.y + y, textColour);
		y -= m_lineHeight;
	}
}
Beispiel #17
0
Perlin::Perlin() {
	srand( Uint32( time( NULL ) ) );

	p = new Sint32[256];
	Gx = new GLfloat[256];
	Gy = new GLfloat[256];
	Gz = new GLfloat[256];

	for ( Sint32 i=0; i < 256; ++i )
	{
		p[i] = i;

		Gx[i] = ( GLfloat( rand() ) / ( RAND_MAX/2 ) ) - 1.0f;
		Gy[i] = ( GLfloat( rand() ) / ( RAND_MAX/2 ) ) - 1.0f;
		Gz[i] = ( GLfloat( rand() ) / ( RAND_MAX/2 ) ) - 1.0f;
	}

	Sint32 j=0;
	Sint32 swp=0;
	for ( Sint32 i=0; i < 256; i++ )
	{
		j = rand() & 255;

		swp = p[i];
		p[i] = p[j];
		p[j] = swp;
	}
}
Beispiel #18
0
void FileSourceZip::AddFile(const std::string &path, const FileStat &fileStat)
{
	std::vector<std::string> fragments;
	SplitPath(path, fragments);

	assert(fragments.size() > 0);

	Directory *dir = &m_root;

	if (fragments.size() > 1) {
		std::string fullPath;

		for (unsigned int i = 0; i < fragments.size()-1; i++) {
			fullPath += ((i > 0) ? "/" : "") + fragments[i];

			std::map<std::string,FileStat>::const_iterator it = dir->files.find(fragments[i]);
			if (it == dir->files.end())
				dir->files.insert(std::make_pair(fragments[i], FileStat(Uint32(-1), 0, MakeFileInfo(fullPath, FileInfo::FT_DIR))));
			dir = &(dir->subdirs[fragments[i]]);
		}
	}

	const std::string &filename = fragments.back();

	if (fileStat.info.IsDir())
		dir->subdirs.insert(std::make_pair(filename, Directory()));
	
	dir->files.insert(std::make_pair(filename, fileStat));
}
Beispiel #19
0
inline
void
RecordPool<T, P>::init(Uint32 type_id, const Pool_context& pc)
{
  T tmp;
  const char * off_base = (char*)&tmp;
  const char * off_next = (char*)&tmp.nextPool;
  const char * off_magic = (char*)&tmp.m_magic;

  Record_info ri;
  ri.m_size = sizeof(T);
  ri.m_offset_next_pool = Uint32(off_next - off_base);
  ri.m_offset_magic = Uint32(off_magic - off_base);
  ri.m_type_id = type_id;
  m_pool.init(ri, pc);
}
Beispiel #20
0
void
Win32AsyncFile::appendReq(Request * request){

  const char * buf = request->par.append.buf;
  Uint32 size = Uint32(request->par.append.size);

  m_write_wo_sync += size;

  DWORD dwWritten = 0;
  while(size > 0){
    if(!WriteFile(hFile, buf, size, &dwWritten, 0)){
      request->error = GetLastError();
      return ;
    }

    buf += dwWritten;
    size -= dwWritten;
  }

  if((m_auto_sync_freq && m_write_wo_sync > m_auto_sync_freq) ||
      m_always_sync)
  {
    syncReq(request);
  }
}
Beispiel #21
0
bool SoundData::loadOgg(const byte * buffer, Uint32 bufferSize)
{
    clear();

    short* samples;
    int channels;
    int sample_rate;
    int len;

    len = stb_vorbis_decode_memory(buffer, (int)bufferSize, &channels, &sample_rate, &samples);

    if (!samples)
    {
        return false;
    }

    Uint32 dataSize = Uint32(len * channels * 2);

    if (!separateChannels((byte*)samples, dataSize, channels, 16))
    {
        free(samples);
        return false;
    }

    free(samples);

    _channels = channels;
    _sampleRate = sample_rate;
    _bitsPerSample = 16;

    return true;
}
int
SHM_Transporter::doSend()
{
  struct iovec iov[64];
  Uint32 cnt = fetch_send_iovec_data(iov, NDB_ARRAY_SIZE(iov));

  if (cnt == 0)
  {
    return 0;
  }

  Uint32 sum = 0;
  for(Uint32 i = 0; i<cnt; i++)
  {
    assert(iov[i].iov_len);
    sum += iov[i].iov_len;
  }

  int nBytesSent = writer->writev(iov, cnt);

  if (nBytesSent > 0)
  {
    kill(m_remote_pid, g_ndb_shm_signum);
    iovec_data_sent(nBytesSent);

    if (Uint32(nBytesSent) == sum && (cnt != NDB_ARRAY_SIZE(iov)))
    {
      return 0;
    }
    return 1;
  }

  return 1;
}
Beispiel #23
0
Effect::Effect(Point impact, Snake *snake) : _map(snake->_map)
{
    _color = snake->_color;

    float speed = (float) sqrt(snake->_speed.x*snake->_speed.x + snake->_speed.y*snake->_speed.y);
    double angle = atan2(snake->_speed.y, snake->_speed.x);

    float d_speed = (snake->_speedMax - snake->_speedMin)/4;
    double d_angle = M_PI/12 + M_PI/3 * (1.0 - speed/snake->_speedMax);


    auto random = [](double min, double max) -> double
    {
        return min + double(rand()) / RAND_MAX * (max - min);
    };
    auto random_angle = [random](double middle, double max_delta)
    {
        middle += 2*M_PI;
        return random(middle - max_delta, middle + max_delta);
    };
    auto random_speed = [random](double middle, double max_delta) -> double
    {
        return random(middle, max_delta);
    };

    _particles.resize(Uint32(50 * speed/snake->_speedMax));
    double p_speed, p_angle;
    for(Uint32 i = 0; i < _particles.size(); ++i)
    {
        _particles[i].pos = Point(snake->_pos.x, snake->_pos.y);
        p_speed = random_speed(speed, d_speed);
        p_angle = random_angle(angle, d_angle);
        _particles[i].speed = Point( float(p_speed * cos(p_angle)), float(p_speed * sin(p_angle)) );
    }
}
static void TestExceptionHandling()
{
    Monitor monitor;
    HTTPConnector httpConnector(&monitor);
    WSMANExportClient client(&httpConnector,&monitor);

    CIMInstance indication(CIMName("My_IndicationClass"));
    indication.addProperty(CIMProperty(CIMName("DeviceName"), String("Disk")));
    indication.addProperty(CIMProperty(CIMName("DeviceId"), Uint32(1)));

    /*
         Missing call to client.connect(...).  Verify NotConnectedException
         is returned.
    */
    Boolean exceptionCaught;
    exceptionCaught = false;
    try
    {
        client.exportIndication(
           "/WSMANListener/Pegasus_IndicationStressTestConsumer", indication);

    }
    catch (const NotConnectedException&)
    {
        exceptionCaught = true;
    }
    PEGASUS_TEST_ASSERT(exceptionCaught);
}
void
Restore::restore_lcp_conf(Signal* signal, FilePtr file_ptr)
{
  RestoreLcpConf* rep= (RestoreLcpConf*)signal->getDataPtrSend();
  rep->senderData= file_ptr.p->m_sender_data;
  if(file_ptr.p->is_lcp())
  {
    /**
     * Temporary reset DBTUP's #disk attributes on table
     *
     * TUP will send RESTORE_LCP_CONF
     */
    c_tup->complete_restore_lcp(signal, 
                                file_ptr.p->m_sender_ref,
                                file_ptr.p->m_sender_data,
                                file_ptr.p->m_table_id,
				file_ptr.p->m_fragment_id);
  }
  else
  {
    sendSignal(file_ptr.p->m_sender_ref, 
               GSN_RESTORE_LCP_CONF, signal, 
               RestoreLcpConf::SignalLength, JBB);
  }

  signal->theData[0] = NDB_LE_ReadLCPComplete;
  signal->theData[1] = file_ptr.p->m_table_id;
  signal->theData[2] = file_ptr.p->m_fragment_id;
  signal->theData[3] = Uint32(file_ptr.p->m_rows_restored >> 32);
  signal->theData[4] = Uint32(file_ptr.p->m_rows_restored);
  sendSignal(CMVMI_REF, GSN_EVENT_REP, signal, 5, JBB);

  release_file(file_ptr);
}
Beispiel #26
0
//  Fill in a caller-provided unsigned int
void Optarg::Value(unsigned int& i) const
{
    CString cs = _value.getCString();
    const char* s = cs;
    Boolean valid = true;
    Uint32 j;

    for (j = 0; j < strlen (s); j++)
    {
        if ((!isdigit (s [j])) && (!isspace (s [j])))
        {
            valid = false;
            break;
        }
    }
    if (valid)
    {
        Uint64 i64;
        if ( !(sscanf (s, "%" PEGASUS_64BIT_CONVERSION_WIDTH "u", &i64)) ||
             (i64 > 0xFFFFFFFF))
        {
            throw TypeMismatchException ();
        }

        i = Uint32(i64);
    }
    else
    {
        throw TypeMismatchException();
    }
}
Beispiel #27
0
int main(int argc, char** argv)
{

    verbose = (getenv ("PEGASUS_TEST_VERBOSE")) ? true : false;
  
    if (argc < 2)
    {
	cerr << "Usage: " << argv[0] << " xml-filename ..." << endl;
	exit(1);
    }

    for (Uint32 i = 1; i < Uint32(argc); i++)
    {
	try 
	{ 
	    _parseFile(argv[i]); 
	}
	catch(Exception& e)
	{
	    cerr << "Error: " << e.getMessage() << endl;	
	    exit(1);
	}
    }
    cout << argv[0] << " +++++ passed all tests" << endl;

    return 0;
}
Beispiel #28
0
Context::Context(SDL_Window* window, int major, int minor, GLContextProfile profile, bool debug) noexcept
:
	mActive(true)
{
	// Set context attributes
	if (SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, major) < 0) {
		error("Failed to set gl context major version: %s", SDL_GetError());
	}
	if (SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, minor) < 0) {
		error("Failed to set gl context minor version: %s", SDL_GetError());
	}
	if (SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, int(Uint32(profile))) < 0) {
		error("Failed to set gl context profile: %s", SDL_GetError());
	}

	// Set debug context if requested
	if (debug) {
		if (SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, SDL_GL_CONTEXT_DEBUG_FLAG) < 0) {
			printErrorMessage("Failed to request debug context: %s", SDL_GetError());
		}
	}

	handle = SDL_GL_CreateContext(window);
	if (handle == NULL) {
		error("Failed to create GL context: %s", + SDL_GetError());
	}
}
void TestGroupingProvider2::invokeMethod(
    const OperationContext& context,
    const CIMObjectPath& objectReference,
    const CIMName& methodName,
    const Array<CIMParamValue>& inParameters,
    MethodResultResponseHandler& handler)
{
    if (!objectReference.getClassName().equal("Test_GroupingClass2"))
    {
        throw CIMNotSupportedException(
            objectReference.getClassName().getString());
    }

    handler.processing();
    if (methodName.equal("getNextIdentifier"))
    {
        handler.deliver(CIMValue(Uint32(getNextIdentifier())));
    }
    else if (methodName.equal("getSubscriptionCount"))
    {
         handler.deliver(CIMValue(_subscriptionCount));
    }

    handler.complete();
}
Beispiel #30
0
bool SoundData::loadOgg(const std::string & filename)
{
    clear();

    short* samples;
    int channels;
    int sample_rate;
    int len;

    len = stb_vorbis_decode_filename(filename.c_str(), &channels, &sample_rate, &samples);

    if (!samples)
    {
        return false;
    }

    Uint32 dataSize = Uint32(len * channels * 2);

    if (!separateChannels((byte*)samples, dataSize, channels, 16))
    {
        free(samples);
        return false;
    }

    free(samples);

    _channels = channels;
    _sampleRate = sample_rate;
    _bitsPerSample = 16;

    return true;
}