(t *testing.T)
| 95 | } |
| 96 | |
| 97 | func TestZilParsing(t *testing.T) { |
| 98 | zilFile, err := os.Open("fixtures/proc/spl/kstat/zfs/zil") |
| 99 | if err != nil { |
| 100 | t.Fatal(err) |
| 101 | } |
| 102 | defer zilFile.Close() |
| 103 | |
| 104 | c := zfsCollector{} |
| 105 | if err != nil { |
| 106 | t.Fatal(err) |
| 107 | } |
| 108 | |
| 109 | handlerCalled := false |
| 110 | err = c.parseProcfsFile(zilFile, "zil", func(s zfsSysctl, v any) { |
| 111 | |
| 112 | if s != zfsSysctl("kstat.zfs.misc.zil.zil_commit_count") { |
| 113 | return |
| 114 | } |
| 115 | |
| 116 | handlerCalled = true |
| 117 | |
| 118 | if v.(uint64) != 10 { |
| 119 | t.Fatalf("Incorrect value parsed from procfs data") |
| 120 | } |
| 121 | |
| 122 | }) |
| 123 | |
| 124 | if err != nil { |
| 125 | t.Fatal(err) |
| 126 | } |
| 127 | |
| 128 | if !handlerCalled { |
| 129 | t.Fatal("Zil parsing handler was not called for some expected sysctls") |
| 130 | } |
| 131 | } |
| 132 | |
| 133 | func TestVdevCacheStatsParsing(t *testing.T) { |
| 134 | vdevCacheStatsFile, err := os.Open("fixtures/proc/spl/kstat/zfs/vdev_cache_stats") |
nothing calls this directly
no test coverage detected