netlink_test.go 481 B

1234567891011121314151617181920212223
  1. // +build linux
  2. package linux
  3. import (
  4. "bytes"
  5. "encoding/binary"
  6. "testing"
  7. "notabug.org/themusicgod1/gosigar/sys"
  8. "github.com/stretchr/testify/assert"
  9. )
  10. func TestParseNetlinkErrorDataTooShort(t *testing.T) {
  11. assert.Error(t, ParseNetlinkError(nil), "too short")
  12. }
  13. func TestParseNetlinkErrorErrno(t *testing.T) {
  14. buf := new(bytes.Buffer)
  15. binary.Write(buf, sys.GetEndian(), -1*int32(NLE_MSG_TOOSHORT))
  16. assert.Equal(t, ParseNetlinkError(buf.Bytes()), NLE_MSG_TOOSHORT)
  17. }