commit 4ea3d2055c3103e5f95ccde2ff71ad9e49590f23
parent 9ee44dbed55c7c017f8bff23d1f7fe5cca70874c
Author: Kyle Milz <kyle@0x30.net>
Date: Mon, 29 Aug 2016 18:10:32 -0600
test: compile test program with build
Diffstat:
5 files changed, 56 insertions(+), 0 deletions(-)
diff --git a/Jamfile b/Jamfile
@@ -2,3 +2,4 @@ SubDir TOP ;
SubInclude TOP man ;
SubInclude TOP src ;
+SubInclude TOP test ;
diff --git a/test/Jamfile b/test/Jamfile
@@ -0,0 +1,12 @@
+SubDir TOP test ;
+
+PROG_SRCS = one.c two.c three.c ;
+MakeLocate $(PROG_SRCS) : $(LOCATE_SOURCE) ;
+
+Depends $(PROG_SRCS) : $(TOP)/src/inst_main.cc ;
+Depends program : $(TOP)/src/runtime.h $(TOP)/src/runtime.c ;
+
+CC on program = $(TOP)/src/citrun-wrap cc ;
+LINK on program = $(TOP)/src/citrun-wrap cc ;
+
+Main program : one.c two.c three.c ;
diff --git a/test/one.c b/test/one.c
@@ -0,0 +1,25 @@
+#include <err.h>
+#include <stdlib.h>
+
+long long fib(long long);
+void print_output(long long);
+
+void
+usr1_sig(int signal)
+{
+ exit(0);
+}
+
+int
+main(int argc, char *argv[])
+{
+ long long n;
+
+ if (argc != 2)
+ errx(1, "argc != 2");
+
+ n = atoi(argv[1]);
+
+ print_output(fib(n));
+ return 0;
+}
diff --git a/test/three.c b/test/three.c
@@ -0,0 +1,8 @@
+#include <stdio.h>
+
+void
+print_output(long long n)
+{
+ fprintf(stderr, "%lli", n);
+ return;
+}
diff --git a/test/two.c b/test/two.c
@@ -0,0 +1,10 @@
+long long
+fib(long long n)
+{
+ if (n == 0)
+ return 0;
+ else if (n == 1)
+ return 1;
+
+ return fib(n - 1) + fib(n - 2);
+}