Skip to content

Commit

Permalink
Avoid printing file descriptor numbers as they vary across machines, …
Browse files Browse the repository at this point in the history
…even with Docker
  • Loading branch information
DQNEO committed Apr 25, 2024
1 parent f4cb499 commit c1b2000
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
9 changes: 5 additions & 4 deletions t/expected.txt
Original file line number Diff line number Diff line change
Expand Up @@ -263,17 +263,18 @@ myargs
-1234567890
-7
OK isLetter A
pass nil slice
vaargs1: pass nil slice
a bc def
777 nil vaargs ok
3
777 nil vaargs2 ok
testOpenRead
Open ok
280
In a hole in the ground there lived a hobbit. Not a nasty, dirty, wet hole, filled with the ends of worms and an oozy smell, nor yet a dry, bare, sandy hole with nothing in it to sit down on or to eat: it was a hobbit-hole, and that means comfort.

― J.R.R. Tolkien, The Hobbit

testOpenWrite
3
Open ok
8
infer string literal
8
Expand Down
9 changes: 5 additions & 4 deletions t/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1463,14 +1463,14 @@ func funcVaarg1(f string, a ...interface{}) {
func funcVaarg2(a int, b ...int) {
if b == nil {
write(strconv.Itoa(a))
writeln(" nil vaargs ok")
writeln(" nil vaargs2 ok")
} else {
writeln("ERROR")
}
}

func testVaargs() {
funcVaarg1("pass nil slice\n")
funcVaarg1("vaargs1: pass nil slice\n")
funcVaarg1("%s %s %s\n", "a", "bc", "def")
funcVaarg2(777)
}
Expand All @@ -1479,9 +1479,10 @@ const O_READONLY_ int = 0
const O_CREATE_WRITE int = 524866 // O_RDWR|O_CREAT|O_TRUNC|O_CLOEXEC

func testOpenRead() {
writeln("testOpenRead")
var fd int
fd, _ = syscall.Open("t/text.txt", O_READONLY_, 0)
writeln(fd) // should be 4
writeln("Open ok")
var buf []uint8 = make([]uint8, 300, 300)
var n int
n, _ = syscall.Read(fd, buf)
Expand All @@ -1500,12 +1501,12 @@ func testOpenWrite() {
//var fd int
var fd int
fd, _ = syscall.Open("/tmp/bbgwrite.txt", O_CREATE_WRITE, 438)
writeln("Open ok")
//println(os.O_RDWR|os.O_CREATE|os.O_TRUNC|syscall.O_CLOEXEC)
// println(0666)
// if err != nil {
// panic(err)
// }
writeln(fd) // should be 5
var buf []uint8 = []uint8{'a', 'b', 'c', 'd', 'e', 'f', 'g', '\n'}
var n int
n, _ = syscall.Write(fd, buf)
Expand Down

0 comments on commit c1b2000

Please sign in to comment.