Bug 432278 - Fix a couple of the static-checking testcases: clean up the makefile-fu a little bit, and add a new class of test: one which should issue warnings, which equates to "should fail with -Werror and should pass without -Werror." r=dmandelin
authorBenjamin Smedberg <benjamin@smedbergs.us>
Mon, 05 May 2008 14:32:31 -0400
changeset 14933 572802919ad2ad7c0c50d27aa29587fd239f510b
parent 14932 631ebb79c3f72e3d901f195f6e13197e973dcbe6
child 15032 b7dd3823dbdd731e555817977c1667a96dc41ee0
push id24
push userbsmedberg@mozilla.com
push dateMon, 05 May 2008 20:18:13 +0000
treeherdermozilla-central@572802919ad2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdmandelin
bugs432278
milestone2.0a1pre
Bug 432278 - Fix a couple of the static-checking testcases: clean up the makefile-fu a little bit, and add a new class of test: one which should issue warnings, which equates to "should fail with -Werror and should pass without -Werror." r=dmandelin
xpcom/tests/static-checker/Makefile.in
xpcom/tests/static-checker/e10.cpp
xpcom/tests/static-checker/o7.cpp
--- a/xpcom/tests/static-checker/Makefile.in
+++ b/xpcom/tests/static-checker/Makefile.in
@@ -42,24 +42,27 @@ srcdir = @srcdir@
 VPATH = @srcdir@
 
 # MAKE_DIRS: List of directories to build while looping over directories.
 MAKE_DIRS               += $(MDDEPDIR)
 GARBAGE_DIRS            += $(MDDEPDIR)
 
 include $(DEPTH)/config/autoconf.mk
 
-STATIC_FAILURE_TESTCASES = \
+FINAL_FAILURE_TESTCASES = \
   TestFinal.cpp \
   TestFinalTemplate.cpp \
+  $(NULL)
+
+STACK_FAILURE_TESTCASES = \
   TestStack.cpp \
   TestStackTemplate.cpp \
   $(NULL)
 
-OUTPARAMS_FAILURE_TESTCASES = \
+OUTPARAMS_WARNING_TESTCASES = \
   e1.cpp \
   e2.cpp \
   e3.cpp \
   e4.cpp \
   e5.cpp \
   e6.cpp \
   e7.cpp \
   e8.cpp \
@@ -77,32 +80,60 @@ OUTPARAMS_PASS_TESTCASES = \
   o6.cpp \
   o7.cpp \
   o8.cpp \
   o9.cpp \
   o10.cpp \
   o11.cpp \
   $(NULL)
 
+STATIC_FAILURE_TESTCASES = \
+  $(FINAL_FAILURE_TESTCASES) \
+  $(STACK_FAILURE_TESTCASES) \
+  $(NULL)
+
+STATIC_WARNING_TESTCASES = \
+  $(OUTPARAMS_WARNING_TESTCASES) \
+  $(NULL)
+
+STATIC_PASS_TESTCASES = \
+  $(OUTPARAMS_PASS_TESTCASES) \
+  $(NULL)
+
 include $(topsrcdir)/config/rules.mk
 
 # We want to compile each file and invert the result to ensure that
 # compilation failed.
-check:: $(STATIC_FAILURE_TESTCASES:.cpp=.s-fail) \
-  $(OUTPARAMS_FAILURE_TESTCASES:.cpp=.s-fail) $(OUTPARAMS_PASS_TESTCASES:.cpp=.s-pass)
+check:: \
+  $(STATIC_FAILURE_TESTCASES:.cpp=.s-fail) \
+  $(STATIC_WARNING_TESTCASES:.cpp=.s-warn) \
+  $(STATIC_PASS_TESTCASES:.cpp=.s-pass)
 
 %.s-fail: %.cpp Makefile Makefile.in $(DEHYDRA_SCRIPTS)
 	@printf "Compiling $(<F) to check that the static-analysis script is checking properly..."
-	@if $(CCC) -Werror $(OUTOPTION)/dev/null -S $(COMPILE_CXXFLAGS) $(_VPATH_SRCS) >$(*F).errlog 2>&1; then \
+	@if $(CCC) $(OUTOPTION)/dev/null -S $(COMPILE_CXXFLAGS) $(_VPATH_SRCS) >$(*F).errlog 2>&1; then \
 	  printf "fail:\nerror: compilation of $(<F) succeeded. It shouldn't have!\n"; \
 	  exit 1; \
 	else \
 	  printf "ok.\n"; \
 	fi
 
+%.s-warn: %.cpp Makefile Makefile.in $(DEHYDRA_SCRIPTS)
+	@printf "Compiling $(<F) to check that the static-analysis script is checking properly..."
+	@if $(CCC) -Werror $(OUTOPTION)/dev/null -S $(COMPILE_CXXFLAGS) $(_VPATH_SRCS) >$(*F).errlog 2>&1; then \
+	  printf "fail:\nerror: compilation of $(<F) succeeded with -Werror. It shouldn't have!\n" \
+	  exit 1; \
+	fi
+	@if $(CCC) $(OUTOPTION)/dev/null -S $(COMPILE_CXXFLAGS) $(_VPATH_SRCS) >$(*F).werrlog 2>&1; then \
+	  printf "ok.\n"; \
+	else \
+	  printf "fail:\nerror: compilation of $(<F) without -Werror failed. A warning should have been issued.\n" \
+	  exit 1; \
+	fi
+
 %.s-pass: %.cpp Makefile Makefile.in $(DEHYDRA_SCRIPTS)
 	@printf "Compiling $(<F) to check that the static-analysis script is checking properly..."
-	@if $(CCC) $(OUTOPTION)/dev/null -S $(COMPILE_CXXFLAGS) $(_VPATH_SRCS) >$(*F).errlog 2>&1; then \
+	@if $(CCC) -Werror $(OUTOPTION)/dev/null -S $(COMPILE_CXXFLAGS) $(_VPATH_SRCS) >$(*F).errlog 2>&1; then \
 	  printf "ok.\n"; \
 	else \
 	  printf "fail:\nerror: compilation of $(<F) failed. It shouldn't have!\n"; \
 	  exit 1; \
 	fi
--- a/xpcom/tests/static-checker/e10.cpp
+++ b/xpcom/tests/static-checker/e10.cpp
@@ -1,13 +1,15 @@
 typedef int PRUint32;
 typedef int PRInt32;
 
 typedef PRUint32 nsresult;
 typedef short PRUnichar;
 
+class nsACString;
+
 nsresult bar(nsACString &a);
 nsresult baz();
 
 nsresult foo(nsACString &a) {
   bar(a);
   return baz();
 }
--- a/xpcom/tests/static-checker/o7.cpp
+++ b/xpcom/tests/static-checker/o7.cpp
@@ -1,8 +1,8 @@
 typedef int PRUint32;
 typedef int PRInt32;
 
 typedef PRUint32 nsresult;
 
-nsresult foo(__attribute__((user("inoutparam"))) int *a) {
+nsresult foo(__attribute__((user("NS_inoutparam"))) int *a) {
   return 0;
 }