Skip to content

Commit c463423

Browse files
committed
tests: aegc: Fix possible false postive failure
If the auto algorithm converges on the same gain/exposure as the last manual value, the test will fail. Try and detect this case and do one more manual control step before switching back to auto mode. Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
1 parent 06a39ea commit c463423

1 file changed

Lines changed: 16 additions & 5 deletions

File tree

tests/aegc.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,20 @@ def test_control_auto(control):
2222
for _ in range(5):
2323
check = picam2.capture_metadata()[control]
2424
if abs(check - current) > current * 0.05:
25-
print(f"Control {control} changed from {current} to {check}")
26-
return
27-
print(f"ERROR: {control} has not returned to auto - still {check}")
25+
return True, current, check
26+
return False, current, check
27+
28+
29+
def run_auto_test(control, reset_value):
30+
success, current, check = test_control_auto(control)
31+
if not success:
32+
# Retry in case the auto algorithm converged back to the last fixed value
33+
test_control_fixed(control, reset_value)
34+
success, current, check = test_control_auto(control)
35+
if success:
36+
print(f"Control {control} changed from {current} to {check}")
37+
else:
38+
print(f"ERROR: {control} has not returned to auto - still {check}")
2839

2940

3041
picam2 = Picamera2()
@@ -33,12 +44,12 @@ def test_control_auto(control):
3344
test_control_fixed("ExposureTime", 5000)
3445
test_control_fixed("ExposureTime", 10000)
3546
test_control_fixed("ExposureTime", 1000)
36-
test_control_auto("ExposureTime")
47+
run_auto_test("ExposureTime", 5000)
3748

3849
test_control_fixed("AnalogueGain", 1.5)
3950
test_control_fixed("AnalogueGain", 3.0)
4051
test_control_fixed("AnalogueGain", 5.8)
41-
test_control_auto("AnalogueGain")
52+
run_auto_test("AnalogueGain", 1.0)
4253

4354

4455
# Also test that it works when we start the camera.

0 commit comments

Comments
 (0)