summaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'src/test')
-rw-r--r--src/test/test-parse-util.c21
-rw-r--r--src/test/test-psi-util.c51
2 files changed, 35 insertions, 37 deletions
diff --git a/src/test/test-parse-util.c b/src/test/test-parse-util.c
index b1b23e2fbf..1163a55bc6 100644
--- a/src/test/test-parse-util.c
+++ b/src/test/test-parse-util.c
@@ -1,7 +1,6 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <errno.h>
-#include <linux/loadavg.h>
#include <locale.h>
#include <math.h>
#include <sys/socket.h>
@@ -805,24 +804,24 @@ static void test_parse_loadavg_fixed_point(void) {
loadavg_t fp;
assert_se(parse_loadavg_fixed_point("1.23", &fp) == 0);
- assert_se(LOAD_INT(fp) == 1);
- assert_se(LOAD_FRAC(fp) == 23);
+ assert_se(INT_SIDE(fp) == 1);
+ assert_se(DECIMAL_SIDE(fp) == 23);
assert_se(parse_loadavg_fixed_point("1.80", &fp) == 0);
- assert_se(LOAD_INT(fp) == 1);
- assert_se(LOAD_FRAC(fp) == 80);
+ assert_se(INT_SIDE(fp) == 1);
+ assert_se(DECIMAL_SIDE(fp) == 80);
assert_se(parse_loadavg_fixed_point("0.07", &fp) == 0);
- assert_se(LOAD_INT(fp) == 0);
- assert_se(LOAD_FRAC(fp) == 7);
+ assert_se(INT_SIDE(fp) == 0);
+ assert_se(DECIMAL_SIDE(fp) == 7);
assert_se(parse_loadavg_fixed_point("0.00", &fp) == 0);
- assert_se(LOAD_INT(fp) == 0);
- assert_se(LOAD_FRAC(fp) == 0);
+ assert_se(INT_SIDE(fp) == 0);
+ assert_se(DECIMAL_SIDE(fp) == 0);
assert_se(parse_loadavg_fixed_point("4096.57", &fp) == 0);
- assert_se(LOAD_INT(fp) == 4096);
- assert_se(LOAD_FRAC(fp) == 57);
+ assert_se(INT_SIDE(fp) == 4096);
+ assert_se(DECIMAL_SIDE(fp) == 57);
/* Caps out at 2 digit fracs */
assert_se(parse_loadavg_fixed_point("1.100", &fp) == -ERANGE);
diff --git a/src/test/test-psi-util.c b/src/test/test-psi-util.c
index c636cf255b..999a1fb51e 100644
--- a/src/test/test-psi-util.c
+++ b/src/test/test-psi-util.c
@@ -1,10 +1,9 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
-#include <linux/loadavg.h>
-
#include "alloc-util.h"
#include "fileio.h"
#include "fs-util.h"
+#include "parse-util.h"
#include "psi-util.h"
#include "tests.h"
@@ -36,40 +35,40 @@ static void test_read_mem_pressure(void) {
assert_se(write_string_file(path, "some avg10=0.22 avg60=0.17 avg300=1.11 total=58761459\n"
"full avg10=0.23 avg60=0.16 avg300=1.08 total=58464525", WRITE_STRING_FILE_CREATE) == 0);
assert_se(read_resource_pressure(path, PRESSURE_TYPE_SOME, &rp) == 0);
- assert_se(LOAD_INT(rp.avg10) == 0);
- assert_se(LOAD_FRAC(rp.avg10) == 22);
- assert_se(LOAD_INT(rp.avg60) == 0);
- assert_se(LOAD_FRAC(rp.avg60) == 17);
- assert_se(LOAD_INT(rp.avg300) == 1);
- assert_se(LOAD_FRAC(rp.avg300) == 11);
+ assert_se(INT_SIDE(rp.avg10) == 0);
+ assert_se(DECIMAL_SIDE(rp.avg10) == 22);
+ assert_se(INT_SIDE(rp.avg60) == 0);
+ assert_se(DECIMAL_SIDE(rp.avg60) == 17);
+ assert_se(INT_SIDE(rp.avg300) == 1);
+ assert_se(DECIMAL_SIDE(rp.avg300) == 11);
assert_se(rp.total == 58761459);
assert(read_resource_pressure(path, PRESSURE_TYPE_FULL, &rp) == 0);
- assert_se(LOAD_INT(rp.avg10) == 0);
- assert_se(LOAD_FRAC(rp.avg10) == 23);
- assert_se(LOAD_INT(rp.avg60) == 0);
- assert_se(LOAD_FRAC(rp.avg60) == 16);
- assert_se(LOAD_INT(rp.avg300) == 1);
- assert_se(LOAD_FRAC(rp.avg300) == 8);
+ assert_se(INT_SIDE(rp.avg10) == 0);
+ assert_se(DECIMAL_SIDE(rp.avg10) == 23);
+ assert_se(INT_SIDE(rp.avg60) == 0);
+ assert_se(DECIMAL_SIDE(rp.avg60) == 16);
+ assert_se(INT_SIDE(rp.avg300) == 1);
+ assert_se(DECIMAL_SIDE(rp.avg300) == 8);
assert_se(rp.total == 58464525);
/* Pressure file with extra unsupported fields */
assert_se(write_string_file(path, "some avg5=0.55 avg10=0.22 avg60=0.17 avg300=1.11 total=58761459\n"
"full avg10=0.23 avg60=0.16 avg300=1.08 avg600=2.00 total=58464525", WRITE_STRING_FILE_CREATE) == 0);
assert_se(read_resource_pressure(path, PRESSURE_TYPE_SOME, &rp) == 0);
- assert_se(LOAD_INT(rp.avg10) == 0);
- assert_se(LOAD_FRAC(rp.avg10) == 22);
- assert_se(LOAD_INT(rp.avg60) == 0);
- assert_se(LOAD_FRAC(rp.avg60) == 17);
- assert_se(LOAD_INT(rp.avg300) == 1);
- assert_se(LOAD_FRAC(rp.avg300) == 11);
+ assert_se(INT_SIDE(rp.avg10) == 0);
+ assert_se(DECIMAL_SIDE(rp.avg10) == 22);
+ assert_se(INT_SIDE(rp.avg60) == 0);
+ assert_se(DECIMAL_SIDE(rp.avg60) == 17);
+ assert_se(INT_SIDE(rp.avg300) == 1);
+ assert_se(DECIMAL_SIDE(rp.avg300) == 11);
assert_se(rp.total == 58761459);
assert(read_resource_pressure(path, PRESSURE_TYPE_FULL, &rp) == 0);
- assert_se(LOAD_INT(rp.avg10) == 0);
- assert_se(LOAD_FRAC(rp.avg10) == 23);
- assert_se(LOAD_INT(rp.avg60) == 0);
- assert_se(LOAD_FRAC(rp.avg60) == 16);
- assert_se(LOAD_INT(rp.avg300) == 1);
- assert_se(LOAD_FRAC(rp.avg300) == 8);
+ assert_se(INT_SIDE(rp.avg10) == 0);
+ assert_se(DECIMAL_SIDE(rp.avg10) == 23);
+ assert_se(INT_SIDE(rp.avg60) == 0);
+ assert_se(DECIMAL_SIDE(rp.avg60) == 16);
+ assert_se(INT_SIDE(rp.avg300) == 1);
+ assert_se(DECIMAL_SIDE(rp.avg300) == 8);
assert_se(rp.total == 58464525);
}