diff options
| author | xengineering <me@xengineering.eu> | 2025-08-02 13:55:15 +0200 |
|---|---|---|
| committer | xengineering <me@xengineering.eu> | 2025-08-02 13:55:15 +0200 |
| commit | 80e4ef190e3f86e9d51ae16739baa95b4e8d71dc (patch) | |
| tree | ffc6ac3c605a1e673adb427e37f91092c21db6cc | |
| parent | 015671d278463d656e1ccea5a604226bd4fd483d (diff) | |
| download | iot-contact-go-80e4ef190e3f86e9d51ae16739baa95b4e8d71dc.tar iot-contact-go-80e4ef190e3f86e9d51ae16739baa95b4e8d71dc.tar.zst iot-contact-go-80e4ef190e3f86e9d51ae16739baa95b4e8d71dc.zip | |
integration: Add simple execution test
This test starts the native sim firmware of iot-contact and runs it for
5 seconds.
| -rw-r--r-- | integration/execution_test.go | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/integration/execution_test.go b/integration/execution_test.go new file mode 100644 index 0000000..87a7ee6 --- /dev/null +++ b/integration/execution_test.go @@ -0,0 +1,35 @@ +package integration + +import ( + "os" + "os/exec" + "testing" + "time" +) + +const ( + ENV_NATIVE_SIM_FIRMWARE = `IOT_CONTACT_NATIVE_SIM_FIRMWARE` + SIMPLE_EXECUTION_TIME_S = 5 +) + +func TestExecuteFirmware(t *testing.T) { + firmware := os.Getenv(ENV_NATIVE_SIM_FIRMWARE) + + if firmware == "" { + t.Skip("Environment variable '" + ENV_NATIVE_SIM_FIRMWARE + "' not set") + } + + cmd := exec.Command(firmware) + + err := cmd.Start() + if err != nil { + t.Fatalf("Could not start native sim firmware: %v", err) + } + + time.Sleep(SIMPLE_EXECUTION_TIME_S * time.Second) + + err = cmd.Process.Kill() + if err != nil { + t.Fatalf("Could not stop native sim firmware: %v", err) + } +} |
