Re: [PATCH V7 7/8] libgpiod: Add rust tests

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Oct 14, 2022 at 04:17:24PM +0530, Viresh Kumar wrote:
> Add tests for the rust bindings, quite similar to the ones in cxx
> bindings.
> 
> Signed-off-by: Viresh Kumar <viresh.kumar@xxxxxxxxxx>
> ---

<snip>
> +
> +        #[test]
> +        fn clock() {

My preference would be event_clock(), but I can live with clock().

> +            let mut config = TestConfig::new(NGPIO).unwrap();
> +            config.lconfig_add_settings(&[0]);
> +            config.request_lines().unwrap();
> +            let info = config.chip().line_info(0).unwrap();
> +            assert_eq!(info.event_clock().unwrap(), EventClock::Monotonic);
> +
> +            let mut config = TestConfig::new(NGPIO).unwrap();
> +            config.lconfig_clock(EventClock::Monotonic);
> +            config.lconfig_add_settings(&[0]);
> +            config.request_lines().unwrap();
> +            let info = config.chip().line_info(0).unwrap();
> +            assert_eq!(info.event_clock().unwrap(), EventClock::Monotonic);
> +
> +            let mut config = TestConfig::new(NGPIO).unwrap();
> +            config.lconfig_clock(EventClock::Realtime);
> +            config.lconfig_add_settings(&[0]);
> +            config.request_lines().unwrap();
> +            let info = config.chip().line_info(0).unwrap();
> +            assert_eq!(info.event_clock().unwrap(), EventClock::Realtime);
> +
> +            let mut config = TestConfig::new(NGPIO).unwrap();
> +            config.lconfig_clock(EventClock::HTE);
> +            config.lconfig_add_settings(&[0]);
> +            config.request_lines().unwrap();
> +            let info = config.chip().line_info(0).unwrap();
> +            assert_eq!(info.event_clock().unwrap(), EventClock::HTE);

I was surprised to find HTE tests passing on a kernel without CONFIG_HTE.
I take that as being a kernel bug (GPIO_V2_LINE_VALID_FLAGS includes the
HTE flag unconditionally - which is wrong IMHO).

You probably shouldn't assume HTE works - unless you have a system that
supports HTE.

Other than that the tests look good to me, though as with the Python
bindings I've only skimmed them.

Cheers,
Kent.



[Index of Archives]     [Linux SPI]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux