void TestDehollowficationFromDatabaseOfTwoPointers(void) { CIndexedConfig cConfig; CFileUtil cFileUtil; cConfig.Manual("Output\\Dehollowfication\\Database", FALSE, TRUE, FALSE, 1 MB); cFileUtil.RemoveDir("Output\\Dehollowfication\\Database"); MemoryInit(); ObjectsInit(&cConfig); SetupDehollowficationScene(); gcObjects.Flush(FALSE, FALSE); ObjectsKill(); MemoryKill(); MemoryInit(); ObjectsInit(&cConfig); SetupDehollowficationConstructors(); Ptr<CRoot> pRoot = ORoot(); Ptr<CTestDoubleNamedString> pDouble = pRoot->Get<CTestDoubleNamedString>("Double Start"); Ptr<CTestNamedString> pString1 = pDouble->mpSplit1; Ptr<CTestNamedString> pString2 = pDouble->mpSplit2; pString1->ClassName(); pString2->ClassName(); Ptr<CTestNamedString> pDiamond1 = pString1->mpAnother; Ptr<CTestNamedString> pDiamond2 = pString2->mpAnother; AssertTrue(pDiamond1.IsHollow()); AssertTrue(pDiamond2.IsHollow()); AssertPointer(pDiamond1.Object(), pDiamond2.Object()); AssertPointer(pString1->mpAnother.Object(), pString2->mpAnother.Object()); AssertLongLongInt(3LL, pDiamond1.GetIndex()); AssertLongLongInt(3LL, pDiamond2.GetIndex()); //Dehollofication of pDiamond1 happens here. pString1->mpAnother and pString2->mpAnother are remapped to the dehollowed diamond object. pDiamond1->ClassName(); AssertFalse(pDiamond1.IsHollow()); AssertFalse(pDiamond2.IsHollow()); //This should be false but it's not until I remap local pointers. AssertPointer(pDiamond1.Object(), pDiamond2.Object()); //These should be the same but they're not until I remap local pointers. AssertLongLongInt(3LL, pDiamond1.GetIndex()); AssertFalse(pString1->mpAnother.IsHollow()); AssertFalse(pString2->mpAnother.IsHollow()); AssertPointer(pString1->mpAnother.Object(), pString2->mpAnother.Object()); ObjectsKill(); MemoryKill(); }
void TestDehollowficationFromChunkFileSource(void) { CFileUtil cFileUtil; cFileUtil.RemoveDir("Output\\Dehollowfication\\ChunkFile"); MemoryInit(); ObjectsInit("Output\\Dehollowfication\\Temp"); WriteDehollowficationChunkedFile(); ObjectsKill(); MemoryKill(); cFileUtil.RemoveDir("Output\\Dehollowfication\\Temp"); CObjectSourceChunked* pcObjectSourceChunked; CDiskFile* pcDiskFile = DiskFile("Output\\Dehollowfication\\ChunkFile\\Double.DRG"); MemoryInit(); ObjectsInit("Output\\Dehollowfication\\Temp"); SetupDehollowficationConstructors(); pcObjectSourceChunked = (CObjectSourceChunked*)gcObjects.AddSource<CObjectConverterNative>(pcDiskFile, "Double"); //Note the .DRG is intentionally dropped. AssertNotNull(pcObjectSourceChunked); AssertInt(4, pcObjectSourceChunked->NumNames()); AssertString("Diamond End", pcObjectSourceChunked->GetName(0)); AssertString("Double Start", pcObjectSourceChunked->GetName(1)); AssertString("NamedString 1", pcObjectSourceChunked->GetName(2)); AssertString("NamedString 2", pcObjectSourceChunked->GetName(3)); Ptr<CTestDoubleNamedString> pStart; pStart = gcObjects.Get("Double Start"); AssertTrue(pStart.IsNotNull()); AssertString("CTestDoubleNamedString", pStart.ClassName()); AssertTrue(pStart->mpSplit1.IsHollow()); AssertTrue(pStart->mpSplit2.IsHollow()); AssertFalse(pStart->mszString.IsHollow()); pStart->mpSplit1->ClassName(); AssertFalse(pStart->mpSplit1.IsHollow()); AssertString("CTestNamedString", pStart->mpSplit1.ClassName()); ObjectsKill(); MemoryKill(); }
void TestEmbeddedObjectPointTo(void) { BOOL bResult; CFileUtil cFileUtil; OIndex oiComplex; char* szClassName; cFileUtil.RemoveDir("Output/EmbeddedObject"); MemoryInit(); ObjectsInit("Output/EmbeddedObject/"); SetupEmbeddedObjectConstructors(); Ptr<CRoot> pRoot = ORoot(); Ptr<CEmbeddedComplex> pComplex = OMalloc(CEmbeddedComplex)->Init(); oiComplex = pComplex->GetOI(); Ptr<CEmbeddedContainer> pContainer = &pComplex->mcContainer; pRoot->Add(pContainer); bResult = gcObjects.Flush(TRUE, TRUE); AssertTrue(bResult); ObjectsKill(); MemoryKill(); AssertNull(&pContainer); MemoryInit(); ObjectsInit("Output/EmbeddedObject/"); SetupEmbeddedObjectConstructors(); pRoot = gcObjects.GetRoot(); AssertTrue(pRoot.IsNotNull()); pContainer = pRoot->Get(0); AssertTrue(pContainer.IsHollow()); AssertInt(0, pContainer.Object()->GetNumEmbedded()); AssertLongLongInt(-1, pContainer.GetIndex()); szClassName = pContainer->ClassName(); AssertString("CEmbeddedContainer", szClassName); pComplex = pContainer->GetEmbeddingContainer(); //Kinda feels like this test just stopped... ObjectsKill(); MemoryKill(); }
void TestScratchPadAllocatorPop(void) { MemoryInit(); CScratchPadAllocator cAlloc; CConstructorTestClass* pcTest1; CConstructorTestClass* pcTest2; gcConstructors.Add<CConstructorTestClass>("CConstructorTestClass"); cAlloc.Init(); AssertInt(0, cAlloc.GetScratchPad()->GetUsedSize()); pcTest1 = (CConstructorTestClass*)gcConstructors.Construct("CConstructorTestClass", &cAlloc); AssertInt(28, cAlloc.GetScratchPad()->GetUsedSize()); pcTest1->k = 7; AssertInt(3, pcTest1->Method1()); AssertInt(7, pcTest1->k); pcTest2 = (CConstructorTestClass*)gcConstructors.Construct("CConstructorTestClass", &cAlloc); AssertInt(56, cAlloc.GetScratchPad()->GetUsedSize()); cAlloc.Free(pcTest1); AssertInt(56, cAlloc.GetScratchPad()->GetUsedSize()); cAlloc.Free(pcTest2); AssertInt(56, cAlloc.GetScratchPad()->GetUsedSize()); cAlloc.Kill(); MemoryKill(); }
void TestIndexTreeMemory(void) { BeginTests(); FastFunctionsInit(); MemoryInit(); TestIndexTreeMemoryKill(); TestIndexTreeMemoryAdd(); TestIndexTreeMemoryGet(); TestIndexTreeMemoryPutPtrDuplicate(); TestIndexTreeMemoryPutDifferenceSizeDuplicates(); TestIndexTreeMemoryValidateInternalConsistency(); TestIndexTreeMemoryCountAllocatedNodes(); TestIndexTreeMemoryRemoveResize(); TestIndexTreeMemoryRemoveByObject(); TestIndexTreeMemoryHasKey(); TestIndexTreeMemoryRemoveNullNode(); TestIndexTreeMemoryAddLongLong(); TestIndexTreeMemoryIterate(); TestIndexTreeMemoryReadWrite(); TestIndexTreeMemoryRemoveOnRoot(); TestIndexTreeMemoryResizeData(); MemoryKill(); FastFunctionsKill(); TestStatistics(); }
void TestMemoryAllocatorFree(void) { MemoryInit(); CMemoryAllocator cAlloc; CConstructorTestClass* pcTest; gcConstructors.Add<CConstructorTestClass>("CConstructorTestClass"); cAlloc.Init(); AssertInt(0, cAlloc.GetMemory()->NumElements()); pcTest = (CConstructorTestClass*)gcConstructors.Construct("CConstructorTestClass", &cAlloc); AssertInt(1, cAlloc.GetMemory()->NumElements()); pcTest->k = 7; AssertInt(3, pcTest->Method1()); AssertInt(7, pcTest->k); cAlloc.Free(pcTest); AssertInt(0, cAlloc.GetMemory()->NumElements()); cAlloc.Kill(); MemoryKill(); }
void InitAll(int argc, char **argv) { PrefsInit(argc, argv); MemoryInit(); SIDInit(); CPUInit(); }
void TestEmbeddedGetEmbeddedIndex(void) { MemoryInit(); ObjectsInit(); CEmbeddedComplex cComplex; cComplex.Class(); cComplex.Init(); AssertInt(0, cComplex.TestGetNumEmbeddedFromFlags()); AssertInt(6, cComplex.GetNumEmbedded()); AssertInt(6, cComplex.TestGetNumEmbeddedFromFlags()); AssertInt(1, cComplex.mcSimple.GetNumEmbedded()); AssertInt(1, cComplex.ma.GetNumEmbedded()); AssertInt(3, cComplex.mcContainer.GetNumEmbedded()); AssertInt(1, cComplex.mcContainer.mcOne.GetNumEmbedded()); AssertInt(1, cComplex.mcContainer.mcOne.GetNumEmbedded()); AssertInt(0, cComplex.GetEmbeddedIndex(&cComplex)); AssertInt(1, cComplex.GetEmbeddedIndex(&cComplex.mcSimple)); AssertInt(2, cComplex.GetEmbeddedIndex(&cComplex.ma)); AssertInt(3, cComplex.GetEmbeddedIndex(&cComplex.mcContainer)); AssertInt(4, cComplex.GetEmbeddedIndex(&cComplex.mcContainer.mcOne)); AssertInt(5, cComplex.GetEmbeddedIndex(&cComplex.mcContainer.mcTwo)); AssertInt(-1, cComplex.GetEmbeddedIndex(NULL)); ObjectsKill(); MemoryKill(); }
void TestMapStringUnknownPut(void) { MemoryInit(); UnknownsInit(); CMapStringUnknown cMap; CTestUnknownJobbie* pcTest; cMap.Init(); AssertInt(0, cMap.NumElements()); pcTest = cMap.Put<CTestUnknownJobbie>("Hello"); pcTest->Init(7, "1st"); AssertInt(1, cMap.NumElements()); pcTest = cMap.Put<CTestUnknownJobbie>("World"); pcTest->Init(19, "A pony"); AssertInt(2, cMap.NumElements()); pcTest = cMap.Put<CTestUnknownJobbie>("Aardvark"); pcTest->Init(4, "Restore"); AssertInt(3, cMap.NumElements()); pcTest = cMap.Put<CTestUnknownJobbie>(NULL); AssertNull(pcTest); AssertInt(3, cMap.NumElements()); cMap.Kill(); UnknownsKill(); MemoryKill(); }
void TestMapStringUnknownNoOverwrite(void) { MemoryInit(); UnknownsInit(); CMapStringUnknown cMap; CTestUnknownJobbie* pcTest; cMap.Init(TRUE, FALSE); AssertInt(0, gcUnknowns.NumElements()); pcTest = cMap.Put<CTestUnknownJobbie>("One"); pcTest->Init(2, ""); AssertNotNull(pcTest); AssertInt(1, gcUnknowns.NumElements()); pcTest = cMap.Put<CTestUnknownJobbie>("One"); AssertNull(pcTest); AssertInt(1, gcUnknowns.NumElements()); cMap.Kill(); AssertInt(0, gcUnknowns.NumElements()); UnknownsKill(); MemoryKill(); }
void TestObjectReaderSimpleDeserialised(void) { WriteObjectReaderSimpleFile(); CObjectReaderSimpleDisk cReader; CObjectGraphDeserialiser cGraphDeserialiser; CPointer cBase; Ptr<CTestNamedString> cNS1; Ptr<CTestNamedString> cNS2; CPointer cTemp; CObjectAllocator cAllocator; CDependentReadObjects cDependentReadObjects; MemoryInit(); ObjectsInit(); gcObjects.AddConstructor<CTestNamedString>(); AssertLongLongInt(0, gcObjects.NumDatabaseObjects()); AssertLongLongInt(0, gcObjects.NumMemoryIndexes()); cAllocator.Init(&gcObjects); cDependentReadObjects.Init(); cReader.Init("Output\\ObjectReaderSimple\\Test\\"); cGraphDeserialiser.Init(&cReader, FALSE, &cAllocator, &cDependentReadObjects, gcObjects.GetMemory()); cBase = cGraphDeserialiser.Read("Waggy"); AssertLongLongInt(0, gcObjects.NumDatabaseObjects()); AssertLongLongInt(2, gcObjects.NumMemoryIndexes()); cNS1 = gcObjects.Get("Waggy"); AssertTrue(cNS1.IsNotNull()); AssertString("NS1", cNS1->mszEmbedded.Text()); cNS2 = gcObjects.Get("Dog"); AssertTrue(cNS2.IsNotNull()); AssertString("NS2", cNS2->mszEmbedded.Text()); AssertTrue(cBase.IsNotNull()); AssertString("CTestNamedString", cBase->ClassName()); AssertPointer(&cNS1, &cBase); AssertPointer(&cNS2, &cNS1->mpAnother); AssertPointer(NULL, &cNS2->mpAnother); cGraphDeserialiser.Kill(); cDependentReadObjects.Kill(); cAllocator.Kill(); cReader.Kill(); ObjectsKill(); }
void TestVirtualCall(void) { MemoryInit(); UnknownsInit(); CTestObjectIsListenerWithEvent* pcTest; CTestObjectIsListener* pcListener; CTestAnotherListener cAnother1; CTestAnotherListener cAnother2; CTestAnotherListener cAnother3; BOOL bResult; pcTest = UMalloc(CTestObjectIsListenerWithEvent); pcTest->Init(); pcListener = UMalloc(CTestObjectIsListener); pcListener->Init(); AssertInt(WH_SomeOneSetUpUsTheBomb, pcTest->meWhatHappen); AssertString("Nothing to see here", pcListener->mszAlsoBored.Text()); AssertInt(0, pcTest->miBored); bResult = pcTest->AddListener<CTestListener>(pcListener); AssertTrue(bResult); bResult = pcTest->AddListener(&cAnother1); AssertTrue(bResult); bResult = pcTest->AddListener(&cAnother2); AssertTrue(bResult); pcTest->MakeEventStyle1Happen(); AssertInt(WH_WeGetSignal, pcTest->meWhatHappen); AssertString("Sup my homies", pcListener->mszAlsoBored.Text()); AssertInt(1, pcTest->miBored); pcTest->MakeEventStyle2Happen(); AssertInt(WH_MoveZigForGreatJustice, pcTest->meWhatHappen); AssertString("Wikky wikky free styling", pcListener->mszAlsoBored.Text()); AssertInt(2, pcTest->miBored); pcTest->CallListeners(&CTestAnotherListener::Another, pcTest, NULL); AssertInt(1, cAnother1.iThisIsNotTheRightWayToUseListeners); AssertInt(1, cAnother2.iThisIsNotTheRightWayToUseListeners); AssertInt(0, cAnother3.iThisIsNotTheRightWayToUseListeners); bResult = pcTest->AddListener<CTestBadListener>(NULL); AssertFalse(bResult); pcListener->Kill(); pcTest->Kill(); UnknownsKill(); MemoryKill(); }
bool SchedulingInited; void SchedulingInit() { if(!SchedulingInited) { MemoryInit(); TimeInit(); ControlRequests=1; CurrentTask=SystemTasks=NULL; ActiveScheduler=NullScheduler; InterruptVectorCount=0; SystemLock=LockCreate(); //CurrentSP=NULL; SchedulingInited=TRUE; } }
void TestChunkFile(void) { BeginTests(); FastFunctionsInit(); MemoryInit(); TestChunkFileSimple(); TestChunkFileMD5ing(); TestChunkFileNameing(); MemoryKill(); FastFunctionsKill(); TestStatistics(); }
void TestPackFilesPacker(void) { BeginTests(); FastFunctionsInit(); MemoryInit(); TestPackFilesPackerSimple(); TestPackFilesPackerCopyDir(); MemoryKill(); FastFunctionsKill(); TestStatistics(); }
void TestMapBlock(void) { BeginTests(); MemoryInit(); FastFunctionsInit(); TestMapBlockInternals(); TestMapBlockGet(); TestMapBlockAddDuplicate(); TestMapBlockRemove(); TestMapBlockReadWrite(); FastFunctionsKill(); MemoryKill(); TestStatistics(); }
void TestArrayTemplate(void) { BeginTests(); MemoryInit(); FastFunctionsInit(); TestMisc(); TestArrayAllocation(); TestArrayCopy(); TestArraySorting(); TestArrayRemove(); TestArrayFake(); FastFunctionsKill(); MemoryKill(); TestStatistics(); }
void TestEmbeddedObjectClass(void) { MemoryInit(); ObjectsInit(); CEmbeddedComplex cComplex; CPointer* pcPtr0; CPointer* pcPtr1; CPointer* pcPtr2; CPointer* pcPtr3; CPointer* pcPtr4; CPointer* pcPtr5; //Class not yet called. Always call Class. AssertInt(0, cComplex.GetNumFieldPointerTos()); AssertInt(1, cComplex.GetNumEmbedded()); cComplex.ClearFlagNumEmbedded(); cComplex.Class(); AssertInt(5, cComplex.GetNumFieldPointerTos()); AssertInt(6, cComplex.GetNumEmbedded()); pcPtr0 = cComplex.GetFieldPointerTo(0); pcPtr1 = cComplex.GetFieldPointerTo(1); pcPtr2 = cComplex.GetFieldPointerTo(2); pcPtr3 = cComplex.GetFieldPointerTo(3); pcPtr4 = cComplex.GetFieldPointerTo(4); pcPtr5 = cComplex.GetFieldPointerTo(5); AssertPointer(cComplex.mpTest.This(), pcPtr0); AssertPointer(cComplex.mcSimple.mpTest.This(), pcPtr1); AssertPointer(cComplex.mcContainer.mpTest.This(), pcPtr2); AssertPointer(cComplex.mcContainer.mcOne.mpTest.This(), pcPtr3); AssertPointer(cComplex.mcContainer.mcTwo.mpTest.This(), pcPtr4); AssertNull(pcPtr5); AssertInt(0, cComplex.GetFieldPointerToIndex(pcPtr0)); AssertInt(1, cComplex.GetFieldPointerToIndex(pcPtr1)); AssertInt(2, cComplex.GetFieldPointerToIndex(pcPtr2)); AssertInt(3, cComplex.GetFieldPointerToIndex(pcPtr3)); AssertInt(4, cComplex.GetFieldPointerToIndex(pcPtr4)); AssertInt(-1, cComplex.GetFieldPointerToIndex(NULL)); ObjectsKill(); MemoryKill(); }
void TestFiles(void) { BeginTests(); FastFunctionsInit(); TypeConverterInit(); MemoryInit(); TestFilesSimple(); TestFileSystemIteration(); TestFilesIteration(); TestGetFileNames(); TestFilesWholeDirectory(); MemoryKill(); FastFunctionsKill(); TypeConverterKill(); TestStatistics(); }
void TestFileUtil(void) { BeginTests(); MemoryInit(); FastFunctionsInit(); TestFileUtilRemoveExtension(); TestFileUtilFindExtension(); TestFileUtilNaming(); TestFileUtilMisc(); TestFileUtilMakeNameFromDirectory(); TestFileUtilMakeDirectory(); TestFileUtilRemoveLastFromPath(); TestFileUtilTouchDirectory(); TestFileUtilPrependToPath(); FastFunctionsKill(); MemoryKill(); TestStatistics(); }
void TestChannelsAccessor(void) { BeginTests(); MemoryInit(); TypesInit(); TypeConverterInit(); UnknownsInit(); TestChannelsAccessorContiguous(); TestChannelsAccessorByteAligned(); TestChannelsAccessorTypeConvert(); TestChannelsAccessorChannelBitty(); TestChannelsAccessorAccessBitty(); TestChannelsAccessorWorstCase(); UnknownsKill(); TypeConverterKill(); TypesKill(); MemoryKill(); TestStatistics(); }
void TestEmbeddedOjectIsAllocatedInObjects() { MemoryInit(); ObjectsInit(); Ptr<CClusterMissile> pClusterMissile = ONMalloc(CClusterMissile, "Gerbil")->Init(NULL); AssertTrue(pClusterMissile->IsAllocatedInObjects()); AssertTrue(pClusterMissile->mcMissile1.IsAllocatedInObjects()); AssertTrue(pClusterMissile->mcMissile2.IsAllocatedInObjects()); pClusterMissile = NULL; CClusterMissile cClusterMissile; cClusterMissile.Class(); cClusterMissile.Init(NULL); AssertFalse(cClusterMissile.IsAllocatedInObjects()); AssertFalse(cClusterMissile.mcMissile1.IsAllocatedInObjects()); AssertFalse(cClusterMissile.mcMissile2.IsAllocatedInObjects()); ObjectsKill(); MemoryKill(); }
void WriteObjectReaderSimpleFile(void) { MemoryInit(); ObjectsInit(); gcObjects.AddConstructor<CTestNamedString>(); CPointer cBase; CObjectWriterSimple cWriter; CObjectGraphSerialiser cGraphSerialiser; cBase = SetupObjectReaderSimpleFile(); cWriter.Init("Output\\ObjectReaderSimple\\Test\\", ""); cGraphSerialiser.Init(&cWriter); AssertTrue(cGraphSerialiser.Write(cBase.BaseObject())); cGraphSerialiser.Kill(); cWriter.Kill(); ObjectsKill(); MemoryKill(); }
void TestScratchPadAllocatorReadWrite(void) { MemoryInit(); CScratchPadAllocator cAlloc; CFileBasic cFile; CScratchPadAllocator cAllocIn; int i; SScratchPadParams sParams; cFile.Init(MemoryFile()); cFile.Open(EFM_ReadWrite_Create); cFile.WriteInt(789); cAlloc.Init(32 KB); AssertTrue(cAlloc.Write(&cFile)); cFile.WriteInt(124); cFile.Close(); cAlloc.Kill(); cFile.Open(EFM_Read); cFile.ReadInt(&i); AssertInt(789, i); AssertTrue(cAllocIn.Read(&cFile)); cFile.ReadInt(&i); AssertInt(124, i); AssertInt(0, cAllocIn.GetScratchPad()->GetMemorySize()); AssertInt(0, cAllocIn.GetScratchPad()->GetUsedSize()); cAllocIn.GetScratchPad()->GetParams(&sParams); AssertInt(32 KB, sParams.iChunkSize); MemoryKill(); }
void TestEmbeddedGetEmbeddedObject(void) { MemoryInit(); ObjectsInit(); CEmbeddedComplex cComplex; CEmbeddedObject* pcEmbedded; cComplex.Class(); cComplex.Init(); pcEmbedded = cComplex.GetEmbeddedObject(0); AssertPointer(&cComplex, pcEmbedded); pcEmbedded = cComplex.GetEmbeddedObject(1); AssertPointer(&cComplex.mcSimple, pcEmbedded); pcEmbedded = cComplex.GetEmbeddedObject(2); AssertPointer(&cComplex.ma, pcEmbedded); pcEmbedded = cComplex.GetEmbeddedObject(3); AssertPointer(&cComplex.mcContainer, pcEmbedded); pcEmbedded = cComplex.GetEmbeddedObject(4); AssertPointer(&cComplex.mcContainer.mcOne, pcEmbedded); pcEmbedded = cComplex.GetEmbeddedObject(5); AssertPointer(&cComplex.mcContainer.mcTwo, pcEmbedded); pcEmbedded = cComplex.GetEmbeddedObject(6); AssertNull(pcEmbedded); pcEmbedded = cComplex.mcSimple.GetEmbeddedObject(0); AssertPointer(&cComplex.mcSimple, pcEmbedded); pcEmbedded = cComplex.mcSimple.GetEmbeddedObject(1); AssertNull(pcEmbedded); pcEmbedded = cComplex.ma.GetEmbeddedObject(0); AssertPointer(&cComplex.ma, pcEmbedded); pcEmbedded = cComplex.ma.GetEmbeddedObject(1); AssertNull(pcEmbedded); ObjectsKill(); MemoryKill(); }
void test_MemoryAlloc() { MemoryInit((void *)pool, POOL_SIZE); ERROR(g_hunk_base == pool); ERROR(g_hunk_total_size == POOL_SIZE); I32 size = Align16(DYNAMIC_ZONE_SIZE + sizeof(HunkHeader)); ERROR(g_hunk_low_used == size); ERROR(g_hunk_high_used == 0); ERROR((U8 *)g_main_zone == pool + sizeof(HunkHeader)); ERROR(g_main_zone->rover == (MemoryBlock *)(g_main_zone + 1)); ERROR(g_main_zone->size == DYNAMIC_ZONE_SIZE); // ==================== // test hunk allocation // ==================== void *hunk0 = HunkLowAlloc(1231, "hunk0"); HunkHeader *hunk0Header = (HunkHeader *)hunk0 - 1; I32 hunk0Size = Align16(1231 + sizeof(HunkHeader)); ERROR(hunk0Header->size == hunk0Size); ERROR(hunk0Header->sentinel == HUNK_SENTINEL); ERROR(StringCompare(hunk0Header->name, "hunk0") == 0); ERROR(g_hunk_low_used == size + hunk0Size); void *hunk1 = HunkHighAlloc(3211, "hunk1"); HunkHeader *hunk1Header = (HunkHeader *)hunk1 - 1; I32 hunk1Size = Align16(3211 + sizeof(HunkHeader)); ERROR(hunk0Header->size == hunk0Size); ERROR(hunk0Header->sentinel == HUNK_SENTINEL); ERROR(StringCompare(hunk1Header->name, "hunk1") == 0); ERROR(g_hunk_high_used == hunk1Size); // ==================== // test zone allocation // ==================== void *zone0 = ZoneTagMalloc(234, 8); MemoryBlock *zone0Block = (MemoryBlock *)zone0 - 1; I32 zone0Size = Align8(234 + sizeof(MemoryBlock) + 4); ERROR(zone0Block->size == zone0Size); ERROR(zone0Block->tag == 8); ERROR(zone0Block->id == ZONE_ID); ERROR(zone0Block->prev == &g_main_zone->tailhead); MemoryBlock *freeBlock = zone0Block->next; ERROR(freeBlock->tag == 0); void *zone1 = ZoneTagMalloc(324, 1); void *zone2 = ZoneTagMalloc(432, 2); void *zone3 = ZoneTagMalloc(223, 3); void *zone4 = ZoneTagMalloc(333, 4); ZoneFree(zone1); MemoryBlock *zone1Block = (MemoryBlock *)zone1 - 1; I32 zone1Size = Align8(324 + sizeof(MemoryBlock) + 4); ERROR(zone1Block->tag == 0); ERROR(zone1Block->size == zone1Size); ERROR(zone1Block->id == ZONE_ID); ERROR(zone1Block->prev == (MemoryBlock *)zone0 - 1); ERROR(zone1Block->next == (MemoryBlock *)zone2 - 1); ZoneFree(zone3); MemoryBlock *zone3Block = (MemoryBlock *)zone3 - 1; I32 zone3Size = Align8(223 + sizeof(MemoryBlock) + 4); ERROR(zone3Block->tag == 0); ERROR(zone3Block->size == zone3Size); ERROR(zone3Block->id == ZONE_ID); ERROR(zone3Block->prev == (MemoryBlock *)zone2 - 1); ERROR(zone3Block->next == (MemoryBlock *)zone4 - 1); ZoneFree(zone2); I32 zone2Size = Align8(432 + sizeof(MemoryBlock) + 4); ERROR(zone1Block->tag == 0); ERROR(zone1Block->size == zone1Size + zone2Size + zone3Size); ERROR(zone1Block->prev == (MemoryBlock *)zone0 - 1); ERROR(zone1Block->next == (MemoryBlock *)zone4 - 1); void *tooBig = ZoneTagMalloc(DYNAMIC_ZONE_SIZE * 2, 22); ERROR(tooBig == NULL); ZoneClearAll(g_main_zone); ERROR(g_main_zone->tailhead.next == g_main_zone->rover); ERROR(g_main_zone->tailhead.prev == g_main_zone->rover); ERROR(g_main_zone->rover->next == &g_main_zone->tailhead); ERROR(g_main_zone->rover->next == &g_main_zone->tailhead); }
void main() { task* TI1; task* TI2; char* Data; char* Encoded; register unsigned int i; _asm; di ld sp,#0xffff ld a,#0x0 ld bc,#0x0 ld de,#0x0 ld hl,#0x0 ld ix,#0x0 ld iy,#0x0 _endasm; _SimWriteProtect((void*)0x0000, (void*)0x3fff); _SimPrintString("\n-------------------\n"); _SimPrintString("System reset\n"); _SimPrintString("-------------------\n"); IntsOff(); _SimPrintString("Interrupts disabled. Booting...\n"); TestMemory(); HardwareInit(); LocksInit(); SchedulingInit(); SupervisorMode(); TimeInit(); SystemInit(); MemoryInit(); //KeyboardInit(); //TapeInit(); ConsoleInit(); ConsoleWrite("LJL OS 0.1 FOR ZX SPECTRUM 48\n"); ConsoleWrite("\nCONSOLE OUTPUT\n\n"); /* TapeSave((void*)0x4000, (void*)0x5800); TapeLoad((void*)0x4000, (void*)0x5800); for(i=0; i<0x4000; i+=0x100) { ConsoleWrite("."); SaveBlock((void*)i); } Halt("Saved"); */ MainEntry=Task1; TI1=CreateTask(MainEntry, 100); MainEntry=Task2; TI2=CreateTask(MainEntry, 100); ConsoleWrite("TASKS CREATED\n"); SetScheduler(DefaultScheduler); ConsoleWrite("SCHEDULER SET\n"); Resume(); //ConsoleWrite("RESUMING\n"); //if(!IsMultitasking()) Halt("NOT MULTITASKING"); for(;;); Halt("SYSTEM SHUTDOWN"); }
Common::Error TinselEngine::run() { // Initialize backend if (getGameID() == GID_DW2) { #ifndef DW2_EXACT_SIZE initGraphics(640, 480, true); #else initGraphics(640, 432, true); #endif _screenSurface.create(640, 432, 1); } else { initGraphics(320, 200, false); _screenSurface.create(320, 200, 1); } g_system->getEventManager()->registerRandomSource(_random, "tinsel"); _console = new Console(); _scheduler = new Scheduler(); InitSysVars(); // init memory manager MemoryInit(); // load user configuration ReadConfig(); #if 1 // FIXME: The following is taken from RestartGame(). // It may have to be adjusted a bit CountOut = 1; RebootCursor(); RebootDeadTags(); RebootMovers(); resetUserEventTime(); RebootTimers(); RebootScalingReels(); DelayedScene.scene = HookScene.scene = 0; #endif // Load in text strings ChangeLanguage(g_language); // Init palette and object managers, scheduler, keyboard and mouse RestartDrivers(); // load in graphics info SetupHandleTable(); // Actors, globals and inventory icons LoadBasicChunks(); // Continuous game processes CreateConstProcesses(); // allow game to run in the background //RestartBackgroundProcess(); // FIXME: is this still needed? //dumpMusic(); // dumps all of the game's music in external XMIDI files // Load game from specified slot, if any // // TODO: We might want to think about properly taking care of possible // errors when loading the save state. if (ConfMan.hasKey("save_slot")) { if (loadGameState(ConfMan.getInt("save_slot")) == Common::kNoError) loadingFromGMM = true; } // Foreground loop uint32 timerVal = 0; while (!shouldQuit()) { assert(_console); if (_console->isAttached()) _console->onFrame(); // Check for time to do next game cycle if ((g_system->getMillis() > timerVal + GAME_FRAME_DELAY)) { timerVal = g_system->getMillis(); AudioCD.updateCD(); NextGameCycle(); } if (bRestart) { RestartGame(); bRestart = false; bHasRestarted = true; // Set restarted flag } // Save/Restore scene file transfers ProcessSRQueue(); // Handle any playing movie FettleBMV(); #ifdef DEBUG if (bFast) continue; // run flat-out #endif // Loop processing events while there are any pending while (pollEvent()) ; DoCdChange(); if (MoviePlaying() && NextMovieTime()) g_system->delayMillis(MAX<int>(NextMovieTime() - g_system->getMillis() + MovieAudioLag(), 0)); else g_system->delayMillis(10); } // Write configuration WriteConfig(); return Common::kNoError; }
void TestMemoryAllocatorReadWrite(void) { MemoryInit(); CMemoryAllocator cAlloc; CFileBasic cFile; CMemoryAllocator cAllocIn; int i; SMemoryParams sParams; SMemoryFreeListParams* psBlockParams; cFile.Init(MemoryFile()); cFile.Open(EFM_ReadWrite_Create); cFile.WriteInt(789); cAlloc.Init(16, FALSE); cAlloc.GetMemory()->AddParamBlock(24 , 16 , 32*32); cAlloc.GetMemory()->AddParamBlock(32 , 24 , 28*32); cAlloc.GetMemory()->AddParamBlock(40 , 32 , 24*32); AssertTrue(cAlloc.Write(&cFile)); cFile.WriteInt(124); cFile.Close(); cAlloc.Kill(); cFile.Open(EFM_Read); cFile.ReadInt(&i); AssertInt(789, i); AssertTrue(cAllocIn.Read(&cFile)); cFile.ReadInt(&i); AssertInt(124, i); AssertInt(16, cAllocIn.GetMemory()->ByteSize()); cAllocIn.GetMemory()->GetParams(&sParams); AssertInt(16, sParams.iDefaultAlignment); AssertInt(56, sParams.uiFreeListSizeLimit); AssertInt(3, sParams.iFreeListParams); psBlockParams = cAllocIn.GetMemory()->GetFreeListParams(0); AssertNotNull(psBlockParams); AssertInt(32*32, psBlockParams->iChunkSize); AssertInt(17, psBlockParams->iMinElementSize); AssertInt(24, psBlockParams->iMaxElementSize); psBlockParams = cAllocIn.GetMemory()->GetFreeListParams(1); AssertNotNull(psBlockParams); AssertInt(28*32, psBlockParams->iChunkSize); AssertInt(25, psBlockParams->iMinElementSize); AssertInt(32, psBlockParams->iMaxElementSize); psBlockParams = cAllocIn.GetMemory()->GetFreeListParams(2); AssertNotNull(psBlockParams); AssertInt(24*32, psBlockParams->iChunkSize); AssertInt(33, psBlockParams->iMinElementSize); AssertInt(40, psBlockParams->iMaxElementSize); psBlockParams = cAllocIn.GetMemory()->GetFreeListParams(3); AssertNull(psBlockParams); MemoryKill(); }
void TestDehollowficationFromDatabase(void) { CIndexedConfig cConfig; CFileUtil cFileUtil; cConfig.Manual("Output\\Dehollowfication\\Database", FALSE, TRUE, FALSE, 1 MB); cFileUtil.RemoveDir("Output\\Dehollowfication\\Database"); MemoryInit(); ObjectsInit(&cConfig); SetupDehollowficationScene(); gcObjects.Flush(FALSE, FALSE); ObjectsKill(); MemoryKill(); MemoryInit(); ObjectsInit(&cConfig); SetupDehollowficationConstructors(); AssertLongLongInt(0, gcUnknowns.NumElements()); AssertInt(0, gcObjects.GetStackPointers()->UsedPointers()); AssertLongLongInt(0, gcObjects.NumMemoryIndexes()); AssertLongLongInt(0, gcObjects.NumMemoryNames()); AssertLongLongInt(11, gcObjects.NumDatabaseObjects()); AssertLongLongInt(0, gcObjects.NumDatabaseObjectsCached()); AssertLongLongInt(6, gcObjects.NumDatabaseNames()); Ptr<CRoot> pRoot = ORoot(); AssertTrue(pRoot->IsSetHollow()); AssertLongLongInt(2, gcUnknowns.NumElements()); AssertLongLongInt(2, gcObjects.NumMemoryIndexes()); AssertLongLongInt(1, gcObjects.NumMemoryNames()); AssertLongLongInt(1, gcObjects.NumDatabaseObjectsCached()); AssertLongLongInt(6, gcObjects.NumDatabaseNames()); AssertInt(1, gcObjects.GetStackPointers()->UsedPointers()); Ptr<CTestDoubleNamedString> pTest = pRoot->Get<CTestDoubleNamedString>("Double Start"); //This will cause pRoot.Set to be dehollowed. AssertInt(2, gcObjects.GetStackPointers()->UsedPointers()); AssertFalse(pRoot->IsSetHollow()); AssertTrue(pTest.IsNotNull()); AssertTrue(pTest.IsHollow()); AssertLongLongInt(10, pTest.GetIndex()); AssertLongLongInt(4, gcUnknowns.NumElements()); AssertLongLongInt(4, gcObjects.NumMemoryIndexes()); AssertString("12345", pTest->mpSplit1->mszEmbedded.Text()); //This will cause pTest and pTest.Split1 to be dehollowed. AssertLongLongInt(9, gcUnknowns.NumElements()); AssertLongLongInt(9, gcObjects.NumMemoryIndexes()); AssertFalse(pTest.IsHollow()); AssertLongLongInt(10, pTest.GetIndex()); AssertInt(2, gcObjects.GetStackPointers()->UsedPointers()); AssertTrue(pTest->mpSplit1->mpAnother.IsHollow()); AssertTrue(pTest->mpSplit2.IsHollow()); AssertTrue(pTest->mpSplit1->mszString.IsHollow()); AssertString("Diamond End", pTest->mpSplit1->mpAnother.GetName()); AssertString("6789", pTest->mpSplit1->mszString->Text()); AssertFalse(pTest->mpSplit1->mszString.IsHollow()); AssertInt(2, gcObjects.GetStackPointers()->UsedPointers()); Ptr<CTestNamedString> pDiamond = pTest->mpSplit1->mpAnother; AssertLongLongInt(9, gcUnknowns.NumElements()); AssertLongLongInt(9, gcObjects.NumMemoryIndexes()); AssertInt(3, gcObjects.GetStackPointers()->UsedPointers()); AssertTrue(pTest->mpSplit1->mpAnother.IsHollow()); AssertTrue(pDiamond.IsHollow()); pDiamond->ClassName(); //This will cause pDiamond to be de-hollowed AssertFalse(pDiamond.IsHollow()); AssertFalse(pTest->mpSplit1->mpAnother.IsHollow()); AssertLongLongInt(10, gcUnknowns.NumElements()); AssertLongLongInt(10, gcObjects.NumMemoryIndexes()); AssertLongLongInt(6, gcObjects.NumMemoryNames()); AssertLongLongInt(3, gcObjects.NumDatabaseObjectsCached()); AssertLongLongInt(6, gcObjects.NumDatabaseNames()); AssertTrue(pTest->mpSplit2.IsHollow()); pTest->mpSplit2->ClassSize(); AssertFalse(pTest->mpSplit2.IsHollow()); AssertFalse(pTest->mpSplit2->mpAnother.IsHollow()); AssertPointer(pDiamond.Object(), pTest->mpSplit2->mpAnother.Object()); AssertLongLongInt(11, gcObjects.NumMemoryIndexes()); AssertLongLongInt(6, gcObjects.NumMemoryNames()); AssertLongLongInt(2, gcObjects.NumDatabaseObjectsCached()); AssertLongLongInt(6, gcObjects.NumDatabaseNames()); Ptr<CTestNamedString> pRandom = pRoot->Get<CTestNamedString>("NamedString 3"); AssertTrue(pRandom.IsNotNull()); AssertTrue(pRandom.IsHollow()); AssertTrue(pRandom->mszString.IsHollow()); AssertFalse(pRandom.IsHollow()); AssertTrue(pTest->mpSplit2->mszString.IsHollow()); AssertString("World", pRandom->mszString->Text()); AssertFalse(pRandom->mszString.IsHollow()); AssertFalse(pTest->mpSplit2->mszString.IsHollow()); AssertPointer(pRandom->mszString.Object(), pTest->mpSplit2->mszString.Object()); AssertLongLongInt(11, gcObjects.NumDatabaseObjects()); ObjectsKill(); AssertTrue(pRoot.IsNull()); AssertTrue(pTest.IsNull()); AssertTrue(pDiamond.IsNull()); AssertTrue(pRandom.IsNull()); pDiamond.UnsafeClearObject(); MemoryKill(); }