Fix our fortify tests for global -Werror.

If anyone has a better way of doing this it would be welcome...

Bug: http://b/26936282
Change-Id: I796896866327b4b5b5ee4ec36994fb320993f85d
diff --git a/tests/Android.mk b/tests/Android.mk
index 3712920..fb3c254 100644
--- a/tests/Android.mk
+++ b/tests/Android.mk
@@ -162,7 +162,7 @@
       -D_FORTIFY_SOURCE=$(test) \
       -DTEST_NAME=Fortify$(test)_$(compiler)); \
     $(eval fortify$(test)-tests-$(compiler)_src_files := \
-      fortify_test.cpp); \
+      fortify_test_main.cpp); \
     $(eval fortify_libs += fortify$(test)-tests-$(compiler)); \
   ) \
 )
diff --git a/tests/file-check-cxx b/tests/file-check-cxx
index 4018265..d3bc5f7 100755
--- a/tests/file-check-cxx
+++ b/tests/file-check-cxx
@@ -5,7 +5,7 @@
 shift 3
 SOURCE=$(echo "$@" | grep -oP '\S+\.cpp\b')
 OBJ=$(echo "$@" | grep -oP '\S+\.o\b')
-$CXX "$@" 2>&1 | $FILECHECK -check-prefix=$PREFIX $SOURCE
+$CXX "$@" -Wno-error 2>&1 | $FILECHECK -check-prefix=$PREFIX $SOURCE
 if [ "$?" -eq 0 ]; then
   touch $OBJ
 else
diff --git a/tests/fortify_test.cpp b/tests/fortify_test.cpp
index a349da9..4ffd5f9 100644
--- a/tests/fortify_test.cpp
+++ b/tests/fortify_test.cpp
@@ -14,6 +14,14 @@
  * limitations under the License.
  */
 
+// -Werror is on whether we like it or not, and we're intentionally doing awful
+// things in this file. GCC is dumb and doesn't have a specific error class for
+// the fortify failures (it's just -Werror), so we can't use anything more
+// constrained than disabling all the warnings in the file :( It also won't let
+// us use system_header in a .cpp file, so we have to #include this from
+// fortify_test_main.cpp.
+#pragma GCC system_header
+
 #include <gtest/gtest.h>
 #include "BionicDeathTest.h"
 
diff --git a/tests/fortify_test_main.cpp b/tests/fortify_test_main.cpp
new file mode 100644
index 0000000..8e52d42
--- /dev/null
+++ b/tests/fortify_test_main.cpp
@@ -0,0 +1,17 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "fortify_test.cpp"