aboutsummaryrefslogtreecommitdiffstats
path: root/tests/blogc/check_sysinfo2.c
diff options
context:
space:
mode:
authorRafael G. Martins <rafael@rafaelmartins.eng.br>2019-02-10 20:15:58 +0100
committerRafael G. Martins <rafael@rafaelmartins.eng.br>2019-02-10 20:15:58 +0100
commit74dec7c69ae961f98e0a91da9fc3f6214183467a (patch)
tree4ff7444d46a5519ba47352965cedc7ea14116251 /tests/blogc/check_sysinfo2.c
parent8b7ef9a86d712f0939d1170b5abfe9af13b1873e (diff)
downloadblogc-74dec7c69ae961f98e0a91da9fc3f6214183467a.tar.gz
blogc-74dec7c69ae961f98e0a91da9fc3f6214183467a.tar.bz2
blogc-74dec7c69ae961f98e0a91da9fc3f6214183467a.zip
blogc: sysinfo: added tests
Diffstat (limited to 'tests/blogc/check_sysinfo2.c')
-rw-r--r--tests/blogc/check_sysinfo2.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/tests/blogc/check_sysinfo2.c b/tests/blogc/check_sysinfo2.c
new file mode 100644
index 0000000..2bb4273
--- /dev/null
+++ b/tests/blogc/check_sysinfo2.c
@@ -0,0 +1,49 @@
+/*
+ * blogc: A blog compiler.
+ * Copyright (C) 2014-2019 Rafael G. Martins <rafael@rafaelmartins.eng.br>
+ *
+ * This program can be distributed under the terms of the BSD License.
+ * See the file LICENSE.
+ */
+
+#include <stdarg.h>
+#include <stddef.h>
+#include <setjmp.h>
+#include <cmocka.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+#include "../../src/common/error.h"
+#include "../../src/common/utils.h"
+#include "../../src/blogc/sysinfo.h"
+
+// this test exists because we can't test more than one return values for
+// blogc_sysinfo_get_inside_docker() in the same binary, because the results
+// are cached globally for performance.
+
+
+char*
+__wrap_bc_file_get_contents(const char *path, bool utf8, size_t *len, bc_error_t **err)
+{
+ assert_string_equal(path, "/proc/1/cgroup");
+ assert_false(utf8);
+ *err = bc_error_new(0, "");
+ return NULL;
+}
+
+
+static void
+test_sysinfo_get_inside_docker(void **state)
+{
+ assert_false(blogc_sysinfo_get_inside_docker());
+}
+
+
+int
+main(void)
+{
+ const UnitTest tests[] = {
+ unit_test(test_sysinfo_get_inside_docker),
+ };
+ return run_tests(tests);
+}