Example #1
0
	bool readLine(StreamSource& in, PodVector<char>::type& buf) {
		char buffer[1024];
		bool eol = false;
		uint32 i;
		buf.clear();
		for (i = 0; *in && (eol = in.matchEol()) == false; ++in) {
			buffer[i] = *in;
			if (++i == 1024) {
				buf.insert(buf.end(), buffer, buffer + i);
				i = 0;
			}
		}
		buf.insert(buf.end(), buffer, buffer + i);
		buf.push_back('\0');
		return eol;
	}
Example #2
0
bool readLine(StreamSource& in, PodVector<char>::type& buf ) {
	char   buffer[1024];
	uint32 i;
	buf.clear();
	for (i = 0;;) {
		buffer[i] = *in;
		++in;
		if (buffer[i] == '\n' || buffer[i] == '\0') {
			buf.insert(buf.end(), buffer, buffer+i+1);
			buf.back() = '\0';
			break;
		}
		if (++i == 1024) {
			buf.insert(buf.end(), buffer, buffer+i);
			i = 0;
		}
	}
	return buffer[i] == '\n';
}
Example #3
0
void X86TestSuite::run()
{
  size_t i;
  size_t testCount = testList.getLength();

  for (i = 0; i < testCount; i++)
  {
    X86Compiler compiler;
    StringLogger logger;

    logger.setLogBinary(true);
    compiler.setLogger(&logger);

    X86Test* test = testList[i];
    test->compile(compiler);

    void *func = compiler.make();

    // In case that compilation fails uncomment this section to log immediately
    // after "compiler.make()".
    //
    // fprintf(stdout, "%s\n", logger.getString());
    // fflush(stdout);

    if (func != NULL)
    {
      StringBuilder output;
      StringBuilder expected;

      if (test->run(func, output, expected))
      {
        fprintf(stdout, "[Success] %s.\n", test->getName());
      }
      else
      {
        fprintf(stdout, "[Failure] %s.\n", test->getName());
        fprintf(stdout, "-------------------------------------------------------------------------------\n");
        fprintf(stdout, "%s", logger.getString());
        fprintf(stdout, "\n");
        fprintf(stdout, "Result  : %s\n", output.getData());
        fprintf(stdout, "Expected: %s\n", expected.getData());
        fprintf(stdout, "-------------------------------------------------------------------------------\n");
      }

      MemoryManager::getGlobal()->free(func);
    }
    else
    {
      fprintf(stdout, "[Failure] %s.\n", test->getName());
      fprintf(stdout, "-------------------------------------------------------------------------------\n");
      fprintf(stdout, "%s\n", logger.getString());
      fprintf(stdout, "-------------------------------------------------------------------------------\n");
    }

    fflush(stdout);
  }

  fputs("\n", stdout);
  fputs(testOutput.getData(), stdout);
  fflush(stdout);
}