From e8c790b3ceab06eb0433c3a234d3e16980f7ef19 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Mon, 10 May 2010 16:21:10 -0700 Subject: [PATCH] Add a very simple test for the pre-processor. Validate desired test cases by ensuring the output of glcpp matches the output of the gcc preprocessor, (ignoring any lines of the gcc output beginning with '#'). Only one test case so far with a trivial #define. --- .gitignore | 3 +++ Makefile | 4 ++++ tests/001-define.c | 2 ++ tests/glcpp-test | 9 +++++++++ 4 files changed, 18 insertions(+) create mode 100644 tests/001-define.c create mode 100755 tests/glcpp-test diff --git a/.gitignore b/.gitignore index 5bbd660f22b..d67bd38c93c 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,6 @@ glcpp-parse.c glcpp-parse.h *.o *~ +tests/*.expected +tests/*.gcc +tests/*.out diff --git a/Makefile b/Makefile index d37e9233ec0..38cc1f314a9 100644 --- a/Makefile +++ b/Makefile @@ -10,5 +10,9 @@ glcpp: glcpp.o glcpp-lex.o glcpp-parse.o hash_table.o glcpp-lex.c: glcpp-parse.h +test: + @(cd tests; ./glcpp-test) + clean: rm -f glcpp-lex.c glcpp-parse.c *.o *~ + rm -f tests/*.out tests/*.gcc tests/*.expected diff --git a/tests/001-define.c b/tests/001-define.c new file mode 100644 index 00000000000..cbf2fee0e75 --- /dev/null +++ b/tests/001-define.c @@ -0,0 +1,2 @@ +#define foo 1 +foo diff --git a/tests/glcpp-test b/tests/glcpp-test new file mode 100755 index 00000000000..25685eeabe5 --- /dev/null +++ b/tests/glcpp-test @@ -0,0 +1,9 @@ +#!/bin/sh + +for test in *.c; do + echo "Testing $test" + ../glcpp < $test > $test.out + gcc -E $test -o $test.gcc + grep -v '^#' < $test.gcc > $test.expected + diff -u $test.expected $test.out +done -- 2.30.2