static int _testLoadPluginWithAbsolutePath(const char *testName, const CharString applicationPath, const CharString resourcesPath) { File resourcesFile = newFileWithPath(resourcesPath); CharString vstDirName = newCharStringWithCString("vst"); File vstFile = newFileWithParent(resourcesFile, vstDirName); freeFile(resourcesFile); freeCharString(vstDirName); PlatformInfo platformInfo = newPlatformInfo(); CharString platformDirName = newCharStringWithCString(_getPlatformVstDirName(platformInfo)); File vstPlatformFile = newFileWithParent(vstFile, platformDirName); freeCharString(platformDirName); freePlatformInfo(platformInfo); freeFile(vstFile); CharString vstPluginName = newCharStringWithCString("again"); charStringAppendCString(vstPluginName, _getVst2xPlatformExtension()); File pluginFile = newFileWithParent(vstPlatformFile, vstPluginName); freeCharString(vstPluginName); freeFile(vstPlatformFile); CharString inputPath = getDefaultInputPath(resourcesPath); int result = runIntegrationTest( testName, buildTestArgumentString("--plugin \"%s\" --input \"%s\"", pluginFile->absolutePath->data, inputPath->data), RETURN_CODE_SUCCESS, kTestOutputPcm, applicationPath, resourcesPath); freeCharString(inputPath); freeFile(pluginFile); return result; }
static CharString _getDefaultArguments(const char *testName, const CharString resourcesPath, const CharString outputFilename) { CharString outString = newCharStringWithCapacity(kCharStringLengthLong); CharString logfileName = getTestOutputFilename(testName, kTestOutputText); CharString pluginRootPath = _getTestPluginResourcesPath(resourcesPath); snprintf(outString->data, outString->capacity, "--log-file \"%s\" --verbose --plugin-root \"%s\"", logfileName->data, pluginRootPath->data); if (outputFilename != NULL) { charStringAppendCString(outString, " --output \""); charStringAppend(outString, outputFilename); charStringAppendCString(outString, "\""); } freeCharString(logfileName); freeCharString(pluginRootPath); return outString; }
static void printWelcomeMessage(int argc, char** argv) { CharString stringBuffer = newCharString(); CharString versionString = buildInfoGetVersionString(); char* space; int i; logInfo("%s initialized, build %ld", versionString->data, buildInfoGetDatestamp()); // Recycle to use for the platform name freeCharString(stringBuffer); freeCharString(versionString); if(isExecutable64Bit()) { logWarn("Running in 64-bit mode, this is experimental. Hold on to your hats!"); } // Prevent a bunch of silly work in case the log level isn't debug if(isLogLevelAtLeast(LOG_DEBUG)) { stringBuffer = getPlatformName(); logDebug("Host platform is %s (%s)", getShortPlatformName(), stringBuffer->data); logDebug("Application is %d-bit", isExecutable64Bit() ? 64 : 32); freeCharString(stringBuffer); stringBuffer = newCharString(); for(i = 1; i < argc; i++) { space = strchr(argv[i], ' '); if(space != NULL) { charStringAppendCString(stringBuffer, "\""); } charStringAppendCString(stringBuffer, argv[i]); if(space != NULL) { charStringAppendCString(stringBuffer, "\""); } charStringAppendCString(stringBuffer, " "); } logDebug("Launched with options: %s", stringBuffer->data); freeCharString(stringBuffer); } }
int runIntegrationTest(const char *testName, CharString testArguments, ReturnCode expectedResultCode, const TestOutputType testOutputType, const CharString mrsWatsonExePath, const CharString resourcesPath) { int result = 0; int returnCode; ReturnCode resultCode; ChannelCount failedAnalysisChannel; SampleCount failedAnalysisFrame; #if WINDOWS STARTUPINFOA startupInfo; PROCESS_INFORMATION processInfo; #endif // Remove files from a previous test run File outputFolder = newFileWithPathCString(kApplicationRunnerOutputFolder); if (fileExists(outputFolder)) { _removeOutputFiles(testName); } else { fileCreate(outputFolder, kFileTypeDirectory); } freeFile(outputFolder); if (mrsWatsonExePath == NULL) { return -1; } else { File mrsWatsonExe = newFileWithPath(mrsWatsonExePath); boolByte mrsWatsonExeExists = fileExists(mrsWatsonExe); freeFile(mrsWatsonExe); if (!mrsWatsonExeExists) { freeCharString(testArguments); return -1; } } if (resourcesPath == NULL) { freeCharString(testArguments); return -1; } else { File resourcesFile = newFileWithPath(resourcesPath); boolByte resourcesExists = fileExists(resourcesFile); freeFile(resourcesFile); if (!resourcesExists) { freeCharString(testArguments); return -1; } } // Create the command line argument CharString arguments = newCharStringWithCapacity(kCharStringLengthLong); charStringAppendCString(arguments, "\""); charStringAppend(arguments, mrsWatsonExePath); charStringAppendCString(arguments, "\""); charStringAppendCString(arguments, " "); CharString defaultArguments; CharString outputFilename = getTestOutputFilename(testName, testOutputType); defaultArguments = _getDefaultArguments(testName, resourcesPath, outputFilename); charStringAppend(arguments, defaultArguments); freeCharString(defaultArguments); charStringAppendCString(arguments, " "); charStringAppend(arguments, testArguments); // Although testArguments is passed into this function (and hence, it would // generally not take ownership of it), in this case we free the arguments // here to make writing the test cases simpler and reduce the amount of // boilerplate code. freeCharString(testArguments); #if WINDOWS memset(&startupInfo, 0, sizeof(startupInfo)); memset(&processInfo, 0, sizeof(processInfo)); startupInfo.cb = sizeof(startupInfo); returnCode = CreateProcessA( (LPCSTR)(mrsWatsonExePath->data), (LPSTR)(arguments->data), 0, 0, false, CREATE_DEFAULT_ERROR_MODE, 0, 0, &startupInfo, &processInfo); if (returnCode) { // TODO: Check return codes for these calls WaitForSingleObject(processInfo.hProcess, kApplicationRunnerWaitTimeoutInMs); GetExitCodeProcess(processInfo.hProcess, (LPDWORD)&resultCode); CloseHandle(processInfo.hProcess); CloseHandle(processInfo.hThread); } else { logCritical("Could not launch process, got error %s", stringForLastError(GetLastError())); return 1; } #else returnCode = system(arguments->data); resultCode = (ReturnCode)WEXITSTATUS(returnCode); #endif freeCharString(arguments); if (resultCode == RETURN_CODE_FORK_FAILED || resultCode == RETURN_CODE_SHELL_FAILED || resultCode == RETURN_CODE_LAUNCH_FAILED_OTHER) { logCritical("Could not launch shell, got return code %d\n\ Please check the executable path specified in the --mrswatson-path argument.", resultCode); return 1; } else if (resultCode == expectedResultCode) { CharString failedAnalysisFunctionName = newCharString(); if (testOutputType != kTestOutputNone) { if (analyzeFile(outputFilename->data, failedAnalysisFunctionName, &failedAnalysisChannel, &failedAnalysisFrame)) { // TODO: // if (!testEnvironment->results->keepFiles) { // _removeOutputFiles(testName); // } result = 0; } else { fprintf(stderr, "Audio analysis check for %s failed at frame %lu, channel %d. ", failedAnalysisFunctionName->data, failedAnalysisFrame, failedAnalysisChannel); result = 1; } } else { result = 0; // TODO: // if (!testEnvironment->results->keepFiles) { // _removeOutputFiles(testName); // } } freeCharString(failedAnalysisFunctionName); } else { fprintf(stderr, "Expected result code %d (%s), got %d (%s). ", expectedResultCode, _getResultCodeString(expectedResultCode), resultCode, _getResultCodeString(resultCode)); result = 1; } freeCharString(outputFilename); return result; }
void charStringAppend(CharString self, const CharString string) { charStringAppendCString(self, string->data); }