Skip to content

Commit cb08aa0

Browse files
hunshcnclaude
andcommitted
test: use stdlib elf constants and add defer Close
Replace magic numbers with debug/elf constants (elf.DT_FLAGS, elf.DF_BIND_NOW, elf.DT_FLAGS_1, elf.DF_1_NOW) and add missing defer e.Close() to match project conventions. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 76742b4 commit cb08aa0

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

tests/core/go_binary/bind_now_test.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ func TestNoBindNow(t *testing.T) {
3333
if err != nil {
3434
t.Fatal(err)
3535
}
36+
defer e.Close()
3637

3738
ds := e.SectionByType(elf.SHT_DYNAMIC)
3839
if ds == nil {
@@ -60,12 +61,10 @@ func TestNoBindNow(t *testing.T) {
6061
val = uint64(e.ByteOrder.Uint32(d[i+4:]))
6162
}
6263

63-
// DT_FLAGS = 30, DF_BIND_NOW = 0x8
64-
if tag == 30 && val&0x8 != 0 {
64+
if elf.DynTag(tag) == elf.DT_FLAGS && elf.DynFlag(val)&elf.DF_BIND_NOW != 0 {
6565
t.Error("binary hello_auto_bin has DF_BIND_NOW set in DT_FLAGS")
6666
}
67-
// DT_FLAGS_1 = 0x6ffffffb, DF_1_NOW = 0x1
68-
if tag == 0x6ffffffb && val&0x1 != 0 {
67+
if elf.DynTag(tag) == elf.DT_FLAGS_1 && elf.DynFlag1(val)&elf.DF_1_NOW != 0 {
6968
t.Error("binary hello_auto_bin has DF_1_NOW set in DT_FLAGS_1")
7069
}
7170
}

0 commit comments

Comments
 (0)