diff options
author | stuart nelson <stuartnelson3@gmail.com> | 2016-09-27 22:44:13 +0200 |
---|---|---|
committer | Brian Brazil <brian-brazil@users.noreply.github.com> | 2016-09-27 21:44:13 +0100 |
commit | ef1925db7d97e13141ce4fbb41e5caf7fe3895c6 (patch) | |
tree | e87165c5f01a567c5a55de1ec98f46ccab356bca /collector/netdev_bsd_test.go | |
parent | f5a15ee404feceb954f34a3bc0fad3b596c7ad39 (diff) | |
download | prometheus_node_collector-ef1925db7d97e13141ce4fbb41e5caf7fe3895c6.tar.bz2 prometheus_node_collector-ef1925db7d97e13141ce4fbb41e5caf7fe3895c6.tar.xz prometheus_node_collector-ef1925db7d97e13141ce4fbb41e5caf7fe3895c6.zip |
Compile netdev on dragonfly (#314)
* Compile netdev on dragonfly
* Only run netdev bsd test on bsd
* Update README.md
Diffstat (limited to 'collector/netdev_bsd_test.go')
-rw-r--r-- | collector/netdev_bsd_test.go | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/collector/netdev_bsd_test.go b/collector/netdev_bsd_test.go new file mode 100644 index 0000000..a661c1c --- /dev/null +++ b/collector/netdev_bsd_test.go | |||
@@ -0,0 +1,53 @@ | |||
1 | // Copyright 2016 The Prometheus Authors | ||
2 | // Licensed under the Apache License, Version 2.0 (the "License"); | ||
3 | // you may not use this file except in compliance with the License. | ||
4 | // You may obtain a copy of the License at | ||
5 | // | ||
6 | // http://www.apache.org/licenses/LICENSE-2.0 | ||
7 | // | ||
8 | // Unless required by applicable law or agreed to in writing, software | ||
9 | // distributed under the License is distributed on an "AS IS" BASIS, | ||
10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
11 | // See the License for the specific language governing permissions and | ||
12 | // limitations under the License. | ||
13 | |||
14 | // +build !nonetdev | ||
15 | // +build freebsd dragonfly | ||
16 | |||
17 | package collector | ||
18 | |||
19 | import "testing" | ||
20 | |||
21 | type uintToStringTest struct { | ||
22 | in uint64 | ||
23 | out string | ||
24 | } | ||
25 | |||
26 | var uinttostringtests = []uintToStringTest{ | ||
27 | // Copied base10 values from strconv's tests: | ||
28 | {0, "0"}, | ||
29 | {1, "1"}, | ||
30 | {12345678, "12345678"}, | ||
31 | {1<<31 - 1, "2147483647"}, | ||
32 | {1 << 31, "2147483648"}, | ||
33 | {1<<31 + 1, "2147483649"}, | ||
34 | {1<<32 - 1, "4294967295"}, | ||
35 | {1 << 32, "4294967296"}, | ||
36 | {1<<32 + 1, "4294967297"}, | ||
37 | {1 << 50, "1125899906842624"}, | ||
38 | {1<<63 - 1, "9223372036854775807"}, | ||
39 | |||
40 | // Some values that convert correctly on amd64, but not on i386. | ||
41 | {0x1bf0c640a, "7500227594"}, | ||
42 | {0xbee5df75, "3202735989"}, | ||
43 | } | ||
44 | |||
45 | func TestUintToString(t *testing.T) { | ||
46 | for _, test := range uinttostringtests { | ||
47 | is := convertFreeBSDCPUTime(test.in) | ||
48 | if is != test.out { | ||
49 | t.Errorf("convertFreeBSDCPUTime(%v) = %v want %v", | ||
50 | test.in, is, test.out) | ||
51 | } | ||
52 | } | ||
53 | } | ||