Logo ROOT  
Reference Guide
guitest_playback.C File Reference

Detailed Description

This macro plays a recorded ROOT session showing how to perform various interactive GUI operations with the guitest.C macro While replaying the session, several temporary macros (guitest0xx.C) macros will be saved. These files will be later on compared with some reference values to verify the validity of different parts of the test.

#include "TSystem.h"
#include "TSystemFile.h"
#include "TRecorder.h"
#include "Riostream.h"
// count characters in the file, skipping cr/lf
Int_t file_size(const char *filename)
{
FILE *lunin;
Int_t c, wc = 0;
lunin = fopen(filename, "rb");
if (lunin == 0) return -1;
while (!feof(lunin)) {
c = fgetc(lunin);
if (c != 0x0d && c != 0x0a)
wc++;
}
fclose(lunin);
return wc;
}
// main function
void guitest_playback()
{
Int_t i;
Int_t guitest_ref[11], guitest_err[11], guitest_size[11];
gBenchmark->Start("guitest_playback");
// first delete old files, if any
for (i=0;i<11;++i) {
gSystem->Unlink(TString::Format("guitest%03d.C", i+1));
}
TRecorder r("http://root.cern.ch/files/guitest_playback.root");
// wait for the recorder to finish the replay
while (r.GetState() == TRecorder::kReplaying) {
}
for (i=0;i<11;++i) {
guitest_ref[i] = 0;
guitest_err[i] = 100;
guitest_size[i] = file_size(TString::Format("guitest%03d.C", i+1));
}
guitest_ref[0] = 23319;
guitest_ref[1] = 5633;
guitest_ref[2] = 14939;
guitest_ref[3] = 9459;
guitest_ref[4] = 5351;
guitest_ref[5] = 22982;
guitest_ref[6] = 23812;
guitest_ref[7] = 23869;
guitest_ref[8] = 23918;
guitest_ref[9] = 24067;
guitest_ref[10] = 65517;
printf("**********************************************************************\n");
printf("* Results of guitest_playback.C *\n");
printf("**********************************************************************\n");
for (i=0;i<11;++i) {
printf("guitest %02d: output............................................", i+1);
if (TMath::Abs(guitest_ref[i] - guitest_size[i]) <= guitest_err[i]) {
printf("..... OK\n");
// delete successful tests, keep only the failing ones (for verification)
gSystem->Unlink(TString::Format("guitest%03d.C", i+1));
}
else {
printf(". FAILED\n");
}
}
printf("**********************************************************************\n");
gBenchmark->Show("guitest_playback");
}
Author
Bertrand Bellenot

Definition in file guitest_playback.C.

c
#define c(i)
Definition: RSha256.hxx:119
TSystem::Unlink
virtual int Unlink(const char *name)
Unlink, i.e.
Definition: TSystem.cxx:1379
TBenchmark::Start
virtual void Start(const char *name)
Starts Benchmark with the specified name.
Definition: TBenchmark.cxx:172
r
ROOT::R::TRInterface & r
Definition: Object.C:4
Int_t
int Int_t
Definition: RtypesCore.h:45
TRecorder::kReplaying
@ kReplaying
Definition: TRecorder.h:453
TMath::Abs
Short_t Abs(Short_t d)
Definition: TMathBase.h:120
TString::Format
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
Definition: TString.cxx:2311
TSystem.h
gBenchmark
R__EXTERN TBenchmark * gBenchmark
Definition: TBenchmark.h:59
TSystem::Sleep
virtual void Sleep(UInt_t milliSec)
Sleep milliSec milli seconds.
Definition: TSystem.cxx:438
gSystem
R__EXTERN TSystem * gSystem
Definition: TSystem.h:559
TRecorder.h
TRecorder
Definition: TRecorder.h:422
Riostream.h
TBenchmark::Show
virtual void Show(const char *name)
Stops Benchmark name and Prints results.
Definition: TBenchmark.cxx:155
TSystem::ProcessEvents
virtual Bool_t ProcessEvents()
Process pending events (GUI, timers, sockets).
Definition: TSystem.cxx:417
TSystemFile.h