a4b143
From 0fdb6640bb9de89ca739676bbbb43d3a05a42f50 Mon Sep 17 00:00:00 2001
a4b143
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
a4b143
Date: Sun, 15 Sep 2013 08:40:16 -0400
a4b143
Subject: [PATCH] Assume that /proc/meminfo can be missing
a4b143
a4b143
Travis tests are failing, probably because /proc/meminfo is not available
a4b143
in the test environment. The same might be true in some virtualized systems,
a4b143
so just treat missing /proc/meminfo as a sign that hibernation is not
a4b143
possible.
a4b143
---
a4b143
 src/shared/sleep-config.c | 3 ++-
a4b143
 src/test/test-fileio.c    | 6 +++++-
a4b143
 2 files changed, 7 insertions(+), 2 deletions(-)
a4b143
a4b143
diff --git a/src/shared/sleep-config.c b/src/shared/sleep-config.c
a4b143
index 5ec7cce..148c4dc 100644
a4b143
--- a/src/shared/sleep-config.c
a4b143
+++ b/src/shared/sleep-config.c
a4b143
@@ -172,7 +172,8 @@ static bool enough_memory_for_hibernation(void) {
a4b143
 
a4b143
         r = get_status_field("/proc/meminfo", "\nSwapFree:", &swapfree);
a4b143
         if (r < 0) {
a4b143
-                log_error("Failed to retrieve SwapFree from /proc/meminfo: %s", strerror(-r));
a4b143
+                log_full(r == -ENOENT ? LOG_DEBUG : LOG_WARNING,
a4b143
+                         "Failed to retrieve SwapFree from /proc/meminfo: %s", strerror(-r));
a4b143
                 return false;
a4b143
         }
a4b143
 
a4b143
diff --git a/src/test/test-fileio.c b/src/test/test-fileio.c
a4b143
index 4a4ed79..3511f3a 100644
a4b143
--- a/src/test/test-fileio.c
a4b143
+++ b/src/test/test-fileio.c
a4b143
@@ -232,12 +232,16 @@ static void test_executable_is_script(void) {
a4b143
 static void test_status_field(void) {
a4b143
         _cleanup_free_ char *t = NULL, *p = NULL, *s = NULL;
a4b143
         unsigned long long total, buffers;
a4b143
+        int r;
a4b143
 
a4b143
         assert_se(get_status_field("/proc/self/status", "\nThreads:", &t) == 0);
a4b143
         puts(t);
a4b143
         assert_se(streq(t, "1"));
a4b143
 
a4b143
-        assert_se(get_status_field("/proc/meminfo", "MemTotal:", &p) == 0);
a4b143
+        r = get_status_field("/proc/meminfo", "MemTotal:", &p);
a4b143
+        if (r == -ENOENT)
a4b143
+                return;
a4b143
+        assert(r == 0);
a4b143
         puts(p);
a4b143
         assert_se(safe_atollu(p, &total) == 0);
a4b143