Posts

Showing posts from April, 2021

Testing with multi-arch Docker images

Testing with multi-arch Docker images With the introduction of Docker Buildx CLI plugin it became quite easy to test various platforms using single Dockerfile without any QEMU static builds. In this tutorial we’re going to use a multistage build with the simple C++ program that tests features of various platforms. First, we need to register QEMU handlers. Please note that the handler registration won’t survive a reboot. $ docker run --rm --privileged docker/binfmt:a7996909642ee92942dcd6cff44b9b95f08dad64 There is no latest alias for the docker/binfmt and it’s recommended to grab the proper tag on their homepage: https://hub.docker.com/r/docker/binfmt/tags?page=1&ordering=last_updated The code to detect the platform endianness and its sizes for the basic types: #include <iostream> #ifndef PLATFORM #define PLATFORM "N/A" #endif void platform () { std :: cout << "Platform: " << PLATFORM << std

Testing C++ code on PowerPC with QEMU

PowerPC is not a commonly used platform, but it’s quite useful for testing proper handling of endianness (as the vast majority of the current modern platforms is little-endian, but original PPC is big-endian). Let me provide simple instructions how to test C++ code on the PowerPC platform. First, let’s install all the required dependencies (using Debian as an example): $ sudo apt-get install qemu-system-ppc g++-powerpc-linux-gnu sshfs Second, we need to get a proper image for QEMU. There are few QCOW2 ready-to-use images on https://people.debian.org/~aurel32/qemu/ . They are quite outdated, but easy to use, and still helpful for testing. For PPC we’re going to use standard (headless) Debian Wheezy image: $ curl -O https://people.debian.org/~aurel32/qemu/powerpc/debian_wheezy_powerpc_standard.qcow2 We’re going to use SSHFS for data sharing, therefore we’ll start the image with the port forwarding (binding port 60022 on the host with port 22 on the guest). Surely