From e42c52cb35e2e35002050f4b551b37b140bbeab2 Mon Sep 17 00:00:00 2001 From: Lars Meyer Date: Fri, 4 Jun 2021 10:36:22 +0200 Subject: [PATCH] [process][linux] add test for missing iotime in SmartOS lx containers --- process/process_linux_test.go | 24 ++++++++++++++++++++++++ process/testdata/lx_brandz/1/stat | 1 + 2 files changed, 25 insertions(+) create mode 100644 process/testdata/lx_brandz/1/stat diff --git a/process/process_linux_test.go b/process/process_linux_test.go index e0ff628c..9a3dfaad 100644 --- a/process/process_linux_test.go +++ b/process/process_linux_test.go @@ -115,3 +115,27 @@ func Test_fillFromStatusWithContext(t *testing.T) { } } } + +func Test_fillFromTIDStatWithContext_lx_brandz(t *testing.T) { + pids, err := ioutil.ReadDir("testdata/lx_brandz/") + if err != nil { + t.Error(err) + } + f := common.MockEnv("HOST_PROC", "testdata/lx_brandz") + defer f() + for _, pid := range pids { + pid, err := strconv.ParseInt(pid.Name(), 0, 32) + if err != nil { + continue + } + if _, err := os.Stat(fmt.Sprintf("testdata/lx_brandz/%d/stat", pid)); err != nil { + continue + } + p, _ := NewProcess(int32(pid)) + _, _, cpuTimes, _, _, _, _, err := p.fillFromTIDStatWithContext(context.Background(), -1) + if err != nil { + t.Error(err) + } + assert.Equal(t, float64(0), cpuTimes.Iowait) + } +} diff --git a/process/testdata/lx_brandz/1/stat b/process/testdata/lx_brandz/1/stat new file mode 100644 index 00000000..82f60621 --- /dev/null +++ b/process/testdata/lx_brandz/1/stat @@ -0,0 +1 @@ +1 (systemd) S 0 0 0 0 -1 0 0 0 0 0 8 15 48 52 1 0 0 0 25 31883264 1413 18446744073709551615 0 0 140737487261696 0 0 0 0 0 0 18446741901776689794 0 0 17 0