From e5c708bc443089924b2e8c0f1c9dffa083e71117 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Toke=20H=C3=B8iland-J=C3=B8rgensen?= Date: Mon, 18 Mar 2019 12:31:57 +0100 Subject: [PATCH] testenv: Update README and link it from top-level MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Toke Høiland-Jørgensen --- README.org | 4 ++++ testenv/README.org | 34 +++++++++++++++++++++++++--------- 2 files changed, 29 insertions(+), 9 deletions(-) diff --git a/README.org b/README.org index aad29072..a0ca532a 100644 --- a/README.org +++ b/README.org @@ -52,6 +52,10 @@ Before you can start completing step in this tutorial, you will need to install a few dependencies on your system. These are are described in [[file:setup_dependencies.org]]. +We also provide a helper script that will set up a test environment with +virtual interfaces for you to test your code on. This is introduced in the +basic lessons, and also has [[file:testenv/README.org][it's own README file]]. + * How the lessons are organised The tutorial is organised into a number of lessons; each lesson has its own subdirectory, and the lessons are grouped by category: diff --git a/testenv/README.org b/testenv/README.org index 8fc4499a..daf01aa3 100644 --- a/testenv/README.org +++ b/testenv/README.org @@ -2,23 +2,39 @@ #+TITLE: Test environment script #+OPTIONS: ^:nil -This directory contains a test environment setup script that you can use to -create test environments for testing your XDP programs. It works by creating -virtual ethernet (veth) interface pairs and moving one end of each pair to -another namespace. You can load the XDP program in the other namespace and +This directory contains a setup script that you can use to create test +environments for testing your XDP programs. It works by creating virtual +ethernet (veth) interface pairs and moving one end of each pair to another +network namespace. You can load the XDP program in the other namespace and send traffic to it through the interface that is visible in the root namespace. +Run =./testenv.sh= with no parameter to get a list of available commands, or +run =./testenv.sh --help= to get the full help listing with all options. The +script can maintain several environments active at the same time, and you +can switch between them using the =--name= option. + +If you don't specify a name, the most recently used environment will be +used. If you don't specify a name when setting up a new environment, a +random name will be generated for you. + Examples: Setup new environment named "test": -=./testenv.sh create test= +=./testenv.sh setup --name=test= + +Create a shell alias for easy use of script from anywhere: +=eval $(./testenv.sh alias)= + +See the currently active environment, and a list of all active environment +names (with alias defined as above): +=t status= -Enter the environment: -=./testenv.sh enter test= +Enter the currently active environment: +=t enter= Execute a command inside the environment: -=./testenv ns_exec test ip a= +=t exec -- ip a= Teardown the environment: -=./testenv teardown test= +=t teardown=