blob: 82fa2b9b11742f35a21d6b0bcec29a2645d05c56 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
// 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)
}
}
|