////////// // // Top level for running test cases against the current system. // Attempts to load each plugin in turn, vvmt_core.dll first, then all other DLLs. // ////// void ivvm_runTestPlugins(void) { u64 lnHandle; ////////// // Prepare the test results file ////// lnHandle = oss_sharedAsciiOpenFile((s8*)cgcVvmTestLogFile, true, false, true, true, false, true, false, false); if (!lnHandle) { // The log file is an essential, integral component of testing. We cannot leave it out. oss_messageBox(NULL, "Unable to open log file for test results. Terminating.", "Test Failure", false, false, false, false, true); return; } ////////// // Run the tests, core first, then all other tests ////// // vvmt_core.dll -- the core test must be run first and must pass, or the other tests cannot run if (ivvm_loadTestsByName(lnHandle, _csu8p(cgcVvmTestsDirectory)/*.\tests\*/, _csu8p(cgcVvmTestCoreDll)/*vvmt_core.dll*/, _csu8p_NULL())) { // *.dll -- all other tests, but don't run vvmt_core.dll again ivvm_loadTestsByName(lnHandle, _csu8p(cgcVvmTestsDirectory)/*.\tests\*/, _csu8p(cgcVvmTestFilePattern)/**.dll*/, _csu8p(cgcVvmTestCoreDll)/*exclude this test*/); } }
////////// // // Assembles the indicated file.vasm, creating a file.bxml // ////// void iAssembleFile(s8* tcPathname) { u32 lnI, lnMachineCodeBytes, lnErrorCount, lnWarningCount; s64 lnHandle, lnFileSize, lnNumread; s8* lcData; s8* lcBxmlPathname; SStartEnd prog; SProgram* lp; // program SVvmmcError* lve; // error SVvmmcWarning* lvw; // warning SAssembly* la; // assembly info SSourceFile* lsf; // top-level source file // Attempt to open the file lnHandle = oss_sharedAsciiOpenFile(tcPathname, false, true, false, false, false, false, false, false); if (lnHandle < 0) { // Open file error printf(mc_loadResourceAsciiText(IDS_UNABLE_TO_OPEN), tcPathname); ++gnErrors; return; } // If we get here, we're good // Get file size lnFileSize = oss_sharedAsciiFileSize(lnHandle); if (lnFileSize > 0xffffffff) { // Uhhh... what are they trying to do to us? :-) printf(mc_loadResourceAsciiText(IDS_FILE_IS_TOO_BIG), tcPathname); ++gnErrors; return; } if (lnFileSize == 0) { printf(mc_loadResourceAsciiText(IDS_FILE_IS_ZERO_BYTES), tcPathname); ++gnErrors; return; } // Allocate memory to load lcData = (s8*)oss_alloc((u32)lnFileSize, false); if (!lcData) { printf(mc_loadResourceAsciiText(IDS_ERROR_ALLOCATING), lnFileSize, tcPathname); ++gnErrors; return; } // If we get here, memory is allocated // Read into it lnNumread = oss_sharedAsciiReadFile(lnHandle, lcData, (u32)lnFileSize); if (lnNumread != lnFileSize) { printf(mc_loadResourceAsciiText(IDS_UNABLE_TO_READ_BYTES_FROM), (u32)lnFileSize, tcPathname, lnNumread); ++gnErrors; return; } // We're good oss_sharedAsciiCloseFile(lnHandle); // Initialize our variables memset(&prog, 0, sizeof(prog)); // Define this initial program to its default empty state lp = (SProgram*)vvm_SEChain_append(&prog, vvm_getNextUniqueId(), vvm_getNextUniqueId(), sizeof(SProgram), _COMMON_START_END_SMALL_BLOCK_SIZE, NULL); printf(mc_loadResourceAsciiText(IDS_ASSEMBLING), tcPathname); ////////// // Physically translate into machine code, and the output bxml file ////// lnMachineCodeBytes = mc_assembleSourceCode(tcPathname, lcData, (u32)lnFileSize, lp); // When we get here, we've assembled our source file, with warnings, errors, or whatever // Free up our processed memory oss_free(lcData); // See where we sit if (!lp->_assembly.root) { // A fatal, unrecoverable error occurred where we didn't even get the initial startup data allocated printf(mc_loadResourceAsciiText(IDS_UNRECOVERABLE_ERROR)); ++gnErrors; return; } // We're good. // Grab the top-level file info la = (SAssembly*)lp->_assembly.root->ptr; // SAssembly information lsf = (SSourceFile*)la->includeFiles.root->ptr; // Top-level source file (which contains the master list of all errors, warnings, and source file lines) // Report on warnings and errors if (!glQuiet) { // Report warnings if (!glIgnoreWarnings) { lnWarningCount = 0; for (lnI = 0; lnI < lsf->warnings.masterCount; lnI++) { if (lsf->warnings.master[lnI] && lsf->warnings.master[lnI]->used) { // Grab the warning data lvw = (SVvmmcWarning*)lsf->warnings.master[lnI]->ptr; printf("--- %s\n--- |W:%u L:%u C:%u - %s\n", lvw->pathName, lvw->code, lvw->lineNumber, lvw->column, lvw->text); ++lnWarningCount; } } } // Report errors lnErrorCount = 0; for (lnI = 0; lnI < lsf->errors.masterCount; lnI++) { if (lsf->errors.master[lnI] && lsf->errors.master[lnI]->used) { // Grab the warning data lve = (SVvmmcError*)lsf->errors.master[lnI]->ptr; printf("--- %s\n--- |E:%u L:%u C:%u - %s\n", lve->pathName, lve->code, lve->lineNumber, lve->column, lve->text); ++lnErrorCount; } } } // Write the output lcBxmlPathname = oss_changePathnameExtension(tcPathname, ".bxml"); mc_saveSnippetsToBxml(lcBxmlPathname, &prog, true); oss_free(lcBxmlPathname); // Indicate we've processed another file ++gnFilesProcessed; // Indicate our final status printf("---\n"); printf(mc_loadResourceAsciiText(IDS_ERRORS_WARNINGS_FOUND), lsf->errors.masterCount, lsf->warnings.masterCount, tcPathname); printf("---\n"); // Update global totals gnErrors += lnErrorCount; gnWarnings += lnWarningCount; }