...

Source file src/edge-infra.dev/pkg/lib/kernel/devices/devices_suite_test.go

Documentation: edge-infra.dev/pkg/lib/kernel/devices

     1  //nolint:typecheck
     2  package devices
     3  
     4  import (
     5  	"testing"
     6  
     7  	. "github.com/onsi/ginkgo/v2" //nolint:revive
     8  	. "github.com/onsi/gomega"    //nolint:revive
     9  )
    10  
    11  // Mock dev path and subsystem logic without symlink support
    12  // 1. change the root dev path to testing path.
    13  // 2. change the subsystem function to return current base path since symlinks do not work.
    14  // 3. change the isRegular function since the embedded files are symlinks.
    15  var _ = BeforeSuite(func() {
    16  	SetTestEnvs()
    17  	var err error
    18  	testDevice, err = New(testDevicePath)
    19  	Expect(err).To(BeNil())
    20  })
    21  
    22  // Ensure file system mocks are reset
    23  var _ = BeforeEach(func() {
    24  	SetTestEnvs()
    25  })
    26  
    27  func TestDeviceRead(t *testing.T) {
    28  	RegisterFailHandler(Fail)
    29  	RunSpecs(t, "Device Tests")
    30  }
    31  
    32  var _ = Describe("Read device from sys fs", func() {
    33  	It("Read basic usb device", func() {
    34  		device, err := New(testDevicePath)
    35  		Expect(err).To(BeNil())
    36  
    37  		Expect(device).NotTo(BeNil())
    38  		Expect(device.Path()).To(Equal(testDevicePath))
    39  
    40  		subsystem, found, err := device.Property("SUBSYSTEM")
    41  		Expect(err).To(BeNil())
    42  		Expect(found).To(BeTrue())
    43  		Expect(subsystem).To(Equal("usb"))
    44  
    45  	})
    46  })
    47  

View as plain text