Skip to content

Commit

Permalink
tests: enable debug output
Browse files Browse the repository at this point in the history
  • Loading branch information
rfjakob committed Apr 4, 2024
1 parent 0d77af3 commit 9bc52bf
Showing 1 changed file with 28 additions and 5 deletions.
33 changes: 28 additions & 5 deletions testsuite_c_wrappers.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ import (
// #include "proc_pid.h"
import "C"

func init() {
C.enable_debug = 1
}

func parse_term_kill_tuple(optarg string, upper_limit int) (error, float64, float64) {
cs := C.CString(optarg)
tuple := C.parse_term_kill_tuple(cs, C.longlong(upper_limit))
Expand All @@ -38,10 +42,26 @@ func parse_meminfo() C.meminfo_t {
return C.parse_meminfo()
}

// Wrapper so _test.go code can create a poll_loop_args_t
// struct. _test.go code cannot use C.
func poll_loop_args_t(sort_by_rss bool) (args C.poll_loop_args_t) {
args.sort_by_rss = C.bool(sort_by_rss)
return
}

func procinfo_t() C.procinfo_t {
return C.procinfo_t{}
}

func is_larger(args *C.poll_loop_args_t, victim mockProcProcess, cur mockProcProcess) bool {
cVictim := victim.toProcinfo_t()
cCur := cur.toProcinfo_t()
return bool(C.is_larger(args, &cVictim, &cCur))
}

func find_largest_process() {
var args C.poll_loop_args_t
var m C.meminfo_t
C.find_largest_process(&args, &m)
C.find_largest_process(&args)
}

func kill_process() {
Expand Down Expand Up @@ -78,9 +98,12 @@ func get_cmdline(pid int) (int, string) {
return int(res), C.GoString(cstr)
}

func procdir_path(str string) {
cstr := C.CString(str)
C.procdir_path = cstr
func procdir_path(str string) string {
if str != "" {
cstr := C.CString(str)
C.procdir_path = cstr
}
return C.GoString(C.procdir_path)
}

func parse_proc_pid_stat_buf(buf string) (res bool, out C.pid_stat_t) {
Expand Down

0 comments on commit 9bc52bf

Please sign in to comment.