Skip to main content

Pyroxene is a Python test interface: Execute tests on remote device using minmal shim and ELF debug data

Project description

lint test

Pyroxene

Introduction

Testing libraries on embedded devices requires always "some code around" to establish a communication between host and embedded device. This ist often called "MiniOS" or "TestOS". Usually every team of develops such a small operating system independently.

In the end you have a bunch of embedded applications with only one purpose: Functional verification of a library.

What would happens if we could unify all these approaches? Thinking about what is needed for such a unified test application we realize that we need only 3 "commands" the embedded device must support:

  1. Read data from memory locations.
  2. Write data to memory locations.
  3. Call functions with parameters and return the result.

Everything else can be done on a host system!

Overview and example

flowchart LR
    subgraph Device
        direction TB
        pyroxene --> A(Embedded\nlibrary)
    end
    subgraph Host
        direction TB
        Testcode --> device_proxy
        elfbackend --> device_proxy
        device_proxy --> device_commands
        B(Elffile) --> C(pyelftoos)
        C <--> elfbackend
    end
    device_commands <--> pyroxene

Example

Let's consider the following example: A C library (for embedded devices) implements the following function:

unsigned int addition(unsigned int arg1, unsigned int arg2)
{
    return arg1 + arg2;
}

A tester familiar with Python unittest wants to write the following test code:

class TestLibrary(unittest.TestCase):
    def test_addition(self)
        response = lib.addition(39, 3)
        self.assertEqual(response, 42)

Pyroxene makes this possible!

  • lib is a pyroxene.device_proxy.LibProxy object.
  • LibProxy "knows" everything about the library by examining the elf-binary. So it is able to resolve the address of the exported function addition. (lib.addition is an object of type pyroxene.device_proxy.FuncProxy)
  • Calling that function instructs the FuncProxy to convert all arguments to a list of integers (see #Scope).
  • These list is marshaled in device_commands and sent to the (embedded) target device.
  • The answer get's un-marshaled and returned to the caller.

Scope

  • Pyroxene focuses on libraries written in C.
  • Pyroxene needs debug information in the compiled elf-file.
  • Pyroxene supports reading macros currently only using fromelf.
  • Pyroxene makes assumptions about the calling convention of the target architecture: All arguments which are passed to functions must be compatible to unsigned long. E.g. A uint8_t-value must be passed same as it would be a uint32_t. For ARM Thumb-2 and x86_64 this holds true. In a nutshell: Everything is ulong!

Pyroxene Commands

There are three device commands:

  • memory_read:
    0x01 [uint16] | cmdlen [uint16] | addr [ulong] | length [ulong]
    Returns: response [length]
  • memory_write:
    0x02 [uint16] | cmdlen [uint16] | addr [ulong] | data [datalength]
    Returns: Nothing.
  • call:
    0x03 [uint16] | cmdlen [uint16] | addr [ulong] | retlength [ulong] | number_of_args [ulong] | arg1 [ulong] | ... | argn[ulong]
    Returns: response [retlength].

Limitations (as of now)

  • Pyroxene does not support floating point data types.
  • Pyroxene does not support target architectures where the size of the address space does not equal the size of unsigned long.
  • Pyroxene does not implement error handling on protocol level.

Project details


Release history Release notifications | RSS feed

This version

1.0

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyroxene-1.0.tar.gz (25.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyroxene-1.0-py3-none-any.whl (28.6 kB view details)

Uploaded Python 3

File details

Details for the file pyroxene-1.0.tar.gz.

File metadata

  • Download URL: pyroxene-1.0.tar.gz
  • Upload date:
  • Size: 25.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.7

File hashes

Hashes for pyroxene-1.0.tar.gz
Algorithm Hash digest
SHA256 c3089d37b005c65c5a56ac7e27003759639210ed0551360a3d9be0edf1f4f0c8
MD5 a9976ed9ce78b21e9da94124617b8f47
BLAKE2b-256 9de82fc21c9ffb27c67d9bb224952d14ab45c6db3ae5d16cadf69e4177d68b84

See more details on using hashes here.

File details

Details for the file pyroxene-1.0-py3-none-any.whl.

File metadata

  • Download URL: pyroxene-1.0-py3-none-any.whl
  • Upload date:
  • Size: 28.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.7

File hashes

Hashes for pyroxene-1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 770fd5a41ab6b438f2111d95e36f46bd2e60ec3922b945d5d522dc478f4f8167
MD5 8ab27d4eafaeddd00665b45fa43670ea
BLAKE2b-256 1069407a069a77223446de881972f0a846a86f3ab70bb9c48ab233503b84beca

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page