Aggiunto un programma per il test dell' ISAM.
git-svn-id: svn://10.65.10.50/trunk@288 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
fb03331361
commit
3275903d6e
@ -5,7 +5,7 @@
|
||||
|
||||
#include "ba1.h"
|
||||
|
||||
#define usage "Errore - uso : ba1 [-{0|1}]"
|
||||
#define usage "Errore - uso : ba1 [-{0|1|2}]"
|
||||
|
||||
int main(int argc,char** argv)
|
||||
{
|
||||
@ -20,6 +20,7 @@ int main(int argc,char** argv)
|
||||
{
|
||||
case '0': rt = ba1100(argc,argv); break;
|
||||
case '1': rt = ba1200(argc,argv); break;
|
||||
case '2': rt = ba1300(argc,argv);break;
|
||||
default : fatal_box(usage); break;
|
||||
}
|
||||
}
|
||||
|
1
ba/ba1.h
1
ba/ba1.h
@ -3,6 +3,7 @@
|
||||
|
||||
int ba1100(int argc, char** argv);
|
||||
int ba1200(int argc, char** argv);
|
||||
int ba1300(int argc, char** argv);
|
||||
|
||||
#endif // __BA1_H
|
||||
|
||||
|
@ -20,6 +20,7 @@ MENUBAR MENU_BAR(2)
|
||||
|
||||
MENU MENU_BAR(2)
|
||||
SUBMENU MENU_FILE "~File"
|
||||
ITEM BAR_ITEM(1) "~Debug"
|
||||
|
||||
|
||||
|
||||
|
10
ba/ba1100.h
10
ba/ba1100.h
@ -10,17 +10,17 @@
|
||||
|
||||
class TDir_sheet : public TSheet
|
||||
{
|
||||
TTrec *_rec;
|
||||
TDir *_dir;
|
||||
FileDes _s_dir;
|
||||
long _items;
|
||||
TTrec *_rec;
|
||||
TDir *_dir;
|
||||
FileDes _s_dir;
|
||||
long _items;
|
||||
|
||||
protected: set_firm();
|
||||
|
||||
void page_build(long first, byte rows);
|
||||
|
||||
public:
|
||||
TDir_sheet(const char* title);
|
||||
TDir_sheet(const char* title,const char* columns="N.@5|Nome@20|EOD@7|EOX@7|Lung. |Descrizione@43|Formula@33|Flags@7",byte buttons=0xC);
|
||||
~TDir_sheet();
|
||||
TDir* dir() const { return _dir; }
|
||||
TTrec* rec() const { return _rec; }
|
||||
|
@ -35,8 +35,8 @@ void TDir_sheet::add ()
|
||||
// select(nitems - 1);
|
||||
}
|
||||
|
||||
TDir_sheet::TDir_sheet(const char* title)
|
||||
: TSheet(-1,-1, 0, 0, title,"N.@5|Nome@20|EOD@7|EOX@7|Lung. |Descrizione@43|Formula@33|Flags@7", 0xC)
|
||||
TDir_sheet::TDir_sheet(const char* title, const char * columns, byte buttons)
|
||||
:TSheet(-1,-1, 0, 0, title,columns,buttons)
|
||||
{
|
||||
_dir = new TDir;
|
||||
_rec = new TTrec;
|
||||
|
162
ba/ba1300.cpp
Executable file
162
ba/ba1300.cpp
Executable file
@ -0,0 +1,162 @@
|
||||
#include <stdlib.h>
|
||||
#include <applicat.h>
|
||||
#include <xvtility.h>
|
||||
#include <utility.h>
|
||||
#include <prefix.h>
|
||||
#include <mask.h>
|
||||
#include <isam.h>
|
||||
#include <string.h>
|
||||
#include <sheet.h>
|
||||
#include <msksheet.h>
|
||||
#include <progind.h>
|
||||
#include <urldefid.h>
|
||||
#include <validate.h>
|
||||
#include "ba1.h"
|
||||
#include "ba1300.h"
|
||||
#include "ba1300a.h"
|
||||
|
||||
|
||||
class BA1300_application:public TApplication
|
||||
{
|
||||
TTestSheet * _testsheet;
|
||||
TTestProc * _test;
|
||||
TMask * _mask;
|
||||
long _firm;
|
||||
|
||||
protected:
|
||||
virtual bool menu(MENU_TAG);
|
||||
virtual bool create () ;
|
||||
virtual bool destroy();
|
||||
virtual bool extended_firm() const { return TRUE; }
|
||||
|
||||
public:
|
||||
BA1300_application() : _testsheet(NULL), _mask(NULL) {}
|
||||
TTestSheet * get_sheet() {return _testsheet;}
|
||||
TTestProc * get_test() {return _test;}
|
||||
TMask * get_mask() {return _mask;}
|
||||
|
||||
};
|
||||
|
||||
bool BA1300_application::create() // initvar e arrmask
|
||||
|
||||
{
|
||||
_firm = get_firm();
|
||||
|
||||
if (argc() > 2)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
_mask = new TMask ("ba1300a"); // Maschera principale
|
||||
set_firm();
|
||||
_testsheet = new TTestSheet("Selezione Files") ;
|
||||
get_sheet()->add_button(DLG_RESET,"~Reset",K_F6);
|
||||
dispatch_e_menu(BAR_ITEM(1));
|
||||
}
|
||||
return TRUE ;
|
||||
}
|
||||
|
||||
bool BA1300_application::destroy() // releasev e arrmask
|
||||
|
||||
{
|
||||
if (_firm) set_firm(_firm);
|
||||
if (_testsheet != NULL) delete _testsheet;
|
||||
if (_mask != NULL) delete _mask;
|
||||
return TRUE ;
|
||||
}
|
||||
|
||||
|
||||
bool BA1300_application::menu(MENU_TAG m)
|
||||
{
|
||||
KEY tasto,tastoS;
|
||||
long numtest;
|
||||
|
||||
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("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;
|
||||
}
|
||||
} while (tasto != K_ESC);
|
||||
return xvt_test_menu_tag(BAR_ITEM(2));
|
||||
}
|
||||
|
||||
int ba1300(int argc, char** argv)
|
||||
{
|
||||
BA1300_application a;
|
||||
a.run(argc,argv,"Test dell'ISAM");
|
||||
return 0;
|
||||
}
|
94
ba/ba1300.h
Executable file
94
ba/ba1300.h
Executable file
@ -0,0 +1,94 @@
|
||||
#ifndef __BA1300_H
|
||||
#define __BA1300_H
|
||||
|
||||
#include "ba1100.h"
|
||||
|
||||
#if XVT_OS == XVT_OS_WIN
|
||||
#define Separator '\\'
|
||||
#else
|
||||
#define Separator '/'
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////
|
||||
// Here defining classes //
|
||||
////////////////////////////////////////
|
||||
|
||||
class TTestSheet : public TDir_sheet
|
||||
{
|
||||
TBit_array _oldstatus; // Previous status of selected files
|
||||
protected:
|
||||
void page_build(long first, byte rows);
|
||||
public:
|
||||
TTestSheet(const char* titolo, const char* colonne="@1|N.@5|Nome@20|EOD@7|EOX@7|Lung. |Descrizione@43|Flags@7", byte bottoni=0x0);
|
||||
~TTestSheet() ;
|
||||
void sr_status(bool save=TRUE);
|
||||
};
|
||||
|
||||
class TTestFile : public TBaseisamfile
|
||||
{
|
||||
public:
|
||||
int close() {return _close();}
|
||||
int open(unsigned int mode = _manulock) {return _open(mode);}
|
||||
const char * file_name() const {return filename();}
|
||||
};
|
||||
|
||||
class TTestWin : public TIndwin
|
||||
{
|
||||
protected:
|
||||
virtual void update() {update_text();}
|
||||
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();}
|
||||
TTestWin();
|
||||
~TTestWin() {};
|
||||
};
|
||||
|
||||
class TTestProc
|
||||
{
|
||||
TTestSheet * _sheet; // Sheet with files selected
|
||||
TTestFile * _workf; // working file
|
||||
TTestWin * _win; // Output window
|
||||
long * _randseq; // Random sequence
|
||||
long _ntest; // number of test in progress
|
||||
long _nfile; // number of file being tested
|
||||
int _nkeys; // # of keys defined for current file
|
||||
bool _block; // is test blocked ?
|
||||
bool _rmc; // Remove copies at the end of test ?
|
||||
protected:
|
||||
void do_random(long eod);
|
||||
void filecopy(bool save=TRUE);
|
||||
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();
|
||||
const char * fmttime(const long);
|
||||
public:
|
||||
TTestProc();
|
||||
~TTestProc();
|
||||
const char* get_base();
|
||||
void do_test_1();
|
||||
void do_test_2();
|
||||
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;}
|
||||
long number(const long n) {return _randseq[n];}
|
||||
void set_sheet (TTestSheet * sh) {_sheet=sh;}
|
||||
TTestSheet * get_isheet() {return _sheet;}
|
||||
TTestWin * get_win() {return _win;}
|
||||
};
|
||||
|
||||
class TTestReport : public TScroll_window
|
||||
{
|
||||
TArray _report;
|
||||
protected:
|
||||
virtual void update();
|
||||
virtual bool on_key(KEY);
|
||||
public:
|
||||
TTestReport(const char* title);
|
||||
~TTestReport() {};
|
||||
void load_report();
|
||||
TString& get_row(int n) {return (TString&)_report[n];}
|
||||
};
|
||||
#endif
|
13
ba/ba1300a.h
Executable file
13
ba/ba1300a.h
Executable file
@ -0,0 +1,13 @@
|
||||
#ifndef __BA1300A_H
|
||||
#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 DLG_RESET 201 // Reset button for sheet mask
|
||||
#endif
|
55
ba/ba1300a.uml
Executable file
55
ba/ba1300a.uml
Executable file
@ -0,0 +1,55 @@
|
||||
#include <defmask.h>
|
||||
#include <tokens.h>
|
||||
#include "ba1300a.h"
|
||||
|
||||
PAGE "Selezione principale" -1 -1 44 9
|
||||
|
||||
GROUPBOX DLG_NULL 20 5
|
||||
BEGIN
|
||||
PROMPT 1 1 "Opzioni"
|
||||
END
|
||||
|
||||
BOOLEAN F_CONTINUO
|
||||
BEGIN
|
||||
PROMPT 2 2 " Continuo"
|
||||
MESSAGE TRUE DISABLE,F_ITERAZIONI|RESET,F_ITERAZIONI
|
||||
MESSAGE FALSE ENABLE,F_ITERAZIONI
|
||||
HELP "Inserire il tipo di test"
|
||||
END
|
||||
|
||||
NUMBER F_ITERAZIONI 3
|
||||
BEGIN
|
||||
PROMPT 2 4 ""
|
||||
HELP "Inserire il numero di iterazioni del test"
|
||||
END
|
||||
|
||||
TEXT F_LABEL
|
||||
BEGIN
|
||||
PROMPT 9 4 "Iterazioni"
|
||||
END
|
||||
|
||||
BUTTON DLG_FILES 9 2
|
||||
BEGIN
|
||||
PROMPT 30 1 "~Files"
|
||||
MESSAGE EXIT,K_F4
|
||||
END
|
||||
|
||||
BUTTON DLG_REPORT 9 2
|
||||
BEGIN
|
||||
PROMPT 30 3 "~Report"
|
||||
MESSAGE EXIT,K_F5
|
||||
END
|
||||
|
||||
BUTTON DLG_TEST 9 2
|
||||
BEGIN
|
||||
PROMPT 30 5 "~Test"
|
||||
MESSAGE EXIT,K_ENTER
|
||||
END
|
||||
|
||||
BUTTON DLG_NULL 9 2
|
||||
BEGIN
|
||||
PROMPT 30 7 "F~ine"
|
||||
MESSAGE EXIT,K_ESC
|
||||
END
|
||||
ENDMASK
|
||||
|
409
ba/ba1301.cpp
Executable file
409
ba/ba1301.cpp
Executable file
@ -0,0 +1,409 @@
|
||||
#include <sys/stat.h>
|
||||
#include <applicat.h>
|
||||
#include <files.h>
|
||||
#include <utility.h>
|
||||
#include <expr.h>
|
||||
#include <isam.h>
|
||||
#include <mask.h>
|
||||
#include <sheet.h>
|
||||
#include <msksheet.h>
|
||||
#include <urldefid.h>
|
||||
#include <validate.h>
|
||||
#include <utility.h>
|
||||
#include <progind.h>
|
||||
|
||||
#include "ba1300.h"
|
||||
|
||||
extern "C" {
|
||||
void cgettime(char *);
|
||||
}
|
||||
|
||||
TTestSheet::TTestSheet(const char* titolo, const char* colonne,byte bottoni)
|
||||
:TDir_sheet(titolo, colonne, bottoni)
|
||||
{}
|
||||
|
||||
TTestSheet::~TTestSheet()
|
||||
{}
|
||||
|
||||
void TTestSheet::page_build(long first, byte rows)
|
||||
|
||||
{
|
||||
TToken_string l(128);
|
||||
for (byte i = 0; i < rows; i++)
|
||||
{
|
||||
const int n = int(i+first+1);
|
||||
dir()->get (n,_nolock,_nordir,_sysdirop);
|
||||
l.cut(0);
|
||||
l.add("");
|
||||
l.add(format("%3d", n)); // Numero progressivo del file
|
||||
l.add(dir()->name());
|
||||
const TRecnotype eod = dir()->eod();
|
||||
l.add(format("%ld", eod));
|
||||
const TRecnotype eox = dir()->eox();
|
||||
l.add(format("%ld", eox));
|
||||
const word len = dir()->len();
|
||||
l.add(format("%u", len));
|
||||
l.add(dir()->des());
|
||||
l.add(format("%ld", dir()->flags()));
|
||||
set_row(l, i);
|
||||
}
|
||||
}
|
||||
|
||||
void TTestSheet::sr_status(bool save)
|
||||
{
|
||||
for (int i=0; i<items();i++)
|
||||
if (save)
|
||||
_oldstatus.set(i,checked(i));
|
||||
else
|
||||
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;
|
||||
}
|
||||
|
||||
const char * TTestProc::get_base()
|
||||
{
|
||||
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';
|
||||
return name;
|
||||
}
|
||||
|
||||
void TTestProc::filecopy(bool save)
|
||||
{
|
||||
TString St0,St1,St2;
|
||||
TTestFile fn(_nfile);
|
||||
|
||||
fn.open();
|
||||
St0=fn.file_name();
|
||||
fn.close();
|
||||
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);
|
||||
St0.rtrim(4);
|
||||
St1=St0 << ".ndx";
|
||||
St0.rtrim(4);
|
||||
St2=St0 << ".sdx";
|
||||
if (save)
|
||||
fcopy((const char*)St1,(const char*)St2);
|
||||
else
|
||||
fcopy((const char*)St2,(const char*)St1);
|
||||
}
|
||||
|
||||
void TTestProc::do_random(long eod)
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
int TTestProc::ctrl_keys()
|
||||
{
|
||||
int err=1;
|
||||
|
||||
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;
|
||||
|
||||
_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);
|
||||
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
|
||||
if (_workf != NULL)
|
||||
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;
|
||||
|
||||
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,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));
|
||||
optr++;
|
||||
int k=1;
|
||||
while (k<=_nkeys && err==NOERR)
|
||||
{
|
||||
TTrec r;
|
||||
r.get(_nfile);
|
||||
TToken_string def(r.keydef(k));
|
||||
|
||||
_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++;
|
||||
}
|
||||
j++;
|
||||
}
|
||||
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;
|
||||
|
||||
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);
|
||||
#else
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
TTestProc::TTestProc()
|
||||
: _block(FALSE), _ntest(0), _nfile(0), _randseq(NULL), _rmc(FALSE), _workf(NULL), _sheet(NULL), _win(NULL)
|
||||
{
|
||||
_win = new TTestWin;
|
||||
}
|
||||
|
||||
TTestProc::~TTestProc()
|
||||
{
|
||||
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)
|
||||
{}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
void TTestReport::load_report()
|
||||
{
|
||||
FILE *fp;
|
||||
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());
|
||||
}
|
||||
|
||||
void TTestReport::update()
|
||||
{
|
||||
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);
|
||||
}
|
@ -111,6 +111,6 @@ then
|
||||
gmake $FLAGS -f maketrc.mak
|
||||
gmake $FLAGS $1
|
||||
else
|
||||
gmake $FLAGS $P2HOME/campo/$1
|
||||
gmake $FLAGS $EP$1
|
||||
fi
|
||||
rm /tmp/build_ba_in_progress$1
|
||||
|
12
ba/makefile
12
ba/makefile
@ -48,8 +48,12 @@ $(O)/ba1102.o: ba1102.cpp $(I39) $(I33) $(I40) $(I37) $(I45) ba1100.h
|
||||
|
||||
$(O)/ba1200.o: ba1200.cpp $(I24) $(I30) $(I37) $(I43)
|
||||
|
||||
$(EP)ba1: $(O)/ba1.o $(O)/ba1100.o $(O)/ba1101.o $(O)/ba1102.o $(O)/ba1200.o $(LIBD1) $(EP)ba1.frl
|
||||
$(LINK) $(LFLAGSD2) $@ $(O)/ba1.o $(O)/ba1100.o $(O)/ba1101.o $(O)/ba1102.o $(O)/ba1200.o
|
||||
$(O)/ba1300.o: ba1300.cpp $(I24) $(I23) $(I31) $(I12) $(I33) $(I30) $(I40) $(I54) $(I43) $(I46) ba1.h ba1300.h ba1100.h
|
||||
|
||||
$(O)/ba1301.o: ba1301.cpp $(I24) $(I16) $(I31) $(I28) $(I30) $(I33) $(I40) $(I54) $(I43) $(I46) ba1300.h ba1100.h
|
||||
|
||||
$(EP)ba1: $(O)/ba1.o $(O)/ba1100.o $(O)/ba1101.o $(O)/ba1102.o $(O)/ba1200.o $(O)/ba1300.o $(O)/ba1301.o $(LIBD1) $(EP)ba1.frl
|
||||
$(LINK) $(LFLAGSD2) $@ $(O)/ba1.o $(O)/ba1100.o $(O)/ba1101.o $(O)/ba1102.o $(O)/ba1200.o $(O)/ba1300.o $(O)/ba1301.o
|
||||
|
||||
$(EP)ba1.frl: ba1.url $(U1)
|
||||
$(RCOMP) ba1 -l $(EP)ba1
|
||||
@ -166,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)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)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 \
|
||||
@ -194,6 +198,8 @@ $(EP)ba1100e.msk: ba1100e.uml $(I45) ba1100a.h
|
||||
|
||||
$(EP)ba1100f.msk: ba1100f.uml $(I45) ba1100a.h
|
||||
|
||||
$(EP)ba1300a.msk: ba1300a.uml $(I45) ba1300a.h
|
||||
|
||||
$(EP)ba2300a.msk: ba2300a.uml ba2300.h
|
||||
|
||||
$(EP)ba2300b.msk: ba2300b.uml ba2300.h
|
||||
|
Loading…
x
Reference in New Issue
Block a user