From 232e364f608f2396977fabc9bd1e872dce29e4f2 Mon Sep 17 00:00:00 2001
From: Jeremy Soller <jackpot51@gmail.com>
Date: Sun, 11 Mar 2018 21:20:56 -0600
Subject: [PATCH] Remove warnings, build openlibm without stack protector

---
 test.sh                     | 9 +++------
 tests/.gitignore            | 7 ++-----
 tests/Makefile              | 2 +-
 tests/expected/chdir.stderr | 0
 tests/expected/chdir.stdout | 2 --
 tests/expected/math.stdout  | 1 +
 tests/fcntl.out             | 0
 tests/link.c                | 1 +
 tests/math.c                | 5 ++++-
 9 files changed, 12 insertions(+), 15 deletions(-)
 delete mode 100644 tests/expected/chdir.stderr
 delete mode 100644 tests/expected/chdir.stdout
 delete mode 100755 tests/fcntl.out

diff --git a/test.sh b/test.sh
index 27f033bb..1e6d7b81 100755
--- a/test.sh
+++ b/test.sh
@@ -4,10 +4,7 @@ set -ex
 cargo build
 cargo build --manifest-path src/crt0/Cargo.toml
 
-cd openlibm
-make
-cd ..
+CFLAGS=-fno-stack-protector make -C openlibm
 
-cd tests
-make clean
-make run
+make -C tests clean
+make -C tests run
diff --git a/tests/.gitignore b/tests/.gitignore
index 9d5272bf..6cfb8396 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -1,3 +1,4 @@
+/*.out
 /gen/
 /alloc
 /args
@@ -6,19 +7,15 @@
 /brk
 /chdir
 /create
-/create.out
 /ctype
 /dup
-/dup.out
 /error
 /fchdir
 /fcntl
 /fsync
 /ftruncate
-/ftruncate.out
 /getid
 /link
-/link.out
 /math
 /mem
 /setid
@@ -36,5 +33,5 @@
 /string/strrchr
 /string/strspn
 /unlink
-/unlink.out
 /write
+
diff --git a/tests/Makefile b/tests/Makefile
index 7b61b5e6..a2528896 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -4,7 +4,6 @@ EXPECT_BINS=\
 	atoi \
 	brk \
 	args \
-	chdir \
 	create \
 	ctype \
 	dup \
@@ -35,6 +34,7 @@ EXPECT_BINS=\
 BINS=\
 	$(EXPECT_BINS) \
 	alloc \
+	chdir \
 	getid \
 	setid
 
diff --git a/tests/expected/chdir.stderr b/tests/expected/chdir.stderr
deleted file mode 100644
index e69de29b..00000000
diff --git a/tests/expected/chdir.stdout b/tests/expected/chdir.stdout
deleted file mode 100644
index 6d79e11b..00000000
--- a/tests/expected/chdir.stdout
+++ /dev/null
@@ -1,2 +0,0 @@
-initial cwd: /home/jeremy/Projects/relibc/tests
-final cwd: /home/jeremy/Projects/relibc
diff --git a/tests/expected/math.stdout b/tests/expected/math.stdout
index e69de29b..087a3bdf 100644
--- a/tests/expected/math.stdout
+++ b/tests/expected/math.stdout
@@ -0,0 +1 @@
+cos(3.14) = -0.9999987483024597
diff --git a/tests/fcntl.out b/tests/fcntl.out
deleted file mode 100755
index e69de29b..00000000
diff --git a/tests/link.c b/tests/link.c
index 383575e8..4df0dfde 100644
--- a/tests/link.c
+++ b/tests/link.c
@@ -1,3 +1,4 @@
+#include <stdio.h>
 #include <unistd.h>
 
 int main(int argc, char** argv) {
diff --git a/tests/math.c b/tests/math.c
index 159bb14c..981300fd 100644
--- a/tests/math.c
+++ b/tests/math.c
@@ -1,5 +1,8 @@
 #include <math.h>
+#include <stdio.h>
 
 int main(int argc, char ** argv) {
-    float c = cos(3.14);
+    double pi = 3.14;
+    float c = cos(pi);
+    printf("cos(%f) = %f\n", pi, c);
 }
-- 
GitLab