Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pr/align adapters api #1

Closed
wants to merge 425 commits into from
Closed

Pr/align adapters api #1

wants to merge 425 commits into from

Conversation

gopiotr
Copy link
Owner

@gopiotr gopiotr commented Jul 25, 2023

TBD

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Hello @gopiotr, and thank you very much for your first pull request to the Zephyr project!

A project maintainer just triggered our CI pipeline to run it against your PR and ensure it's compliant and doesn't cause any issues. You might want to take this opportunity to review the project's Contributor Expectations and make any updates to your pull request if necessary. 😊

self._end_of_data_detected = True

@staticmethod
def _get_west() -> str:
Copy link

Choose a reason for hiding this comment

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

moze property? mozna wtedy dodać sprawdzanie tylko raz, coś w stylu

    def __init__(self):
        self._west = None
    @property
    def west(self):
        if not self._west:
            west= shutil.which('west')
            ....
            self._west = west
        return self._west

class QemuAdapter(DeviceAbstract):
"""Adapter for Qemu simulator"""

class QemuAdapter(SimulatorAdapterBase):
Copy link

Choose a reason for hiding this comment

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

chcemy wiązać Qemu z Simulator?

"""Return true if application is running on device."""

@abc.abstractmethod
def _is_device_connected(self) -> bool:
Copy link

Choose a reason for hiding this comment

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

zmieniłbym na nie-prywatna metodę (bez podkreślenia z przodu)

self.command: list[str] = []

self.handler_log_path: Path = Path(device_config.build_dir) / 'handler.log'
self.device_log_path: Path = Path(device_config.build_dir) / 'device.log'
Copy link

Choose a reason for hiding this comment

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

device.log był dodawany tylko dla hardware, może nie ma sensu trzymać tego tutaj.

Copy link

Choose a reason for hiding this comment

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

dobre pytanie. generalnie build/device/handler logi są cechą workflow twistera i tam nie ma rozróżnienia, co powinno mieć a co nie danego loga. chyba bym zostawił. może np do renoda się przyda? jak będzie jakiś problem z wywołaniem renoda a nie samego testu. Myślałem, czy z qemu nie mogłoby być podobnie, że jak jest z qemu problem to tam trafia, ale tego chyba nie potrafimy rozróżnić. west -t run jak się wywali to raczej problem aplikacji niż qemu

Comment on lines 56 to 58
Start from close previously run application (if was already run). Then
flash and run application and start reader thread to capture output
from device.
Copy link

@PerMac PerMac Jul 28, 2023

Choose a reason for hiding this comment

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

Suggested change
Start from close previously run application (if was already run). Then
flash and run application and start reader thread to capture output
from device.
Start by closing previously running application (no effect if not needed). Then, flash and run test application. Finally, start a reader thread capturing an output from a device.

TODO:
Do we need this?
Maybe we should add to log file info about currently executed test?
What about multiple devices used in the same test?
Copy link

Choose a reason for hiding this comment

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

Jeśli planujemy dodawać kolejne dut-y (np. do testów z bsim), to może już teraz warto rozszerzyć nazwy plików o numer, np. handler_0.log, device_0.log. Albo pierwszy zostawić tak jak jest (czyli ten ładowany z fixtury, bez parametrów), a przy dodawaniu kolejnego dut-a, dodać numer.

Copy link

Choose a reason for hiding this comment

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

wg mnie pierwszy bez numeru kolejne z, żeby jak jest tylko jeden to było kompatybilne z twisterem

# ignore output from device
self._flush_device_output()
time.sleep(0.1)
# TODO: what should be END_OF_DATA instance of object, or rather string
Copy link

Choose a reason for hiding this comment

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

Uprościłoby to annotacje w kilku metodach (str | object) ...
Ja się zastanawiam, czy potrzebujemy ten obiekt (choć lepiej żeby był, bo nie chcę później rozwiązywać problemów z synchronizacją ... bo już miesza mi się kiedy używamy is_device_connected a kiedy is_device_running)

Copy link

Choose a reason for hiding this comment

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

ok, sam sobie odpowiem: END_OF_DATA jest tylko o to, żeby pozwolić odczytać kolejkę, nawet jak już device is not connected

tristan-google and others added 25 commits July 28, 2023 17:48
The sensor driver uses the value 500 to convert bit counts to microgauss
values, but it should actually be 1500. Edit the driver unit test to use
the macro instead of a magic number.

Signed-off-by: Tristan Honscheid <honscheid@google.com>
This PR introduces a backend API to be implemented by sensor emulators
that creates a standardized mechanism for setting expected sensor
readings in tests. This unlocks the ability to create a generic sensor
test that can automatically set expected values in supported sensor
emulators and verify them through the existing sensor API. An
implementation of this API is provided for the AKM09918C magnetometer.

A generic sensor test is also created to exercise this implementation.
Observe that this test knows nothing about the AKM09918C; info about
supported channels and sample ranges is discovered through the backend
API. The test iterates over all devices attached to the virtual I2C and
SPI buses in the test binary's device tree, which (theoretically) covers
all sensors. Sensors whose emulator does not exist yet or does not
support the backend API are skipped.

Signed-off-by: Tristan Honscheid <honscheid@google.com>
Adds new boards and SoCs for the Intel Sensor Hub (ISH).

Signed-off-by: Dong Wang <dong.d.wang@intel.com>
It provides a low level Hardware Abstraction Layer for Intel
specific hardware, like Intel ISH

Signed-off-by: Dong Wang <dong.d.wang@intel.com>
Add a new Kconfig option to enable the build of Intel HAL and select
it always for ish SoCs

Signed-off-by: Dong Wang <dong.d.wang@intel.com>
Adds a new serial shim driver for Intel SoCs. Builds upon the SEDI bare
metal UART driver in the hal-intel module.

Signed-off-by: Nachiketa Kumar <nachiketa.kumar@intel.com>
Signed-off-by: Dong Wang <dong.d.wang@intel.com>
Revise the documentation around canceling pending SQEs.

Signed-off-by: Yuval Peress <peress@google.com>
Add zephyr_udc0 nodelabel to allow building all USB device samples
for adafruit_feather_m0_basic_proto board out of the box.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
I'm using a new account now.

Do the corresponding CODEOWNERS change just for consistency as well.

Signed-off-by: Martí Bolívar <mbolivar@amperecomputing.com>
The Thrift library has its own abstraction for mutexes, which
normally just a wrapper around `std::mutex` using the PIMPL
idiom (pointer-to-impl).

Since Zephyr does not yet support `std::mutex`, a workaround
was added in Zephyr that was essentially no-op, and actually
the PIMPL idiom made it quite easy to do that. However,
pretending there is no synchronization requirement is not a
solution for it.

We can't yet just use a `struct k_mutex` yet, because we
don't yet support userspace, but for now we can fake a mutex
interface with a spinlock.

We hope to eventually drop this workaround entirely and just
support `std::mutex`.

Signed-off-by: Christopher Friedt <cfriedt@meta.com>
There is no need to pass a second parameter to `pthread_join()`
if it is unused. Just use `NULL` instead.

Signed-off-by: Christopher Friedt <cfriedt@meta.com>
A recent modification to the `build_all/sensor` testsuite changed
`build-only` to `false` in `testcase.yaml`, which is causing CI
to go bonkers.

https://bit.ly/3rSe0Te

Do not run build-only testsuites.

Signed-off-by: Christopher Friedt <cfriedt@meta.com>
Discovered this while implementing c11 threads, but there
was a regression recently that made it so that `pthread_join()`
would report success when attempting to join a thread that had
been detached with `pthread_detach()`.

Technically now that is undefined behaviour, but historically,
we have reported `EINVAL`, which was the older specified
return value.

Signed-off-by: Christopher Friedt <cfriedt@meta.com>
A thread that has been previously detached using
`pthread_detach()` should not be able to be joined. A recent
change made it so that `pthread_join()` would always report
success (0), even when `ret` (return value) had an error.

Signed-off-by: Christopher Friedt <cfriedt@meta.com>
Ensure that the thread return value is set by `pthread_join()`
when `status` is non-NULL.

Additionally, we have an opportunity to synchronously clean
up thread stacks in `pthread_join()`, which is preferable.

Signed-off-by: Christopher Friedt <cfriedt@meta.com>
Ensure that the thread return value is set by `pthread_join()`
when `status` is non-NULL.

Signed-off-by: Christopher Friedt <cfriedt@meta.com>
Now that vendor name in board compatible is meant to be actually used,
it should be properly filled.
Update when not correct and don't put any name when vendor is not known

Signed-off-by: Erwan Gouriou <erwan.gouriou@st.com>
Added Doxygen comments for 1-Wire commands

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Double promotion warnings are generated with the flag -Wdouble-promotion

Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
For platforms that select Kconfig option CONFIG_KERNEL_COHERENCE,
the receive buffer used in mq_timedreceive() must not be on the
stack. This is because the k_msgq that underlies the POSIX mqueue
will attempt to perform a direct to buffer copy from the sender
when there is a waiting reader.

Fixes zephyrproject-rtos#60796

Signed-off-by: Peter Mitsis <peter.mitsis@intel.com>
This adds a check and option for edge triggered interrupts

Signed-off-by: Joshua Lilly <jgl@meta.com>
At any ack, the retransmission timer was cancelled. This means when an ACK
is only partially acknowledging pending data, followed by a packet loss,
the connection ended in a deadlock eventually timing out.
By checking if there is any pending data for transmission before canceling
the retransmission timer, there is no risk of this lock-up any more.

Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
Rename the phy-dev property with phy-handle to match the Linux
ethernet-controller binding and move it up to ethernet.yaml so that it
can be used by other drivers.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
Rename the ethernet.yaml template to ethernet-controller.yaml to match
the Linux one.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
The test thread and the system workqueue have the same priority,
so it is a bit arbitrary whether the workqueue cleans up
the send context before the next send.

Signed-off-by: Francois Ramu <francois.ramu@st.com>
msobkowski and others added 28 commits August 4, 2023 10:48
UART controller present in Ambiq SoCs is mostly compatible with PL011, but
requires some quirks that are implemented in this commit:
- the peripheral needs to be powered on first, via the PWRCTRL core,
- peripheral clock needs to be enabled and configured via the CLKEN/CLKSEL.
  registers.

The quirks mechanism was inspired by support for STM32F4 SoC in the
usb_dc_dw driver (fce0b85).

Co-authored-by: Mateusz Sierszulski <msierszulski@antmicro.com>
Signed-off-by: Maciej Sobkowski <msobkowski@antmicro.com>
Signed-off-by: Mateusz Sierszulski <msierszulski@antmicro.com>
PINCTRL needs to be enabled for the driver to work on the Apollo4 family
SoCs.

Signed-off-by: Maciej Sobkowski <msobkowski@antmicro.com>
This commit adds PL011 UART instances to the apollo4p dts.

Signed-off-by: Maciej Sobkowski <msobkowski@antmicro.com>
This commit addst support for the system timer peripheral which
can be found in Apollo4 SoCs.

Signed-off-by: Maciej Sobkowski <msobkowski@antmicro.com>
Disable SysTick when STIMER is in use and configure
SYS_CLOCK_HW_CYCLES_PER_SEC setting for it.

Signed-off-by: Maciej Sobkowski <msobkowski@antmicro.com>
This commit adds support for the Ambiq Apollo4P EVB board (AMAP4PEVB).

Signed-off-by: Maciej Sobkowski <msobkowski@antmicro.com>
Add people responsible for maintaining Zephyr on Ambiq SoCs.

Signed-off-by: Maciej Sobkowski <msobkowski@antmicro.com>
Check and propagate return values from GPIO calls.

Fixes zephyrproject-rtos#59529.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
This seems to be failing fairly persistently in CI runs. Filed an issue
for having it checked, let's exclude it from the test run until it's
fixed.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
PytestAssertRewriteWarning is raised when pytest-twister-harness
plugin is called from twister. Call register method to get rid
of that warning

Signed-off-by: Grzegorz Chwierut <grzegorz.chwierut@nordicsemi.no>
Add possibility of passing timeouts from Twister to pytest and unify
various timeouts used in adapters to point to one main timeout.

Signed-off-by: Piotr Golyzniak <piotr.golyzniak@nordicsemi.no>
Change name of DeviceAbstract class to more meaningful like
DeviceAdapter.

Signed-off-by: Piotr Golyzniak <piotr.golyzniak@nordicsemi.no>
Change name of SimulatorAdapterBase class to more meaningful like
BinaryAdapterBase. This changes is also made to be more align with
Twister terminology.

Signed-off-by: Piotr Golyzniak <piotr.golyzniak@nordicsemi.no>
Config CONFIG_NATIVE_UART_0_ON_STDINOUT=y should be applied only for
posix architecture platforms.

Signed-off-by: Piotr Golyzniak <piotr.golyzniak@nordicsemi.no>
Select and place common code of three adapters (HardwareAdapter,
BinaryAdapterBase and QemuAdapter) into basic DeviceAdapter class.

Introduce new way of reading device output by run separate thread which
try to read device output and place it into internal python queue.
Thanks to this, now it is possible to create readline method for all
adapters, which can be unblock when timeout occur.

Collect all common steps which have to be done before setup device in
launch method. The same was done for teardown operations which were
placed into close method.

Additionally some protection mechanisms were introduced to prevent for
undesirable side-effects when user could try to launch to already
launched device or try to send some data to disconnected device.

iter_stdout method was replaced by two new methods: readline and
readlines. To make it possible to remove all read output from internal
buffer (queue), clear_buffer method was introduced.

Also unit tests were rewritten to work properly with current version
of adapters.

Signed-off-by: Piotr Golyzniak <piotr.golyzniak@nordicsemi.no>
LogFile class is not used anymore, so there is no sense to keep it
and its unit tests.

Signed-off-by: Piotr Golyzniak <piotr.golyzniak@nordicsemi.no>
Constants variables are no longer used, so this file can be removed.

Signed-off-by: Piotr Golyzniak <piotr.golyzniak@nordicsemi.no>
Introduce changes into FifoHandler class to make it more safe
(especially to avoid blocking all program when FIFO queue is not opened
by other application).

Signed-off-by: Piotr Golyzniak <piotr.golyzniak@nordicsemi.no>
Add readlines_until method to DeviceAdapter class to simplify using
adapters in tests by give user possibility to read output from device
until following conditions:
- provided regex was found
- provided number of lines was already read
- timeout was occurred

Signed-off-by: Piotr Golyzniak <piotr.golyzniak@nordicsemi.no>
Pass pytest test name to handler.log header to make it easier to
analyze handler.log content.

Signed-off-by: Piotr Golyzniak <piotr.golyzniak@nordicsemi.no>
Divide dut fixture into three smaller fixtures to make it easier
to user to change dut fixture scope or to write her/his own dut
fixture.

Signed-off-by: Piotr Golyzniak <piotr.golyzniak@nordicsemi.no>
Move helper.py file content to utils.py file in device directory,
where those helper functions are used.

Signed-off-by: Piotr Golyzniak <piotr.golyzniak@nordicsemi.no>
Create helper class Shell which can be used in tests which require
interaction with shell application.

Signed-off-by: Piotr Golyzniak <piotr.golyzniak@nordicsemi.no>
Remove log.py and by this logging configuration from
pytest-harness-plugin. Instead use pytest options for setting verbosity
and format of printed logs. Thanks to this management of verbosity
level can be easier for users.

Signed-off-by: Piotr Golyzniak <piotr.golyzniak@nordicsemi.no>
Add better description of available options and add actions which
should help to prevent from passing invalid options to plugin.

Signed-off-by: Piotr Golyzniak <piotr.golyzniak@nordicsemi.no>
According to new adapters API add new tests which verify their
correctness. Introduce some minor naming changes to describe better
their role.

Signed-off-by: Piotr Golyzniak <piotr.golyzniak@nordicsemi.no>
Add tests which use pytester to call pytest with pytest-twister-harness
plugin on previously defined test. This gives a possibility to test
plugin in end-to-end variant.

Signed-off-by: Piotr Golyzniak <piotr.golyzniak@nordicsemi.no>
Add unit tests dedicated for Shell helper sample class.
Add shell_simulator_script.py script to simulate shell application
behavior.

Signed-off-by: Piotr Golyzniak <piotr.golyzniak@nordicsemi.no>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.