shared/sleep-config: fix memleak of strv, add test

CID #1390921, #1390951.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2018-05-10 01:36:50 +02:00
parent f5ce2e764f
commit db983479af
2 changed files with 12 additions and 7 deletions
+8
View File
@@ -14,6 +14,13 @@
#include "strv.h"
#include "util.h"
static void test_parse_sleep_config(void) {
const char *verb;
FOREACH_STRING(verb, "suspend", "hibernate", "hybrid-sleep", "suspend-then-hibernate")
assert_se(parse_sleep_config(verb, NULL, NULL, NULL) == 0);
}
static int test_fiemap(const char *path) {
_cleanup_free_ struct fiemap *fiemap = NULL;
_cleanup_close_ int fd = -1;
@@ -84,6 +91,7 @@ int main(int argc, char* argv[]) {
if (getuid() != 0)
log_warning("This program is unlikely to work for unprivileged users");
test_parse_sleep_config();
test_sleep();
if (argc <= 1)