From be7b57412ec63b4b69829da0d67a628f76e27321 Mon Sep 17 00:00:00 2001 From: Tobias Waldekranz Date: Thu, 15 Jun 2023 09:59:22 +0200 Subject: [PATCH] test/case: Add meta/play Launches an interactive ipython environment, attached to Infix nodes. This can be used as a playground for developing tests, testing out NETCONF operations, etc. --- board/x86_64/board.mk | 3 +++ test/case/meta/play.py | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100755 test/case/meta/play.py diff --git a/board/x86_64/board.mk b/board/x86_64/board.mk index 5e356fcd..553c127d 100644 --- a/board/x86_64/board.mk +++ b/board/x86_64/board.mk @@ -24,5 +24,8 @@ test-run: | ~/.infix-test-venv test-run-sh: $(call test-env-run,/bin/sh) +test-run-play: + $(call test-env-run,$(test-dir)/case/meta/play.py) + ~/.infix-test-venv: $(test-dir)/docker/init-venv.sh $(test-dir)/docker/pip-requirements.txt diff --git a/test/case/meta/play.py b/test/case/meta/play.py new file mode 100755 index 00000000..18fa7f19 --- /dev/null +++ b/test/case/meta/play.py @@ -0,0 +1,19 @@ +#!/usr/bin/env -S ipython3 -i + +import json + +import infamy + +def jq(yangdata): + print(json.dumps(yangdata, indent=True)) + +env = infamy.Env() + +ctrl = env.ptop.get_ctrl() +infixen = env.ptop.get_infixen() +for ix in infixen: + (_, cport), (_, ixport) = env.ptop.get_path(ctrl, ix) + print(f"Attaching to {ix}:{ixport} via {ctrl}:{cport}") + exec(f"{ix} = env.attach(\"{ix}\", \"{ixport}\")") + +print("\nGLHF")