test-procfs-util: convert to new ASSERT macros

Replace assert_se()/assert() with the typed ASSERT_* macros, matching the
conversions done across the rest of src/test/.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2026-08-21 09:17:51 +02:00
parent 9b6911d2e6
commit aa1045f862
+17 -19
View File
@@ -15,37 +15,35 @@ int main(int argc, char *argv[]) {
test_setup_logging(LOG_DEBUG);
assert_se(procfs_cpu_get_usage(&nsec) >= 0);
ASSERT_OK(procfs_cpu_get_usage(&nsec));
log_info("Current system CPU time: %s", FORMAT_TIMESPAN(nsec/NSEC_PER_USEC, 1));
assert_se(procfs_memory_get_used(&v) >= 0);
ASSERT_OK(procfs_memory_get_used(&v));
log_info("Current memory usage: %s", FORMAT_BYTES(v));
assert_se(procfs_tasks_get_current(&v) >= 0);
ASSERT_OK(procfs_tasks_get_current(&v));
log_info("Current number of tasks: %" PRIu64, v);
pid_max = TASKS_MAX;
r = procfs_get_pid_max(&pid_max);
if (r == -ENOENT || ERRNO_IS_NEG_PRIVILEGE(r))
return log_tests_skipped_errno(r, "can't get pid max");
assert(r >= 0);
ASSERT_OK(r);
log_info("kernel.pid_max: %"PRIu64, pid_max);
threads_max = TASKS_MAX;
r = procfs_get_threads_max(&threads_max);
if (r == -ENOENT || ERRNO_IS_NEG_PRIVILEGE(r))
return log_tests_skipped_errno(r, "can't get threads max");
assert(r >= 0);
ASSERT_OK(r);
log_info("kernel.threads-max: %"PRIu64, threads_max);
limit = MIN(pid_max - (pid_max > 0), threads_max);
assert_se(r >= 0);
log_info("Limit of tasks: %" PRIu64, limit);
assert_se(limit > 0);
ASSERT_GT(limit, 0U);
/* This call should never fail, as we're trying to set it to the same limit */
assert(procfs_tasks_set_limit(limit) >= 0);
ASSERT_OK(procfs_tasks_set_limit(limit));
if (limit > 100) {
log_info("Reducing limit by one to %"PRIu64"…", limit-1);
@@ -53,22 +51,22 @@ int main(int argc, char *argv[]) {
r = procfs_tasks_set_limit(limit-1);
if (r == -ENOENT || ERRNO_IS_NEG_FS_WRITE_REFUSED(r))
return log_tests_skipped_errno(r, "can't set tasks limit");
assert_se(r >= 0);
ASSERT_OK(r);
assert_se(procfs_get_pid_max(&v) >= 0);
ASSERT_OK(procfs_get_pid_max(&v));
/* We never decrease the pid_max, so it shouldn't have changed */
assert_se(v == pid_max);
ASSERT_EQ(v, pid_max);
assert_se(procfs_get_threads_max(&v) >= 0);
assert_se(v == limit-1);
ASSERT_OK(procfs_get_threads_max(&v));
ASSERT_EQ(v, limit - 1);
assert_se(procfs_tasks_set_limit(limit) >= 0);
ASSERT_OK(procfs_tasks_set_limit(limit));
assert_se(procfs_get_pid_max(&v) >= 0);
assert_se(v == pid_max);
ASSERT_OK(procfs_get_pid_max(&v));
ASSERT_EQ(v, pid_max);
assert_se(procfs_get_threads_max(&v) >= 0);
assert_se(v == limit);
ASSERT_OK(procfs_get_threads_max(&v));
ASSERT_EQ(v, limit);
}
return 0;