summaryrefslogtreecommitdiff
path: root/src/test/test-fileio.c
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2013-09-13 19:41:52 -0400
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2013-09-13 19:41:52 -0400
commit69ab80881552d5f79ca95f6b3be48ad122ab1ec2 (patch)
tree6b099f9f4f5693bb819ca4ac7dda4ad2798177b3 /src/test/test-fileio.c
parente39ff1f48d7ffcf7c20f9178ec64efbd7e244cab (diff)
Advertise hibernation only if there's enough free swap
Condition that is checked is taken from upower: active(anon) < free swap * 0.98 This is really stupid, because the kernel knows the situation better, e.g. there could be two swap files, and then hibernation would be impossible despite passing this check, or the kernel could start supporting compressed swap and/or compressed hibernation images, and then this this check would be too stringent. Nevertheless, until we have something better, this should at least return a true negative if there's no swap. Logging of capabilities in the journal is changed to not strip leading zeros. I consider this more readable anyway. http://cgit.freedesktop.org/upower/tree/src/up-daemon.c#n613 https://bugzilla.redhat.com/show_bug.cgi?id=1007059
Diffstat (limited to 'src/test/test-fileio.c')
-rw-r--r--src/test/test-fileio.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/test/test-fileio.c b/src/test/test-fileio.c
index 1184e7e02f..4a4ed79c11 100644
--- a/src/test/test-fileio.c
+++ b/src/test/test-fileio.c
@@ -229,9 +229,29 @@ static void test_executable_is_script(void) {
unlink(t);
}
+static void test_status_field(void) {
+ _cleanup_free_ char *t = NULL, *p = NULL, *s = NULL;
+ unsigned long long total, buffers;
+
+ assert_se(get_status_field("/proc/self/status", "\nThreads:", &t) == 0);
+ puts(t);
+ assert_se(streq(t, "1"));
+
+ assert_se(get_status_field("/proc/meminfo", "MemTotal:", &p) == 0);
+ puts(p);
+ assert_se(safe_atollu(p, &total) == 0);
+
+ assert_se(get_status_field("/proc/meminfo", "\nBuffers:", &s) == 0);
+ puts(s);
+ assert_se(safe_atollu(s, &buffers) == 0);
+
+ assert(buffers < total);
+}
+
int main(int argc, char *argv[]) {
test_parse_env_file();
test_parse_multiline_env_file();
test_executable_is_script();
+ test_status_field();
return 0;
}