dls-controls / pythonSoftIOC

Embed an EPICS IOC in a Python process
Apache License 2.0
32 stars 7 forks source link

Protect against overflow/underflow for integer record types #110

Open AlexanderWells-diamond opened 1 year ago

AlexanderWells-diamond commented 1 year ago

Long, Bool and MBB record types are now protected from out of range values - .set() will throw an exception, and caput() will fail to store the new value. This means records can no longer be put into invalid values, or suffer from integer overflow/underflow.

Also correct an oversight in get_field_offsets, to properly raise a Python exception when the record type cannot be found.

Closes #66

codecov[bot] commented 1 year ago

Codecov Report

Merging #110 (9c19bed) into master (dc4a63f) will decrease coverage by 0.13%. The diff coverage is 85.71%.

@@            Coverage Diff             @@
##           master     #110      +/-   ##
==========================================
- Coverage   87.03%   86.90%   -0.14%     
==========================================
  Files          14       14              
  Lines         972      985      +13     
==========================================
+ Hits          846      856      +10     
- Misses        126      129       +3     
Impacted Files Coverage Δ
softioc/device.py 94.67% <85.71%> (-0.93%) :arrow_down:

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

github-actions[bot] commented 1 year ago

Unit Test Results

     15 files  ±  0       15 suites  ±0   30m 21s :stopwatch: + 2m 3s    253 tests +  6     246 :heavy_check_mark: +  5      7 :zzz: +  1  0 :x: ±0  3 795 runs  +90  3 330 :heavy_check_mark: +65  465 :zzz: +25  0 :x: ±0 

Results for commit 9c19bedb. ± Comparison against base commit dc4a63f8.

:recycle: This comment has been updated with latest results.

AlexanderWells-diamond commented 1 year ago

Thinking about it, in its current form this PR does mean you can no longer signal a boolOut/mbbOut record is in an invalid state by setting an out-of-range number to trigger the "ILLEGAL VALUE" error handling in EPICS. That's related to issue #53. I don't know if this is a significant concern.