Skip to content

Commit

Permalink
Add tests for stm GO library
Browse files Browse the repository at this point in the history
Steps to reproduce:
    # Compile tests.
    GOARCH=arm GOARM=7 GOOS=linux ginkgo build ./...
    # Copy stm/stm.test to MuxPI.
    # Run on MuxPI.
    ./stm.test -ginkgo.v

Tests fail if there is no "OK" response. Person running them should also
observe OLED display, blinking LEDs and relay switching (it is audible).

Change-Id: I86992a1356382645d156053c15d14d9a57603b71
  • Loading branch information
amistewicz committed Oct 3, 2017
1 parent 0094f78 commit 0a88530
Show file tree
Hide file tree
Showing 2 changed files with 111 additions and 0 deletions.
29 changes: 29 additions & 0 deletions stm/stm_suite_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License
*/

package stm_test

import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"

"testing"
)

func TestStm(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "Stm Suite")
}
82 changes: 82 additions & 0 deletions stm/stm_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
/*
* Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License
*/

package stm_test

import (
"time"

. "git.tizen.org/tools/muxpi/stm"

. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)

var _ = Describe("Stm", func() {
BeforeEach(func() {
err := Open()
Expect(err).ToNot(HaveOccurred())
})

AfterEach(func() {
err := Close()
Expect(err).ToNot(HaveOccurred())
})

It("should switch to DUT", func() {
err := DUT()
Expect(err).ToNot(HaveOccurred())
})

It("should do power tick", func() {
err := PowerTick(time.Second)
Expect(err).ToNot(HaveOccurred())
})

It("should switch to TS", func() {
err := TS()
Expect(err).ToNot(HaveOccurred())
})

It("should clear the display", func() {
err := ClearDisplay()
Expect(err).ToNot(HaveOccurred())
})

It("should print text on the display", func() {
err := PrintText(0, 0, Foreground, "test text")
Expect(err).ToNot(HaveOccurred())
time.Sleep(2 * time.Second)
err = PrintText(0, 0, Background, "test text")
Expect(err).ToNot(HaveOccurred())
})

It("should blink the left LED", func() {
err := SetLED(LED1, 255, 255, 255)
Expect(err).ToNot(HaveOccurred())
time.Sleep(2 * time.Second)
err = SetLED(LED1, 0, 0, 0)
Expect(err).ToNot(HaveOccurred())
})

It("should blink the right LED", func() {
err := SetLED(LED2, 255, 255, 255)
Expect(err).ToNot(HaveOccurred())
time.Sleep(2 * time.Second)
err = SetLED(LED2, 0, 0, 0)
Expect(err).ToNot(HaveOccurred())
})
})

0 comments on commit 0a88530

Please sign in to comment.