Skip to content

Conversation

rickwu666666
Copy link
Contributor

@rickwu666666 rickwu666666 commented Jul 28, 2025

Description

Rewrite button test to python to fix the issue of fail detect the IRQ if it not effect CPU0.
Our original design to check only the interrupt trigger for CPU0. However, that is not correct logic for the IRQ. The IRQ could be trigger for sepcific CPU, and it been defined in /proc/irq/{irq_number}/smp_affinity.
The new design will do following logic.

  1. check the IRQ number for interrupt name, and also handle multiple IRQs for one interrupt name.
  2. check the smp_affinity for the IRQ.
  3. Monitor the interrupts count for specific CPUs
  4. check if any interrupts of CPUs increased

Resolved issues

https://bugs.launchpad.net/shiner/+bug/2098460

Documentation

Tests

button that support only one IRQ.

==============[ Running job 1 / 2. Estimated time left: 0:00:50 ]===============                                                                       
-----[ To test system detect a interrupts by press service button button ]------                                                                       
ID: com.canonical.contrib::ce-oem-button/detect-by-interrupts-press-service button                                                                     
Category: com.canonical.contrib::button                                                                                                                
Purpose:                                                                                                                                               
                                                                                                                                                       
Check service button button can trigger a interrupts after pressing and releasing button.                                                              
                                                                                                                                                       
Pick an action                                                                                                                                         
    => press ENTER to continue                                                                                                                         
  c => add a comment                                                                                                                                   
  s => skip this job                                                                                                                                   
  q => save the session and quit                                                                                                                       
[csq]:                                                                                                                                                 
... 8< -------------------------------------------------------------------------                                                                       
Searching for IRQ name 'service button' in /proc/interrupts...                                                                                         
Successfully found IRQ numbers: 135                                                                                                                    
IRQ 135 is tuned to run on CPU(s): [0, 1]                                                                                                              
Initial interrupt counts on target CPUs:                                                                                                               
IRQ 135, CPU 0: 0                                                                                                                                      
IRQ 135, CPU 1: 0                                                                                                                                      
Monitoring for interrupt activity for 30 seconds...                                                                                                    
SUCCESS: Interrupt detected on IRQ 135 (CPU 0)!                                                                                                        
Initial count: 0, Final count: 1                                                                                                                       
Button Test for 'service button' PASSED!                                                                                                               
------------------------------------------------------------------------- >8 ---                                                                       
Outcome: job passed 

Trial run for the interrupt that support multiple IRQs

==============[ Running job 2 / 2. Estimated time left: 0:00:25 ]===============                                                                       
----[ To test system detect a interrupts by press 30be0000.ethernet button ]----                                                                       
ID: com.canonical.contrib::ce-oem-button/detect-by-interrupts-press-30be0000.ethernet                                                                  
Category: com.canonical.contrib::button                                                                                                                
Purpose:                                                                                                                                               
                                                                                                                                                       
Check 30be0000.ethernet button can trigger a interrupts after pressing and releasing button.                                                           
                                                                                                                                                       
Pick an action                                                                                                                                         
    => press ENTER to continue
  c => add a comment
  s => skip this job
  q => save the session and quit
[csq]: 
Searching for IRQ name '30be0000.ethernet' in /proc/interrupts...
Successfully found IRQ numbers: 39, 40, 41
IRQ 39 is tuned to run on CPU(s): [0, 1]
IRQ 40 is tuned to run on CPU(s): [0, 1]
IRQ 41 is tuned to run on CPU(s): [0, 1]
Initial interrupt counts on target CPUs:
IRQ 39, CPU 0: 0
IRQ 39, CPU 1: 0
IRQ 40, CPU 0: 0
IRQ 40, CPU 1: 0
IRQ 41, CPU 0: 40349
IRQ 41, CPU 1: 0
Monitoring for interrupt activity for 30 seconds...
SUCCESS: Interrupt detected on IRQ 41 (CPU 0)!
Initial count: 40349, Final count: 40351
Button Test for '30be0000.ethernet' PASSED!

GPIO button

==============[ Running job 2 / 3. Estimated time left: 0:00:50 ]===============                                                                       
------------[ To test system detect a signal by press right button ]------------                                                                       
ID: com.canonical.contrib::ce-oem-button/detect-by-gpio-press-right                                                                                    
Category: com.canonical.contrib::button                                                                                                                
Purpose:                                                                                                                                               
                                                                                                                                                       
Check right button can trigger a signal after pressing and releasing button.                                                                           
                                                                                                                                                       
Pick an action                                                                                                                                         
    => press ENTER to continue                                                                                                                         
  c => add a comment                                                                                                                                   
  s => skip this job                                                                                                                                   
  q => save the session and quit                                                                                                                       
[csq]:                                                                                                                                                 
... 8< -------------------------------------------------------------------------                                                                       
Initialized test for 'right' on GPIO 874                                                                                                               
--- Entering context: Setting up GPIO ---                                                                                                              
GPIO 874 was already exported. Will not unexport on exit.                                                                                              
Set GPIO 874 direction to 'in'                                                                                                                         
Initial value of gpio874 is: High                                                                                                                      
Please PRESS and HOLD the 'right' button...                                                                                                            
PASS: Button press detected!                                                                                                                           
Please RELEASE the 'right' button...
PASS: Button release detected!
--- Exiting context: Cleaning up GPIO ---
Leaving GPIO 874 exported as it was found.
Button Test for 'right' PASSED!
------------------------------------------------------------------------- >8 ---
Outcome: job passed
==============[ Running job 3 / 3. Estimated time left: 0:00:25 ]===============                                                                       
------------[ To test system detect a signal by press left button ]-------------                                                                       
ID: com.canonical.contrib::ce-oem-button/detect-by-gpio-press-left                                                                                     
Category: com.canonical.contrib::button                                                                                                                
Purpose:                                                                                                                                               
                                                                                                                                                       
Check left button can trigger a signal after pressing and releasing button.                                                                            
                                                                                                                                                       
Pick an action                                                                                                                                         
    => press ENTER to continue                                                                                                                         
  c => add a comment                                                                                                                                   
  s => skip this job                                                                                                                                   
  q => save the session and quit                                                                                                                       
[csq]:                                                                                                                                                 
... 8< -------------------------------------------------------------------------                                                                       
Initialized test for 'left' on GPIO 872                                                                                                                
--- Entering context: Setting up GPIO ---                                                                                                              
Exporting GPIO 872 to system...
Set GPIO 872 direction to 'in'
Initial value of gpio872 is: High
Please PRESS and HOLD the 'left' button...
PASS: Button press detected!
Please RELEASE the 'left' button...
PASS: Button release detected!
--- Exiting context: Cleaning up GPIO ---
Unexporting GPIO 872 (we exported it)...
Button Test for 'left' PASSED!
------------------------------------------------------------------------- >8 ---
Outcome: job passed

Modify the checkbox config var parser. Since the name of interrupts button could be include space or :

Therefore, we use | to split the different button name. And also include fall back logic for the previous checkbox config var of the interrupts_button
@rickwu666666 rickwu666666 added the ce-oem The PR only contains to the ce-oem provider under the contrib area label Jul 28, 2025
@rickwu666666 rickwu666666 changed the title Rewrite button test to python to fix the issue that IRQ not effect CPU0 Rewrite button test to python to fix the issue that IRQ not effect CPU0(BugFix) Jul 28, 2025
@rickwu666666 rickwu666666 changed the title Rewrite button test to python to fix the issue that IRQ not effect CPU0(BugFix) Rewrite button test to python to fix the issue that IRQ not effect CPU0 (BugFix) Jul 28, 2025
@rickwu666666 rickwu666666 force-pushed the rewrite-button-test-to-python branch from 873b8fd to 5596abc Compare July 28, 2025 08:41
@rickwu666666 rickwu666666 force-pushed the rewrite-button-test-to-python branch from 5596abc to 910f7e3 Compare July 28, 2025 08:46
@rickwu666666 rickwu666666 changed the title Rewrite button test to python to fix the issue that IRQ not effect CPU0 (BugFix) Rewrite button test to python to fix the issue of fail detect the IRQ if it not effect CPU0 (BugFix) Jul 28, 2025
This reverts commit b1f85cb.
Since the GPIO related test not been affect, and also the GPIO test
might be able to leverage from the gpio_control_test.py in PPC.
Since we split the gpio and interrupts button test
Copy link
Collaborator

@stanley31huang stanley31huang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

per internal discussion, I would suggest we split this whole scripts into two seperate scripts, one for interrupts_button_test and another one for gpio_button_test scripts

Copy link

codecov bot commented Aug 1, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 51.66%. Comparing base (b6bb493) to head (34a15ef).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2047   +/-   ##
=======================================
  Coverage   51.66%   51.66%           
=======================================
  Files         386      386           
  Lines       41492    41492           
  Branches     7711     7711           
=======================================
  Hits        21435    21435           
  Misses      19294    19294           
  Partials      763      763           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

#!/usr/bin/env python3
"""
A script to monitor interrupts, verify IRQ CPU affinity, and test
interrupt triggers via GPIO or manual sysfs interaction.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the interrupt should be triggers by sysfs only, not GPIO?

return False
return True

def _get_interrupt_counts(self, irq_number: int) -> Optional[List[int]]:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest we could merge _get_irq_numbers and _get_interrupt_counts as it's pretty much the same.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ce-oem The PR only contains to the ce-oem provider under the contrib area
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants