function gravenPass = testall

% $Id: testall.m,v 1.11 2004/05/14 20:15:28 stuver Exp $

addpath ../

now = fix(clock);
fileName = ['gravenBuildTest_' num2str(now(2)) '_' num2str(now(3)) ...
        '_' num2str(now(1)) '.txt'];

fid = fopen(fileName, 'a');
fprintf(1, ['# This GravEn build test was run on %2.0f/%2.0f/%4.0f '...
        'at %2.0f:%2.0f:%2.0f\n'], now(2), now(3), now(1), now(4), ...
    now(5), now(6));
fprintf(fid, ['# This GravEn build test was run on %2.0f/%2.0f/%4.0f '...
        'at %2.0f:%2.0f:%2.0f\n'], now(2), now(3), now(1), now(4), ...
    now(5), now(6));

TOLERANCE = 10*eps;

failCounter = 0;

% Load refernce data:
load ./refData/gravenData7May2004.mat
load ./refData/makelistData6May2004.mat
load ./refData/ifodelayData21Apr2004.mat
load ./refData/makehData5May2004.mat
load ./refData/detprojData21Apr2004.mat

gpsTime = 729273660;

% graven

% Test that the log file can be read as input file
SimInput = graven('log.txt', gpsTime, 'H1', 'testopt.txt', 16384, 123);
SimOutput = graven('relog.txt', gpsTime, 'H1', 'log.txt', 16384, 123);

difSig1 = SimOutput(1).sig - SimInput(1).sig;
difSig2 = SimOutput(end).sig - SimInput(end).sig;

if abs(difSig1) > TOLERANCE | abs(difSig2) > TOLERANCE
    failCounter = failCounter+1;
    fprintf(1, 'FAIL: graven, original waveform logfile as input file \n')
    fprintf(fid, 'FAIL: graven, original waveform logfile as input file \n');
else
    fprintf(1, 'PASS: graven, original waveform logfile as input file \n')
    fprintf(fid, 'PASS: graven, original waveform logfile as input file \n');
end

delete log.txt relog.txt

% Test that the log file can be read as input file
SimPreGenIn = graven(10,'pregenlog.txt', gpsTime, 'H1', {'./refData/ZM_A1B1G1.ilwd', 'm1.real_8'}, [1 2], 'random', 16384, 123);
SimPreGenOut = graven('repregenlog.txt', gpsTime, 'H1', 'pregenlog.txt', 16384, 123);

difSigPreGen1 = SimPreGenOut(1).sig - SimPreGenIn(1).sig;
difSigPreGen2 = SimPreGenOut(end).sig - SimPreGenIn(end).sig;

if abs(difSigPreGen1) > TOLERANCE | abs(difSigPreGen2) > TOLERANCE
    failCounter = failCounter+1;
    fprintf(1, 'FAIL: graven, pre-generated waveform logfile as input file \n')
    fprintf(fid, 'FAIL: graven, pre-generated waveform logfile as input file \n');
else
    fprintf(1, 'PASS: graven, pre-generated waveform logfile as input file \n')
    fprintf(fid, 'PASS: graven, pre-generated waveform logfile as input file \n');
end

delete pregenlog.txt repregenlog.txt

% Mode 1

Sim1Test = graven('mode1.txt', gpsTime, 'H1', 'testopt.txt', 16384, 123);

difSim11 = Sim1(1).sig - Sim1Test(1).sig;
difSim12 = Sim1(end).sig - Sim1Test(end).sig;

if abs(difSim11) > TOLERANCE | abs(difSim12) > TOLERANCE
    failCounter = failCounter+1;
    fprintf(1, 'FAIL: graven, mode 1 (read line-by-line from file) \n')
    fprintf(fid, 'FAIL: graven, mode 1 (read line-by-line from file) \n');
else
    fprintf(1, 'PASS: graven, mode 1 (read line-by-line from file) \n')
    fprintf(fid, 'PASS: graven, mode 1 (read line-by-line from file) \n');
end

Sim2Test = graven(10, 'mode2.txt', gpsTime, 'H2', 'testopt.txt', 16384, 123);

difSim21 = Sim2(1).sig - Sim2Test(1).sig;
difSim22 = Sim2(end).sig - Sim2Test(end).sig;

if abs(difSim21) > TOLERANCE | abs(difSim22) > TOLERANCE
    failCounter = failCounter+1;
    fprintf(1, 'FAIL: graven, mode 2 (make N random draws on file) \n')
    fprintf(fid, 'FAIL: graven, mode 2 (make N random draws on file) \n');
else
    fprintf(1, 'PASS: graven, mode 2 (make N random draws on file) \n')
    fprintf(fid, 'PASS: graven, mode 2 (make N random draws on file) \n');
end

Sim3Test = graven(10, 'mode3.txt', 729273660, 'L1', 'CG_512_0.01_0.2', ...
    1e-21, [1 2], 'RANDOM', 'OPTIMAL', 16384, 123);

difSim31 = Sim3(1).sig - Sim3Test(1).sig;
difSim32 = Sim3(end).sig - Sim3Test(end).sig;

if abs(difSim31) > TOLERANCE | abs(difSim32) > TOLERANCE
    failCounter = failCounter+1;
    fprintf(1, 'FAIL: graven, mode 3 (all user input) \n')
    fprintf(fid, 'FAIL: graven, mode 3 (all user input) \n');
else
    fprintf(1, 'PASS: graven, mode 3 (all user input) \n')
    fprintf(fid, 'PASS: graven, mode 3 (all user input) \n');
end

delete mode1.txt mode2.txt mode3.txt

SimIlwd1Test = graven(1,'mode4.txt', 729273660, 'H1', ...
    './refData/ZM_A1B1G1.ilwd', [1 2], 'optimal', 16384, 123);
SimIlwd2Test = graven(1,'mode4.txt', 729273660, 'H1', ...
    {'./refData/ZM_A1B1G1.ilwd', 'm1.real_8'}, [1 2], 'optimal', 16384, 123);

difSimIlwd1 = SimIlwd1(1).sig - SimIlwd1Test(1).sig;
difSimIlwd2 = SimIlwd1(1).sig - SimIlwd2Test(1).sig;

if abs(difSimIlwd1) > TOLERANCE | abs(difSimIlwd2) > TOLERANCE
    failCounter = failCounter+1;
    fprintf(1, 'FAIL: graven, mode 4, ilwd (pre-generated waveform) \n')
    fprintf(fid, 'FAIL: graven, mode 4, ilwd (pre-generated waveform) \n');
else
    fprintf(1, 'PASS: graven, mode 4, ilwd (pre-generated waveform) \n')
    fprintf(fid, 'PASS: graven, mode 4, ilwd (pre-generated waveform) \n');
end

SimTxt1Test = graven(1,'mode4.txt', 729273660, 'H1', ...
    './refData/pregentest.txt', [1 2], 'optimal', 16384, 123);
SimTxt2Test = graven(1,'mode4.txt', 729273660, 'H1', ...
    {'./refData/pregentest.txt', 'pregentest'}, [1 2], 'optimal', 16384, 123);

difSimTxt1 = SimTxt1(1).sig - SimTxt1Test(1).sig;
difSimTxt2 = SimTxt1(1).sig - SimTxt2Test(1).sig;

if abs(difSimTxt1) > TOLERANCE | abs(difSimTxt2) > TOLERANCE
    failCounter = failCounter+1;
    fprintf(1, 'FAIL: graven, mode 4, txt (pre-generated waveform) \n')
    fprintf(fid, 'FAIL: graven, mode 4, txt (pre-generated waveform) \n');
else
    fprintf(1, 'PASS: graven, mode 4, txt (pre-generated waveform) \n')
    fprintf(fid, 'PASS: graven, mode 4, txt (pre-generated waveform) \n');
end

% The following code is commented out since the GravEn code needed to
% comple this will not work (however, it will work perfectly fine in the
% MATLAB environment):
% SimMat1Test = graven(1,'mode4.txt', 729273660, 'H1', ...
%    './refData/pregentest.mat', [1 2], 'optimal', 16384, 123);
% SimMat2Test = graven(1,'mode4.txt', 729273660, 'H1', ...
%     {'./refData/pregentest.mat', 'pregentest'}, [1 2], 'optimal', 16384, 123);
% 
% difSimMat1 = SimMat1(1).sig - SimMat1Test(1).sig;
% difSimMat2 = SimMat1(1).sig - SimMat2Test(1).sig;
% 
% if abs(difSimMat1) > TOLERANCE | abs(difSimMat2) > TOLERANCE
%     failCounter = failCounter+1;
%     fprintf(1, 'FAIL: graven, mode 4, mat (pre-generated waveform) \n')
%     fprintf(fid, 'FAIL: graven, mode 4, mat (pre-generated waveform) \n');
% else
%     fprintf(1, 'PASS: graven, mode 4, mat (pre-generated waveform) \n')
%     fprintf(fid, 'PASS: graven, mode 4, mat (pre-generated waveform) \n');
% end

delete mode4.txt

% makelist

% Mode 1
rand('state', seed);
mode1Test = makelist('testrand.txt');

if ~isequal(mode1,mode1Test)
    failCounter = failCounter+1;
    fprintf(1, ['FAIL: makelist, mode 1 \n'])
    fprintf(fid, ['FAIL: makelist, mode 1 \n']);
else
    fprintf(1, ['PASS: makelist, mode 1 \n'])
    fprintf(fid, ['PASS: makelist, mode 1 \n']);
end


% Mode 2
rand('state', seed);
mode2Test = makelist(N, 'testrand.txt');

if ~isequal(mode2,mode2Test)
    failCounter = failCounter+1;
    fprintf(1, ['FAIL: makelist, mode 2 \n'])
    fprintf(fid, ['FAIL: makelist, mode 2 \n']);
else
    fprintf(1, ['PASS: makelist, mode 2 \n'])
    fprintf(fid, ['PASS: makelist, mode 2 \n']);
end

% Mode 3
rand('state', seed);
mode3H1Test = makelist('testopt.txt', 'H1');
rand('state', seed);
mode3H2Test = makelist('testopt.txt', 'H2');
rand('state', seed);
mode3L1Test = makelist('testopt.txt', 'L1');

if ~isequal(mode3H1,mode3H1Test)
    failCounter = failCounter+1;
    fprintf(1, ['FAIL: makelist, mode 3, H1 \n'])
    fprintf(fid, ['FAIL: makelist, mode 3, H1 \n']);
else
    fprintf(1, ['PASS: makelist, mode 3, H1 \n'])
    fprintf(fid, ['PASS: makelist, mode 3, H1 \n']);
end

if ~isequal(mode3H2,mode3H2Test)
    failCounter = failCounter+1;
    fprintf(1, ['FAIL: makelist, mode 3, H2 \n'])
    fprintf(fid, ['FAIL: makelist, mode 3, H2 \n']);
else
    fprintf(1, ['PASS: makelist, mode 3, H2 \n'])
    fprintf(fid, ['PASS: makelist, mode 3, H2 \n']);
end

if ~isequal(mode3L1,mode3L1Test)
    failCounter = failCounter+1;
    fprintf(1, ['FAIL: makelist, mode 3, L1 \n'])
    fprintf(fid, ['FAIL: makelist, mode 3, L1 \n']);
else
    fprintf(1, ['PASS: makelist, mode 3, L1 \n'])
    fprintf(fid, ['PASS: makelist, mode 3, L1 \n']);
end

% Mode 4
rand('state', seed);
mode4H1Test = makelist(N, 'testopt.txt', 'H1');
rand('state', seed);
mode4H2Test = makelist(N, 'testopt.txt', 'H2');
rand('state', seed);
mode4L1Test = makelist(N, 'testopt.txt', 'L1');

if ~isequal(mode4H1,mode4H1Test)
    failCounter = failCounter+1;
    fprintf(1, ['FAIL: makelist, mode 4, H1 \n'])
    fprintf(fid, ['FAIL: makelist, mode 4, H1 \n']);
else
    fprintf(1, ['PASS: makelist, mode 4, H1 \n'])
    fprintf(fid, ['PASS: makelist, mode 4, H1 \n']);
end

if ~isequal(mode4H2,mode4H2Test)
    failCounter = failCounter+1;
    fprintf(1, ['FAIL: makelist, mode 4, H2 \n'])
    fprintf(fid, ['FAIL: makelist, mode 4, H2 \n']);
else
    fprintf(1, ['PASS: makelist, mode 4, H2 \n'])
    fprintf(fid, ['PASS: makelist, mode 4, H2 \n']);
end

if ~isequal(mode4L1,mode4L1Test)
    failCounter = failCounter+1;
    fprintf(1, ['FAIL: makelist, mode 4, L1 \n'])
    fprintf(fid, ['FAIL: makelist, mode 4, L1 \n']);
else
    fprintf(1, ['PASS: makelist, mode 4, L1 \n'])
    fprintf(fid, ['PASS: makelist, mode 4, L1 \n']);
end

% Mode 5
rand('state', seed);
mode5aTest = makelist(N,simId,amplA,startSamp,'optimal','random');
rand('state', seed);
mode5bTest = makelist(N,simId,amplB,startSamp,internal,external);
rand('state', seed);
mode5cTest = makelist(N,simId,amplC,startSamp,Internal,External);

if ~isequal(mode5a,mode5aTest)
    failCounter = failCounter+1;
    fprintf(1, ['FAIL: makelist, mode 5, ampl fixed, ' ...
            'internal=''optimal'', external=''random'' \n'])
    fprintf(fid, ['FAIL: makelist, mode 5, ampl fixed, ' ...
            'internal=''optimal'', external=''random'' \n']);
else
    fprintf(1, ['PASS: makelist, mode 5, ampl fixed, ' ...
            'internal=''optimal'', external=''random'' \n'])
    fprintf(fid, ['PASS: makelist, mode 5, ampl fixed, ' ...
            'internal=''optimal'', external=''random'' \n']);
end

if ~isequal(mode5b,mode5bTest)
    failCounter = failCounter+1;   
    fprintf(1, ['FAIL: makelist, mode 5, ampl log dist., ' ...
            'internal double, external double \n'])
    fprintf(fid, ['FAIL: makelist, mode 5, ampl log dist., ' ...
            'internal double, external double \n']);
else
    fprintf(1, ['PASS: makelist, mode 5, ampl log dist., ' ...
            'internal double, external double \n'])
    fprintf(fid, ['PASS: makelist, mode 5, ampl log dist., ' ...
            'internal double, external double \n']);
end

if ~isequal(mode5c,mode5cTest)
    failCounter = failCounter+1;
    fprintf(1, ['FAIL: makelist, mode 5, ampl lin. discrete, ' ...
            'internal struct, external struct \n'])
    fprintf(fid, ['FAIL: makelist, mode 5, ampl lin. discrete, ' ...
            'internal struct, external struct \n']);
else
    fprintf(1, ['PASS: makelist, mode 5, ampl lin. discrete, ' ...
            'internal struct, external struct \n'])
    fprintf(fid, ['PASS: makelist, mode 5, ampl lin. discrete, ' ...
            'internal struct, external struct \n']);
end

% Mode 6
rand('state', seed);
mode6H1Test = makelist(N,simId,amplA,startSamp,'optimal','optimal','H1');
rand('state', seed);
mode6H2Test = makelist(N,simId,amplA,startSamp,'optimal','optimal','H2');
rand('state', seed);
mode6L1Test = makelist(N,simId,amplA,startSamp,'optimal','optimal','L1');

if ~isequal(mode6H1,mode6H1Test)
    failCounter = failCounter+1;
    fprintf(1, ['FAIL: makelist, mode 6, H1 \n'])
    fprintf(fid, ['FAIL: makelist, mode 6, H1 \n']);
else
    fprintf(1, ['PASS: makelist, mode 6, H1 \n'])
    fprintf(fid, ['PASS: makelist, mode 6, H1 \n']);
end

if ~isequal(mode6H2,mode6H2Test)
    failCounter = failCounter+1;
    fprintf(1, ['FAIL: makelist, mode 6, H2 \n'])
    fprintf(fid, ['FAIL: makelist, mode 6, H2 \n']);
else
    fprintf(1, ['PASS: makelist, mode 6, H2 \n'])
    fprintf(fid, ['PASS: makelist, mode 6, H2 \n']);
end

if ~isequal(mode6L1,mode6L1Test)
    failCounter = failCounter+1;
    fprintf(1, ['FAIL: makelist, mode 6, L1 \n'])
    fprintf(fid, ['FAIL: makelist, mode 6, L1 \n']);
else
    fprintf(1, ['PASS: makelist, mode 6, L1 \n'])
    fprintf(fid, ['PASS: makelist, mode 6, L1 \n']);
end

% getifo

[errorH1, errorH2, errorL1] = testgetifo;

if errorH1
    failCounter = failCounter+1;
    fprintf(1, 'FAIL: getifo, H1 \n')
    fprintf(fid, 'FAIL: getifo, H1 \n');
else
    fprintf(1, 'PASS: getifo, H1 \n')
    fprintf(fid, 'PASS: getifo, H1 \n');
end

if errorH2
    failCounter = failCounter+1;
    fprintf(1, 'FAIL: getifo, H2 \n')
    fprintf(fid, 'FAIL: getifo, H2 \n');
else
    fprintf(1, 'PASS: getifo, H2 \n')
    fprintf(fid, 'PASS: getifo, H2 \n');
end

if errorL1
    failCounter = failCounter+1;
    fprintf(1, 'FAIL: getifo, L1 \n')
    fprintf(fid, 'FAIL: getifo, L1 \n');
else
    fprintf(1, 'PASS: getifo, L1 \n')
    fprintf(fid, 'PASS: getifo, L1 \n');
end

% ifodelay

delayH1 = testifodelay('H1', 16384, 'off');
delayH2 = testifodelay('H2', 16384, 'off');
delayL1 = testifodelay('L1', 16384, 'off');

difDelayLho1 = delayLHO-delayH1;
difDelayLho2 = delayLHO-delayH2;
difDelayLlo = delayLLO-delayL1;

maxDifDelayLho1 = max(max(difDelayLho1));
maxDifDelayLho2 = max(max(difDelayLho2));
maxDifDelayLlo = max(max(difDelayLlo));

if abs(maxDifDelayLho1) > TOLERANCE
    failCounter = failCounter+1;
    fprintf(1, 'FAIL: ifodelay, H1 \n')
    fprintf(fid, 'FAIL: ifodelay, H1 \n');
else
    fprintf(1, 'PASS: ifodelay, H1 \n')
    fprintf(fid, 'PASS: ifodelay, H1 \n');
end

if abs(maxDifDelayLho2) > TOLERANCE
    failCounter = failCounter+1;
    fprintf(1, 'FAIL: ifodelay, H2 \n')
    fprintf(fid, 'FAIL: ifodelay, H2 \n');
else
    fprintf(1, 'PASS: ifodelay, H2 \n')
    fprintf(fid, 'PASS: ifodelay, H2 \n');
end

if abs(maxDifDelayLlo) > TOLERANCE
    failCounter = failCounter+1;
    fprintf(1, 'FAIL: ifodelay, L1 \n')
    fprintf(fid, 'FAIL: ifodelay, L1 \n');
else
    fprintf(1, 'PASS: ifodelay, L1 \n')
    fprintf(fid, 'PASS: ifodelay, L1 \n');
end

% simparse

errorSimparse = testsimparse;

if errorSimparse
    failCounter = failCounter+1;
    fprintf(1, 'FAIL: simparse \n')
    fprintf(fid, 'FAIL: simparse \n');
else
    fprintf(1, 'PASS: simparse \n')
    fprintf(fid, 'PASS: simparse \n');
end

% makeh

ampl = 1e-21;
startSamp = 1;
sampFreq = 16384;

hijGTest = makeh(simIdG, ampl, startSamp, sampFreq);

if ~isequal(hijGTest, hijG)
    failCounter = failCounter+1;
    fprintf(1, ['FAIL: makeh, ' simIdG '\n'])
    fprintf(fid, ['FAIL: makeh, ' simIdG '\n']);
else
    fprintf(1, ['PASS: makeh, ' simIdG '\n'])
    fprintf(fid, ['PASS: makeh, ' simIdG '\n']);
end

hijSGTest = makeh(simIdSG, ampl, startSamp, sampFreq);

if ~isequal(hijSGTest, hijSG)
    failCounter = failCounter+1;
    fprintf(1, ['FAIL: makeh, ' simIdSG '\n'])
    fprintf(fid, ['FAIL: makeh, ' simIdSG '\n']);
else
    fprintf(1, ['PASS: makeh, ' simIdSG '\n'])
    fprintf(fid, ['PASS: makeh, ' simIdSG '\n']);
end

hijCGTest = makeh(simIdCG, ampl, startSamp, sampFreq);

if ~isequal(hijCGTest, hijCG)
    failCounter = failCounter+1;
    fprintf(1, ['FAIL: makeh, ' simIdCG '\n'])
    fprintf(fid, ['FAIL: makeh, ' simIdCG '\n']);
else
    fprintf(1, ['PASS: makeh, ' simIdCG '\n'])
    fprintf(fid, ['PASS: makeh, ' simIdCG '\n']);
end

hijBHTest = makeh(simIdBH, ampl, startSamp, sampFreq);

if ~isequal(hijBHTest, hijBH)
    failCounter = failCounter+1;
    fprintf(1, ['FAIL: makeh, ' simIdBH '\n'])
    fprintf(fid, ['FAIL: makeh, ' simIdBH '\n']);
else
    fprintf(1, ['PASS: makeh, ' simIdBH '\n'])
    fprintf(fid, ['PASS: makeh, ' simIdBH '\n']);
end

hijSINTest = makeh(simIdSIN, ampl, startSamp, sampFreq);

if ~isequal(hijSINTest, hijSIN)
    failCounter = failCounter+1;
    fprintf(1, ['FAIL: makeh, ' simIdSIN '\n'])
    fprintf(fid, ['FAIL: makeh, ' simIdSIN '\n']);
else
    fprintf(1, ['PASS: makeh, ' simIdSIN '\n'])
    fprintf(fid, ['PASS: makeh, ' simIdSIN '\n']);
end

hijCOSTest = makeh(simIdCOS, ampl, startSamp, sampFreq);

if ~isequal(hijCOSTest, hijCOS)
    failCounter = failCounter+1;
    fprintf(1, ['FAIL: makeh, ' simIdCOS '\n'])
    fprintf(fid, ['FAIL: makeh, ' simIdCOS '\n']);
else
    fprintf(1, ['PASS: makeh, ' simIdCOS '\n'])
    fprintf(fid, ['PASS: makeh, ' simIdCOS '\n']);
end

hijSINCTest = makeh(simIdSINC, ampl, startSamp, sampFreq);

if ~isequal(hijSINCTest, hijSINC)
    failCounter = failCounter+1;
    fprintf(1, ['FAIL: makeh, ' simIdSINC '\n'])
    fprintf(fid, ['FAIL: makeh, ' simIdSINC '\n']);
else
    fprintf(1, ['PASS: makeh, ' simIdSINC '\n'])
    fprintf(fid, ['PASS: makeh, ' simIdSINC '\n']);
end

hijCHIRPTest = makeh(simIdCHIRP, ampl, startSamp, sampFreq);

if ~isequal(hijCHIRPTest, hijCHIRP)
    failCounter = failCounter+1;
    fprintf(1, ['FAIL: makeh, ' simIdCHIRP '\n'])
    fprintf(fid, ['FAIL: makeh, ' simIdCHIRP '\n']);
else
    fprintf(1, ['PASS: makeh, ' simIdCHIRP '\n'])
    fprintf(fid, ['PASS: makeh, ' simIdCHIRP '\n']);
end

hijSQUARETest = makeh(simIdSQUARE, ampl, startSamp, sampFreq);

if ~isequal(hijSQUARETest, hijSQUARE)
    failCounter = failCounter+1;
    fprintf(1, ['FAIL: makeh, ' simIdSQUARE '\n'])
    fprintf(fid, ['FAIL: makeh, ' simIdSQUARE '\n']);
else
    fprintf(1, ['PASS: makeh, ' simIdSQUARE '\n'])
    fprintf(fid, ['PASS: makeh, ' simIdSQUARE '\n']);
end

hijSQUAREGTest = makeh(simIdSQUAREG, ampl, startSamp, sampFreq);

if ~isequal(hijSQUAREGTest, hijSQUAREG)
    failCounter = failCounter+1;
    fprintf(1, ['FAIL: makeh, ' simIdSQUAREG '\n'])
    fprintf(fid, ['FAIL: makeh, ' simIdSQUAREG '\n']);
else
    fprintf(1, ['PASS: makeh, ' simIdSQUAREG '\n'])
    fprintf(fid, ['PASS: makeh, ' simIdSQUAREG '\n']);
end

hijSAWTOOTHTest = makeh(simIdSAWTOOTH, ampl, startSamp, sampFreq);

if ~isequal(hijSAWTOOTHTest, hijSAWTOOTH)
    failCounter = failCounter+1;
    fprintf(1, ['FAIL: makeh, ' simIdSAWTOOTH '\n'])
    fprintf(fid, ['FAIL: makeh, ' simIdSAWTOOTH '\n']);
else
    fprintf(1, ['PASS: makeh, ' simIdSAWTOOTH '\n'])
    fprintf(fid, ['PASS: makeh, ' simIdSAWTOOTH '\n']);
end

hijSAWTOOTHGTest = makeh(simIdSAWTOOTHG, ampl, startSamp, sampFreq);

if ~isequal(hijSAWTOOTHGTest, hijSAWTOOTHG)
    failCounter = failCounter+1;
    fprintf(1, ['FAIL: makeh, ' simIdSAWTOOTHG '\n'])
    fprintf(fid, ['FAIL: makeh, ' simIdSAWTOOTHG '\n']);
else
    fprintf(1, ['PASS: makeh, ' simIdSAWTOOTHG '\n'])
    fprintf(fid, ['PASS: makeh, ' simIdSAWTOOTHG '\n']);
end

% makett

errorMakeTt = testmakett;

if errorMakeTt
    failCounter = failCounter+1;
    fprintf(1, 'FAIL: makett \n')
    fprintf(fid, 'FAIL: makett \n');
else
    fprintf(1, 'PASS: makett \n')
    fprintf(fid, 'PASS: makett \n');
end

% detproj

antennaH1 = testdetproj('H1', 'off');
antennaH2 = testdetproj('H2', 'off');
antennaL1 = testdetproj('L1', 'off');

difAntennaH1 = antennaLHO-antennaH1;
difAntennaH2 = antennaLHO-antennaH2;
difAntennaL1 = antennaLLO-antennaL1;

maxDifAntennaH1 = max(max(difAntennaH1));
maxDifAntennaH2 = max(max(difAntennaH2));
maxDifAntennaL1 = max(max(difAntennaL1));

if abs(maxDifAntennaH1) > TOLERANCE
    failCounter = failCounter+1;
    fprintf(1, 'FAIL: detproj, H1 \n')
    fprintf(fid, 'FAIL: detproj, H1 \n');
else
    fprintf(1, 'PASS: detproj, H1 \n')
    fprintf(fid, 'PASS: detproj, H1 \n');
end

if abs(maxDifAntennaH2) > TOLERANCE
    failCounter = failCounter+1;
    fprintf(1, 'FAIL: detproj, H2 \n')
    fprintf(fid, 'FAIL: detproj, H2 \n');
else
    fprintf(1, 'PASS: detproj, H2 \n')
    fprintf(fid, 'PASS: detproj, H2 \n');
end

if abs(maxDifAntennaL1) > TOLERANCE
    failCounter = failCounter+1;
    fprintf(1, 'FAIL: detproj, L1 \n')
    fprintf(fid, 'FAIL: detproj, L1 \n');
else
    fprintf(1, 'PASS: detproj, L1 \n')
    fprintf(fid, 'PASS: detproj, L1 \n');
end

if failCounter == 0
    fprintf(1, ['# GravEn build test ran successfully without error! '...
            '\n# +++ \n'])
    fprintf(fid, ['# GravEn build test ran successfully without ' ...
            'error! \n# +++ \n']);
    gravenPass = true;
else 
    nFails = num2str(failCounter);
    fprintf(1, ['# GravEn build test encountered ' nFails ' error(s). ' ...
            '\n# --- \n'])
    fprintf(fid, ['# GravEn build test encountered ' nFails ' ' ...
            'error(s). \n# --- \n']);
    gravenPass = ~true;
end

fclose(fid);

return