Exemplo n.º 1
0
/*
 * Read the configuration script, allocating and filling in the structure of
 * global parameters.
 */
IOR_test_t *ReadConfigScript(char *scriptName)
{
        int test_num = 0;
        int runflag = 0;
        char linebuf[MAX_STR];
        char empty[MAX_STR];
        FILE *file;
        IOR_test_t *head = NULL;
        IOR_test_t *tail = NULL;
        IOR_test_t *newTest = NULL;

        /* Initialize the first test */
        head = CreateTest(&initialTestParams, test_num++);
        tail = head;

        /* open the script */
        file = fopen(scriptName, "r");
        if (file == NULL)
                ERR("fopen() failed");

        /* search for the "IOR START" line */
        while (fgets(linebuf, MAX_STR, file) != NULL) {
                if (contains_only(linebuf, "ior start")) {
                        break;
                }
        }

        /* Iterate over a block of IOR commands */
        while (fgets(linebuf, MAX_STR, file) != NULL) {
                /* skip empty lines */
                if (sscanf(linebuf, "%s", empty) == -1)
                        continue;
                /* skip lines containing only comments */
                if (sscanf(linebuf, " #%s", empty) == 1)
                        continue;
                if (contains_only(linebuf, "ior stop")) {
			AllocResults(tail);
                        break;
                } else if (contains_only(linebuf, "run")) {
			AllocResults(tail);
                        runflag = 1;
                } else if (runflag) {
                        /* If this directive was preceded by a "run" line, then
                           create and initialize a new test structure */
			runflag = 0;
			tail->next = CreateTest(&tail->params, test_num++);
			tail = tail->next;
                        ParseLine(linebuf, &tail->params);
		} else {
                        ParseLine(linebuf, &tail->params);
                }
        }

        /* close the script */
        if (fclose(file) != 0)
                ERR("fclose() of script file failed");

        return head;
}
Exemplo n.º 2
0
PoseMeshScene::PoseMeshScene(QObject *parent)
: QGraphicsScene(parent)
{    
   double graphicsWidth  = 512;
   double graphicsHeight = 1024;   

   // This rectangle will be a visual representation 
   // of the bounds that the map can be dragged in  
   mCanvasRect.setLeft(0);
   mCanvasRect.setTop(0);
   mCanvasRect.setWidth(graphicsWidth);
   mCanvasRect.setHeight(graphicsHeight);   

   mVerticalMeshOffset = mCanvasRect.y() + 64;

   QBrush canvasBrush(QColor(192, 192, 255));

   QGraphicsRectItem *canvasItem = addRect(mCanvasRect, QPen(), canvasBrush);  
   canvasItem->setZValue(-100.0f);
   canvasItem->setEnabled(false);

   QBrush backgroundBrush(QPixmap(":/images/checker.png"));  
   setBackgroundBrush(backgroundBrush);

   CreateTest();
}
Exemplo n.º 3
0
/****************************************
* Set up the test of the interface name
*****************************************/
int InitTestInterfaceName(){
	int	TestID;

	DEBUGPATH;

	TestID=CreateTest("InterfaceName");
	if (TestID==TEST_NONE) return FALSE;
	
	if (!BindTestToDecoder(TestID, "Interface")){
		printf("Failed to Bind to Interface\n");
		return FALSE;
	} 
	
	snprintf(Globals.Tests[TestID].ShortName, MAX_NAME_LEN, "name");
	Globals.Tests[TestID].AddNode=InterfaceNameAddNode;
	Globals.Tests[TestID].TestFunc=TestInterfaceName;
	
	InterfaceDecoderID=GetDecoderByName("Interface");

	return TRUE;
}
Exemplo n.º 4
0
/****************************************
* Set up the test of the TCP Flags Field
*****************************************/
int InitTestTCPFlags(){
	int	TestID;

	DEBUGPATH;

	TCPFlagsHead=NULL;

	TestID=CreateTest("TCPFlags");
	if (TestID==TEST_NONE) return FALSE;
	
	if (!BindTestToDecoder(TestID, "TCP")){
		printf("Failed to Bind to TCP\n");
		return FALSE;
	} 
	
	snprintf(Globals.Tests[TestID].ShortName, MAX_NAME_LEN, "flags");
	Globals.Tests[TestID].AddNode=TCPFlagsAddNode;
	Globals.Tests[TestID].TestFunc=TestTCPFlags;
	
	TCPDecoderID=GetDecoderByName("TCP");

	return TRUE;
}
Exemplo n.º 5
0
/****************************************
* Set up the test of the TCP NoCase
*****************************************/
int InitTestTCPListNoCase(){
	int	TestID;

	DEBUGPATH;

	InitJTree(&TCPListNoCaseTree, TRUE);

	TestID=CreateTest("TCPListNoCase");
	if (TestID==TEST_NONE) return FALSE;
	
	if (!BindTestToDecoder(TestID, "TCP")){
		printf("Failed to Bind to TCP\n");
		return FALSE;
	} 
	
	snprintf(Globals.Tests[TestID].ShortName, MAX_NAME_LEN, "listnocase");
	Globals.Tests[TestID].AddNode=TCPListNoCaseAddNode;
	Globals.Tests[TestID].TestFunc=TestTCPListNoCase;
	Globals.Tests[TestID].FinishedSetup=TestTCPListNoCaseFinishedSetup;
	
	TCPDecoderID=GetDecoderByName("TCP");

	return TRUE;
}
Exemplo n.º 6
0
/*
 * Parse Commandline.
 */
IOR_test_t *ParseCommandLine(int argc, char **argv)
{
        static const char *opts =
          "a:A:b:BcCd:D:eEf:FgG:hHi:Ij:J:kKlL:mM:nN:o:O:pPqQ:rRs:St:T:uU:vVwWxX:YzZ";
        int c, i;
        static IOR_test_t *tests = NULL;

        /* suppress getopt() error message when a character is unrecognized */
        opterr = 0;

        init_IOR_Param_t(&initialTestParams);
        GetPlatformName(initialTestParams.platform);
        initialTestParams.writeFile = initialTestParams.readFile = FALSE;
        initialTestParams.checkWrite = initialTestParams.checkRead = FALSE;

        while ((c = getopt(argc, argv, opts)) != -1) {
                switch (c) {
                case 'A':
                        initialTestParams.referenceNumber = atoi(optarg);
                        break;
                case 'a':
                        strcpy(initialTestParams.api, optarg);
                        break;
                case 'b':
                        initialTestParams.blockSize = StringToBytes(optarg);
                        RecalculateExpectedFileSize(&initialTestParams);
                        break;
                case 'B':
                        initialTestParams.useO_DIRECT = TRUE;
                        break;
                case 'c':
                        initialTestParams.collective = TRUE;
                        break;
                case 'C':
                        initialTestParams.reorderTasks = TRUE;
                        break;
                case 'Q':
                        initialTestParams.taskPerNodeOffset = atoi(optarg);
                        break;
                case 'Z':
                        initialTestParams.reorderTasksRandom = TRUE;
                        break;
                case 'X':
                        initialTestParams.reorderTasksRandomSeed = atoi(optarg);
                        break;
                case 'd':
                        initialTestParams.interTestDelay = atoi(optarg);
                        break;
                case 'D':
                        initialTestParams.deadlineForStonewalling =
                            atoi(optarg);
                        break;
                case 'Y':
                        initialTestParams.fsyncPerWrite = TRUE;
                        break;
                case 'e':
                        initialTestParams.fsync = TRUE;
                        break;
                case 'E':
                        initialTestParams.useExistingTestFile = TRUE;
                        break;
                case 'f':
                        tests = ReadConfigScript(optarg);
                        break;
                case 'F':
                        initialTestParams.filePerProc = TRUE;
                        break;
                case 'g':
                        initialTestParams.intraTestBarriers = TRUE;
                        break;
                case 'G':
                        initialTestParams.setTimeStampSignature = atoi(optarg);
                        break;
                case 'h':
                        initialTestParams.showHelp = TRUE;
                        break;
                case 'H':
                        initialTestParams.showHints = TRUE;
                        break;
                case 'i':
                        initialTestParams.repetitions = atoi(optarg);
                        break;
                case 'I':
                        initialTestParams.individualDataSets = TRUE;
                        break;
                case 'j':
                        initialTestParams.outlierThreshold = atoi(optarg);
                        break;
                case 'J':
                        initialTestParams.setAlignment = StringToBytes(optarg);
                        break;
                case 'k':
                        initialTestParams.keepFile = TRUE;
                        break;
                case 'K':
                        initialTestParams.keepFileWithError = TRUE;
                        break;
                case 'l':
                        initialTestParams.storeFileOffset = TRUE;
                        break;
                case 'L':
                        initialTestParams.interOpDelay = atoi(optarg);
                        break;
		case 'M':
                        initialTestParams.memoryPerNode =
                                NodeMemoryStringToBytes(optarg);
                        break;
                case 'm':
                        initialTestParams.multiFile = TRUE;
                        break;
                case 'n':
                        initialTestParams.noFill = TRUE;
                        break;
                case 'N':
                        initialTestParams.numTasks = atoi(optarg);
                        RecalculateExpectedFileSize(&initialTestParams);
                        break;
                case 'o':
                        strcpy(initialTestParams.testFileName, optarg);
                        break;
                case 'O':
                        ParseLine(optarg, &initialTestParams);
                        break;
                case 'p':
                        initialTestParams.preallocate = TRUE;
                        break;
                case 'P':
                        initialTestParams.useSharedFilePointer = TRUE;
                        break;
                case 'q':
                        initialTestParams.quitOnError = TRUE;
                        break;
                case 'r':
                        initialTestParams.readFile = TRUE;
                        break;
                case 'R':
                        initialTestParams.checkRead = TRUE;
                        break;
                case 's':
                        initialTestParams.segmentCount = atoi(optarg);
                        RecalculateExpectedFileSize(&initialTestParams);
                        break;
                case 'S':
                        initialTestParams.useStridedDatatype = TRUE;
                        break;
                case 't':
                        initialTestParams.transferSize = StringToBytes(optarg);
                        break;
                case 'T':
                        initialTestParams.maxTimeDuration = atoi(optarg);
                        break;
                case 'u':
                        initialTestParams.uniqueDir = TRUE;
                        break;
                case 'U':
                        strcpy(initialTestParams.hintsFileName, optarg);
                        break;
                case 'v':
                        initialTestParams.verbose++;
                        break;
                case 'V':
                        initialTestParams.useFileView = TRUE;
                        break;
                case 'w':
                        initialTestParams.writeFile = TRUE;
                        break;
                case 'W':
                        initialTestParams.checkWrite = TRUE;
                        break;
                case 'x':
                        initialTestParams.singleXferAttempt = TRUE;
                        break;
                case 'z':
                        initialTestParams.randomOffset = TRUE;
                        break;
                default:
                        fprintf(stdout,
                                "ParseCommandLine: unknown option `-%c'.\n",
                                optopt);
                }
        }

        for (i = optind; i < argc; i++)
                fprintf(stdout, "non-option argument: %s\n", argv[i]);

        /* If an IOR script was not used, initialize test queue to the defaults */
        if (tests == NULL) {
                tests = CreateTest(&initialTestParams, 0);
		AllocResults(tests);
        }

        CheckRunSettings(tests);

        return (tests);
}
void ribi::trim::Template::Test() noexcept
{
  {
    static bool is_tested{false};
    if (is_tested) return;
    is_tested = true;
  }
  PointFactory();
  FaceFactory();

  const TestTimer test_timer(__func__,__FILE__,1.0);
  const bool verbose{false};
  if (verbose) { TRACE("IsClockWise, confirmation"); }
  {
    /*

    Cartesian plane

          |
          |
          A = (0,1)
         /|\
        / | \
    ---+--+--+----
      /   |   \
     C----+----B
          |
          |


    */
    //12 o'clock
    const boost::shared_ptr<const ConstCoordinat2D> a {
      new ConstCoordinat2D(0.0,1.0)
    };
    //4 o'clock
    const boost::shared_ptr<const ConstCoordinat2D> b {
      new ConstCoordinat2D(0.83,-0.5)
    };
    //8 o'clock
    const boost::shared_ptr<const ConstCoordinat2D> c {
      new ConstCoordinat2D(-0.83,-0.5)
    };
    std::vector<boost::shared_ptr<Point>> points {
      PointFactory().Create(a),
      PointFactory().Create(b),
      PointFactory().Create(c)
    };
    points[0]->SetZ(1.0 * boost::units::si::meter);
    points[1]->SetZ(1.0 * boost::units::si::meter);
    points[2]->SetZ(1.0 * boost::units::si::meter);
    assert( Helper().IsClockwiseHorizontal(points));
    std::reverse(points.begin(),points.end());
    assert(!Helper().IsClockwiseHorizontal(points));
  }
  if (verbose) { TRACE("IsClockWise, rejection"); }
  {
    /*

    Cartesian plane

          |
          |
          A = (0,1)
         /|\
        / | \
    ---+--+--+----
      /   |   \
     B----+----C
          |
          |


    */
    //12 o'clock
    const boost::shared_ptr<const ConstCoordinat2D> a {
      new ConstCoordinat2D(0.0,1.0)
    };
    //8 o'clock
    const boost::shared_ptr<const ConstCoordinat2D> b {
      new ConstCoordinat2D(-0.83,-0.5)
    };
    //4 o'clock
    const boost::shared_ptr<const ConstCoordinat2D> c {
      new ConstCoordinat2D(0.83,-0.5)
    };
    std::vector<boost::shared_ptr<Point>> points {
      PointFactory().Create(a),
      PointFactory().Create(b),
      PointFactory().Create(c)
    };
    points[0]->SetZ(1.0 * boost::units::si::meter);
    points[1]->SetZ(1.0 * boost::units::si::meter);
    points[2]->SetZ(1.0 * boost::units::si::meter);
    assert(!Helper().IsClockwiseHorizontal(points));
    std::reverse(points.begin(),points.end());
    assert(Helper().IsClockwiseHorizontal(points));
  }
  for (int i=0; i!=4; ++i)
  {
    const boost::shared_ptr<Template> my_template {
      CreateTest(i)
    };
    assert(my_template);
    for (const auto& face: my_template->GetFaces())
    {
      if (!Helper().IsClockwiseHorizontal(face->GetPoints()))
      {
        TRACE("BREAK");
      }
      assert(Helper().IsClockwiseHorizontal(face->GetPoints()));
    }
  }
}