Skip to content

Commit

Permalink
feat: Restructured Bash scripts and added BATS unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
2b-t committed Jul 20, 2022
1 parent b3f1729 commit 5f11553
Show file tree
Hide file tree
Showing 18 changed files with 730 additions and 312 deletions.
9 changes: 9 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[submodule "test/bats"]
path = test/bats
url = https://github.com/bats-core/bats-core.git
[submodule "test/test_helper/bats-support"]
path = test/test_helper/bats-support
url = https://github.com/bats-core/bats-support.git
[submodule "test/test_helper/bats-assert"]
path = test/test_helper/bats-assert
url = https://github.com/bats-core/bats-assert.git
19 changes: 11 additions & 8 deletions ReadMe.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# Docker real-time guide for `PREEMPT_RT`

Author: [Tobit Flatscher](https://github.com/2b-t) (August 2021 - April 2022)
Author: [Tobit Flatscher](https://github.com/2b-t) (August 2021 - July 2022)



Expand Down Expand Up @@ -35,36 +35,39 @@ The manual set-up of `PREEMPT_RT` takes quite a while (see [`doc/realtime_basics

### 1.1 Installing `PREEMPT_RT`

The installation procedure either by compilation from source or from an existing [Debian package](https://packages.debian.org/buster/linux-image-rt-amd64) is lined out in [`doc/realtime_basics/PreemptRt.md`](./doc/realtime_basics/PreemptRt.md). The same procedure can also be performed with the provided scripts [`install_debian_preemptrt.sh`](./install_debian_preemptrt) and [`compile_kernel_preemptrt.sh`](./compile_kernel_preemptrt.sh).
The installation procedure either by compilation from source or from an existing [Debian package](https://packages.debian.org/buster/linux-image-rt-amd64) is lined out in [`doc/realtime_basics/PreemptRt.md`](./doc/realtime_basics/PreemptRt.md). The same procedure can also be performed with the provided scripts [`src/install_debian_preemptrt`](./src/install_debian_preemptrt) and [`src/compile_kernel_preemptrt`](./src/compile_kernel_preemptrt).

[`install_debian_preemptrt.sh`](./install_debian_preemptrt) checks online if there are already precompiled `PREEMPT_RT` packages available and lets you select a suiting version graphically, while [`compile_kernel_preemptrt.sh`](./compile_kernel_preemptrt.sh) compiles the kernel from scratch from you and installs it. Before using the scripts be sure to make them executable on your system with `$ sudo chmod +x install_debian_preemptrt.sh`.
[`src/install_debian_preemptrt`](./src/install_debian_preemptrt) checks online if there are already precompiled `PREEMPT_RT` packages available and lets you select a suiting version graphically, while [`src/compile_kernel_preemptrt`](./src/compile_kernel_preemptrt) compiles the kernel from scratch from you and installs it. Before using the scripts be sure to make them executable on your system with `$ sudo chmod +x install_debian_preemptrt`.

#### 1.1.1 Installation from pre-compiled Debian package (recommended)

Start of by launching [`install_debian_preemptrt.sh`](./install_debian_preemptrt) and follow the installation instructions
Start of by launching [`src/install_debian_preemptrt`](./src/install_debian_preemptrt) and follow the installation instructions

```shell
$ ./install_debian_preemptrt.sh
$ cd src
$ ./install_debian_preemptrt
```

Afterwards you can reboot your system (be sure to select the correct kernel!) and should already be ready to go. You can check the kernel version with `$ uname -r` to verify that you are using the correct kernel and the installation was indeed successful.

#### 1.1.2 Compilation of the kernel

If the installation above fails or for some good reason you have to compile the kernel yourself you can use the [`compile_kernel_preemptrt.sh`](./compile_kernel_preemptrt.sh) script.
If the installation above fails or for some good reason you have to compile the kernel yourself you can use the [`src/compile_kernel_preemptrt`](./src/compile_kernel_preemptrt) script.

You can launch it in two different ways:

```shell
$ ./compile_kernel_preemptrt.sh
$ cd src
$ ./compile_kernel_preemptrt
```

will install the required dependencies and then open a dialog which lets you browse the possible versions and available options manually, reducing the copy and paste operations.

If you supply a correct real-time patch version from the list of available ones as an input argument, launching the command with superuser privileges it will download all files, patch the kernel, create a Debian package if no official one is available and install it automatically.

```shell
$ sudo ./compile_kernel_preemptrt.sh 5.10.78-rt55
$ cd src
$ sudo ./compile_kernel_preemptrt 5.10.78-rt55
```

This might be helpful for deploying a new kernel automatically on a remote system. The possible version numbers can be found at [here](https://mirrors.edge.kernel.org/pub/linux/kernel/projects/rt/).
Expand Down
254 changes: 0 additions & 254 deletions compile_kernel_preemptrt.sh

This file was deleted.

6 changes: 3 additions & 3 deletions doc/realtime_basics/PreemptRt.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ The `PREEMPT_RT` kernels are known for causing a headache with the **official Nv

The installation of `PREEMPT_RT` can be performed either by installing the patch from an existing **Debian package** or by re-compiling the kernel yourself. While the first option should be preferred for having a more detailed control over the kernel set-up latter might still be desired or might be your only options in rare cases of lacking compatibility.

In the main folder of this I have provided two **scripts `install_debian_preemptrt.sh` and `compile_kernel_preemptrt.sh`** which is able to install either from an existing Debian package or by recompiling the kernel automatically. This means it should not be necessary to perform this steps manually. Nonetheless I will leave this here as a reference!
In the main folder of this I have provided two **scripts `src/install_debian_preemptrt` and `src/compile_kernel_preemptrt`** which is able to install either from an existing Debian package or by recompiling the kernel automatically. This means it should not be necessary to perform this steps manually. Nonetheless I will leave this here as a reference!

#### 1.2.1 Installation from Debian package (recommended)

The installation from a Debian package is way **simpler** than the recompilation listed below but is at the same time **less flexible** as it is only available for a limited number of kernels and kernel configurations. You might not be able to make the Debian package work with your particular system and might have to re-compile the kernel anyways. Nonetheless it is **highly advised** that you follow these simple steps before turning to a full re-compilation of the kernel. The script that already performs the steps for you is `install_debian_preemptrt.sh`.
The installation from a Debian package is way **simpler** than the recompilation listed below but is at the same time **less flexible** as it is only available for a limited number of kernels and kernel configurations. You might not be able to make the Debian package work with your particular system and might have to re-compile the kernel anyways. Nonetheless it is **highly advised** that you follow these simple steps before turning to a full re-compilation of the kernel. The script that already performs the steps for you is `src/install_debian_preemptrt`.

Have a look at the search results resulting from [this query on package.debian.org](https://packages.debian.org/search?keywords=linux-image-rt-amd64) (potentially changing the architecture!) and see if you can find a kernel close to yours, e.g. [this one](https://packages.debian.org/bullseye/linux-image-rt-amd64). If you can find one click on the architecture `amd64` under `Download linux-image-rt-amd64` on the bottom and select a geographically suiting mirror and save the image in a location of your choice.

Expand All @@ -33,7 +33,7 @@ Jump to section 2.1.3 and then try to reboot. In case it does not work you will

#### 1.2.2 Re-compilation of the kernel

The re-compilation of the kernel is described in the [official Ubuntu installation guide](https://help.ubuntu.com/lts/installation-guide/amd64/install.en.pdf#page=98) as well as on the [Franka Emika installation guide](https://frankaemika.github.io/docs/installation_linux.html#setting-up-the-real-time-kernel) page but [might depend on the precise version](https://stackoverflow.com/a/51709420). In case you are running into issues you might have to consider [this](https://askubuntu.com/a/1338150) and [this](https://askubuntu.com/a/1329625) post. As already mentioned the script `compile_kernel_preemptrt.sh` does the steps that are listed in this section. Therefore it should not be necessary for you to do the following steps manually!
The re-compilation of the kernel is described in the [official Ubuntu installation guide](https://help.ubuntu.com/lts/installation-guide/amd64/install.en.pdf#page=98) as well as on the [Franka Emika installation guide](https://frankaemika.github.io/docs/installation_linux.html#setting-up-the-real-time-kernel) page but [might depend on the precise version](https://stackoverflow.com/a/51709420). In case you are running into issues you might have to consider [this](https://askubuntu.com/a/1338150) and [this](https://askubuntu.com/a/1329625) post. As already mentioned the script `src/compile_kernel_preemptrt` does the steps that are listed in this section. Therefore it should not be necessary for you to do the following steps manually!

Start by installing the Debian packages required for the re-compilation. For a Debian-based Linux distribution this can be done conveniently with:

Expand Down
5 changes: 5 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ RUN apt-get update && apt-get install -y \
python3 \
python3-distutils \
gnuplot-qt
# For unit-testing bash
RUN apt-get update && apt-get install -y \
bats \
dialog \
xdotool

# Fetch most recent version of rt-tests and mklatencyplot
RUN cd ${WS_DIR} \
Expand Down
4 changes: 3 additions & 1 deletion docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@ services:
tty: true
privileged: true
network_mode: host

volumes:
- ../src:/benchmark/src
- ../test:/benchmark/test
Loading

0 comments on commit 5f11553

Please sign in to comment.