Skip to content

Commit

Permalink
Merge pull request #2192 from AllenInstitute/feature/2192-spring_clea…
Browse files Browse the repository at this point in the history
…nup_tests

Refactor Utils/SweepFormula test code
  • Loading branch information
t-b authored Jul 19, 2024
2 parents 85572d3 + 1228f73 commit 8947c77
Show file tree
Hide file tree
Showing 31 changed files with 12,231 additions and 11,563 deletions.
47 changes: 45 additions & 2 deletions Packages/tests/Basic/UTF_Basic.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,42 @@
#include "UTF_AsynFrameworkTest"
#include "UTF_Configuration"
#include "UTF_DAEphyswoHardware"
#include "UTF_Debugging"
#include "UTF_EpochswoHardware"
#include "UTF_GuiUtilities"
#include "UTF_JSONWaveNotes"
#include "UTF_Labnotebook"
#include "UTF_Macros"
#include "UTF_oodDAQ"
#include "UTF_PGCSetAndActivateControl"
#include "UTF_StimsetAPI"
#include "UTF_SweepFormula"
#include "UTF_SweepFormula_Operations"
#include "UTF_SweepFormula_PSX"
#include "UTF_Testpulse"
#include "UTF_ThreadsafeDataSharing"
#include "UTF_TraceUserData"
#include "UTF_UpgradeDataFolderLocation"
#include "UTF_UpgradeWaveLocationAndGetIt"
#include "UTF_Utils"
#include "UTF_Utils_Algorithm"
#include "UTF_Utils_Checks"
#include "UTF_Utils_Conversions"
#include "UTF_Utils_DataFolder"
#include "UTF_Utils_File"
#include "UTF_Utils_GUI"
#include "UTF_Utils_List"
#include "UTF_Utils_Mies_Algorithm"
#include "UTF_Utils_Mies_BackupWaves"
#include "UTF_Utils_Mies_Config"
#include "UTF_Utils_Mies_Logging"
#include "UTF_Utils_Mies_Sweep"
#include "UTF_Utils_Numeric"
#include "UTF_Utils_ProgramFlow"
#include "UTF_Utils_Strings"
#include "UTF_Utils_Settings"
#include "UTF_Utils_System"
#include "UTF_Utils_Time"
#include "UTF_Utils_WaveHandling"
#include "UTF_UtilsChecks"
#include "UTF_WaveAveraging"
#include "UTF_WaveBuilder"
Expand Down Expand Up @@ -101,12 +123,15 @@ Function RunWithOpts([string testcase, string testsuite, variable allowdebug, va
list = AddListItem("UTF_AnalysisFunctionHelpers.ipf", list, ";", Inf)
list = AddListItem("UTF_AnalysisFunctionParameters.ipf", list, ";", Inf)
list = AddListItem("UTF_AsynFrameworkTest.ipf", list, ";", Inf)
list = AddListItem("UTF_Debugging.ipf", list, ";", Inf)
list = AddListItem("UTF_Configuration.ipf", list, ";", Inf)
list = AddListItem("UTF_DAEphyswoHardware.ipf", list, ";", Inf)
list = AddListItem("UTF_EpochswoHardware.ipf", list, ";", Inf)
list = AddListItem("UTF_GuiUtilities.ipf", list, ";", Inf)
list = AddListItem("UTF_JSONWaveNotes.ipf", list, ";", Inf)
list = AddListItem("UTF_Labnotebook.ipf", list, ";", Inf)
list = AddListItem("UTF_Macros.ipf", list, ";", Inf)
list = AddListItem("UTF_oodDAQ.ipf", list, ";", Inf)
list = AddListItem("UTF_PGCSetAndActivateControl.ipf", list, ";", Inf)
list = AddListItem("UTF_StimsetAPI.ipf", list, ";", Inf)
list = AddListItem("UTF_SweepFormula.ipf", list, ";", Inf)
Expand All @@ -116,7 +141,25 @@ Function RunWithOpts([string testcase, string testsuite, variable allowdebug, va
list = AddListItem("UTF_ThreadsafeDataSharing.ipf", list, ";", Inf)
list = AddListItem("UTF_UpgradeDataFolderLocation.ipf", list, ";", Inf)
list = AddListItem("UTF_UpgradeWaveLocationAndGetIt.ipf", list, ";", Inf)
list = AddListItem("UTF_Utils.ipf", list, ";", Inf)
list = AddListItem("UTF_Utils_Algorithm.ipf", list, ";", Inf)
list = AddListItem("UTF_Utils_Checks.ipf", list, ";", Inf)
list = AddListItem("UTF_Utils_Conversions.ipf", list, ";", Inf)
list = AddListItem("UTF_Utils_DataFolder.ipf", list, ";", Inf)
list = AddListItem("UTF_Utils_File.ipf", list, ";", Inf)
list = AddListItem("UTF_Utils_GUI.ipf", list, ";", Inf)
list = AddListItem("UTF_Utils_List.ipf", list, ";", Inf)
list = AddListItem("UTF_Utils_Mies_Algorithm.ipf", list, ";", Inf)
list = AddListItem("UTF_Utils_Mies_BackupWaves.ipf", list, ";", Inf)
list = AddListItem("UTF_Utils_Mies_Config.ipf", list, ";", Inf)
list = AddListItem("UTF_Utils_Mies_Logging.ipf", list, ";", Inf)
list = AddListItem("UTF_Utils_Mies_Sweep.ipf", list, ";", Inf)
list = AddListItem("UTF_Utils_Numeric.ipf", list, ";", Inf)
list = AddListItem("UTF_Utils_ProgramFlow.ipf", list, ";", Inf)
list = AddListItem("UTF_Utils_Strings.ipf", list, ";", Inf)
list = AddListItem("UTF_Utils_Settings.ipf", list, ";", Inf)
list = AddListItem("UTF_Utils_System.ipf", list, ";", Inf)
list = AddListItem("UTF_Utils_Time.ipf", list, ";", Inf)
list = AddListItem("UTF_Utils_WaveHandling.ipf", list, ";", Inf)
list = AddListItem("UTF_UtilsChecks.ipf", list, ";", Inf)
list = AddListItem("UTF_WaveAveraging.ipf", list, ";", Inf)
list = AddListItem("UTF_WaveBuilder.ipf", list, ";", Inf)
Expand Down
34 changes: 34 additions & 0 deletions Packages/tests/Basic/UTF_DAEphyswoHardware.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -205,3 +205,37 @@ Function CheckStimsetUpdateAndSearch([STRUCT IUTF_mData &m])
WAVE/T stimsetsFromMenu = GetStimsetFromUserData(device, ctrlWave)
CHECK_EQUAL_TEXTWAVES({"stimsetD"}, stimsetsFromMenu)
End

/// DAP_GetRAAcquisitionCycleID
/// @{

static StrConstant device = "ITC18USB_DEV_0"

Function AssertOnInvalidSeed()
NVAR rngSeed = $GetRNGSeed(device)
rngSeed = NaN

try
MIES_DAP#DAP_GetRAAcquisitionCycleID(device)
FAIL()
catch
PASS()
endtry
End

Function CreatesReproducibleResults()
NVAR rngSeed = $GetRNGSeed(device)

// Use GetNextRandomNumberForDevice directly
// as we don't have a locked device

rngSeed = 1
Make/FREE/N=1024/L dataInt = GetNextRandomNumberForDevice(device)
CHECK_EQUAL_VAR(2932874867, WaveCRC(0, dataInt))

rngSeed = 1
Make/FREE/N=1024/D dataDouble = GetNextRandomNumberForDevice(device)

CHECK_EQUAL_WAVES(dataInt, dataDouble, mode = WAVE_DATA)
End
/// @}
69 changes: 69 additions & 0 deletions Packages/tests/Basic/UTF_Debugging.ipf
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#pragma TextEncoding="UTF-8"
#pragma rtGlobals=3 // Use modern global access method and strict wave access.
#pragma rtFunctionErrors=1
#pragma ModuleName=TESTS_DEBUGGING

/// BUG
/// BUG_TS
/// @{

Function BUGWorks()
variable bugCount

bugCount = ROVar(GetBugCount())
CHECK_EQUAL_VAR(bugCount, 0)

BUG("abcd")

bugCount = ROVar(GetBugCount())
CHECK_EQUAL_VAR(bugCount, 1)

DisableBugChecks()
End

Function BUG_TSWorks1()
variable bugCount

TUFXOP_Clear/N=(TSDS_BUGCOUNT)/Q/Z

bugCount = TSDS_ReadVar(TSDS_BUGCOUNT)
CHECK_EQUAL_VAR(bugCount, NaN)

BUG_TS("abcd")

bugCount = TSDS_ReadVar(TSDS_BUGCOUNT)
CHECK_EQUAL_VAR(bugCount, 1)

DisableBugChecks()
End

threadsafe static Function BugHelper(variable idx)

BUG_TS(num2str(idx))

return TSDS_ReadVar(TSDS_BUGCOUNT) == 0
End

Function BUG_TSWorks2()
variable bugCount, numThreads

TUFXOP_Clear/N=(TSDS_BUGCOUNT)/Q/Z

bugCount = TSDS_ReadVar(TSDS_BUGCOUNT)
CHECK_EQUAL_VAR(bugCount, NaN)

numThreads = 10

Make/FREE/N=(numThreads) junk = NaN

MultiThread/NT=(numThreads) junk = BugHelper(p)

CHECK_EQUAL_VAR(Sum(junk), 0)

bugCount = TSDS_ReadVar(TSDS_BUGCOUNT)
CHECK_EQUAL_VAR(bugCount, numThreads)

DisableBugChecks()
End

/// @}
22 changes: 22 additions & 0 deletions Packages/tests/Basic/UTF_EpochswoHardware.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -290,3 +290,25 @@ static Function EP_TestSortEpochs()
INFO("mixed order = %s", s0 = orderStr)
CHECK_EQUAL_STR(refHash, orderHash)
End

Function RPI_WorksWithOldData()
string epochInfo

// 4e534e29 (Pulse Averaging: Pulse starting times are now read from the lab notebook, 2020-10-07)
// no level 3 info
epochInfo = EP_EpochWaveToStr(root:EpochsWave:EpochsWave_4e534e298, 0, XOP_CHANNEL_TYPE_DAC)
WAVE/Z pulseInfos = MIES_PA#PA_RetrievePulseInfosFromEpochs(epochInfo)
CHECK_WAVE(pulseInfos, NULL_WAVE)

// d150d896 (DC_AddEpochsFromStimSetNote: Add sub sub epoch information, 2021-02-02)
epochInfo = EP_EpochWaveToStr(root:EpochsWave:EpochsWave_d150d896e, 0, XOP_CHANNEL_TYPE_DAC)
WAVE/Z pulseInfos_d150d896e = MIES_PA#PA_RetrievePulseInfosFromEpochs(epochInfo)
CHECK_WAVE(pulseInfos_d150d896e, NUMERIC_WAVE)

// 22c735d7 (Merge pull request #1130 from AllenInstitute/feature/1130-fix-is-constant, 2021-11-03)
epochInfo = EP_EpochWaveToStr(root:EpochsWave:EpochsWave_22c735d7, 0, XOP_CHANNEL_TYPE_DAC)
WAVE/Z pulseInfos_22c735d7 = MIES_PA#PA_RetrievePulseInfosFromEpochs(epochInfo)
CHECK_WAVE(pulseInfos_22c735d7, NUMERIC_WAVE)

CHECK_EQUAL_WAVES(pulseInfos_d150d896e, pulseInfos_22c735d7, mode = WAVE_DATA)
End
Loading

0 comments on commit 8947c77

Please sign in to comment.