imeghar2408-max opened a new pull request, #4030: URL: https://github.com/apache/nuttx-apps/pull/4030
Add a CMocka test for the ADC upper-half open and close lifecycle using a mock lower half. Verify that failed setup does not retain an open reference, a subsequent open retries setup, successful opens maintain the reference count, and shutdown runs after the final close. Tested: - Simulator build. - cmocka_driver_adc_open: 1 test passed. Assisted-by: ChatGPT:GPT-6 ## Summary Add `cmocka_driver_adc_open`, a CMocka regression test for the ADC upper-half open and close lifecycle. The test registers a mock ADC lower half and exercises the actual VFS open/close path. It verifies that: - A failed first `ao_setup()` does not retain an open reference. - A subsequent open retries setup. - Successful opens maintain the correct reference count. - Closing the first of two open descriptors does not shut down the device. - Shutdown is called exactly once after the final close. ## Impact - Adds `testing/drivers/drivertest/drivertest_adc_open.c`. - Registers the test in both CMake and Make build systems. - Uses the existing ADC drivertest configuration and CMocka dependency. - Does not require a physical ADC peripheral or ADC hardware. ## Testing **Build host:** Linux x86_64 **Target:** NuttX Simulator ### Build Command: ```bash make -j4 ``` Output: ```text LD: nuttx Pac SIM with dynamic libs.. '/usr/lib/x86_64-linux-gnu/libz.so.1' -> 'sim-pac/libs/libz.so.1' '/usr/lib/x86_64-linux-gnu/libc.so.6' -> 'sim-pac/libs/libc.so.6' '/lib64/ld-linux-x86-64.so.2' -> 'sim-pac/ld-linux-x86-64.so.2' SIM elf with dynamic libs archive in nuttx.tgz ``` ### Runtime regression test Command: ```bash set -o pipefail printf 'cmocka_driver_adc_open\npoweroff\n' | timeout 30s ./nuttx ``` Output: ```text nsh> cmocka_driver_adc_open [==========] tests: Running 1 test(s). [ RUN ] test_adc_open_setup_failure [ OK ] test_adc_open_setup_failure [==========] tests: 1 test(s) run. [ PASSED ] 1 test(s). nsh> poweroff ``` ### Additional checks - `git diff --check` — passed. - `tools/checkpatch.sh` — passed for the new ADC test source. ## Dependency This regression test accompanies the ADC upper-half production fix in `apache/nuttx`. NuttX fix PR: The production fix must be applied for this regression test to pass. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
