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