コード例 #1
0
ファイル: manifest.c プロジェクト: fabgithub/zerovm
struct Manifest *ManifestTextCtor(char *text)
{
  struct Manifest *manifest = g_malloc0(sizeof *manifest);
  int counters[XSIZE(KEYWORDS)] = {0};
  char **lines;
  int i;

  /* initialize channels */
  manifest->channels = g_ptr_array_new();

  /* extract all lines */
  lines = g_strsplit(text, LINE_DELIMITER, MANIFEST_LINES_LIMIT);

  /* parse each line */
  for(i = 0; lines[i] != NULL; ++i)
  {
    char **tokens;

    tokens = g_strsplit(lines[i], KEY_DELIMITER, MANIFEST_TOKENS_LIMIT);
    if(strlen(lines[i]) > 0 && tokens[Key] != NULL
        && tokens[Value] != NULL && tokens[KeyValueTokensNumber] == NULL)
    {
      /* switch invoking functions by the keyword */
#define XSWITCH(a) switch(GetKey(tokens[Key])) {a};
#define X(a, o, s) case Key##a: ++counters[Key##a]; a(manifest, tokens[Value]); break;
      XSWITCH(KEYWORDS)
#undef X
    }
    g_strfreev(tokens);
  }

  /* check obligatory and singleton keywords */
  g_strfreev(lines);
  CheckCounters(counters, XSIZE(KEYWORDS));

  return manifest;
}
コード例 #2
0
/// Routine for checking the result of the SoftwareTriggersTestConfig() config in TriggerConfig.C
bool CheckSoftwareTriggerTestConfig(const char* testName = "Software trigger config")
{
	AliHLTGlobalTriggerDecision* decision = NULL;
	bool result = false;
	
	AliHLTTriggerDomain domainPHOS("*******:PHOS");
	AliHLTTriggerDomain domainSPD("*******:SPD");
	AliHLTTriggerDomain domainTPC("DAQRDOUT:TPC");
	AliHLTTriggerDomain domainMUON("TRACKS:MUON");
	domainMUON.Add(AliHLTReadoutList("MUONTRK MUONTRG"));

	TFile* file = new TFile("testOutputFile.root", "READ");
	TArrayL64 expectedCounters;
	expectedCounters.Set(6);
	
	decision = dynamic_cast<AliHLTGlobalTriggerDecision*>(file->Get("HLTGlobalTrigger;1"));
	result = Check(testName, 1, decision, true, AliHLTTriggerDomain(), "Start of data");
	if (! result) goto cleanup;
	expectedCounters[0] = 1; expectedCounters[5] = 1;
	result = CheckCounters(testName, 1, decision, expectedCounters);
	if (! result) goto cleanup;
	
	decision = dynamic_cast<AliHLTGlobalTriggerDecision*>(file->Get("HLTGlobalTrigger;2"));
	result = Check(testName, 2, decision, true, domainSPD, "Software trigger");
	if (! result) goto cleanup;
	expectedCounters[2] = 1; expectedCounters[5] = 2;
	result = CheckCounters(testName, 2, decision, expectedCounters);
	if (! result) goto cleanup;
	
	decision = dynamic_cast<AliHLTGlobalTriggerDecision*>(file->Get("HLTGlobalTrigger;3"));
	result = Check(testName, 3, decision, true, domainPHOS, "Calibration trigger");
	if (! result) goto cleanup;
	expectedCounters[3] = 1; expectedCounters[5] = 3;
	result = CheckCounters(testName, 3, decision, expectedCounters);
	if (! result) goto cleanup;
	
	decision = dynamic_cast<AliHLTGlobalTriggerDecision*>(file->Get("HLTGlobalTrigger;4"));
	result = Check(testName, 4, decision, true, domainMUON, "MUON trigger");
	if (! result) goto cleanup;
	expectedCounters[4] = 1; expectedCounters[5] = 4;
	result = CheckCounters(testName, 4, decision, expectedCounters);
	if (! result) goto cleanup;
	
	decision = dynamic_cast<AliHLTGlobalTriggerDecision*>(file->Get("HLTGlobalTrigger;5"));
	result = Check(testName, 5, decision, true, domainSPD|domainTPC, "Software trigger");
	if (! result) goto cleanup;
	expectedCounters[2] = 2; expectedCounters[5] = 5;
	result = CheckCounters(testName, 5, decision, expectedCounters);
	if (! result) goto cleanup;
	
	decision = dynamic_cast<AliHLTGlobalTriggerDecision*>(file->Get("HLTGlobalTrigger;6"));
	result = Check(testName, 6, decision, true, AliHLTTriggerDomain(), "End of data");
	if (! result) goto cleanup;
	expectedCounters[1] = 1; expectedCounters[5] = 6;
	result = CheckCounters(testName, 6, decision, expectedCounters);
	if (! result) goto cleanup;
	
	delete file;
	return true;
	
cleanup:
	if (decision != NULL)
	{
		cout << "========== Dumping incorrect decision ========== " << endl;
		decision->Print();
	}
	delete file;
	return false;
}