From 9d252a883ed4f8c9cb0f20a3eca068b98924029d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ga=C3=ABtan=20Harter?= <gaetan.harter@fu-berlin.de>
Date: Wed, 5 Dec 2018 20:03:02 +0100
Subject: [PATCH] tests/build_system_utils: add test for build system utilities

This will allow testing the build system 'utils' functions.
---
 tests/build_system_utils/Makefile  | 33 ++++++++++++++++++++++++++++++
 tests/build_system_utils/README.md | 14 +++++++++++++
 tests/build_system_utils/main.c    | 25 ++++++++++++++++++++++
 3 files changed, 72 insertions(+)
 create mode 100644 tests/build_system_utils/Makefile
 create mode 100644 tests/build_system_utils/README.md
 create mode 100644 tests/build_system_utils/main.c

diff --git a/tests/build_system_utils/Makefile b/tests/build_system_utils/Makefile
new file mode 100644
index 0000000000..4581c7d942
--- /dev/null
+++ b/tests/build_system_utils/Makefile
@@ -0,0 +1,33 @@
+BOARD_WHITELIST = native
+
+include ../Makefile.tests_common
+include $(RIOTBASE)/Makefile.include
+
+
+# Test utils commands
+define command_should_fail
+$1 2>/dev/null && { echo "Command '$1' should have failed but did not" >&2; $1; exit 1; } || true
+endef
+
+define command_should_succeed
+$1 || { echo "Command '$1' failed" >&2; $1; exit 1; }
+endef
+
+
+MAKEFILES_UTILS = $(RIOTMAKE)/utils
+
+TESTS = test-ensure_value test-ensure_value-negative
+
+# Tests will be run both in the host machine and in `docker`
+all: build-system-utils-tests
+
+build-system-utils-tests: $(TESTS)
+.PHONY: build-system-utils-tests $(TESTS)
+
+
+# tests for 'ensure_value'
+test-ensure_value:
+	$(Q)$(call command_should_succeed,"$(MAKE)" -C $(MAKEFILES_UTILS) -f test-checks.mk test-ensure_value)
+
+test-ensure_value-negative:
+	$(Q)$(call command_should_fail,"$(MAKE)" -C $(MAKEFILES_UTILS) -f test-checks.mk test-ensure_value-negative)
diff --git a/tests/build_system_utils/README.md b/tests/build_system_utils/README.md
new file mode 100644
index 0000000000..1f20b68447
--- /dev/null
+++ b/tests/build_system_utils/README.md
@@ -0,0 +1,14 @@
+Build system utils tests
+========================
+
+This test checks the build system 'utils' functions declared in
+`makefiles/utils`.
+
+The test output says nothing in case of success.
+
+Note
+----
+
+It should not be necessary to compile but this simplifies the integration in
+murdock for the moment. Also there will be other tests that may need to check
+the result of the compilation.
diff --git a/tests/build_system_utils/main.c b/tests/build_system_utils/main.c
new file mode 100644
index 0000000000..59d2d4dcce
--- /dev/null
+++ b/tests/build_system_utils/main.c
@@ -0,0 +1,25 @@
+/*
+ * Copyright (C) 2018 Freie Universität Berlin
+ *
+ * This file is subject to the terms and conditions of the GNU Lesser General
+ * Public License v2.1. See the file LICENSE in the top level directory for more
+ * details.
+ */
+
+/**
+ * @ingroup     tests
+ * @{
+ *
+ * @file
+ * @brief       Empty main file
+ *
+ * @author      Gaëtan Harter <gaetan.harter@fu-berlin.de>
+ *
+ * @}
+ */
+
+int main(void)
+{
+    /* The important rules are in the Makefile */
+    return 0;
+}
-- 
GitLab