Esempio n. 1
0
void go(void)
{
	GFLW_LIBRARY::Initialise(); 
	GFLW_LIBRARY::EnableLZW(GFL_TRUE); 
	
	GFLW_FORMAT
		format; 
	GFL_ERROR
		ret; 

	format.FindByName("jpeg"); 
	PrintInfo(format); 
	format.FindByFilename("toto.tif"); 
	PrintInfo(format); 
	format.FindByIndex(10); 
	PrintInfo(format); 
	
	ret = GFLW_FORMAT::FindFirst(format); 
	while ( ret == GFL_NO_ERROR )
	{
		ret = GFLW_FORMAT::FindNext(format); 
		PrintInfo(format); 
	}

	GetInfo( DIR"test1" ); 
	TestFile( DIR"test1", DIR"test1.bmp", -1 ); 
	GetInfo( DIR"test1.bmp" ); 
	TestFile( DIR"test2", DIR"test2.bmp", -1 ); 
	GetInfo( DIR"test2.bmp" ); 
	
	GetInfo( DIR"test3" ); 
	TestFile( DIR"test3", DIR"test3.bmp", GFLW_FORMAT("jpeg").GetIndex() ); 
	GetInfo( DIR"test2.bmp" ); 
	TestFile( DIR"test4", DIR"test.bmp", -1 ); 
	
	Test2File( DIR"test2", DIR"test4.bmp", GFLW_FORMAT("bmp").GetIndex() ); 
	GetInfo( DIR"test4.bmp" ); 
	
	Test3File( DIR"test2", DIR"test5.bmp", GFLW_FORMAT("bmp").GetIndex() ); 
	GetInfo( DIR"test5.bmp" ); 
	
	Test4File( DIR"test2", DIR"test6.jpg", GFLW_FORMAT("jpeg").GetIndex(), 5 ); 
	Test4File( DIR"test2", DIR"test7.jpg", GFLW_FORMAT("jpeg").GetIndex(), 80 ); 
	
	Test5File( DIR"test2", DIR"test10.gif", GFLW_FORMAT("gif").GetIndex(), GFL_MODE_TO_BINARY, GFL_MODE_FLOYD_STEINBERG ); 
	Test5File( DIR"test2", DIR"test11.gif", GFLW_FORMAT("gif").GetIndex(), GFL_MODE_TO_64GREY, GFL_MODE_PATTERN_DITHER ); 
	Test5File( DIR"test2", DIR"test12.gif", GFLW_FORMAT("gif").GetIndex(), GFL_MODE_TO_64GREY, GFL_MODE_ADAPTIVE ); 
	Test5File( DIR"test2", DIR"test13.gif", GFLW_FORMAT("gif").GetIndex(), GFL_MODE_TO_216COLORS, GFL_MODE_PATTERN_DITHER ); 
	Test5File( DIR"test2", DIR"test14.gif", GFLW_FORMAT("gif").GetIndex(), GFL_MODE_TO_216COLORS, GFL_MODE_ADAPTIVE ); 
	Test5File( DIR"test10.gif", DIR"test15.jpg", GFLW_FORMAT("jpeg").GetIndex(), GFL_MODE_TO_RGB, 0 ); 
	
	Test6File( DIR"test1", DIR"test16.png" ); 

	Test7File( "jpeg" ); 

	Test8File(); 

	GFLW_LIBRARY::Exit(); 
}
Esempio n. 2
0
void TestLargeImagePerformance()
{

	TestFile("test/rgb8bit/artificial.ppm", 17, Size(3072,2048),  8, 3);
	TestFile("test/rgb8bit/bridge.ppm", 17, Size(2749,4049),  8, 3);
	TestFile("test/rgb8bit/flower_foveon.ppm", 17, Size(2268,1512),  8, 3);
	//TestFile("test/rgb8bit/big_building.ppm", 17, Size(7216,5412),  8, 3);
	//	TestFile("test/rgb16bit/bridge.ppm", 19, Size(2749,4049),  16, 3, true);
}
Esempio n. 3
0
void TestPerformance()
{
	TestFile("test/bad.raw", 0, Size(512, 512),  8, 1);

	// RGBA image (This is a common PNG sample)
	TestFile("test/alphatest.raw", 0, Size(380, 287),  8, 4);

	Size size1024 = Size(1024, 1024);
	Size size512 = Size(512, 512);

	// 16 bit mono
	TestFile("test/MR2_UNC", 1728, size1024,  16, 1, true);

	// 8 bit mono
	TestFile("test/0015.raw", 0, size1024,  8, 1);
	TestFile("test/lena8b.raw", 0, size512,  8, 1);


	// 8 bit color
	TestFile("test/desktop.ppm", 40, Size(1280,1024),  8, 3);

	// 12 bit RGB
	TestFile("test/SIEMENS-MR-RGB-16Bits.dcm", -1, Size(192,256),  12, 3, true);
	TestFile16BitAs12("test/DSC_5455.raw", 142949, Size(300,200), 3, true);

	// 16 bit RGB
	TestFile("test/DSC_5455.raw", 142949, Size(300,200),  16, 3, true);
}
Esempio n. 4
0
static bool TestCombinedFile(const std::string& inputPath, ETargetVersion version, bool checkGL)
{
	std::string outname = inputPath.substr (0,inputPath.size()-7);
	std::string frag_out, vert_out;
	
	if (version == ETargetGLSL_ES_100) {
		vert_out = outname + "-vertex-outES.txt";
		frag_out = outname + "-fragment-outES.txt";
	} else {
		vert_out = outname + "-vertex-out.txt";
		frag_out = outname + "-fragment-out.txt";
	}
	
	bool res = TestFile(VERTEX, inputPath, vert_out, "vs_main", version, 0, checkGL);
	return res & TestFile(FRAGMENT, inputPath, frag_out, "ps_main", version, 0, checkGL);
}
Esempio n. 5
0
int TestDirectory(char *dir, char *picoc)
{
	char pattern[MAX_PATH];
	WIN32_FIND_DATA findData;
	HANDLE h;
	int errorCount = 0;
	int dirLen = (int) strlen(dir);

	// Make sure the dir has a trailing slash, then add "*.*" to it.
	strcpy(pattern, dir);
	if (pattern[dirLen - 1] != '\\' && pattern[dirLen - 1] != '/')
	{
		strcpy(pattern + dirLen, "\\*.*");
		++dirLen;
	}
	else
	{
		strcpy(pattern + dirLen, "*.*");
	}

	// Go through all the files in the directory
	h = FindFirstFile(pattern, &findData);
	if (h != INVALID_HANDLE_VALUE)
	{
		do
		{
			// If we find a subdirectory, recurse into it
			if ((findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0)
			{
				if (findData.cFileName[0] != '.')
				{
					strcpy(pattern + dirLen, findData.cFileName);
					errorCount += TestDirectory(pattern, picoc);
				}
			}
			// Else (not a subdirectory)
			else
			{
				// If it's a .c file
				int fileNameLen = (int) strlen(findData.cFileName);
				if (_stricmp(findData.cFileName + fileNameLen - 2, ".c") == 0)
				{
					// Run it through PicoC and check the results
					strcpy(pattern + dirLen, findData.cFileName);
					errorCount += TestFile(pattern, picoc);
				}
			}

		} while (FindNextFile(h, &findData));
		FindClose(h);
	}

	return errorCount;
}
Esempio n. 6
0
int main()
 {
    std::string word;
    std::vector<std::string> WordVector;
    std::vector<std::string> ReversedWordVector;

    //Reverse the initial text file
    std::ifstream input_file("TheReverseWordTest.txt", std::ios_base::binary);
    std::ofstream output_file("TheReverseWordTest_reversed.txt", std::ios_base::binary);
    std::istreambuf_iterator<char> input_begin(input_file);
    std::istreambuf_iterator<char> input_end;
    std::ostreambuf_iterator<char> output_begin(output_file);
    std::vector<char> input_data(input_begin, input_end);
    std::reverse_copy(input_data.begin(), input_data.end(), output_begin);
    input_file.close();
    output_file.close();
    
    //Construct a vector of words
    std::ifstream TestFile("TheReverseWordTest.txt");
    while (TestFile >> word) {
        WordVector.push_back(word);
    }
    TestFile.close();
    
    //Construct a vector of reversed words
    std::ifstream ReversedFile("TheReverseWordTest_reversed.txt");
    while (ReversedFile >> word) {
        ReversedWordVector.push_back(word);
    }
    ReversedFile.close();
    
    // Allocate space for intersection
    std::vector<std::string> IntersectionVector;
    // Sort as required by std::set_intersection
    std::sort(WordVector.begin(), WordVector.end());
    std::sort(ReversedWordVector.begin(), ReversedWordVector.end());
    // Compute the set intersection
    std::set_intersection(WordVector.begin(), WordVector.end(), ReversedWordVector.begin(), ReversedWordVector.end(), std::back_inserter(IntersectionVector));
    
    
  
    std::ofstream myfile;
    myfile.open ("uniquepairs.txt");
    

    
    for (std::string n : IntersectionVector)
        myfile<< n << std::endl;
    
    myfile.close();
    return 0;

}
Esempio n. 7
0
int main( int argc, char **argv )
{
  int     algo, arg, verbose;
  char    *filename;

  /* Check arguments */
  if( (argc < 3) || (argc > 4) )
  {
    Help( argv[ 0 ] );
    return 0;
  }
  arg = 1;

  /* Check for options */
  verbose = 0;
  if( strcmp( argv[arg], "-v" ) == 0 )
  {
    verbose = 1;
    ++ arg;
  }

  /* Get algo */
  algo = 0;
  if( strcmp( argv[arg], "rle" ) == 0 )     algo = 1;
  if( strcmp( argv[arg], "huff" ) == 0 )    algo = 2;
  if( strcmp( argv[arg], "rice8" ) == 0 )   algo = 3;
  if( strcmp( argv[arg], "rice16" ) == 0 )  algo = 4;
  if( strcmp( argv[arg], "rice32" ) == 0 )  algo = 5;
  if( strcmp( argv[arg], "rice8s" ) == 0 )  algo = 6;
  if( strcmp( argv[arg], "rice16s" ) == 0 ) algo = 7;
  if( strcmp( argv[arg], "rice32s" ) == 0 ) algo = 8;
  if( strcmp( argv[arg], "lz" ) == 0 )      algo = 9;
  if( strcmp( argv[arg], "lz_f" ) == 0 )    algo = 10;
  if( strcmp( argv[arg], "sf" ) == 0 )      algo = 11;
  if( !algo )
  {
    Help( argv[ 0 ] );
    return 0;
  }
  ++ arg;

  /* Get file name */
  filename = argv[arg];

  /* Initialize timer */
  InitTimer();

  /* Test file */
  TestFile( filename, algo, verbose );

  return 0;
}
static void TestRead()
{
  mitk::NavigationToolReader::Pointer myReader = mitk::NavigationToolReader::New();
  mitk::NavigationTool::Pointer readTool = myReader->DoRead("TestTool.tool");
  MITK_TEST_OUTPUT(<<"---- Testing navigation tool reader with first test tool (claron tool) ----");

  //Test if the surfaces do have the same number of vertexes (it would be better to test for real equality of the surfaces!)
  MITK_TEST_CONDITION_REQUIRED(dynamic_cast<mitk::Surface*>(readTool->GetDataNode()->GetData())->GetSizeOfPolyDataSeries()==m_testSurface->GetSizeOfPolyDataSeries(),"Test if surface was restored correctly ...");

  MITK_TEST_CONDITION_REQUIRED(readTool->GetType()==mitk::NavigationTool::Fiducial,"Testing Tool Type");

  MITK_TEST_CONDITION_REQUIRED(readTool->GetTrackingDeviceType()==mitk::ClaronMicron,"Testing Tracking Device Type");

  MITK_TEST_CONDITION_REQUIRED(readTool->GetSerialNumber()=="0815","Testing Serial Number");

  std::ifstream TestFile(readTool->GetCalibrationFile().c_str());
  MITK_TEST_CONDITION_REQUIRED(TestFile,"Testing If Calibration File Exists");

}
Esempio n. 9
0
static KpBool_t TestFileCB(KpfileDirEntry_t FAR *fileSearch,
                           Limits_t                 *Limits)
{
SpCallerId_t		CallerId = Limits->CallerId;
SpSearch_t		*SearchCriterion = Limits->SearchCriterion;
SpProfile_t		*profileList = Limits->profileList;
KpInt32_t		listSize = Limits->listSize;
KpInt32_t		*CurrentIndex = &(Limits->CurrentIndex);
KpBool_t		Result;
SpStatus_t		*RetStatus = &(Limits->RetStatus);
KpInt32_t		GetALL = Limits->GetALL;

/* This call back is for a search 
   of profiles in the directory.   */

Result = TestFile(fileSearch,
		  CallerId, RetStatus, SearchCriterion, profileList,
		  listSize, GetALL, CurrentIndex);
return Result;
}
Esempio n. 10
0
int main(int argc, char* argv[])
{
	if ( argc < 2 )
	{
		printf("Usage: test_binaries <FILENAME>\n" );
	}
	else
	{
		char fileName[2048], dir[2048];
		if ( !Q_ExtractFilePath( argv[1], dir, sizeof( dir ) ) )
		{
			strcpy( dir, "" );
		}
		else
		{
			Q_FixSlashes( dir, '/' );
			int len = strlen(dir);
			if ( len && dir[len-1] !='/' )
			{
				strcat( dir, "/" );
			}
		}
		
		WIN32_FIND_DATA findData;
		HANDLE hFind = FindFirstFile( argv[1], &findData );
		if ( hFind == INVALID_HANDLE_VALUE )
		{
			printf("Can't find %s\n", argv[1] );
		}
		else
		{
			do
			{
				sprintf( fileName, "%s%s", dir, findData.cFileName );
				TestFile( fileName );
			} while ( FindNextFile( hFind, &findData ) );
			FindClose( hFind );
		}
	}
	return 0;
}
Esempio n. 11
0
static bool TestFile (TestRun type,
					  const std::string& inputPath,
					  ETargetVersion version,
					  unsigned options,
					  bool checkGL)
{
	std::string outname = inputPath.substr (0,inputPath.size()-7);

	const char* suffix = "-out.txt";
	if (version == ETargetGLSL_ES_100)
		suffix = "-outES.txt";
	else if (version == ETargetGLSL_ES_300)
		suffix = "-outES3.txt";
	else if (options & ETranslateOpEmitGLSL120ArrayInitWorkaround)
		suffix = "-out120arr.txt";
	
	if (type == VERTEX_FAILURES || type == FRAGMENT_FAILURES) {
		return TestFileFailure(type, inputPath, outname + suffix);
	} else {
		return TestFile(type, inputPath, outname + suffix, "main", version, options, checkGL);
	}
	return false;
}
Esempio n. 12
0
/*----------------------------------------------------------------------
|       main
+---------------------------------------------------------------------*/
int
main(int argc, char** argv)
{
    // setup debugging
#if defined(_WIN32) && defined(_DEBUG) && !defined(UNDER_CE)
    int flags = _crtDbgFlag       | 
        _CRTDBG_ALLOC_MEM_DF      |
        _CRTDBG_DELAY_FREE_MEM_DF |
        _CRTDBG_CHECK_ALWAYS_DF;

    _CrtSetDbgFlag(flags);
    //AllocConsole();
    //freopen("CONOUT$", "w", stdout);
#endif 

    // check args
    if (argc == 2) {
        TestFile(argv[1]);
        return 0;
    }

    TestRegression();
    TestComments();
    TestCdata();
    TestWhitespace();
    TestAttributes();
    TestAttributeNormalization();
    TestNamespaces();
    TestSerializer();
    TestMakeStandalone();
    TestCanonicalizer();
    TestFinders();
    TestWriter();
    TestBadInput();
    
    return 0;
}
Esempio n. 13
0
void WriteOutputFile (const char*	outputFilePath, 
					OSType			dataFormat, 
					Float64			srate, 
					MusicTimeStamp	sequenceLength, 
					bool			shouldPrint,
					AUGraph			inGraph,
					UInt32			numFrames,
					MusicPlayer		player)
{
		// delete existing output  file
	TestFile (outputFilePath, true);
	OSStatus result = 0;
	UInt32 size;

	CAStreamBasicDescription outputFormat;
	outputFormat.mChannelsPerFrame = 2;
	outputFormat.mSampleRate = srate;
	outputFormat.mFormatID = dataFormat;
	
	AudioFileTypeID destFileType;
	CAAudioFileFormats::Instance()->InferFileFormatFromFilename (outputFilePath, destFileType);
	
	if (dataFormat == kAudioFormatLinearPCM) {
		outputFormat.mBytesPerPacket = outputFormat.mChannelsPerFrame * 2;
		outputFormat.mFramesPerPacket = 1;
		outputFormat.mBytesPerFrame = outputFormat.mBytesPerPacket;
		outputFormat.mBitsPerChannel = 16;
		
		if (destFileType == kAudioFileWAVEType)
			outputFormat.mFormatFlags = kLinearPCMFormatFlagIsSignedInteger
								| kLinearPCMFormatFlagIsPacked;
		else
			outputFormat.mFormatFlags = kLinearPCMFormatFlagIsBigEndian
								| kLinearPCMFormatFlagIsSignedInteger
								| kLinearPCMFormatFlagIsPacked;
	} else {
		// use AudioFormat API to fill out the rest.
		size = sizeof(outputFormat);
		require_noerr (result = AudioFormatGetProperty(kAudioFormatProperty_FormatInfo, 0, NULL, &size, &outputFormat), fail);
	}

	if (shouldPrint) {
		printf ("Writing to file: %s with format:\n* ", outputFilePath);
		outputFormat.Print();
	}
	
	FSRef parentDir;
	CFStringRef destFileName;
	require_noerr (result = PosixPathToParentFSRefAndName(outputFilePath, parentDir, destFileName), fail);

	ExtAudioFileRef outfile;
	result = ExtAudioFileCreateNew (&parentDir, destFileName, destFileType, &outputFormat, NULL, &outfile);
	CFRelease (destFileName);
	require_noerr (result, fail);

	AudioUnit outputUnit;	
	UInt32 nodeCount;
	require_noerr (result = AUGraphGetNodeCount (inGraph, &nodeCount), fail);
	
	for (UInt32 i = 0; i < nodeCount; ++i) 
	{
		AUNode node;
		require_noerr (result = AUGraphGetIndNode(inGraph, i, &node), fail);

		ComponentDescription desc;
		require_noerr (result = AUGraphNodeInfo(inGraph, node, &desc, NULL), fail);
		
		if (desc.componentType == kAudioUnitType_Output) 
		{
			require_noerr (result = AUGraphNodeInfo(inGraph, node, 0, &outputUnit), fail);
			break;
		}
	}

	{
		CAStreamBasicDescription clientFormat;
		size = sizeof(clientFormat);
		require_noerr (result = AudioUnitGetProperty (outputUnit,
													kAudioUnitProperty_StreamFormat,
													kAudioUnitScope_Output, 0,
													&clientFormat, &size), fail);
		size = sizeof(clientFormat);
		require_noerr (result = ExtAudioFileSetProperty(outfile, kExtAudioFileProperty_ClientDataFormat, size, &clientFormat), fail);
		
		{
			MusicTimeStamp currentTime;
			AUOutputBL outputBuffer (clientFormat, numFrames);
			AudioTimeStamp tStamp;
			memset (&tStamp, 0, sizeof(AudioTimeStamp));
			tStamp.mFlags = kAudioTimeStampSampleTimeValid;
			int i = 0;
			int numTimesFor10Secs = (int)(10. / (numFrames / srate));
			do {
				outputBuffer.Prepare();
				AudioUnitRenderActionFlags actionFlags = 0;
				require_noerr (result = AudioUnitRender (outputUnit, &actionFlags, &tStamp, 0, numFrames, outputBuffer.ABL()), fail);

				tStamp.mSampleTime += numFrames;
				
				require_noerr (result = ExtAudioFileWrite(outfile, numFrames, outputBuffer.ABL()), fail);	

				require_noerr (result = MusicPlayerGetTime (player, &currentTime), fail);
				if (shouldPrint && (++i % numTimesFor10Secs == 0))
					printf ("current time: %6.2f beats\n", currentTime);
			} while (currentTime < sequenceLength);
		}
	}
	
// close
	ExtAudioFileDispose(outfile);

	return;

fail:
	printf ("Problem: %ld\n", result); 
	exit(1);
}
Esempio n. 14
0
static int AppendFile(Directory *d)
{ FILE        *f;
  char        pathName[PATHNAMESIZE], newPathName[PATHNAMESIZE], buf[BUFSIZE];
  int         i, j;
  int         oldIndex, newIndex, iFlag;


  if (verbose)
    printf("AppendFile called with directory '%s'\n", d->DirPathName);
  

  if ( (oldIndex=FindExistingFileName(d, pathName)) == -1 )
    {
	printf("AppendFile: failed to get a file to append to\n");
	return -1;
    }
  else if (oldIndex == -2 )
    {
      printf("AppendFile: found a flaw in the filing system\n");
      return 0;
    }

  printf("AppendFile: appending to file '%s'\n", pathName);
 
  /* Having selected a file to append to, we now have FINDUNUSEDFILETRIES */
  /* goes at finding a name that we can rename it to, having appended     */
  /* to it, such that the new name and the file size match (the number    */
  /* of blocks is encoded in the name), and the new size is greater than  */
  /* the old - as it must be, of course, since we're appending.           */
  
  newIndex=-1; iFlag=0;

  for (i=0; i<FINDUNUSEDFILETRIES; i++)
    if ( (newIndex=FindUnusedFileName(d, newPathName)) > oldIndex )
    { iFlag=1; break; }

  if (!iFlag)
  { printf("AppendFile: failed to find a suitable new name for file %s\n",
	   pathName);
    return 1;  /* Don't request a filesystem check, this is tedious. */
  }


  /* Open file in "r+" mode, so we can overwrite the 2nd header word without */
  /* losing the rest of the file's contents.                                 */
  if ( (f=fopen(pathName, "r+")) == NULL )
  { printf("AppendFile: failed to open file '%s'\n", pathName);
    return 0;
  }

  /* Move file pointer to the 2nd word, & change it to correspond to the */
  /* file's new name.                                                    */
  fseek(f, 4, SEEK_SET);

  if ( !fwrite(&newIndex, sizeof(int), 1, f) )
  { printf("AppendFile: failed to modify header byte of file '%s'\n", 
	    pathName);

    free(safetyBlock);
    ReleaseMem();

    if ( fclose(f) == EOF )
      printf("AppendFile: failed to close file '%s'\n", pathName);
    
    if ( unlink(pathName) == -1 )
      printf("AppendFile: couldn't delete file '%s'\n", pathName);

    return 0;
  }

  /* Now move the file pointer to its end and append the new blocks on to */
  /* the end.                                                             */
  fseek(f, 0, SEEK_END);

  for (i=oldIndex; i<newIndex; i++)
  { for (j=0; j<BUFSIZE; j++)
      buf[j]=(unsigned char)i;

    if ( !fwrite(buf, 1, BUFSIZE, f) )
    { printf("AppendFile: failed to append a block to file '%s'\n", 
	     pathName);

      free(safetyBlock);
      ReleaseMem();

      if ( fclose(f) == EOF )
	printf("AppendFile: failed to close file '%s'\n", pathName);

      if ( unlink(pathName) == -1 )
	printf("AppendFile: couldn't delete file '%s'\n", pathName);
    }
  }

  if ( fclose(f) ==EOF )
    {
      printf("AppendFile: couldn't close file %s\n", pathName);

      free(safetyBlock);
      ReleaseMem();

      if ( unlink(pathName) == -1 )
	printf("CreateFile: couldn't delete file %s\n", pathName);

      return 0;
    }

  /* Having appended to the file, give it its new name & check its validity */

#if 0
  if (verbose)
#endif
    printf("AppendFile: renaming file '%s' to '%s'\n", 
	   pathName, newPathName);

  /* There's a bug in the posix 'rename' function, so use one of my own */
  /* devising instead.                                                  */
  if ( !RenRRD(pathName, newPathName) )
  { printf("CreateFile: failed to rename file '%s' as '%s'\n", 
	   pathName, newPathName);
    printf("CreateFile: errno is %d\n", errno);
    return 0;
  }
 
  if ( TestFile(newPathName, d->DirLevel) )
    return 1;
  else
    {
      printf("AppendFile: new file '%s' is corrupt!\n", newPathName);
      return 0;
    }
}
Esempio n. 15
0
int main (int argc, const char** argv)
{
	if (argc < 2)
	{
		printf ("USAGE: hlsl2glsltest testfolder\n");
		return 1;
	}

	bool hasOpenGL = InitializeOpenGL ();
	if (!hasOpenGL)
		printf("NOTE: will not check GLSL with actual driver (no GL/GLSL)\n");
	
	clock_t time0 = clock();
	
	Hlsl2Glsl_Initialize ();

	std::string baseFolder = argv[1];

	size_t tests = 0;
	size_t errors = 0;
	for (int type = 0; type < NUM_RUN_TYPES; ++type)
	{
		printf ("TESTING %s...\n", kTypeName[type]);
		const ETargetVersion version1 = kTargets1[type];
		const ETargetVersion version2 = kTargets2[type];
		const ETargetVersion version3 = kTargets3[type];
		std::string testFolder = baseFolder + "/" + kTypeName[type];
		StringVector inputFiles = GetFiles (testFolder, "-in.txt");

		size_t n = inputFiles.size();
		tests += n;
		for (size_t i = 0; i < n; ++i)
		{
			std::string inname = inputFiles[i];
			//if (inname != "_zzz-in.txt")
			//	continue;
			const bool preprocessorTest = (inname.find("pp-") == 0);
			bool ok = true;
			
			printf ("test %s\n", inname.c_str());
			if (type == BOTH) {
				ok = TestCombinedFile(testFolder + "/" + inname, version1, hasOpenGL);
				if (ok && version2 != ETargetVersionCount)
					ok = TestCombinedFile(testFolder + "/" + inname, version2, hasOpenGL);
			} else {
				ok = TestFile(TestRun(type), testFolder + "/" + inname, version1, 0, hasOpenGL);
				if (!preprocessorTest)
				{
					if (ok && version2 != ETargetVersionCount)
						ok = TestFile(TestRun(type), testFolder + "/" + inname, version2, ETranslateOpEmitGLSL120ArrayInitWorkaround, hasOpenGL);
					if (ok && version3 != ETargetVersionCount)
						ok = TestFile(TestRun(type), testFolder + "/" + inname, version3, 0, hasOpenGL);
				}
			}
			
			if (!ok)
				++errors;
		}		
	}

	clock_t time1 = clock();
	float t = float(time1-time0) / float(CLOCKS_PER_SEC);
	if (errors != 0)
		printf ("%i tests, %i FAILED, %.2fs\n", (int)tests, (int)errors, t);
	else
		printf ("%i tests succeeded, %.2fs\n", (int)tests, t);
	
	Hlsl2Glsl_Shutdown();
	CleanupOpenGL();

	return errors ? 1 : 0;
}
Esempio n. 16
0
INT_PTR CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
    WORD wCode, wId;
	DWORD dwThreadId;
    switch(uMsg)
    {
    case WM_CLOSE:
        if(g_hScanProc)
            TerminateThread(g_hScanProc, 0);
        FreeLists(hwndDlg);
		FreeFonts();
		EndDialog(hwndDlg, 0);
        break;
    case WM_COMMAND:
        wId = LOWORD(wParam);
        wCode = HIWORD(wParam);
        switch(wId)
        {
		case IDC_BROWSE:
			if(wCode == BN_CLICKED)
				GetFilename(hwndDlg);
			break;
        case IDC_SCAN:
            if(wCode == BN_CLICKED)
				g_hScanProc = CreateThread(NULL, 0, (PTHREAD_START_ROUTINE)ScanProc, hwndDlg, NULL, &dwThreadId);
            break;
		case IDC_FILENAME:
			if(wCode == EN_CHANGE)
				TestFile(hwndDlg);
			break;
		case IDC_VIEW:
			if(wCode == BN_CLICKED)
				ViewPointer(hwndDlg);
			break;
		case IDC_DEFAULT:
			if(wCode == BN_CLICKED)
				SetHotkey(GetDlgItem(hwndDlg, IDC_HOTKEYS), SET_DEFAULT);
			break;
		case IDC_UNBIND:
			if(wCode == BN_CLICKED)
				SetHotkey(GetDlgItem(hwndDlg, IDC_HOTKEYS), SET_UNBIND);
			break;
		case IDC_ASSIGN:
			if(wCode == BN_CLICKED)
				SetHotkey(GetDlgItem(hwndDlg, IDC_HOTKEYS), GetHotkey(hwndDlg));
			break;
		case IDC_SETFIXED:
			if(wCode == BN_CLICKED)
			{
				if(SelectFont(hwndDlg, g_szFixedFont, &g_lFixedSize, &g_bFixedBold))
					SetFixedWidthFont(hwndDlg, g_szFixedFont, g_lFixedSize, g_bFixedBold);
			}
			break;
		case IDC_SETPROPORTIONAL:
			if(wCode == BN_CLICKED)
			{
				if(SelectFont(hwndDlg, g_szProportionalFont, &g_lProportionalSize, &g_bProportionalBold))
					SetProportionalFont(hwndDlg, g_szProportionalFont, g_lProportionalSize, g_bProportionalBold);
			}
			break;
		case IDC_SAVE:
			if(wCode == BN_CLICKED)
				SaveINI(hwndDlg);
			break;
		}
       break;
	case WM_INITDIALOG:
		Init(hwndDlg);
		break;
    default:
        return FALSE;
        break;
    }
    return TRUE;
}
Esempio n. 17
0
//---------------------------------------------------------------------------
void TUtilities::FileDiagnostics(AnsiString Input)//test function
{
std::ofstream TestFile("TestFile.csv", std::ios_base::app);
TestFile << Input.c_str() << '\n';
TestFile.close();
}
Esempio n. 18
0
static int CreateFile(Directory *d)
{
  int         fileNum, i, j;
  char        pathName[PATHNAMESIZE], buf[BUFSIZE];
  FILE        *f;

  if (verbose)
    printf("CreateFile called on directory '%s'\n", d->DirPathName);

  if ( (fileNum=FindUnusedFileName(d, pathName)) == -1 )
  { if (verbose)
      printf("CreateFile: FindUnusedFileName failed\n");
    return 0;
  }

  printf("Creating file %s\n", pathName);

  if ( (f=fopen(pathName, "wb")) == NULL)
  { printf("CreateFile: failed to open file %s\n", pathName);

    free(safetyBlock);
    ReleaseMem();

    return 0;
  }
  
  if ( !fwrite(&(d->DirLevel), sizeof(int), 1, f) ||
       !fwrite(&fileNum, sizeof(int), 1, f) )
  { printf("CreateFile: error writing header of file %s\n", pathName);

    free(safetyBlock);
    ReleaseMem();

    if ( fclose(f) == EOF)
      printf("CreateFile: couldn't close file %s\n", pathName);

    if ( unlink(pathName) == -1)
      printf("CreateFile: couldn't delete file %s\n", pathName);

    return 0;
  }

  for (i=0; i<fileNum; i++)
  { for (j=0; j<BUFSIZE; j++)
      buf[j]=(unsigned char)i;

    if ( fwrite(buf, 1, BUFSIZE, f) == 0 )
    { printf("CreateFile: error in writing contents of file %s\n", 
	     pathName);

      free(safetyBlock);
      ReleaseMem();
      
      if ( fclose(f) == EOF )
	printf("CreateFile: couldn't close file %s\n", pathName);
      
      if ( unlink(pathName) == -1)
	printf("CreateFile: couldn't delete file %s\n", pathName);
      
      return 0;
    }
  }

#ifndef DEBUG
  if (verbose)
#endif
    printf("CreateFile: created file %s\n", pathName);

  if ( fclose(f) ==EOF )
  { printf("CreateFile: couldn't close file %s\n", pathName);

    free(safetyBlock);
    ReleaseMem();

    if ( unlink(pathName) == -1)
      printf("CreateFile: couldn't delete file %s\n", pathName);

    return 0;
  }
 
  if ( TestFile(pathName, d->DirLevel) )
    return 1;
  else
  { printf("CreateFile: new file '%s' is corrupt!\n", pathName);
    return 0;
  }
}
Esempio n. 19
0
//=====================================================================================
// Fonction		: main
// Entrees		: <loc_s32_argc<: nombre d'arguments
//				  <loc_pps8_argv<: tableau de pointeur de chaque argument
// Sortie		: rien
// Auteur		: CM - 09/09/2009 -
// Description	: PROCESSUS TEST
//=====================================================================================
int main(int loc_s32_argc, s8sod *loc_pps8_argv[]) 
{
	printf("Debut processus Test... \n");

	//-----------------------------------------------
	//Initialisation propres à ce processus
	//-----------------------------------------------
	InitModule_ExecTest();
	InitModule_TestWifi();
	InitModule_RdProcNet();
	InitModule_TestMac();
	InitModule_TestSwap_App();
	InitModule_TestFile();
	InitModule_SetCountryID();

	//-----------------------------------------------
	//Test des arguments passés
	//-----------------------------------------------
	if(loc_s32_argc < 2)//CONDITION: nombre d'argument insufisant
	{
		; //pas assez d'arguments
	}
	else
	{
		if (0 == strcmp(loc_pps8_argv[1],"-w"))
		{
			u8_mode_test = MODE_TEST_TOOL_WIFI;
		}
		if (0 == strcmp(loc_pps8_argv[1],"-mac"))
		{
			u8_mode_test = MODE_TEST_TOOL_MAC;
		}
		if (0 == strcmp(loc_pps8_argv[1],"-route"))
		{
			u8_mode_test = MODE_TEST_TOOL_READ_PROC_NET_ROUTE;
		}
		if (0 == strcmp(loc_pps8_argv[1],"-swap_app1"))
		{
			u8_mode_test = MODE_TEST_TOOL_SWAP_APP1;
		}
		if (0 == strcmp(loc_pps8_argv[1],"-swap_app2"))
		{
			u8_mode_test = MODE_TEST_TOOL_SWAP_APP2;
		}
		if (0 == strcmp(loc_pps8_argv[1],"-file"))
		{
			u8_mode_test = MODE_TEST_TOOL_FILE;
		}
		if (0 == strcmp(loc_pps8_argv[1],"-perso"))
		{
			u8_mode_test = MODE_TEST_TOOL_PERSO;
		}
		if (0 == strcmp(loc_pps8_argv[1],"-setcountryid"))
		{
			if(loc_s32_argc < 3)//CONDITION: nombre d'argument insufisant
			{
				; //pas assez d'arguments
			}
			else
			{
				u8_mode_test = MODE_TEST_TOOL_SETCOUNTRYID;
			}
		}
	}

	if(MODE_TEST_TOOL_AUCUN == u8_mode_test)
	{
		proc_Usage((s8sod *)loc_pps8_argv[0]);
		exit(1);
	}

	//-----------------------------------------------
	//Initialisation des modules de la librairie system
	//-----------------------------------------------
	InitModule_LibrarySystem();
	SetConfig_LibrarySystem(AddMsgDbgLog);
	
	//-----------------------------------------------
	//Initialisation des modules de la librairie bdd
	//-----------------------------------------------
	InitModule_LibraryBdd();

	//-----------------------------------------------
	//Initialisation des modules de la librairie Network
	//-----------------------------------------------
	InitModule_LibraryNetwork();

	//-----------------------------------------------
	//Initialisation des modules de la librairie Wifi
	//-----------------------------------------------
	InitModule_LibraryWifi();
	
	switch(u8_mode_test)
	{
		case MODE_TEST_TOOL_WIFI:
			//Extraction info BSSID sur l'accès Wifi
			TestWifi_ExtractBSSID();
			break;
		case MODE_TEST_TOOL_MAC:
			TestMAC_LanInterface();
			TestMAC_WLanInterface();
			break;
		case MODE_TEST_TOOL_READ_PROC_NET_ROUTE:
			TestLecture_ProcNetRoute();
			break;
		case MODE_TEST_TOOL_SWAP_APP1:
			TestSwap_App(MODE_BOOT_APP1);
			break;
		case MODE_TEST_TOOL_SWAP_APP2:
			TestSwap_App(MODE_BOOT_APP2);
			break;
		case MODE_TEST_TOOL_FILE:
			TestFile();
			break;
		case MODE_TEST_TOOL_PERSO:
		{
			S_STRUCT_SYST_FILE loc_ps_tab[NB_MAX_CERTIFICATS];
			u8sod loc_u8_i;
			for(loc_u8_i=0;loc_u8_i<NB_MAX_CERTIFICATS;loc_u8_i++)
			{
				RazSystFile(&loc_ps_tab[loc_u8_i]); //INIT
			}
			if(FALSE == u8CmdSystem_ListFileInDirectory(PATH_DIR__ETC_CERTIFICATS,&loc_ps_tab[0],NB_MAX_CERTIFICATS))
			{
				printf("Resultat:KO\n");
			}
			else
			{
				printf("Resultat:\n");
				for(loc_u8_i=0;loc_u8_i<NB_MAX_CERTIFICATS;loc_u8_i++)
				{
					if(0 != strcmp(loc_ps_tab[loc_u8_i].ps8_nom, ""))
					{
						printf("%s size=%lu\n",loc_ps_tab[loc_u8_i].ps8_nom,loc_ps_tab[loc_u8_i].u32_sizeoffile);
					}
				}
			}
			break;
		}
		case MODE_TEST_TOOL_SETCOUNTRYID:
			SaveCountryID(loc_pps8_argv[2]);
			break;
		default:
			break;
	}

	
	return 0;
}/*main*/
int main (int argc, const char** argv)
{
#ifndef __S3E__
	if (argc < 2)
	{
		printf ("USAGE: glsloptimizer testfolder\n");
		return 1;
	}
#endif

	bool hasOpenGL = InitializeOpenGL ();
	bool hasMetal = InitializeMetal ();
	glslopt_ctx* ctx[3] = {
		glslopt_initialize(kGlslTargetOpenGLES20),
		glslopt_initialize(kGlslTargetOpenGLES30),
		glslopt_initialize(kGlslTargetOpenGL),
	};
	glslopt_ctx* ctxMetal = glslopt_initialize(kGlslTargetMetal);

#ifndef __S3E__
	std::string baseFolder = argv[1];
#else
	std::string baseFolder = "." ;
#endif

	clock_t time0 = clock();

	// 2.39s
	// ralloc fix 256 initial: 1.35s

	static const char* kTypeName[2] = { "vertex", "fragment" };
	size_t tests = 0;
	size_t errors = 0;

	int type = 0 ; // vertex
	std::string testFolder = baseFolder + "/" + kTypeName[type];

	static const char* kAPIName[3] = { "OpenGL ES 2.0", "OpenGL ES 3.0", "OpenGL" };
	static const char* kApiIn [3] = {"-inES.txt", "-inES3.txt", "-in.txt"};
	static const char* kApiOut[3] = {"-outES.txt", "-outES3.txt", "-out.txt"};
	static const char* kApiOutMetal[3] = {"-outESMetal.txt", "-outES3Metal.txt", "-outMetal.txt"};

	int api= 0 ;		// OpenGL ES 2.0

	printf ("\n** running %s tests for %s...\n", kTypeName[type], kAPIName[api]);

	std::string inname = "ogre-inES.txt";
	std::string outname = inname.substr (0,inname.size()-strlen(kApiIn[api])) + kApiOut[api];
	std::string outnameMetal = inname.substr (0,inname.size()-strlen(kApiIn[api])) + kApiOutMetal[api];
	const bool useMetal = (api == 1);
#ifdef __S3E__
	// with s3e we wont perform GLES check
	hasOpenGL = false ;
#endif
	bool ok = TestFile (ctx[api], type==0, inname, testFolder + "/" + inname, testFolder + "/" + outname, api<=1, hasOpenGL, false);
	if (!ok)
	{
		++errors;
	}

	// for __S3E__ we normally wont test Metal
	if (useMetal)
	{
		ok = TestFile (ctxMetal, type==0, inname, testFolder + "/" + inname, testFolder + "/" + outnameMetal, api==0, false, hasMetal);
		if (!ok)
		{
			++errors;
		}
	}
	++tests;

	clock_t time1 = clock();
	float timeDelta = float(time1-time0)/CLOCKS_PER_SEC;

	if (errors != 0)
		printf ("\n**** %i tests (%.2fsec), %i !!!FAILED!!!\n", (int)tests, timeDelta, (int)errors);
	else
		printf ("\n**** %i tests (%.2fsec) succeeded\n", (int)tests, timeDelta);
	
	// 3.25s
	// with builtin call linking, 3.84s

	for (int i = 0; i < 2; ++i)
		glslopt_cleanup (ctx[i]);
	glslopt_cleanup (ctxMetal);
	CleanupGL();

	return errors ? 1 : 0;
}
Esempio n. 21
0
int main (int argc, const char** argv)
{
	if (argc < 2)
	{
		printf ("USAGE: glsloptimizer testfolder\n");
		return 1;
	}

	bool hasOpenGL = InitializeOpenGL ();
	glslopt_ctx* ctx[2] = {
		glslopt_initialize(true),
		glslopt_initialize(false),
	};

	std::string baseFolder = argv[1];

	clock_t time0 = clock();

	static const char* kTypeName[2] = { "vertex", "fragment" };
	size_t tests = 0;
	size_t errors = 0;
	for (int type = 0; type < 2; ++type)
	{
		std::string testFolder = baseFolder + "/" + kTypeName[type];

		static const char* kAPIName[2] = { "OpenGL ES 2.0", "OpenGL" };
		static const char* kApiIn [2] = {"-inES.txt", "-in.txt"};
		static const char* kApiIR [2] = {"-irES.txt", "-ir.txt"};
		static const char* kApiOut[2] = {"-outES.txt", "-out.txt"};
		for (int api = 0; api < 2; ++api)
		{
			printf ("\n** running %s tests for %s...\n", kTypeName[type], kAPIName[api]);
			StringVector inputFiles = GetFiles (testFolder, kApiIn[api]);

			size_t n = inputFiles.size();
			for (size_t i = 0; i < n; ++i)
			{
				std::string inname = inputFiles[i];
				//if (inname != "ast-in.txt")
				//	continue;
				std::string hirname = inname.substr (0,inname.size()-strlen(kApiIn[api])) + kApiIR[api];
				std::string outname = inname.substr (0,inname.size()-strlen(kApiIn[api])) + kApiOut[api];
				bool ok = TestFile (ctx[api], type==0, inname, testFolder + "/" + inname, testFolder + "/" + hirname, testFolder + "/" + outname, api==0, hasOpenGL);
				if (!ok)
				{
					++errors;
				}
				++tests;
			}
		}
	}
	clock_t time1 = clock();
	float timeDelta = float(time1-time0)/CLOCKS_PER_SEC;

	if (errors != 0)
		printf ("\n**** %i tests (%.2fsec), %i !!!FAILED!!!\n", tests, timeDelta, errors);
	else
		printf ("\n**** %i tests (%.2fsec) succeeded\n", tests, timeDelta);
	
	// 3.25s
	// with builtin call linking, 3.84s

	for (int i = 0; i < 2; ++i)
		glslopt_cleanup (ctx[i]);

	return errors ? 1 : 0;
}
Esempio n. 22
0
int main (int argc, const char** argv)
{
	if (argc < 2)
	{
		printf ("USAGE: hlsl2glsltest testfolder\n");
		return 1;
	}

	bool hasOpenGL = InitializeOpenGL ();
	
	clock_t time0 = clock();
	
	Hlsl2Glsl_Initialize ();

	std::string baseFolder = argv[1];

	static const char* kTypeName[2] = { "vertex", "fragment" };
	size_t tests = 0;
	size_t errors = 0;
	for (int type = 0; type < 2; ++type)
	{
		printf ("testing %s...\n", kTypeName[type]);
		std::string testFolder = baseFolder + "/" + kTypeName[type];
		StringVector inputFiles = GetFiles (testFolder, "-in.txt");

		size_t n = inputFiles.size();
		tests += n;
		for (size_t i = 0; i < n; ++i)
		{
			std::string inname = inputFiles[i];
			printf ("test %s\n", inname.c_str());
			std::string outname = inname.substr (0,inname.size()-7) + "-out.txt";
			std::string outnameES = inname.substr (0,inname.size()-7) + "-outES.txt";
			bool ok = TestFile (type==0,
				testFolder + "/" + inname,
				testFolder + "/" + outname,
				false,
				hasOpenGL);
			if (ok)
			{
				ok = TestFile (type==0,
					testFolder + "/" + inname,
					testFolder + "/" + outnameES,
					true,
					false);
			}
			if (!ok)
			{
				++errors;
			}
		}
	}
	clock_t time1 = clock();
	float t = float(time1-time0) / float(CLOCKS_PER_SEC);
	if (errors != 0)
		printf ("%i tests, %i FAILED, %.2fs\n", tests, errors, t);
	else
		printf ("%i tests succeeded, %.2fs\n", tests, t);

	return errors ? 1 : 0;
}