Blob Blame Raw
From 6ccb2ab66121554f78cec1e4b1eebaa7e7e5ec1c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
Date: Sun, 15 Sep 2013 08:40:16 -0400
Subject: [PATCH] Assume that /proc/meminfo can be missing

Travis tests are failing, probably because /proc/meminfo is not available
in the test environment. The same might be true in some virtualized systems,
so just treat missing /proc/meminfo as a sign that hibernation is not
possible.
---
 src/shared/sleep-config.c | 3 ++-
 src/test/test-fileio.c    | 6 +++++-
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/shared/sleep-config.c b/src/shared/sleep-config.c
index 5ec7cce458..148c4dc617 100644
--- a/src/shared/sleep-config.c
+++ b/src/shared/sleep-config.c
@@ -172,7 +172,8 @@ static bool enough_memory_for_hibernation(void) {
 
         r = get_status_field("/proc/meminfo", "\nSwapFree:", &swapfree);
         if (r < 0) {
-                log_error("Failed to retrieve SwapFree from /proc/meminfo: %s", strerror(-r));
+                log_full(r == -ENOENT ? LOG_DEBUG : LOG_WARNING,
+                         "Failed to retrieve SwapFree from /proc/meminfo: %s", strerror(-r));
                 return false;
         }
 
diff --git a/src/test/test-fileio.c b/src/test/test-fileio.c
index 6c10d9f1fb..a05640a0a1 100644
--- a/src/test/test-fileio.c
+++ b/src/test/test-fileio.c
@@ -229,12 +229,16 @@ static void test_executable_is_script(void) {
 static void test_status_field(void) {
         _cleanup_free_ char *t = NULL, *p = NULL, *s = NULL;
         unsigned long long total, buffers;
+        int r;
 
         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);
+        r = get_status_field("/proc/meminfo", "MemTotal:", &p);
+        if (r == -ENOENT)
+                return;
+        assert(r == 0);
         puts(p);
         assert_se(safe_atollu(p, &total) == 0);