Repository navigation
ADD: Full suite of unit tests - #247
Conversation
|
Just check with Arch - and getting some crashes - investigating |
|
Let us know once you're done troubleshooting and want us to look at this :) |
|
Different things fail on different OSes... |
|
Everything is working on macOS Tahoe, Ubuntu 24.05, and the latest Arch - it is just not working here... |
|
All checks passed! Ready of review! |
|
Tested this locally on my laptop and all tests pass. |
|
@fhagemann I fixed all issues and dropped my duplicate unit test |
fhagemann
left a comment
There was a problem hiding this comment.
Disclaimer: I didn't look through the DEE submodules yet, because I want to give them a closer look when tackling the new issues that were created as a result of this.
I had a very quick look through all other unittests for files/modules that I have worked with before (not by any means a thorough review, just a quick overlook) and commented/flagged some things.
Let me know if I should look through the DEE submodule unit tests BEFORE merging this or only when tackling the issues assigned to me.
| MString Input = MString("module ") + M->GetXmlTag(); | ||
| Passed = EvaluateTrue("MAssembly()", Input, "The XML tag of the module is unique", Tags.insert(M->GetXmlTag()).second) && Passed; | ||
| Passed = EvaluateTrue("MAssembly()", Input, "The name of the module is unique", Names.insert(M->GetName()).second) && Passed; | ||
| Passed = EvaluateFalse("MAssembly()", Input, "The XML tag is not empty", M->GetXmlTag().IsEmpty()) && Passed; | ||
| Passed = EvaluateTrue("MAssembly()", Input, "The module provides at least one module type", M->GetNModuleTypes() > 0) && Passed; | ||
| } | ||
| Passed = EvaluateTrue("MAssembly()", "available modules", "All available modules are non-null", AllValid) && Passed; |
There was a problem hiding this comment.
Let me think about that.
| A test must never read or write the user's files. The `MUnitTest` | ||
| constructor therefore creates a private temporary directory with a | ||
| randomized name (e.g. `MEGAlib_aB3xYz9Qp1_home`) inside its temporary root, | ||
| points `HOME` to it, and changes the working directory into it. Neither is |
There was a problem hiding this comment.
About pointing HOME somewhere else for the unittests:
When running the end-to-end tests for 406-1 and 542-1, they are still generating the cross-sections directories in resource/unittestdata when running this locally(zoglauer/megalib#123). Can this somehow be avoided by having the unit tests create those directories also in a temporary directory instead?
There was a problem hiding this comment.
I know. That requires MEGAlib changes.
| //////////////////////////////////////////////////////////////////////////////// | ||
|
|
||
|
|
||
| bool UTNModuleTrappingCorrection::TestInterpolate() |
There was a problem hiding this comment.
I feel like the Interpolate function we have in MModuleChargeTrapping right now might be useful elsewhere, and might therefore live in some utility module instead (how to we interpolate CTD-to-depth splines in the depth calibration module)?
There was a problem hiding this comment.
Sounds good with me.
There was a problem hiding this comment.
I don't think we need unit tests for the template ^^
Is the template compiled when running make - if so, we might want to update the Makefile to not compile/test it.
| Passed = EvaluateNear("AnalyzeEvent()", "LV strip 10", "The timing is 4200 - 1200 = 3000 ns", L10.m_Timing, 3000.0, 1e-9) && Passed; | ||
| Passed = Evaluate("AnalyzeEvent()", "LV strip 10", "The TAC is (3000 + 500) / 0.5 = 7000", L10.m_TAC, 7000u) && Passed; |
There was a problem hiding this comment.
I guess it's documented here, but as said: not sure if this is the final configuration we want in the long run.
| { | ||
| bool Passed = true; | ||
|
|
||
| // The TAC calibration only covers LV strips 32-63 of detector 0, as in the committed unit-level calibrations |
There was a problem hiding this comment.
????
TAC calibration should cover all strips
This might be due to the strip map, where STRIP_ID 0-31 are LV strips 32-63, but then followed by STRIP_ID 32-63, which are LV strips 0-31. I'm not sure we EVER expect partial TAC calibrations (?)
| MString UTNSubModuleStripReadout::WriteThresholds(unsigned int NStrips) | ||
| { | ||
| // Hardware threshold 1600 ADC (800 keV) for all strips | ||
| MString C = "STRIP_ID,Detector,side,strip,threshold_adc,threshold_keV\n"; | ||
| for (unsigned int s = 0; s < NStrips; ++s) { | ||
| C += MString("") + s + ",0,l," + s + ",1600,800.0\n"; | ||
| C += MString("") + (100 + s) + ",0,h," + s + ",1600,800.0\n"; | ||
| } | ||
| MString FileName = GetTemporaryFileName("sr.thresholds.csv"); | ||
| if (WriteTextFile(FileName, C) == false) return ""; | ||
| return FileName; | ||
| } |
There was a problem hiding this comment.
I expect the hardware thresholds for the DEE to have the same issue as what was fixed for the TAC cal in #239
--> we might need to apply the strip map also to the hardware threshold file or make sure that the Detector/side/strip notation is correct.
| } | ||
|
|
||
| // FWHM at 1000 keV is 3 keV => sigma = 3 / 2.355 | ||
| gRandom->SetSeed(4711); |
There was a problem hiding this comment.
Is there something special about the random seed 4711? 😅
|
You commented „Done“ on some comments, but never posted anything (?) 😅 |
|
I addressed most of the meant to be addressed comments I think. |
| unsigned int UTNSubModuleDepthReadout::GetDIB(unsigned int DetID) const | ||
| { | ||
| // Deliberately different from the detector ID: the DIB column of the TAC calibration file must not be used as detector ID | ||
| return DetID + 4; | ||
| } |
*** MEGAlib update required ***
This PR drops the full unit test suite for nuclearizer.
All tests are a collaboration between Claude Opus 5.5, GPT-6.1-Sol, and Andreas.
The tests uncovered 60-70 bugs where 25-35 affect data correctness. I (or probably Claude) will add issues for them next.
Lot's of tests fail. Those are marked with ExpectedToFail() (161 checks): they are reported as
KNOWN FAILUREwithout failing the run, and asUNEXPECTED PASSonce fixed failing the run. I made it that way so that github is happy while we fix the bugs.This PR adds ~20,000 !! lines of code and ~2,400 tests -- I absolutely do not expect anybody to review it. The PR is intentionally made in a way that 0 production code is touched.