Skip to content

Commit

Permalink
Use cluster ID in all tests for checking the on-off handling
Browse files Browse the repository at this point in the history
  • Loading branch information
farshidtz committed Jul 4, 2024
1 parent 3f97288 commit 8c4d5a8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
8 changes: 8 additions & 0 deletions tests/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"os"
"strings"
"testing"
"time"

"github.com/canonical/matter-snap-testing/utils"
"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -42,3 +43,10 @@ func writeLogFile(t *testing.T, label string, b []byte) {
os.WriteFile(strings.ReplaceAll(t.Name(), "/", "-")+"-"+label+".log", b, 0644),
)
}

func waitForOnOffHandingByAllClustersApp(t *testing.T, start time.Time) {
// 0x6 is the Matter Cluster ID for on-off
// Using cluster ID here because of a buffering issue in the log stream:
// https://github.com/canonical/chip-tool-snap/pull/69#issuecomment-2207189962
utils.WaitForLogMessage(t, allClustersSnap, "ClusterId = 0x6", start)
}
6 changes: 2 additions & 4 deletions tests/upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ func TestUpgrade(t *testing.T) {
stdout, _, _ := utils.Exec(t, "sudo chip-tool onoff on 110 1 2>&1")
writeLogFile(t, "chip-tool-onoff", []byte(stdout))

utils.WaitForLogMessage(t,
allClustersSnap, "Toggle ep1 on/off from state 0 to 1", start)
waitForOnOffHandingByAllClustersApp(t, start)
})

t.Run("Upgrade snap", func(t *testing.T) {
Expand All @@ -78,8 +77,7 @@ func TestUpgrade(t *testing.T) {
stdout, _, _ := utils.Exec(t, "sudo chip-tool onoff off 110 1 2>&1")
writeLogFile(t, "chip-tool-onoff", []byte(stdout))

utils.WaitForLogMessage(t,
allClustersSnap, "Toggle ep1 on/off from state 1 to 0", start)
waitForOnOffHandingByAllClustersApp(t, start)
})

}
5 changes: 1 addition & 4 deletions tests/wifi_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,7 @@ func TestAllClustersAppWiFi(t *testing.T) {
stdout, _, _ := utils.Exec(t, "sudo chip-tool onoff toggle 110 1 2>&1")
writeLogFile(t, "chip-tool-toggle", []byte(stdout))

// 0x6 is the cluster ID for on-off
// Using cluster ID here because of a buffering issue in the log stream:
// https://github.com/canonical/chip-tool-snap/pull/69#issuecomment-2207189962
utils.WaitForLogMessage(t, allClustersSnap, "ClusterId = 0x6", start)
waitForOnOffHandingByAllClustersApp(t, start)
})

}

0 comments on commit 8c4d5a8

Please sign in to comment.