Skip to content

Commit

Permalink
fix(CI): propagate dataset cook version to tests (#56)
Browse files Browse the repository at this point in the history
  • Loading branch information
c-dilks authored Nov 27, 2024
1 parent 4ce0809 commit 103bb53
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 23 deletions.
20 changes: 11 additions & 9 deletions src/tests/testDumpQADB.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,16 @@ def err = { s -> System.err << "ERROR: $s\n" }

// specify run number
int runnum = 5160
String cook = "latest"
if(args.length>=1) runnum = args[0].toInteger()
println "test QADB for RUN NUMBER $runnum"
if(args.length>=2) cook = args[1]
println "test QADB for RUN NUMBER $runnum COOK $cook"


// instantiate QADB
QADB qa = new QADB("latest")
QADB qa = new QADB(cook)
// alternatively, specify run range to restrict QADB (may be more efficient)
//QADB qa = new QADB("latest",5000,5500);
//QADB qa = new QADB(cook,5000,5500);


// loop through files
Expand Down Expand Up @@ -58,12 +60,12 @@ for(int filenum=0; filenum<=qa.getMaxBinnum(runnum); filenum++) {
err("GetEvnumMin() >= GetEvnumMax()");

// print charge (convert to pC and truncate, for easier comparison)
println "- charge,comment"
println ((int)(1000*qa.getCharge()))
// println "- charge"
// println ((int)(1000*qa.getCharge())) // FIXME: too many warnings
qa.accumulateCharge();

// print comment
println "\"" + qa.getComment() + "\""
println "comment: \"" + qa.getComment() + "\""


// print overall defect info
Expand Down Expand Up @@ -96,9 +98,9 @@ for(int filenum=0; filenum<=qa.getMaxBinnum(runnum); filenum++) {
};

// print QA cuts (see above for custom cut check with mask)
println "- cuts"
println (qa.golden(runnum,evnum)?1:0)
println (qa.OkForAsymmetry(runnum,evnum)?1:0)
// println "- cuts"
// println (qa.golden(runnum,evnum)?1:0) // disabled, because of verbose deprecation warnings
// println (qa.OkForAsymmetry(runnum,evnum)?1:0)
}
sep("=",50);

Expand Down
22 changes: 12 additions & 10 deletions srcC/tests/testDumpQADB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,16 @@ int main(int argc, char ** argv) {

// specify run number
int runnum = 5160; // default
std::string cook = "latest";
if(argc>1) runnum = (int) strtof(argv[1],NULL);
cout << "test QADB for RUN NUMBER " << runnum << endl;
if(argc>2) cook = std::string(argv[2]);
cout << "test QADB for RUN NUMBER " << runnum << " COOK " << cook << endl;


// instantiate QADB
QADB * qa = new QADB("latest");
QADB * qa = new QADB(cook);
// alternatively, specify run range to restrict QADB (may be more efficient)
//QADB * qa = new QADB("latest",5000,5500);
//QADB * qa = new QADB(cook,5000,5500);



Expand Down Expand Up @@ -65,13 +67,13 @@ int main(int argc, char ** argv) {
err("GetEvnumMin() >= GetEvnumMax()");

// print charge (convert to pC and truncate, for easier comparison)
chargeInt = (int) (1000*qa->GetCharge());
cout << "- charge,comment" << endl;
cout << chargeInt << endl;
// chargeInt = (int) (1000*qa->GetCharge()); // FIXME: too many warnings
// cout << "- charge" << endl;
// cout << chargeInt << endl;
qa->AccumulateCharge();

// print comment
cout << "\"" << qa->GetComment() << "\"" << endl;
cout << "comment: \"" << qa->GetComment() << "\"" << endl;


// print overall defect info
Expand Down Expand Up @@ -104,9 +106,9 @@ int main(int argc, char ** argv) {
};

// print QA cuts (see above for custom cut check with mask)
cout << "- cuts" << endl;
cout << qa->Golden(runnum,evnum) << endl;
cout << qa->OkForAsymmetry(runnum,evnum) << endl;
// cout << "- cuts" << endl;
// cout << qa->Golden(runnum,evnum) << endl; // disabled, because of verbose deprecation warnings
// cout << qa->OkForAsymmetry(runnum,evnum) << endl;
};

sep("=",50);
Expand Down
4 changes: 3 additions & 1 deletion tests/test_diffGroovyCpp.loop.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@ if [ $# -lt 1 ]; then
fi

datasetSubdir=$1
cook=$(echo $datasetSubdir | sed 's;/.*;;g')

mkdir -p ${QADB}/tmp

echo """
begin TEST:
- test DumpQADB for dataset ${datasetSubdir}
- cook: $cook
- check for differences between C++ and Groovy APIs
- a diff will be dumped for any differences found, and the script will stop
Expand All @@ -27,5 +29,5 @@ begin TEST:
grep -E '^RUN: ' ${QADB}/qadb/${datasetSubdir}/qaTree.json.table |\
awk '{print $2}' |\
while read run; do
${QADB}/tests/test_diffGroovyCpp.sh DumpQADB $run
${QADB}/tests/test_diffGroovyCpp.sh DumpQADB $run $cook
done
8 changes: 5 additions & 3 deletions tests/test_diffGroovyCpp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ if [ -z "$QADB" ]; then
exit 1
fi

cook=latest
if [ $# -lt 2 ]; then
echo """
USAGE: $0 [test name] [run number]
USAGE: $0 [test name] [run number] [cook(default=$cook)]
- [test name] can be any of:
$(ls src/tests | sed 's/^test//' | sed 's/\.groovy$//')
Expand All @@ -22,19 +23,20 @@ fi

testname=$1
run=$2
[ $# -ge 3 ] && cook=$3

mkdir -p ${QADB}/tmp

# groovy test
echo "EXECUTE GROOVY TEST $testname RUN $run"
pushd ${QADB}/src/tests
groovy -cp "$JYPATH" test${testname}.groovy $run > ${QADB}/tmp/groovy.${run}.out
groovy -cp "$JYPATH" test${testname}.groovy $run $cook > ${QADB}/tmp/groovy.${run}.out
popd

# c++ test
echo "EXECUTE C++ TEST $testname RUN $run"
pushd ${QADB}/srcC/tests
./test${testname}.exe $run > ${QADB}/tmp/cpp.${run}.out
./test${testname}.exe $run $cook > ${QADB}/tmp/cpp.${run}.out
popd

# compare
Expand Down

0 comments on commit 103bb53

Please sign in to comment.