From d70c689dd93ab1eb27cd0bbe386cb51014c21f73 Mon Sep 17 00:00:00 2001
From: Michal Rostecki <vadorovsky@protonmail.com>
Date: Wed, 3 May 2023 12:36:43 +0100
Subject: [PATCH] CI: Test execution of projects

---
 .github/workflows/ci.yml |  2 ++
 test.sh                  | 11 +++++++++--
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 3e17667..539eded 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -63,4 +63,6 @@ jobs:
         with:
           tool: bpf-linker,cargo-generate
 
+      - run: sudo apt update
+      - run: sudo apt install expect
       - run: ./test.sh ${{ github.workspace }} ${{ matrix.program }}
diff --git a/test.sh b/test.sh
index 43984bd..9d67357 100755
--- a/test.sh
+++ b/test.sh
@@ -1,6 +1,6 @@
 #!/bin/bash
 
-set -ex
+set -eux
 
 TEMPLATE_DIR=$1
 if [ -z "${TEMPLATE_DIR}" ]; then echo "template dir required"; exit 1; fi
@@ -60,5 +60,12 @@ cargo build --package test --release
 # trying to compile the panic handler twice: once from the bpf program, and again from std via aya.
 cargo clippy --exclude test-ebpf --all-targets --workspace -- --deny warnings
 cargo clippy --package test-ebpf --all-targets -- --deny warnings
+
+expect << EOF
+  log_user 1
+  set pid [spawn cargo xtask run]
+  expect "Waiting for Ctrl-C..."
+  exec kill -SIGINT \$pid
+EOF
+
 popd
-exit 0