summaryrefslogtreecommitdiff
path: root/examples/hello_customtests
diff options
context:
space:
mode:
authorAndrew Shadura <andrew@shadura.me>2015-07-25 14:44:21 +0200
committerAndrew Shadura <andrew@shadura.me>2015-07-25 14:44:21 +0200
commit1d3d0bb1e461a81bc1a9cd4520958bd2b1db4c7f (patch)
tree1aa5b654ab4ab52e936550463aac7e4da0aad722 /examples/hello_customtests
Imported Upstream version 0.24.0
Diffstat (limited to 'examples/hello_customtests')
-rw-r--r--examples/hello_customtests/Makefile29
-rw-r--r--examples/hello_customtests/custom_tests/alloca_in_alloca_h.c9
-rw-r--r--examples/hello_customtests/custom_tests/alloca_in_stdlib_h.c9
-rw-r--r--examples/hello_customtests/custom_tests/cxx_with_templates.cc15
-rwxr-xr-xexamples/hello_customtests/custom_tests/shtest5
-rwxr-xr-xexamples/hello_customtests/custom_tests/true_is_available3
-rw-r--r--examples/hello_customtests/expect.out77
-rw-r--r--examples/hello_customtests/hello_customtests.c38
-rw-r--r--examples/hello_customtests/test.mk34
9 files changed, 219 insertions, 0 deletions
diff --git a/examples/hello_customtests/Makefile b/examples/hello_customtests/Makefile
new file mode 100644
index 0000000..169bbad
--- /dev/null
+++ b/examples/hello_customtests/Makefile
@@ -0,0 +1,29 @@
+PROG = hello_customtests
+
+WARNS = 4
+
+MKC_CHECK_CUSTOM = alloca_in_stdlib_h # C lang check
+MKC_CHECK_CUSTOM += alloca_in_alloca_h # C lang check
+MKC_CHECK_CUSTOM += cxx_with_templates # C++ lang check
+MKC_CHECK_CUSTOM += true_is_available # script-based check
+MKC_CHECK_CUSTOM += shtest # script-based check
+
+MKC_CUSTOM_FN.alloca_in_stdlib_h = custom_tests/alloca_in_stdlib_h.c
+MKC_CUSTOM_FN.alloca_in_alloca_h = custom_tests/alloca_in_alloca_h.c
+MKC_CUSTOM_FN.cxx_with_templates = custom_tests/cxx_with_templates.cc
+MKC_CUSTOM_FN.true_is_available = custom_tests/true_is_available
+MKC_CUSTOM_FN.shtest = custom_tests/shtest
+
+MKC_CHECK_BUILTINS += endianess
+
+MKC_REQD = 0.12.0
+
+.include <mkc.configure.mk>
+
+BUILTIN.endianess ?=
+.if ${BUILTIN.endianess} != little && ${BUILTIN.endianess} != big
+MKC_ERR_MSG = "Do you run PDP-11?"
+.endif
+
+.include "test.mk"
+.include <mkc.prog.mk>
diff --git a/examples/hello_customtests/custom_tests/alloca_in_alloca_h.c b/examples/hello_customtests/custom_tests/alloca_in_alloca_h.c
new file mode 100644
index 0000000..4ff3f19
--- /dev/null
+++ b/examples/hello_customtests/custom_tests/alloca_in_alloca_h.c
@@ -0,0 +1,9 @@
+#include <alloca.h>
+
+int main (int argc, char **argv)
+{
+#ifndef alloca
+ void *p = &alloca;
+#endif
+ return 0;
+}
diff --git a/examples/hello_customtests/custom_tests/alloca_in_stdlib_h.c b/examples/hello_customtests/custom_tests/alloca_in_stdlib_h.c
new file mode 100644
index 0000000..9b1e7a1
--- /dev/null
+++ b/examples/hello_customtests/custom_tests/alloca_in_stdlib_h.c
@@ -0,0 +1,9 @@
+#include <stdlib.h>
+
+int main (int argc, char **argv)
+{
+#ifndef alloca
+ void *p = &alloca;
+#endif
+ return 0;
+}
diff --git a/examples/hello_customtests/custom_tests/cxx_with_templates.cc b/examples/hello_customtests/custom_tests/cxx_with_templates.cc
new file mode 100644
index 0000000..f580a29
--- /dev/null
+++ b/examples/hello_customtests/custom_tests/cxx_with_templates.cc
@@ -0,0 +1,15 @@
+#include <iostream>
+
+template <typename T>
+T ident (T v)
+{
+ return v;
+}
+
+int main (int argc, char **argv)
+{
+ std::cout << ident (123);
+ std::cout << ident ("string");
+
+ return 0;
+}
diff --git a/examples/hello_customtests/custom_tests/shtest b/examples/hello_customtests/custom_tests/shtest
new file mode 100755
index 0000000..ad9ee24
--- /dev/null
+++ b/examples/hello_customtests/custom_tests/shtest
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+# Just a test
+foo_bar_baz
+echo 0
diff --git a/examples/hello_customtests/custom_tests/true_is_available b/examples/hello_customtests/custom_tests/true_is_available
new file mode 100755
index 0000000..51f40e7
--- /dev/null
+++ b/examples/hello_customtests/custom_tests/true_is_available
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+echo 1
diff --git a/examples/hello_customtests/expect.out b/examples/hello_customtests/expect.out
new file mode 100644
index 0000000..92f48f1
--- /dev/null
+++ b/examples/hello_customtests/expect.out
@@ -0,0 +1,77 @@
+=========== all ============
+/objdir/Makefile
+/objdir/_mkc_compiler_type.err
+/objdir/_mkc_compiler_type.res
+/objdir/_mkc_custom_alloca_in_alloca_h.err
+/objdir/_mkc_custom_alloca_in_alloca_h.res
+/objdir/_mkc_custom_alloca_in_stdlib_h.err
+/objdir/_mkc_custom_alloca_in_stdlib_h.res
+/objdir/_mkc_custom_cxx_with_templates.err
+/objdir/_mkc_custom_cxx_with_templates.res
+/objdir/_mkc_custom_endianess.err
+/objdir/_mkc_custom_endianess.res
+/objdir/_mkc_custom_shtest.err
+/objdir/_mkc_custom_shtest.res
+/objdir/_mkc_custom_true_is_available.err
+/objdir/_mkc_custom_true_is_available.res
+/objdir/_mkc_prog_cc.err
+/objdir/_mkc_prog_cc.res
+/objdir/custom_tests/alloca_in_alloca_h.c
+/objdir/custom_tests/alloca_in_stdlib_h.c
+/objdir/custom_tests/cxx_with_templates.cc
+/objdir/custom_tests/shtest
+/objdir/custom_tests/true_is_available
+/objdir/expect.out
+/objdir/hello_customtests
+/objdir/hello_customtests.c
+/objdir/hello_customtests.o
+/objdir/hello_customtests.test.out.tmp
+/objdir/test.mk
+=========== run ============
+alloca(3) succeeded
+We have C++ compiler with working templates: YES
+We have a working 'true' in bourne shell: YES
+shtest is good: NO
+========= install ==========
+/objdir/prefix
+/objdir/prefix/bin
+/objdir/prefix/bin/hello_customtests
+======== uninstall =========
+========== clean ===========
+/objdir/Makefile
+/objdir/_mkc_compiler_type.err
+/objdir/_mkc_compiler_type.res
+/objdir/_mkc_custom_alloca_in_alloca_h.err
+/objdir/_mkc_custom_alloca_in_alloca_h.res
+/objdir/_mkc_custom_alloca_in_stdlib_h.err
+/objdir/_mkc_custom_alloca_in_stdlib_h.res
+/objdir/_mkc_custom_cxx_with_templates.err
+/objdir/_mkc_custom_cxx_with_templates.res
+/objdir/_mkc_custom_endianess.err
+/objdir/_mkc_custom_endianess.res
+/objdir/_mkc_custom_shtest.err
+/objdir/_mkc_custom_shtest.res
+/objdir/_mkc_custom_true_is_available.err
+/objdir/_mkc_custom_true_is_available.res
+/objdir/_mkc_prog_cc.err
+/objdir/_mkc_prog_cc.res
+/objdir/custom_tests/alloca_in_alloca_h.c
+/objdir/custom_tests/alloca_in_stdlib_h.c
+/objdir/custom_tests/cxx_with_templates.cc
+/objdir/custom_tests/shtest
+/objdir/custom_tests/true_is_available
+/objdir/expect.out
+/objdir/hello_customtests.c
+/objdir/hello_customtests.test.out.tmp
+/objdir/test.mk
+======= distclean ==========
+/objdir/Makefile
+/objdir/custom_tests/alloca_in_alloca_h.c
+/objdir/custom_tests/alloca_in_stdlib_h.c
+/objdir/custom_tests/cxx_with_templates.cc
+/objdir/custom_tests/shtest
+/objdir/custom_tests/true_is_available
+/objdir/expect.out
+/objdir/hello_customtests.c
+/objdir/hello_customtests.test.out.tmp
+/objdir/test.mk
diff --git a/examples/hello_customtests/hello_customtests.c b/examples/hello_customtests/hello_customtests.c
new file mode 100644
index 0000000..a801f4f
--- /dev/null
+++ b/examples/hello_customtests/hello_customtests.c
@@ -0,0 +1,38 @@
+#include <stdio.h>
+
+#if CUSTOM_ALLOCA_IN_STDLIB_H
+#include <stdlib.h>
+#elif CUSTOM_ALLOCA_IN_ALLOCA_H
+#include <alloca.h>
+#endif
+
+#ifndef CUSTOM_SHTEST
+#define CUSTOM_SHTEST 0
+#endif
+
+#ifndef CUSTOM_CXX_WITH_TEMPLATES
+#define CUSTOM_CXX_WITH_TEMPLATES 0
+#endif
+
+#ifndef CUSTOM_TRUE_IS_AVAILABLE
+#define CUSTOM_TRUE_IS_AVAILABLE 0
+#endif
+
+int main (int argc, char** argv)
+{
+ if (alloca (100))
+ puts ("alloca(3) succeeded");
+ else
+ puts ("alloca(3) failed");
+
+ printf ("We have C++ compiler with working templates: %s\n",
+ (CUSTOM_CXX_WITH_TEMPLATES ? "YES" : "NO"));
+
+ printf ("We have a working 'true' in bourne shell: %s\n",
+ (CUSTOM_TRUE_IS_AVAILABLE ? "YES" : "NO"));
+
+ printf ("shtest is good: %s\n",
+ (CUSTOM_SHTEST ? "YES" : "NO"));
+
+ return 0;
+}
diff --git a/examples/hello_customtests/test.mk b/examples/hello_customtests/test.mk
new file mode 100644
index 0000000..99e946e
--- /dev/null
+++ b/examples/hello_customtests/test.mk
@@ -0,0 +1,34 @@
+.PHONY : test_output
+test_output:
+ @set -e; \
+ rm -rf ${.OBJDIR}${PREFIX}; \
+ \
+ echo =========== all ============; \
+ find ${.OBJDIR} -type f | \
+ mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \
+ \
+ echo =========== run ============; \
+ ${.OBJDIR}/hello_customtests; \
+ \
+ echo ========= install ==========; \
+ ${MAKE} ${MAKEFLAGS} install DESTDIR=${.OBJDIR} \
+ > /dev/null; \
+ find ${.OBJDIR}${PREFIX} -type f -o -type d | \
+ mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \
+ \
+ echo ======== uninstall =========; \
+ ${MAKE} ${MAKEFLAGS} uninstall DESTDIR=${.OBJDIR} > /dev/null; \
+ find ${.OBJDIR}${PREFIX} -type f | \
+ mkc_test_helper "${PREFIX}" "${.OBJDIR}";\
+ \
+ echo ========== clean ===========; \
+ ${MAKE} ${MAKEFLAGS} clean DESTDIR=${.OBJDIR} > /dev/null; \
+ find ${.OBJDIR} -type f | \
+ mkc_test_helper "${PREFIX}" "${.OBJDIR}";\
+ \
+ echo ======= distclean ==========; \
+ ${MAKE} ${MAKEFLAGS} distclean DESTDIR=${.OBJDIR} > /dev/null; \
+ find ${.OBJDIR} -type f | \
+ mkc_test_helper "${PREFIX}" "${.OBJDIR}"
+
+.include <mkc.minitest.mk>