// This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at https://mozilla.org/MPL/2.0/. package integration import ( "os" "os/exec" "testing" "time" ) const ( ENV_NATIVE_SIM_FIRMWARE = `IOT_CONTACT_NATIVE_SIM_FIRMWARE` SIMPLE_EXECUTION_TIME_S = 5 ) func TestExecuteDUT(t *testing.T) { firmware := os.Getenv(ENV_NATIVE_SIM_FIRMWARE) if firmware == "" { t.Skip("Environment variable '" + ENV_NATIVE_SIM_FIRMWARE + "' not set") } dir, err := os.MkdirTemp("", "iot-contact-go-*") if err != nil { t.Skip("Could not create temporary directory") } defer os.RemoveAll(dir) cmd := exec.Command(firmware) cmd.Dir = dir 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) } }