diff options
Diffstat (limited to 'internal')
| -rw-r--r-- | internal/file/file.go | 18 | ||||
| -rw-r--r-- | internal/file/file_test.go | 17 |
2 files changed, 21 insertions, 14 deletions
diff --git a/internal/file/file.go b/internal/file/file.go index 85894c9..ff8dae2 100644 --- a/internal/file/file.go +++ b/internal/file/file.go @@ -24,15 +24,15 @@ type FdFile struct { } func NewFd(fd int32, name string, flags int32) FdFile { - f := FdFile{ - fd: fd, - name: name, - flags: Flags(flags), - } - if f.flags == -1 { - panic(fmt.Sprintf("DEBUG with -1 flags: %v", f)) - } - return f + f := FdFile{ + fd: fd, + name: name, + flags: Flags(flags), + } + if f.flags == -1 { + f.flags = unknownFlag + } + return f } func NewFdWithPid(fd int32, pid uint32) (f FdFile) { diff --git a/internal/file/file_test.go b/internal/file/file_test.go index 22610ea..726de5a 100644 --- a/internal/file/file_test.go +++ b/internal/file/file_test.go @@ -6,10 +6,17 @@ import ( ) func TestStringValue(t *testing.T) { - var array [128]byte - copy(array[:], "test string") + var array [128]byte + copy(array[:], "test string") - if str := types.StringValue(array[:]); str != "test string" { - t.Errorf("epxected 'test string' but got '%s' with bytes '%v'", str, []byte(str)) - } + if str := types.StringValue(array[:]); str != "test string" { + t.Errorf("epxected 'test string' but got '%s' with bytes '%v'", str, []byte(str)) + } +} + +func TestNewFdUnknownFlags(t *testing.T) { + fdFile := NewFd(1, "test.txt", -1) + if fdFile.Flags() != unknownFlag { + t.Errorf("expected unknown flags, got %v", fdFile.Flags()) + } } |
