Aggiunta selezione di debug per il test dell' ISAM.

git-svn-id: svn://10.65.10.50/trunk@294 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
angelo 1994-09-28 09:24:47 +00:00
parent e60478bc49
commit 0dbd85e23c
8 changed files with 634 additions and 353 deletions

View File

@ -1,6 +1,5 @@
#include <default.url>
/* ba1 -0 */
MENU TASK_MENUBAR
SUBMENU MENU_FILE "~File"
@ -20,8 +19,6 @@ MENUBAR MENU_BAR(2)
MENU MENU_BAR(2)
SUBMENU MENU_FILE "~File"
ITEM BAR_ITEM(1) "~Debug"
ITEM BAR_ITEM(1) "~Test"
ITEM BAR_ITEM(2) "~Debug"

View File

@ -19,8 +19,9 @@
class BA1300_application:public TApplication
{
TTestSheet * _testsheet;
TTestProc * _test;
TMask * _mask;
TTestProc * _test,
* _debug;
TMask * _mask;
long _firm;
protected:
@ -34,9 +35,21 @@ public:
TTestSheet * get_sheet() {return _testsheet;}
TTestProc * get_test() {return _test;}
TMask * get_mask() {return _mask;}
TArray_sheet * field_sheet(TMask *);
};
HIDDEN bool seq_handler(TMask_field& f, KEY key)
{
if (key==K_ENTER)
if (!fexist((const char*)f.get()))
{
warning_box("File inesistente");
return FALSE;
}
return TRUE;
}
bool BA1300_application::create() // initvar e arrmask
{
@ -52,7 +65,6 @@ bool BA1300_application::create() // initvar e arrmask
set_firm();
_testsheet = new TTestSheet("Selezione Files") ;
get_sheet()->add_button(DLG_RESET,"~Reset",K_F6);
dispatch_e_menu(BAR_ITEM(1));
}
return TRUE ;
}
@ -66,91 +78,127 @@ bool BA1300_application::destroy() // releasev e arrmask
return TRUE ;
}
TArray_sheet * BA1300_application::field_sheet(TMask * m)
{
TEdit_field& f=(TEdit_field&) m->field(F_FILE);
TArray_sheet * s=(TArray_sheet*) f.sheet()->sheet();
return s;
}
bool BA1300_application::menu(MENU_TAG m)
{
KEY tasto,tastoS;
long numtest;
TMask *msk;
TDir *cdir;
do {
switch(tasto=get_mask()->run())
disable_menu_item(M_FILE_NEW);
switch (m)
{
case BAR_ITEM(2):
msk = new TMask("ba1300b");
cdir = new TDir;
cdir->get(LF_DIR,_nolock,_nordir,_sysdirop);
const int nitems=cdir->eod();
for (int i=0; i<nitems;i++) // fill sheet
{
case K_ENTER:
if (get_sheet()->checked()>0 && (get_mask()->get_long(F_ITERAZIONI)>0 || get_mask()->get_bool(F_CONTINUO)))
{
_test = new TTestProc;
get_test()->set_sheet(get_sheet());
get_test()->set_rmc();
get_test()->get_win()->set_color(COLOR_BLACK,COLOR_WHITE);
get_test()->get_win()->clear(COLOR_WHITE);
get_test()->get_win()->set_caption("Monitor");
get_test()->get_win()->WriteW(10,5,"Test N. :");
get_test()->get_win()->WriteW(10,7,"Nome File :");
get_test()->get_win()->WriteW(10,9,"Record cancellati :");
get_test()->get_win()->WriteW(10,10,"Operazione in corso :");
get_test()->get_win()->WriteW(10,12,"Tempo trascorso :");
get_test()->get_win()->WriteW(10,13,"Tempo stimato :");
get_test()->get_win()->WriteW(10,15,"Ultimo Errore :");
numtest=0;
while (((++numtest)<=get_mask()->get_long(F_ITERAZIONI) || get_mask()->get_bool(F_CONTINUO)) && (!get_test()->stopped()))
{
if (get_mask()->get_bool(F_CONTINUO))
get_test()->get_win()->WriteW(33,5,(const char*)TString(20).format("%4ld (CONTINUO)",numtest));
else
get_test()->get_win()->WriteW(33,5,(const char*)TString(20).format("%4ld/%-4ld",numtest,_mask->get_long(F_ITERAZIONI)));
get_test()->set_numt(numtest);
get_test()->do_test_1();
}
if (get_test()->rm_copy())
{ // Funzione di cancellazione da implementare sotto windows
TString base(get_test()->get_base());
get_test()->get_win()->WriteW(33,10,"CANCELLAZIONE COPIE ");
for (int i=0;i<get_sheet()->items();i++)
if (get_sheet()->checked(i))
{
TString nome(get_sheet()->row(i).get(2));
TString fpath;
nome.ltrim(1);
nome.rtrim(4);
fpath << base << nome << ".sta";
remove((const char*)fpath);
fpath.rtrim(4);
fpath << ".sdx";
remove((const char*)fpath);
}
}
delete _test;
}
else
warning_box("No files selected!");
break;
case K_F4:
get_sheet()->sr_status();
while ((tastoS=get_sheet()->run()) == K_F6)
for (int i=0; i<get_sheet()->items();i++)
get_sheet()->uncheck(i);
if (tastoS == K_ESC)
get_sheet()->sr_status(FALSE);
else
{ // Cannot select first two files.
get_sheet()->uncheck(0);
get_sheet()->uncheck(1);
}
break;
case K_F5:
if (fexist((const char*)TString(20).format("test%creport.txt",Separator)))
{
TTestReport rep_win("Report");
rep_win.load_report();
rep_win.run();
} else
message_box("Report not available");
break;
default:
break;
TToken_string riga(128);
riga.cut(0);
cdir->get(i+1,_nolock,_nordir,_sysdirop);
riga=format("%3d",i+1);
riga.add(cdir->name());
riga.add(format("%ld",cdir->eod()));
riga.add(format("%ld",cdir->eox()));
riga.add(format("%u",cdir->len()));
riga.add(cdir->des());
field_sheet(msk)->add(riga);
}
} while (tasto != K_ESC);
msk->set_handler(F_SEQUENZA,seq_handler);
if (msk->run()==K_ENTER)
{
_debug = new TTestProc;
_debug->set_file(msk->get_long(F_FILE));
_debug->load_random(msk->get(F_SEQUENZA));
if (!_debug->stopped())
_debug->do_debug();
else
warning_box("File di sequenza non valido");
delete _debug;
}
delete msk;
delete cdir;
break;
case BAR_ITEM(1):
do {
switch(tasto=get_mask()->run())
{
case K_ENTER:
if (get_sheet()->checked()>0 && (get_mask()->get_long(F_ITERAZIONI)>0 || get_mask()->get_bool(F_CONTINUO)))
{
_test = new TTestProc;
get_test()->set_sheet(get_sheet());
get_test()->set_rmc();
get_test()->get_win()->set_color(COLOR_BLACK,COLOR_WHITE);
get_test()->get_win()->clear(COLOR_WHITE);
get_test()->get_win()->set_caption("Verifica di stabilita'");
get_test()->get_win()->WriteW(10,5,"Test N. :");
get_test()->get_win()->WriteW(10,7,"Nome File :");
get_test()->get_win()->WriteW(10,9,"Record cancellati :");
get_test()->get_win()->WriteW(10,10,"Operazione in corso :");
get_test()->get_win()->WriteW(10,12,"Tempo trascorso :");
get_test()->get_win()->WriteW(10,13,"Tempo stimato :");
get_test()->get_win()->WriteW(10,15,"Ultimo Errore :");
numtest=0;
while (((++numtest)<=get_mask()->get_long(F_ITERAZIONI) || get_mask()->get_bool(F_CONTINUO)) && (!get_test()->stopped()))
{
if (get_mask()->get_bool(F_CONTINUO))
get_test()->get_win()->WriteW(33,5,(const char*)TString(20).format("%4ld (CONTINUO)",numtest));
else
get_test()->get_win()->WriteW(33,5,(const char*)TString(20).format("%4ld/%-4ld",numtest,_mask->get_long(F_ITERAZIONI)));
get_test()->set_numt(numtest);
get_test()->do_test_1();
}
if (get_test()->rm_copy())
{
get_test()->get_win()->WriteW(33,10,"CANCELLAZIONE COPIE ");
for (long i=0;i<get_sheet()->items();i++)
if (get_sheet()->checked(i))
get_test()->remove_copy(i+1);
}
delete _test;
}
else
warning_box("Nessun file selezionato");
break;
case K_F4:
get_sheet()->sr_status();
while ((tastoS=get_sheet()->run()) == K_F6)
for (int i=0; i<get_sheet()->items();i++)
get_sheet()->uncheck(i);
if (tastoS == K_ESC)
get_sheet()->sr_status(FALSE);
else
{ // Cannot select first two files.
get_sheet()->uncheck(0);
get_sheet()->uncheck(1);
}
break;
case K_F5:
if (fexist((const char*)TString(20).format("test%creport.txt",Separator)))
{
TTestReport rep_win("Report");
rep_win.load_report();
rep_win.run();
} else
warning_box("Report non disponibile");
break;
default:
break;
}
} while (tasto != K_ESC);
break;
}
enable_menu_item(M_FILE_NEW);
return xvt_test_menu_tag(BAR_ITEM(2));
}

View File

@ -36,6 +36,7 @@ class TTestWin : public TIndwin
{
protected:
virtual void update() {update_text();}
virtual void handler(WINDOW w, EVENT *e);
void update_text() {set_mode(M_COPY); check_stop();}
public:
WriteW(short x, short y, const char* line) {stringat(x,y,line);update_text();do_events();}
@ -51,6 +52,7 @@ class TTestProc
long * _randseq; // Random sequence
long _ntest; // number of test in progress
long _nfile; // number of file being tested
long _kriminal; // number of record incriminated (Debug)
int _nkeys; // # of keys defined for current file
bool _block; // is test blocked ?
bool _rmc; // Remove copies at the end of test ?
@ -60,6 +62,7 @@ protected:
void DumpReport(int err, long i, long x, int key);
long sumop(const long n) {return ((n+1)*(n/2)+(n%2)*((n+1)/2));}
int ctrl_keys();
bool show_mess(int, int, long, long, int);
const char * fmttime(const long);
public:
TTestProc();
@ -67,12 +70,16 @@ public:
const char* get_base();
void do_test_1();
void do_test_2();
void do_debug();
void remove_copy(long n);
void load_random(const TString& st);
bool stopped() {return _block;}
bool rm_copy() {return _rmc;}
void set_rmc(bool a=FALSE) {_rmc = a;}
long num_test() {return _ntest;}
void set_numt(const long num) { _ntest = num;}
long num_file() {return _nfile;}
void set_file(long n) {_nfile=n;}
long number(const long n) {return _randseq[n];}
void set_sheet (TTestSheet * sh) {_sheet=sh;}
TTestSheet * get_isheet() {return _sheet;}

View File

@ -2,12 +2,17 @@
#define __BA1300A_H
#define F_CONTINUO 101
#define F_ITERAZIONI 102
#define F_LABEL 103
#define DLG_FILES 104
#define DLG_REPORT 105
#define DLG_TEST 106
#define F_CONTINUO 101
#define F_ITERAZIONI 102
#define F_LABEL 103
#define DLG_FILES 104
#define DLG_REPORT 105
#define DLG_TEST 106
#define DLG_RESET 201 // Reset button for sheet mask
#define F_FILE 101
#define F_NOMEFILE 102
#define F_SEQUENZA 103
#define DLG_RESET 201 // Reset button for sheet mask
#endif

View File

@ -46,10 +46,9 @@ BEGIN
MESSAGE EXIT,K_ENTER
END
BUTTON DLG_NULL 9 2
BUTTON DLG_CANCEL 9 2
BEGIN
PROMPT 30 7 "F~ine"
MESSAGE EXIT,K_ESC
PROMPT 30 7 ""
END
ENDMASK

33
ba/ba1300b.uml Executable file
View File

@ -0,0 +1,33 @@
#include <defmask.h>
#include <tokens.h>
#include "ba1300a.h"
PAGE "Debugging" -1 -1 42 7
NUMBER F_FILE 3
BEGIN
PROMPT 2 1 "Numero file "
SHEET "N.@5|Nome@20|EOD@7|EOX@7|Lung. |Descrizione@43"
INPUT F_FILE
OUTPUT F_FILE
HELP "Inserire il numero del file da esaminare"
END
STRING F_SEQUENZA 20
BEGIN
PROMPT 2 3 "File Random "
HELP "Introdurre il nome del file della sequenza"
END
BUTTON DLG_OK 9 2
BEGIN
PROMPT -12 6 ""
END
BUTTON DLG_CANCEL 9 2
BEGIN
PROMPT -22 6 ""
END
ENDMASK

View File

@ -15,7 +15,7 @@
#include "ba1300.h"
extern "C" {
void cgettime(char *);
void cgettime(char *);
}
TTestSheet::TTestSheet(const char* titolo, const char* colonne,byte bottoni)
@ -34,7 +34,7 @@ void TTestSheet::page_build(long first, byte rows)
const int n = int(i+first+1);
dir()->get (n,_nolock,_nordir,_sysdirop);
l.cut(0);
l.add("");
l.add("");
l.add(format("%3d", n)); // Numero progressivo del file
l.add(dir()->name());
const TRecnotype eod = dir()->eod();
@ -53,32 +53,32 @@ void TTestSheet::sr_status(bool save)
{
for (int i=0; i<items();i++)
if (save)
_oldstatus.set(i,checked(i));
_oldstatus.set(i,checked(i));
else
check(i,_oldstatus[i]);
check(i,_oldstatus[i]);
}
const char* TTestProc::fmttime(const long tm)
{
TString st;
int sec=(int) tm%60;
int min=(int) tm/60;
int hour=min/60;
min%=60;
st.format("%03d:%02d:%02d",hour,min,sec);
return (const char*) st;
int min=(int) tm/60;
int hour=min/60;
min%=60;
st.format("%03d:%02d:%02d",hour,min,sec);
return (const char*) st;
}
const char * TTestProc::get_base()
{
TTestFile fn(1);
fn.open();
const char * name =(const char *) fn.file_name();
fn.close();
TTestFile fn(1);
fn.open();
const char * name =(const char *) fn.file_name();
fn.close();
char *com;
com=strrchr(name,Separator);
if (com!=NULL)
*(++com)='\0';
com=strrchr(name,Separator);
if (com!=NULL)
*(++com)='\0';
return name;
}
@ -87,323 +87,513 @@ void TTestProc::filecopy(bool save)
TString St0,St1,St2;
TTestFile fn(_nfile);
fn.open();
St0=fn.file_name();
fn.open();
St0=fn.file_name();
fn.close();
St1=St0;
St1=St0;
St0.rtrim(4); // cut extension
St2=St0 << ".sta";
/// Save/Restore data files
if (save)
fcopy((const char*)St1,(const char*)St2);
else
fcopy((const char*)St2,(const char*)St1);
St2=St0 << ".sta";
/// Save/Restore data files
if (save)
fcopy((const char*)St1,(const char*)St2);
else
fcopy((const char*)St2,(const char*)St1);
St0.rtrim(4);
St1=St0 << ".ndx";
St0.rtrim(4);
St2=St0 << ".sdx";
St2=St0 << ".sdx";
if (save)
fcopy((const char*)St1,(const char*)St2);
fcopy((const char*)St1,(const char*)St2);
else
fcopy((const char*)St2,(const char*)St1);
fcopy((const char*)St2,(const char*)St1);
}
void TTestProc::remove_copy(long n)
{
TString base(get_base());
TDir d;
d.get(n,_nolock,_nordir,_sysdirop);
TString nome(d.name());
TString fpath;
nome.ltrim(1);
nome.rtrim(4);
fpath << base << nome << ".sta";
remove((const char*)fpath);
fpath.rtrim(4);
fpath << ".sdx";
remove((const char*)fpath);
}
void TTestProc::do_random(long eod)
{
long i,j,com;
unsigned int cbits,scale,parm,rnd;
time_t tloc;
long i,j,com;
unsigned int cbits,scale,parm,rnd;
time_t tloc;
// Initialize array to mix
for (i=1; i<=eod;i++)
_randseq[i-1]=i;
// Compute scale
i=eod;
cbits=0;
while (i)
{
i=i>>1;
cbits++;
}
scale=(unsigned int)0x8000;
for (i=1;i<=cbits;i++)
{
scale=scale>>1;
scale |= 0x8000;
}
// Extracts "random" seed from time
time(&tloc);
parm=(unsigned int)(tloc & 0x0000FFFF);
srand(parm);
// Mix array...
for (i=0;i<eod;i++)
{
rnd=rand();
rnd&=scale;
for (j=1;j<=(16-cbits);j++)
rnd=rnd>>1;
if (((long) rnd)>=eod) // Difficile che accada...
rnd=(unsigned int) eod-1;
com=_randseq[i];
_randseq[i]=_randseq[(long)rnd];
_randseq[(long)rnd]=com;
}
// Initialize array to mix
for (i=1; i<=eod;i++)
_randseq[i-1]=i;
// Compute scale
i=eod;
cbits=0;
while (i)
{
i=i>>1;
cbits++;
}
scale=(unsigned int)0x8000;
for (i=1;i<=cbits;i++)
{
scale=scale>>1;
scale |= 0x8000;
}
// Extracts "random" seed from time
time(&tloc);
parm=(unsigned int)(tloc & 0x0000FFFF);
srand(parm);
// Mix array...
for (i=0;i<eod;i++)
{
rnd=rand();
rnd&=scale;
for (j=1;j<=(16-cbits);j++)
rnd=rnd>>1;
if (((long) rnd)>=eod) // Difficile che accada...
rnd=(unsigned int) eod-1;
com=_randseq[i];
_randseq[i]=_randseq[(long)rnd];
_randseq[(long)rnd]=com;
}
}
int TTestProc::ctrl_keys()
{
int err=1;
for (int nk=1;nk<=_nkeys;nk++)
{
_workf->setkey(nk);
if ((err=_workf->first())==NOERR)
return NOERR;
}
for (int nk=1;nk<=_nkeys;nk++)
{
_workf->setkey(nk);
if ((err=_workf->first())==NOERR)
return NOERR;
}
return err;
}
void TTestProc::do_test_1()
{
bool FoundError;
long i,EOD;
int err;
time_t inix,finix;
bool FoundError;
long i,EOD;
int err;
time_t inix,finix;
_nfile=0;
while ((_nfile++ <= get_isheet()->items()) && !_block)
{
EOD=get_isheet()->row(_nfile-1).get_long(3);
if (get_isheet()->checked(_nfile-1) && EOD > 0)
{
get_win()->WriteW(33,7,(const char*)TString(18).format("%-18s",get_isheet()->row(_nfile-1).get(2)));
get_win()->WriteW(33,12,"000:00:00");
get_win()->WriteW(33,13,"000:00:00");
if (_ntest == 1)
{
TSystemisamfile f(_nfile);
get_win()->WriteW(33,10,"COMPATTAMENTO ");
if ((f.packfile(FALSE)!=NOERR)||(f.packindex(FALSE) != NOERR))
error_box("Errore in compattamento file %d",_nfile);
get_win()->WriteW(33,10,"COPIA DI SICUREZZA ");
filecopy();
set_rmc(TRUE);
} // If it was test # 1
_nfile=0;
while ((_nfile++ <= get_isheet()->items()) && !_block)
{
EOD=get_isheet()->row(_nfile-1).get_long(3);
if (get_isheet()->checked(_nfile-1) && EOD > 0)
{
get_win()->WriteW(33,7,(const char*)TString(18).format("%-18s",get_isheet()->row(_nfile-1).get(2)));
get_win()->WriteW(33,12,"000:00:00");
get_win()->WriteW(33,13,"000:00:00");
if (_ntest == 1)
{
TSystemisamfile f(_nfile);
get_win()->WriteW(33,10,"COMPATTAMENTO ");
if ((f.packfile(FALSE)!=NOERR)||(f.packindex(FALSE) != NOERR))
error_box("Errore in compattamento file %d",_nfile);
get_win()->WriteW(33,10,"COPIA DI SICUREZZA ");
filecopy();
set_rmc(TRUE);
} // If it was test # 1
_workf = new TTestFile(_nfile);
time(&inix);
time(&inix);
if (_workf->open(_excllock) == NOERR)
{
TTrec r;
r.get(_nfile);
_nkeys=r.keys();
FoundError=FALSE;
i=0;
EOD=_workf->eod();
get_win()->WriteW(33,9,(const char*)TString(14).format(" 0/%-7ld",EOD));
get_win()->WriteW(33,10,"TEST1 (cisreadrec-cisdelete)");
_randseq = new long[EOD];
do_random(EOD);
while (!FoundError && i<EOD && !_block)
{
if ((err=_workf->readat(number(i++)))==NOERR)
err=_workf->remove();
if (err!=NOERR)
FoundError=TRUE;
// Ascoltare se viene premuto esc....eventualmente bloccare
if (get_win()->iscancelled())
_block=TRUE;
if ((i%20)==0)
get_win()->WriteW(33,9,(const char*)TString(20).format("%7ld/%-7ld",i,EOD));
time(&finix);
get_win()->WriteW(33,12,(const char*)TString(10).format("%s",fmttime(finix-inix)));
if (((finix-inix)%3)==0)
{
long com=((finix-inix)*EOD)/(i+1);
get_win()->WriteW(33,13,(const char*)TString(10).format("%s",fmttime(com)));
}
}
if (!_block && ((ctrl_keys()==NOERR) || FoundError))
do_test_2();
_workf->close();
get_win()->WriteW(33,10,"RIPRISTINO ARCHIVI ");
filecopy(FALSE); //restore copies
if (_randseq!=NULL)
delete _randseq;
} // If it was open
{
TTrec r;
r.get(_nfile);
_nkeys=r.keys();
FoundError=FALSE;
i=0;
EOD=_workf->eod();
get_win()->WriteW(33,9,(const char*)TString(14).format(" 0/%-7ld",EOD));
get_win()->WriteW(33,10,"TEST1 (cisreadrec-cisdelete)");
_randseq = new long[EOD];
do_random(EOD);
while (!FoundError && i<EOD && !_block)
{
if ((err=_workf->readat(number(i++)))==NOERR)
err=_workf->remove();
if (err!=NOERR)
FoundError=TRUE;
if (get_win()->iscancelled())
_block=TRUE;
if ((i%20)==0)
get_win()->WriteW(33,9,(const char*)TString(20).format("%7ld/%-7ld",i,EOD));
time(&finix);
get_win()->WriteW(33,12,(const char*)TString(10).format("%s",fmttime(finix-inix)));
if (((finix-inix)%3)==0)
{
long com=((finix-inix)*EOD)/(i+1);
get_win()->WriteW(33,13,(const char*)TString(10).format("%s",fmttime(com)));
}
}
if (!_block && ((ctrl_keys()==NOERR) || FoundError))
do_test_2();
_workf->close();
get_win()->WriteW(33,10,"RIPRISTINO ARCHIVI ");
filecopy(FALSE); //restore copies
if (_randseq!=NULL)
delete _randseq;
} // If it was open
if (_workf != NULL)
delete _workf;
} // If it was selected
} // While test is in progress
delete _workf;
} // If it was selected
} // While test is in progress
}
void TTestProc::do_test_2()
{
time_t alpha,omega;
long i=0,j;
int err=NOERR;
time_t alpha,omega;
long i=0,j;
int err=NOERR;
get_win()->WriteW(33,10,"TEST2: RIPRISTINO ARCHIVI ");
_workf->close();
filecopy(FALSE);
if (_workf->open(_excllock) == NOERR)
{
long EOD=_workf->eod();
long optot=sumop(EOD);
long optr=1;
get_win()->WriteW(33,10,"TEST2: RIPRISTINO ARCHIVI ");
_workf->close();
filecopy(FALSE);
if (_workf->open(_excllock) == NOERR)
{
long EOD=_workf->eod();
long optot=sumop(EOD);
long optr=1;
get_win()->WriteW(33,10,"TEST2 (cisreadrec-cisdelete)");
time(&alpha);
while (!_block && i<EOD && err==NOERR)
{
_workf->readat(number(i));
err=_workf->remove();
j=i+1;
get_win()->WriteW(33,10,"TEST2: CONTROLLO CHIAVI ");
get_win()->WriteW(33,9,(const char*)TString(20).format("%7ld/%-7ld",j,EOD));
while (!_block && j<EOD && err==NOERR)
{
if (get_win()->iscancelled()) _block=TRUE;
time(&omega);
get_win()->WriteW(33,10,"TEST2 (cisreadrec-cisdelete)");
time(&alpha);
while (!_block && i<EOD && err==NOERR)
{
_workf->readat(number(i));
err=_workf->remove();
j=i+1;
get_win()->WriteW(33,10,"TEST2: CONTROLLO CHIAVI ");
get_win()->WriteW(33,9,(const char*)TString(20).format("%7ld/%-7ld",j,EOD));
while (!_block && j<EOD && err==NOERR)
{
if (get_win()->iscancelled()) _block=TRUE;
time(&omega);
get_win()->WriteW(33,12,(const char*)TString(10).format("%s",fmttime(omega-alpha)));
if ((omega-alpha)%3==0)
get_win()->WriteW(33,13,(const char*)TString(10).format("%s",fmttime(((omega-alpha)*optot)/optr)));
err=_workf->readat(number(j));
get_win()->WriteW(33,13,(const char*)TString(10).format("%s",fmttime(((omega-alpha)*optot)/optr)));
err=_workf->readat(number(j));
optr++;
int k=1;
while (k<=_nkeys && err==NOERR)
{
TTrec r;
r.get(_nfile);
TToken_string def(r.keydef(k));
while (k<=_nkeys && err==NOERR)
{
TTrec r;
r.get(_nfile);
TToken_string def(r.keydef(k-1));
_workf->setkey(k);
err=_workf->read();
if (def.get_char(1)=='X') // if keys are duplicated
{
TString ksaved(_workf->curr().key(k));
bool Fnd=FALSE;
_workf->setkey(k);
err=_workf->read();
if (def.get_char(1)=='X') // if keys are duplicated
{
TString ksaved(_workf->curr().key(k));
bool Fnd=FALSE;
while (err==NOERR && !Fnd && ksaved==_workf->curr().key(k))
if (_workf->recno()==number(j))
Fnd=TRUE;
else
err=_workf->next();
}
if (err!=NOERR || number(j)!=_workf->recno())
{
get_win()->WriteW(33,10,"Trovati errori scrittura report");
DumpReport(err,i,j,k);
if (err==NOERR)
err=999; //errore fittizio, tanto per farlo uscire
}
k++;
}
while (err==NOERR && !Fnd && ksaved==_workf->curr().key(k))
if (_workf->recno()==number(j))
Fnd=TRUE;
else
err=_workf->next();
}
if (err!=NOERR || number(j)!=_workf->recno())
{
get_win()->WriteW(33,10,"Trovati errori scrittura report");
DumpReport(err,i,j,k);
if (err==NOERR)
err=999; //errore fittizio, tanto per farlo uscire
}
k++;
}
j++;
}
get_win()->WriteW(33,10,"TEST2 (cisreadrec-cisdelete) ");
i++;
}
get_win()->WriteW(33,10,"TEST2 (cisreadrec-cisdelete) ");
i++;
}
}
}
}
void TTestProc::DumpReport(int err, long i, long x, int key)
{
static rnum=0;
char ora[10];
TString RandomFile,ReportFile;
FILE * fp;
static rnum=0;
char ora[10];
TString RandomFile,ReportFile;
FILE * fp;
get_win()->WriteW(33,15,(const char*)TString(35).format("File nr. %d Test nr. %ld",_nfile,_ntest));
cgettime(ora);
if (!fexist("test")) // create directory
get_win()->WriteW(33,15,(const char*)TString(35).format("File nr. %d Test nr. %ld",_nfile,_ntest));
cgettime(ora);
if (!fexist("test")) // create directory
#if XVT_OS==XVT_OS_SCOUNIX
mkdir("test",0777);
mkdir("test",0777);
#else
mkdir("test");
mkdir("test");
#endif
RandomFile.format("test%crnd%d.dat",Separator,rnum++);
if ((fp=fopen((const char*)RandomFile,"w"))!=NULL)
{
for (int j=0;j<_workf->eod();j++)
fprintf(fp,"%9ld \n",number(j));
fclose(fp);
}
ReportFile.format("test%creport.txt",Separator);
if ((fp=fopen((const char*)ReportFile,"a"))!=NULL)
{
fprintf(fp,"REPORT sulla verifica della stabilita' dell'ISAM\n");
fprintf(fp,"------\n");
fprintf(fp,"\n");
fprintf(fp,"Eseguito il : %s Alle : %s\n",(const char*)TDate(TODAY),ora);
fprintf(fp,"\n");
fprintf(fp,"File nr. : %4d %s\n",_nfile,get_isheet()->row(_nfile-1).get(2));
fprintf(fp,"File Random : %s\n",(const char*)RandomFile);
fprintf(fp,"Nr. Record cancellato: %5ld Nr. Record letto: %5ld\n",number(i),number(x));
fprintf(fp,"Nr. Chiave elaborata: %3d\n",key);
if (err!=NOERR)
fprintf(fp,"Errore generato dal record letto: %d\n",err);
else
fprintf(fp,"Errore generato dal record letto: Numero di record non corretto.\n\n");
fprintf(fp,"------\n\n\n");
fclose(fp);
}
RandomFile.format("test%crnd%d.dat",Separator,rnum++);
if ((fp=fopen((const char*)RandomFile,"w"))!=NULL)
{
for (int j=0;j<_workf->eod();j++)
if (j==i)
fprintf(fp,"%9ld*\n",number(j));
else
fprintf(fp,"%9ld \n",number(j));
fclose(fp);
}
ReportFile.format("test%creport.txt",Separator);
if ((fp=fopen((const char*)ReportFile,"a"))!=NULL)
{
fprintf(fp,"REPORT sulla verifica della stabilita' dell'ISAM\n");
fprintf(fp,"------\n");
fprintf(fp,"\n");
fprintf(fp,"Eseguito il : %s Alle : %s\n",(const char*)TDate(TODAY),ora);
fprintf(fp,"\n");
fprintf(fp,"File nr. : %4d %s\n",_nfile,get_isheet()->row(_nfile-1).get(2));
fprintf(fp,"File Random : %s\n",(const char*)RandomFile);
fprintf(fp,"Nr. Record cancellato: %5ld Nr. Record letto: %5ld\n",number(i),number(x));
fprintf(fp,"Nr. Chiave elaborata: %3d\n",key);
if (err!=NOERR)
fprintf(fp,"Errore generato dal record letto: %d\n",err);
else
fprintf(fp,"Errore generato dal record letto: Numero di record non corretto.\n\n");
fprintf(fp,"------\n\n\n");
fclose(fp);
}
}
void TTestProc::load_random(const TString& st)
{
FILE *fp;
char c;
_kriminal=0;
if ((fp=fopen((const char*)st,"r"))!=NULL)
{
TDir d;
d.get(_nfile,_nolock,_nordir,_sysdirop);
_randseq = new long[d.eod()];
for (long i=0;i<d.eod() && !feof(fp);i++)
{
fscanf(fp,"%9ld%c",&_randseq[i],&c);
if (c=='*')
_kriminal=_randseq[i];
if (_randseq[i]>d.eod())
{
_block=TRUE;
break;
}
}
}
}
void TTestProc::do_debug()
{
TDir d;
d.get(_nfile,_nolock,_nordir,_sysdirop);
get_win()->set_color(COLOR_BLACK,COLOR_WHITE);
get_win()->clear(COLOR_WHITE);
get_win()->set_caption("Ricerca dell'errore");
get_win()->WriteW(8,5,(const char*)TString(25).format("File numero : %4d\t\t\t%s",_nfile,(const char*)d.name()));
get_win()->WriteW(8,7,"Record Cancellati :");
get_win()->WriteW(8,9,"Operazione in corso : COPIA DI SICUREZZA");
get_win()->WriteW(8,11,"Record cancellato :");
get_win()->WriteW(8,12,"Record letto :");
get_win()->WriteW(8,14,"Errore rilevato :");
filecopy(); // Backup copies. Must be placed here
// otherwise I get a "File already open error"
_workf = new TTestFile(_nfile);
if (_workf->open(_excllock) == NOERR)
{
TTrec r;
r.get(_nfile);
_nkeys=r.keys();
long i=0,j;
int k,err=NOERR;
bool step=FALSE;
get_win()->WriteW(30,9,"Cancello fino al Kriminale...");
while (!stopped() && i<_workf->eod() && err==NOERR)
{
if (number(i)==_kriminal)
step=TRUE; // Put here a Break Point to debug step by step
err=_workf->readat(number(i));
if (err!=NOERR || step)
_block=show_mess(1,err,number(i),number(i),0);
err=_workf->remove();
if (err!=NOERR || step)
_block=show_mess(2,err,number(i),number(i),0);
j=i+1;
get_win()->WriteW(30,9,"TEST 2: CONTROLLO CHIAVI ");
get_win()->WriteW(30,7,(const char*)TString(20).format("%5ld/%-5ld",j,_workf->eod()));
get_win()->WriteW(30,11,(const char*)TString(10).format("%5ld",number(i)));
while (!stopped() && j<_workf->eod() && err==NOERR)
{
if (get_win()->iscancelled())
_block=TRUE;
err=_workf->readat(number(j));
if (err!=NOERR || step)
_block=show_mess(3,err,number(j),number(j),0);
get_win()->WriteW(30,12,(const char*)TString(10).format("%5ld",number(j)));
k=1;
while (k<=_nkeys && err==NOERR && !stopped())
{
TToken_string def(r.keydef(k-1));
_workf->setkey(k);
err=_workf->read();
if (err!=NOERR || step)
_block=show_mess(4,err,number(j),_workf->recno(),k);
if (def.get_char(1)=='X') // if keys are duplicated
{
TString ksaved(_workf->curr().key(k));
bool Fnd=FALSE;
while (!stopped() && err==NOERR && !Fnd && ksaved==_workf->curr().key(k))
if (_workf->recno()==number(j))
Fnd=TRUE;
else
{
err=_workf->next();
if (err!=NOERR || step)
_block=show_mess(5,err,number(j),_workf->recno(),k);
}
} // if keys are duplicated
if (err!=NOERR || number(j)!=_workf->recno())
{
_block=show_mess(6,err,number(j),number(j),0);
err=999; // So it will exit
}
k++;
}
j++;
}
get_win()->WriteW(30,9,"Cisreadrec -- Cisdelete ");
i++;
}
_workf->close();
}
get_win()->WriteW(30,9,"RIPRISTINO ARCHIVIO ");
filecopy(FALSE); // Restore copies
get_win()->WriteW(30,9,"CANCELLAZIONE COPIE ");
remove_copy(_nfile); // Delete backup copies
// Free pointers
if (_workf!=NULL)
delete _workf;
if (_randseq != NULL)
delete _randseq;
}
bool TTestProc::show_mess(int act, int err, long n1, long n2, int k)
{
switch (act)
{
case 1:
get_win()->WriteW(30,9,(const char*)TString(42).format("Eseguita la readrec per rec. # %ld",n1));
get_win()->WriteW(30,11,(const char*)TString(40).spaces());
break;
case 2:
get_win()->WriteW(30,9,(const char*)TString(42).format("Eseguita la delete per rec. # %ld",n1));
get_win()->WriteW(30,11,(const char*)TString(10).format("%5ld",n1));
break;
case 3:
get_win()->WriteW(30,9,(const char*)TString(42).format("Eseguita la readrec per contr. chiavi"));
get_win()->WriteW(30,12,(const char*)TString(10).format("%5ld ",n1));
break;
case 4:
get_win()->WriteW(30,9,(const char*)TString(42).format("Eseguita la start con chiave %d ",k));
get_win()->WriteW(30,12,(const char*)TString(15).format("%5ld (%ld)",n1,n2));
break;
case 5:
get_win()->WriteW(30,9,(const char*)TString(42).format("Eseguita la next per chiavi doppie "));
get_win()->WriteW(30,12,(const char*)TString(15).format("%5ld (%ld)",n1,n2));
break;
case 6:
get_win()->WriteW(30,9,(const char*)TString(42).format("Record %ld non trovato nelle chiavi duplicate ",n1));
break;
}
get_win()->WriteW(30,14,(const char*)TString(5).format("%5d",err));
KEY tasto=get_win()->run();
return (tasto == K_ESC);
}
TTestProc::TTestProc()
: _block(FALSE), _ntest(0), _nfile(0), _randseq(NULL), _rmc(FALSE), _workf(NULL), _sheet(NULL), _win(NULL)
{
_win = new TTestWin;
}
{
_win = new TTestWin;
}
TTestProc::~TTestProc()
{
if (_win != NULL)
delete _win;
if (_win != NULL)
delete _win;
}
TTestWin::TTestWin()
:TIndwin(1L,"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",TRUE,FALSE,64)
:TIndwin(1L,"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",TRUE,FALSE,70)
{}
void TTestWin::handler(WINDOW w, EVENT *e)
{
switch (e->type)
{
case E_CHAR:
if (e->v.chr.ch == K_ENTER)
stop_run(K_ENTER);
break;
default:
break;
}
TIndwin::handler(w,e);
}
TTestReport::TTestReport(const char* title)
{
WINDOW parent=TASK_WIN;
long flags=WSF_CLOSE | WSF_SIZE | WSF_VSCROLL | WSF_HSCROLL;
WIN_TYPE wt=W_DOC;
create(6,2,68,20,title,flags,wt,parent);
set_color(COLOR_BLACK,COLOR_WHITE);
long flags=WSF_CLOSE | WSF_SIZE | WSF_VSCROLL | WSF_HSCROLL;
WIN_TYPE wt=W_DOC;
create(6,2,68,20,title,flags,wt,parent);
set_color(COLOR_BLACK,COLOR_WHITE);
}
void TTestReport::load_report()
{
FILE *fp;
char line[256];
char line[256];
fp=fopen((const char *)TString(20).format("test%creport.txt",Separator),"r");
while (fgets(line,256,fp)!=NULL)
{
TString element(line);
_report.add(element);
}
fclose(fp);
set_scroll_max(80,_report.items());
fp=fopen((const char *)TString(20).format("test%creport.txt",Separator),"r");
while (fgets(line,256,fp)!=NULL)
{
TString element(line);
_report.add(element);
}
fclose(fp);
set_scroll_max(80,_report.items());
}
void TTestReport::update()
{
for (int i=0; i<_report.items(); i++)
stringat(1,i+1,(const char*)get_row(i));
for (int i=0; i<_report.items(); i++)
stringat(1,i+1,(const char*)get_row(i));
}
bool TTestReport::on_key(KEY key)
{
switch (key)
{
case K_ESC:
stop_run(key);
break;
default:
break;
}
return TScroll_window::on_key(key);
{
case K_ESC:
stop_run(key);
break;
default:
break;
}
return TScroll_window::on_key(key);
}

View File

@ -170,7 +170,7 @@ $(EP)trc.gen: trc.gen.asc
uudecode trc.gen.asc
mv trc.gen $(EP)
masks: $(EP)ba1100a.msk $(EP)ba1100b.msk $(EP)ba1100c.msk $(EP)ba1100d.msk $(EP)ba1100e.msk $(EP)ba1100f.msk $(EP)ba1300a.msk $(EP)ba2300a.msk $(EP)ba2300b.msk $(EP)ba2300c.msk $(EP)ba2300d.msk \
masks: $(EP)ba1100a.msk $(EP)ba1100b.msk $(EP)ba1100c.msk $(EP)ba1100d.msk $(EP)ba1100e.msk $(EP)ba1100f.msk $(EP)ba1300a.msk $(EP)ba1300b.msk $(EP)ba2300a.msk $(EP)ba2300b.msk $(EP)ba2300c.msk $(EP)ba2300d.msk \
$(EP)ba3200a.msk $(EP)ba3300a.msk $(EP)ba3500a.msk $(EP)ba3600a.msk $(EP)ba3700a.msk $(EP)ba4100a.msk $(EP)ba4200b.msk $(EP)ba4200c.msk $(EP)ba4300a.msk $(EP)ba4400a.msk \
$(EP)ba4500a.msk $(EP)ba4600a.msk $(EP)ba5000.msk $(EP)ba6000a.msk $(EP)ba6000b.msk $(EP)ba6100a.msk $(EP)ba6100b.msk $(EP)ba6200a.msk $(EP)bast%ais.msk $(EP)bast%asf.msk \
$(EP)bast%ban.msk $(EP)bast%cco.msk $(EP)bast%cfi.msk $(EP)bast%cpg.msk $(EP)bast%crs.msk $(EP)bast%cve.msk $(EP)bast%dpn.msk $(EP)bast%itl.msk $(EP)bast%iva.msk $(EP)bast%ivd.msk \
@ -200,6 +200,8 @@ $(EP)ba1100f.msk: ba1100f.uml $(I45) ba1100a.h
$(EP)ba1300a.msk: ba1300a.uml $(I45) ba1300a.h
$(EP)ba1300b.msk: ba1300b.uml $(I45) ba1300a.h
$(EP)ba2300a.msk: ba2300a.uml ba2300.h
$(EP)ba2300b.msk: ba2300b.uml ba2300.h