Build tests as a separate Charmonizer project * Add a regen_charmonizer.pl script to meld the main charmonizer fragment and the other source files into charmonizer.c. * Add configure scripts to build and run charmonizer. * Create the Makefile for the tests using Charmonizer itself.
The test harness still needs to be reworked a bit. Project: http://git-wip-us.apache.org/repos/asf/lucy-charmonizer/repo Commit: http://git-wip-us.apache.org/repos/asf/lucy-charmonizer/commit/6adc7977 Tree: http://git-wip-us.apache.org/repos/asf/lucy-charmonizer/tree/6adc7977 Diff: http://git-wip-us.apache.org/repos/asf/lucy-charmonizer/diff/6adc7977 Branch: refs/heads/rework_tests Commit: 6adc79779cf43c9ae4aadc1834aa8f58fe70458e Parents: 4e612a8 Author: Nick Wellnhofer <[email protected]> Authored: Wed Nov 5 21:29:32 2014 +0100 Committer: Nick Wellnhofer <[email protected]> Committed: Wed Nov 5 21:44:53 2014 +0100 ---------------------------------------------------------------------- Makefile | 88 - Makefile.MSVC | 86 - Makefile.MinGW | 86 - charmonize.c | 103 - gen_makefiles.pl | 370 - regen_charmonizer.pl | 36 + samples/configure | 47 - samples/configure.bat | 46 - src/Charmonizer/Test.c | 205 - src/Charmonizer/Test.h | 140 - src/Charmonizer/Test/TestDirManip.c | 71 - src/Charmonizer/Test/TestFuncMacro.c | 63 - src/Charmonizer/Test/TestHeaders.c | 164 - src/Charmonizer/Test/TestIntegers.c | 127 - src/Charmonizer/Test/TestLargeFiles.c | 281 - src/Charmonizer/Test/TestUnusedVars.c | 42 - src/Charmonizer/Test/TestVariadicMacros.c | 69 - tests/.gitignore | 4 + tests/charmonizer.c | 7910 ++++++++++++++++++ tests/charmonizer.main | 235 + tests/configure | 47 + tests/configure.bat | 46 + tests/src/Charmonizer/Test.c | 205 + tests/src/Charmonizer/Test.h | 160 + tests/src/Charmonizer/Test/TestDirManip.c | 72 + tests/src/Charmonizer/Test/TestFuncMacro.c | 64 + tests/src/Charmonizer/Test/TestHeaders.c | 165 + tests/src/Charmonizer/Test/TestIntegers.c | 128 + tests/src/Charmonizer/Test/TestLargeFiles.c | 282 + tests/src/Charmonizer/Test/TestUnusedVars.c | 43 + tests/src/Charmonizer/Test/TestVariadicMacros.c | 70 + tests/tests/test.c | 32 + 32 files changed, 9499 insertions(+), 1988 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/lucy-charmonizer/blob/6adc7977/Makefile ---------------------------------------------------------------------- diff --git a/Makefile b/Makefile deleted file mode 100644 index 8221cac..0000000 --- a/Makefile +++ /dev/null @@ -1,88 +0,0 @@ -# GENERATED BY gen_makefiles.pl: do not hand-edit!!! - -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You 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. - -CC= cc -DEFS= -D_LARGEFILE64_SOURCE -CFLAGS= -I. -Isrc $(DEFS) -PROGNAME= charmonize -CHARMONY_H= charmony.h -PROBES= -FILES= -OUT= -PERL=/usr/bin/perl - -TESTS= TestDirManip TestFuncMacro TestHeaders TestIntegers TestLargeFiles TestUnusedVars TestVariadicMacros - -OBJS= charmonize.o src/Charmonizer/Core/CFlags.o src/Charmonizer/Core/CLI.o src/Charmonizer/Core/Compiler.o src/Charmonizer/Core/ConfWriter.o src/Charmonizer/Core/ConfWriterC.o src/Charmonizer/Core/ConfWriterPerl.o src/Charmonizer/Core/ConfWriterPython.o src/Charmonizer/Core/ConfWriterRuby.o src/Charmonizer/Core/HeaderChecker.o src/Charmonizer/Core/Library.o src/Charmonizer/Core/Make.o src/Charmonizer/Core/OperatingSystem.o src/Charmonizer/Core/Util.o src/Charmonizer/Probe.o src/Charmonizer/Probe/AtomicOps.o src/Charmonizer/Probe/Booleans.o src/Charmonizer/Probe/BuildEnv.o src/Charmonizer/Probe/DirManip.o src/Charmonizer/Probe/Floats.o src/Charmonizer/Probe/FuncMacro.o src/Charmonizer/Probe/Headers.o src/Charmonizer/Probe/Integers.o src/Charmonizer/Probe/LargeFiles.o src/Charmonizer/Probe/Memory.o src/Charmonizer/Probe/RegularExpressions.o src/Charmonizer/Probe/Strings.o src/Charmonizer/Probe/SymbolVisibility.o src/Charmonizer/Probe/UnusedVars.o src/Charmonizer/Probe/VariadicMacros. o - -TEST_OBJS= src/Charmonizer/Test.o src/Charmonizer/Test/TestDirManip.o src/Charmonizer/Test/TestFuncMacro.o src/Charmonizer/Test/TestHeaders.o src/Charmonizer/Test/TestIntegers.o src/Charmonizer/Test/TestLargeFiles.o src/Charmonizer/Test/TestUnusedVars.o src/Charmonizer/Test/TestVariadicMacros.o - -HEADERS= src/Charmonizer/Core/CFlags.h src/Charmonizer/Core/CLI.h src/Charmonizer/Core/Compiler.h src/Charmonizer/Core/ConfWriter.h src/Charmonizer/Core/ConfWriterC.h src/Charmonizer/Core/ConfWriterPerl.h src/Charmonizer/Core/ConfWriterPython.h src/Charmonizer/Core/ConfWriterRuby.h src/Charmonizer/Core/Defines.h src/Charmonizer/Core/HeaderChecker.h src/Charmonizer/Core/Library.h src/Charmonizer/Core/Make.h src/Charmonizer/Core/OperatingSystem.h src/Charmonizer/Core/Util.h src/Charmonizer/Probe.h src/Charmonizer/Probe/AtomicOps.h src/Charmonizer/Probe/Booleans.h src/Charmonizer/Probe/BuildEnv.h src/Charmonizer/Probe/DirManip.h src/Charmonizer/Probe/Floats.h src/Charmonizer/Probe/FuncMacro.h src/Charmonizer/Probe/Headers.h src/Charmonizer/Probe/Integers.h src/Charmonizer/Probe/LargeFiles.h src/Charmonizer/Probe/Memory.h src/Charmonizer/Probe/RegularExpressions.h src/Charmonizer/Probe/Strings.h src/Charmonizer/Probe/SymbolVisibility.h src/Charmonizer/Probe/UnusedVars.h src/Charmonizer/ Probe/VariadicMacros.h src/Charmonizer/Test.h - -CLEANABLE= $(OBJS) $(PROGNAME) $(CHARMONY_H) $(TEST_OBJS) $(TESTS) - -.c.o: - $(CC) $(CFLAGS) -c $*.c -o $@ - -all: $(PROGNAME) - -meld: - $(PERL) buildbin/meld.pl --probes=$(PROBES) --files=$(FILES) --out=$(OUT) - -$(CHARMONY_H): $(PROGNAME) - ./$(PROGNAME) --cc=$(CC) --enable-c - -valgrind: $(PROGNAME) - valgrind --leak-check=full ./$(PROGNAME) --cc=$(CC) --enable-c - -$(PROGNAME): $(OBJS) - $(CC) $(CFLAGS) $(OBJS) -o $(PROGNAME) - -$(OBJS) $(TEST_OBJS): $(HEADERS) - -$(TEST_OBJS): $(CHARMONY_H) - -tests: $(TESTS) - -TestDirManip: src/Charmonizer/Test.o src/Charmonizer/Test/TestDirManip.o - $(CC) $(CFLAGS) src/Charmonizer/Test/TestDirManip.o src/Charmonizer/Test.o -o $@ - -TestFuncMacro: src/Charmonizer/Test.o src/Charmonizer/Test/TestFuncMacro.o - $(CC) $(CFLAGS) src/Charmonizer/Test/TestFuncMacro.o src/Charmonizer/Test.o -o $@ - -TestHeaders: src/Charmonizer/Test.o src/Charmonizer/Test/TestHeaders.o - $(CC) $(CFLAGS) src/Charmonizer/Test/TestHeaders.o src/Charmonizer/Test.o -o $@ - -TestIntegers: src/Charmonizer/Test.o src/Charmonizer/Test/TestIntegers.o - $(CC) $(CFLAGS) src/Charmonizer/Test/TestIntegers.o src/Charmonizer/Test.o -o $@ - -TestLargeFiles: src/Charmonizer/Test.o src/Charmonizer/Test/TestLargeFiles.o - $(CC) $(CFLAGS) src/Charmonizer/Test/TestLargeFiles.o src/Charmonizer/Test.o -o $@ - -TestUnusedVars: src/Charmonizer/Test.o src/Charmonizer/Test/TestUnusedVars.o - $(CC) $(CFLAGS) src/Charmonizer/Test/TestUnusedVars.o src/Charmonizer/Test.o -o $@ - -TestVariadicMacros: src/Charmonizer/Test.o src/Charmonizer/Test/TestVariadicMacros.o - $(CC) $(CFLAGS) src/Charmonizer/Test/TestVariadicMacros.o src/Charmonizer/Test.o -o $@ - -test: tests - prove ./Test* - - -clean: - rm -f $(CLEANABLE) - http://git-wip-us.apache.org/repos/asf/lucy-charmonizer/blob/6adc7977/Makefile.MSVC ---------------------------------------------------------------------- diff --git a/Makefile.MSVC b/Makefile.MSVC deleted file mode 100644 index 155140c..0000000 --- a/Makefile.MSVC +++ /dev/null @@ -1,86 +0,0 @@ -# GENERATED BY gen_makefiles.pl: do not hand-edit!!! - -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You 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. - -CC= cl -DEFS= -CFLAGS= -I. -Isrc $(DEFS) -nologo -D_CRT_SECURE_NO_WARNINGS -D_SCL_SECURE_NO_WARNINGS -PROGNAME= charmonize.exe -CHARMONY_H= charmony.h -PROBES= -FILES= -OUT= -PERL=/usr/bin/perl - -TESTS= TestDirManip.exe TestFuncMacro.exe TestHeaders.exe TestIntegers.exe TestLargeFiles.exe TestUnusedVars.exe TestVariadicMacros.exe - -OBJS= charmonize.obj src\Charmonizer\Core\CFlags.obj src\Charmonizer\Core\CLI.obj src\Charmonizer\Core\Compiler.obj src\Charmonizer\Core\ConfWriter.obj src\Charmonizer\Core\ConfWriterC.obj src\Charmonizer\Core\ConfWriterPerl.obj src\Charmonizer\Core\ConfWriterPython.obj src\Charmonizer\Core\ConfWriterRuby.obj src\Charmonizer\Core\HeaderChecker.obj src\Charmonizer\Core\Library.obj src\Charmonizer\Core\Make.obj src\Charmonizer\Core\OperatingSystem.obj src\Charmonizer\Core\Util.obj src\Charmonizer\Probe.obj src\Charmonizer\Probe\AtomicOps.obj src\Charmonizer\Probe\Booleans.obj src\Charmonizer\Probe\BuildEnv.obj src\Charmonizer\Probe\DirManip.obj src\Charmonizer\Probe\Floats.obj src\Charmonizer\Probe\FuncMacro.obj src\Charmonizer\Probe\Headers.obj src\Charmonizer\Probe\Integers.obj src\Charmonizer\Probe\LargeFiles.obj src\Charmonizer\Probe\Memory.obj src\Charmonizer\Probe\RegularExpressions.obj src\Charmonizer\Probe\Strings.obj src\Charmonizer\Probe\SymbolVisibility.obj src\Charmonizer\ Probe\UnusedVars.obj src\Charmonizer\Probe\VariadicMacros.obj - -TEST_OBJS= src\Charmonizer\Test.obj src\Charmonizer\Test\TestDirManip.obj src\Charmonizer\Test\TestFuncMacro.obj src\Charmonizer\Test\TestHeaders.obj src\Charmonizer\Test\TestIntegers.obj src\Charmonizer\Test\TestLargeFiles.obj src\Charmonizer\Test\TestUnusedVars.obj src\Charmonizer\Test\TestVariadicMacros.obj - -HEADERS= src\Charmonizer\Core\CFlags.h src\Charmonizer\Core\CLI.h src\Charmonizer\Core\Compiler.h src\Charmonizer\Core\ConfWriter.h src\Charmonizer\Core\ConfWriterC.h src\Charmonizer\Core\ConfWriterPerl.h src\Charmonizer\Core\ConfWriterPython.h src\Charmonizer\Core\ConfWriterRuby.h src\Charmonizer\Core\Defines.h src\Charmonizer\Core\HeaderChecker.h src\Charmonizer\Core\Library.h src\Charmonizer\Core\Make.h src\Charmonizer\Core\OperatingSystem.h src\Charmonizer\Core\Util.h src\Charmonizer\Probe.h src\Charmonizer\Probe\AtomicOps.h src\Charmonizer\Probe\Booleans.h src\Charmonizer\Probe\BuildEnv.h src\Charmonizer\Probe\DirManip.h src\Charmonizer\Probe\Floats.h src\Charmonizer\Probe\FuncMacro.h src\Charmonizer\Probe\Headers.h src\Charmonizer\Probe\Integers.h src\Charmonizer\Probe\LargeFiles.h src\Charmonizer\Probe\Memory.h src\Charmonizer\Probe\RegularExpressions.h src\Charmonizer\Probe\Strings.h src\Charmonizer\Probe\SymbolVisibility.h src\Charmonizer\Probe\UnusedVars.h src\Charmonizer\ Probe\VariadicMacros.h src\Charmonizer\Test.h - -CLEANABLE= $(OBJS) $(PROGNAME) $(CHARMONY_H) $(TEST_OBJS) $(TESTS) *.pdb - -.c.obj: - $(CC) $(CFLAGS) -c $< -Fo$@ - -all: $(PROGNAME) - -meld: - $(PERL) buildbin\meld.pl --probes=$(PROBES) --files=$(FILES) --out=$(OUT) - -$(CHARMONY_H): $(PROGNAME) - $(PROGNAME) --cc=$(CC) --enable-c - - -$(PROGNAME): $(OBJS) - link -nologo $(OBJS) /OUT:$(PROGNAME) - -$(OBJS) $(TEST_OBJS): $(HEADERS) - -$(TEST_OBJS): $(CHARMONY_H) - -tests: $(TESTS) - -TestDirManip.exe: src\Charmonizer\Test.obj src\Charmonizer\Test\TestDirManip.obj - link -nologo src\Charmonizer\Test\TestDirManip.obj src\Charmonizer\Test.obj /OUT:$@ - -TestFuncMacro.exe: src\Charmonizer\Test.obj src\Charmonizer\Test\TestFuncMacro.obj - link -nologo src\Charmonizer\Test\TestFuncMacro.obj src\Charmonizer\Test.obj /OUT:$@ - -TestHeaders.exe: src\Charmonizer\Test.obj src\Charmonizer\Test\TestHeaders.obj - link -nologo src\Charmonizer\Test\TestHeaders.obj src\Charmonizer\Test.obj /OUT:$@ - -TestIntegers.exe: src\Charmonizer\Test.obj src\Charmonizer\Test\TestIntegers.obj - link -nologo src\Charmonizer\Test\TestIntegers.obj src\Charmonizer\Test.obj /OUT:$@ - -TestLargeFiles.exe: src\Charmonizer\Test.obj src\Charmonizer\Test\TestLargeFiles.obj - link -nologo src\Charmonizer\Test\TestLargeFiles.obj src\Charmonizer\Test.obj /OUT:$@ - -TestUnusedVars.exe: src\Charmonizer\Test.obj src\Charmonizer\Test\TestUnusedVars.obj - link -nologo src\Charmonizer\Test\TestUnusedVars.obj src\Charmonizer\Test.obj /OUT:$@ - -TestVariadicMacros.exe: src\Charmonizer\Test.obj src\Charmonizer\Test\TestVariadicMacros.obj - link -nologo src\Charmonizer\Test\TestVariadicMacros.obj src\Charmonizer\Test.obj /OUT:$@ - -test: tests - prove Test* - - -clean: - CMD /c FOR %i IN ($(CLEANABLE)) DO IF EXIST %i DEL /F %i - http://git-wip-us.apache.org/repos/asf/lucy-charmonizer/blob/6adc7977/Makefile.MinGW ---------------------------------------------------------------------- diff --git a/Makefile.MinGW b/Makefile.MinGW deleted file mode 100644 index 0c3104a..0000000 --- a/Makefile.MinGW +++ /dev/null @@ -1,86 +0,0 @@ -# GENERATED BY gen_makefiles.pl: do not hand-edit!!! - -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You 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. - -CC= gcc -DEFS= -CFLAGS= -I. -Isrc $(DEFS) -PROGNAME= charmonize.exe -CHARMONY_H= charmony.h -PROBES= -FILES= -OUT= -PERL=/usr/bin/perl - -TESTS= TestDirManip.exe TestFuncMacro.exe TestHeaders.exe TestIntegers.exe TestLargeFiles.exe TestUnusedVars.exe TestVariadicMacros.exe - -OBJS= charmonize.o src\Charmonizer\Core\CFlags.o src\Charmonizer\Core\CLI.o src\Charmonizer\Core\Compiler.o src\Charmonizer\Core\ConfWriter.o src\Charmonizer\Core\ConfWriterC.o src\Charmonizer\Core\ConfWriterPerl.o src\Charmonizer\Core\ConfWriterPython.o src\Charmonizer\Core\ConfWriterRuby.o src\Charmonizer\Core\HeaderChecker.o src\Charmonizer\Core\Library.o src\Charmonizer\Core\Make.o src\Charmonizer\Core\OperatingSystem.o src\Charmonizer\Core\Util.o src\Charmonizer\Probe.o src\Charmonizer\Probe\AtomicOps.o src\Charmonizer\Probe\Booleans.o src\Charmonizer\Probe\BuildEnv.o src\Charmonizer\Probe\DirManip.o src\Charmonizer\Probe\Floats.o src\Charmonizer\Probe\FuncMacro.o src\Charmonizer\Probe\Headers.o src\Charmonizer\Probe\Integers.o src\Charmonizer\Probe\LargeFiles.o src\Charmonizer\Probe\Memory.o src\Charmonizer\Probe\RegularExpressions.o src\Charmonizer\Probe\Strings.o src\Charmonizer\Probe\SymbolVisibility.o src\Charmonizer\Probe\UnusedVars.o src\Charmonizer\Probe\VariadicMacros. o - -TEST_OBJS= src\Charmonizer\Test.o src\Charmonizer\Test\TestDirManip.o src\Charmonizer\Test\TestFuncMacro.o src\Charmonizer\Test\TestHeaders.o src\Charmonizer\Test\TestIntegers.o src\Charmonizer\Test\TestLargeFiles.o src\Charmonizer\Test\TestUnusedVars.o src\Charmonizer\Test\TestVariadicMacros.o - -HEADERS= src\Charmonizer\Core\CFlags.h src\Charmonizer\Core\CLI.h src\Charmonizer\Core\Compiler.h src\Charmonizer\Core\ConfWriter.h src\Charmonizer\Core\ConfWriterC.h src\Charmonizer\Core\ConfWriterPerl.h src\Charmonizer\Core\ConfWriterPython.h src\Charmonizer\Core\ConfWriterRuby.h src\Charmonizer\Core\Defines.h src\Charmonizer\Core\HeaderChecker.h src\Charmonizer\Core\Library.h src\Charmonizer\Core\Make.h src\Charmonizer\Core\OperatingSystem.h src\Charmonizer\Core\Util.h src\Charmonizer\Probe.h src\Charmonizer\Probe\AtomicOps.h src\Charmonizer\Probe\Booleans.h src\Charmonizer\Probe\BuildEnv.h src\Charmonizer\Probe\DirManip.h src\Charmonizer\Probe\Floats.h src\Charmonizer\Probe\FuncMacro.h src\Charmonizer\Probe\Headers.h src\Charmonizer\Probe\Integers.h src\Charmonizer\Probe\LargeFiles.h src\Charmonizer\Probe\Memory.h src\Charmonizer\Probe\RegularExpressions.h src\Charmonizer\Probe\Strings.h src\Charmonizer\Probe\SymbolVisibility.h src\Charmonizer\Probe\UnusedVars.h src\Charmonizer\ Probe\VariadicMacros.h src\Charmonizer\Test.h - -CLEANABLE= $(OBJS) $(PROGNAME) $(CHARMONY_H) $(TEST_OBJS) $(TESTS) - -.c.o: - $(CC) $(CFLAGS) -c $*.c -o $@ - -all: $(PROGNAME) - -meld: - $(PERL) buildbin\meld.pl --probes=$(PROBES) --files=$(FILES) --out=$(OUT) - -$(CHARMONY_H): $(PROGNAME) - $(PROGNAME) --cc=$(CC) --enable-c - - -$(PROGNAME): $(OBJS) - $(CC) $(CFLAGS) $(OBJS) -o $(PROGNAME) - -$(OBJS) $(TEST_OBJS): $(HEADERS) - -$(TEST_OBJS): $(CHARMONY_H) - -tests: $(TESTS) - -TestDirManip.exe: src\Charmonizer\Test.o src\Charmonizer\Test\TestDirManip.o - $(CC) $(CFLAGS) src\Charmonizer\Test\TestDirManip.o src\Charmonizer\Test.o -o $@ - -TestFuncMacro.exe: src\Charmonizer\Test.o src\Charmonizer\Test\TestFuncMacro.o - $(CC) $(CFLAGS) src\Charmonizer\Test\TestFuncMacro.o src\Charmonizer\Test.o -o $@ - -TestHeaders.exe: src\Charmonizer\Test.o src\Charmonizer\Test\TestHeaders.o - $(CC) $(CFLAGS) src\Charmonizer\Test\TestHeaders.o src\Charmonizer\Test.o -o $@ - -TestIntegers.exe: src\Charmonizer\Test.o src\Charmonizer\Test\TestIntegers.o - $(CC) $(CFLAGS) src\Charmonizer\Test\TestIntegers.o src\Charmonizer\Test.o -o $@ - -TestLargeFiles.exe: src\Charmonizer\Test.o src\Charmonizer\Test\TestLargeFiles.o - $(CC) $(CFLAGS) src\Charmonizer\Test\TestLargeFiles.o src\Charmonizer\Test.o -o $@ - -TestUnusedVars.exe: src\Charmonizer\Test.o src\Charmonizer\Test\TestUnusedVars.o - $(CC) $(CFLAGS) src\Charmonizer\Test\TestUnusedVars.o src\Charmonizer\Test.o -o $@ - -TestVariadicMacros.exe: src\Charmonizer\Test.o src\Charmonizer\Test\TestVariadicMacros.o - $(CC) $(CFLAGS) src\Charmonizer\Test\TestVariadicMacros.o src\Charmonizer\Test.o -o $@ - -test: tests - prove Test* - - -clean: - CMD /c FOR %i IN ($(CLEANABLE)) DO IF EXIST %i DEL /F %i - http://git-wip-us.apache.org/repos/asf/lucy-charmonizer/blob/6adc7977/charmonize.c ---------------------------------------------------------------------- diff --git a/charmonize.c b/charmonize.c deleted file mode 100644 index 3fdbb85..0000000 --- a/charmonize.c +++ /dev/null @@ -1,103 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -/* Charmonize.c -- Create Charmony. - */ - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include "Charmonizer/Probe.h" -#include "Charmonizer/Probe/AtomicOps.h" -#include "Charmonizer/Probe/DirManip.h" -#include "Charmonizer/Probe/Floats.h" -#include "Charmonizer/Probe/FuncMacro.h" -#include "Charmonizer/Probe/Headers.h" -#include "Charmonizer/Probe/Booleans.h" -#include "Charmonizer/Probe/Integers.h" -#include "Charmonizer/Probe/LargeFiles.h" -#include "Charmonizer/Probe/Memory.h" -#include "Charmonizer/Probe/SymbolVisibility.h" -#include "Charmonizer/Probe/UnusedVars.h" -#include "Charmonizer/Probe/VariadicMacros.h" -#include "Charmonizer/Core/HeaderChecker.h" -#include "Charmonizer/Core/CLI.h" -#include "Charmonizer/Core/ConfWriter.h" -#include "Charmonizer/Core/ConfWriterC.h" -#include "Charmonizer/Core/ConfWriterPerl.h" -#include "Charmonizer/Core/ConfWriterRuby.h" - -int main(int argc, const char **argv) { - /* Initialize. */ - { - chaz_CLI *cli = chaz_CLI_new(argv[0], NULL); - int result = chaz_Probe_parse_cli_args(argc, argv, cli); - if (!result) { - fprintf(stderr, "%s", chaz_CLI_help(cli)); - exit(1); - } - chaz_Probe_init(cli); - chaz_CLI_destroy(cli); - } - - /* Run probe modules. */ - chaz_DirManip_run(); - chaz_Headers_run(); - chaz_AtomicOps_run(); - chaz_FuncMacro_run(); - chaz_Booleans_run(); - chaz_Integers_run(); - chaz_Floats_run(); - chaz_LargeFiles_run(); - chaz_Memory_run(); - chaz_SymbolVisibility_run(); - chaz_UnusedVars_run(); - chaz_VariadicMacros_run(); - - /* Write custom postamble. */ - chaz_ConfWriter_append_conf( - "#ifdef CHY_HAS_SYS_TYPES_H\n" - " #include <sys/types.h>\n" - "#endif\n\n" - ); - chaz_ConfWriter_append_conf( - "#ifdef CHY_HAS_ALLOCA_H\n" - " #include <alloca.h>\n" - "#elif defined(CHY_HAS_MALLOC_H)\n" - " #include <malloc.h>\n" - "#elif defined(CHY_ALLOCA_IN_STDLIB_H)\n" - " #include <stdlib.h>\n" - "#endif\n\n" - ); - chaz_ConfWriter_append_conf( - "#ifdef CHY_HAS_WINDOWS_H\n" - " /* Target Windows XP. */\n" - " #ifndef WINVER\n" - " #define WINVER 0x0500\n" - " #endif\n" - " #ifndef _WIN32_WINNT\n" - " #define _WIN32_WINNT 0x0500\n" - " #endif\n" - "#endif\n\n" - ); - - /* Clean up. */ - chaz_Probe_clean_up(); - - return 0; -} - - http://git-wip-us.apache.org/repos/asf/lucy-charmonizer/blob/6adc7977/gen_makefiles.pl ---------------------------------------------------------------------- diff --git a/gen_makefiles.pl b/gen_makefiles.pl deleted file mode 100755 index e558b3b..0000000 --- a/gen_makefiles.pl +++ /dev/null @@ -1,370 +0,0 @@ -#!/usr/bin/perl - -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You 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. - -use strict; -use warnings; - -package Charmonizer::Build::Makefile; -use File::Find qw(); -use FindBin; -use Carp qw( confess ); -use Cwd qw( getcwd ); - -sub new { - my ( $class, %args ) = @_; - - # Validate args, create object. - for (qw( dir filename obj_ext exe_ext cc )) { - defined $args{$_} or confess("Missing required param '$_'"); - } - my $dir = $args{dir}; - my $self = bless { - dir => $dir, - filename => $args{filename}, - obj_ext => $args{obj_ext}, - exe_ext => $args{exe_ext}, - cc => $args{cc}, - extra_cflags => $args{extra_cflags} || '', - extra_clean => $args{extra_clean} || '', - }, $class; - - # Gather source paths, normalized for the target OS. - my $orig_dir = getcwd(); - chdir($dir); - -d 'src' or confess("Can't find 'src' directory within '$dir'"); - my ( @h_files, @c_files, @c_tests ); - push @c_files, "charmonize.c"; - File::Find::find( - { wanted => sub { - if (/\.c$/) { - if (/^Test/) { - push @c_tests, $File::Find::name; - } - else { - push @c_files, $File::Find::name; - } - } - elsif (/\.h$/) { - push @h_files, $File::Find::name; - } - }, - }, - 'src', - ); - chdir($orig_dir); - $self->{c_files} = [ sort map { $self->pathify($_) } @c_files ]; - $self->{h_files} = [ sort map { $self->pathify($_) } @h_files ]; - $self->{c_tests} = [ sort map { $self->pathify($_) } @c_tests ]; - $self->{c_test_cases} - = [ grep { $_ !~ /Test\.c/ } @{ $self->{c_tests} } ]; - - return $self; -} - -sub pathify { confess "abstract method" } - -sub unixify { - my ( $self, $path ) = @_; - $path =~ tr{\\}{/}; - return $path; -} - -sub winnify { - my ( $self, $path ) = @_; - $path =~ tr{/}{\\}; - return $path; -} - -sub objectify { - my ( $self, $c_file ) = @_; - $c_file =~ s/\.c$/$self->{obj_ext}/ or die "No match: $c_file"; - return $c_file; -} - -sub execify { - my ( $self, $file ) = @_; - $file =~ s/.*?(\w+)\.c$/$1$self->{exe_ext}/ or die "No match: $file"; - return $file; -} - -sub build_link_command { - my ( $self, %args ) = @_; - my $objects = join( " ", @{ $args{objects} } ); - return "\$(CC) \$(CFLAGS) $objects -o $args{target}"; -} - -sub c2o_rule { - qq|.c.o:\n\t\$(CC) \$(CFLAGS) -c \$*.c -o \$@|; -} - -sub test_block { - my ( $self, $c_test_case ) = @_; - my $exe = $self->execify($c_test_case); - my $obj = $self->objectify($c_test_case); - my $test_obj - = $self->pathify( $self->objectify("src/Charmonizer/Test.c") ); - my $link_command = $self->build_link_command( - objects => [ $obj, $test_obj ], - target => '$@', - ); - return qq|$exe: $test_obj $obj\n\t$link_command|; -} - -sub clean_rule { confess "abstract method" } - -sub clean_rule_posix { - qq|clean:\n\trm -f \$(CLEANABLE)|; -} - -sub clean_rule_win { - qq|clean:\n\tCMD /c FOR %i IN (\$(CLEANABLE)) DO IF EXIST %i DEL /F %i|; -} - -sub meld_rule { confess "abstract method" } - -sub meld_rule_posix { - qq|meld:\n\t\$(PERL) buildbin/meld.pl --probes=\$(PROBES) | - . qq|--files=\$(FILES) --out=\$(OUT)|; -} - -sub meld_rule_win { - qq|meld:\n\t\$(PERL) buildbin\\meld.pl --probes=\$(PROBES) | - . qq|--files=\$(FILES) --out=\$(OUT)|; -} - -sub charmony_h_rule { confess "abstract method" } - -sub charmony_h_rule_posix { - return <<"EOF"; -\$(CHARMONY_H): \$(PROGNAME) -\t./\$(PROGNAME) --cc=\$(CC) --enable-c -EOF -} - -sub charmony_h_rule_win { - return <<"EOF"; -\$(CHARMONY_H): \$(PROGNAME) -\t\$(PROGNAME) --cc=\$(CC) --enable-c -EOF -} - -sub test_rule { confess "abstract method" } - -sub test_rule_posix { - return <<"EOF"; -test: tests -\tprove ./Test* -EOF -} - -sub test_rule_win { - return <<"EOF"; -test: tests -\tprove Test* -EOF -} - -sub gen_makefile { - my ( $self, %args ) = @_; - my ( $h_files, $c_files, $c_tests, $c_test_cases ) - = @$self{qw( h_files c_files c_tests c_test_cases )}; - - # Derive chunks of Makefile content. - my $progname = $self->execify('charmonize.c'); - my $c2o_rule = $self->c2o_rule; - my $meld_rule = $self->meld_rule; - my $charmony_h_rule = $self->charmony_h_rule; - my $test_rule = $self->test_rule; - my $progname_link_command = $self->build_link_command( - objects => ['$(OBJS)'], - target => '$(PROGNAME)', - ); - my $clean_rule = $self->clean_rule; - my $objs = join " ", map { $self->objectify($_) } @$c_files; - my $test_objs = join " ", map { $self->objectify($_) } @$c_tests; - my $test_blocks = join "\n\n", - map { $self->test_block($_) } @$c_test_cases; - my $test_execs = join " ", map { $self->execify($_) } @$c_test_cases; - my $headers = join " ", @$h_files; - - # Write out Makefile content. - open my $fh, ">", $self->{filename} - or die "open '$self->{filename}' failed: $!\n"; - my $content = <<EOT; -# GENERATED BY $FindBin::Script: do not hand-edit!!! - -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You 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. - -CC= $self->{cc} -DEFS= -CFLAGS= -I. -Isrc \$(DEFS) $self->{extra_cflags} -PROGNAME= $progname -CHARMONY_H= charmony.h -PROBES= -FILES= -OUT= -PERL=/usr/bin/perl - -TESTS= $test_execs - -OBJS= $objs - -TEST_OBJS= $test_objs - -HEADERS= $headers - -CLEANABLE= \$(OBJS) \$(PROGNAME) \$(CHARMONY_H) \$(TEST_OBJS) \$(TESTS) $self->{extra_clean} - -$c2o_rule - -all: \$(PROGNAME) - -$meld_rule - -$charmony_h_rule - -\$(PROGNAME): \$(OBJS) -\t$progname_link_command - -\$(OBJS) \$(TEST_OBJS): \$(HEADERS) - -\$(TEST_OBJS): \$(CHARMONY_H) - -tests: \$(TESTS) - -$test_blocks - -$test_rule - -$clean_rule - -EOT - print $fh $content; -} - -package Charmonizer::Build::Makefile::Posix; -BEGIN { our @ISA = qw( Charmonizer::Build::Makefile ) } - -sub new { - my $class = shift; - return $class->SUPER::new( - filename => 'Makefile', - obj_ext => '.o', - exe_ext => '', - cc => 'cc', - @_ - ); -} - -sub clean_rule { shift->clean_rule_posix } -sub meld_rule { shift->meld_rule_posix } -sub charmony_h_rule { shift->charmony_h_rule_posix } -sub test_rule { shift->test_rule_posix } -sub pathify { shift->unixify(@_) } - -package Charmonizer::Build::Makefile::MSVC; -BEGIN { our @ISA = qw( Charmonizer::Build::Makefile ) } - -sub new { - my $class = shift; - my $flags - = '-nologo -D_CRT_SECURE_NO_WARNINGS ' . '-D_SCL_SECURE_NO_WARNINGS'; - return $class->SUPER::new( - filename => 'Makefile.MSVC', - obj_ext => '.obj', - exe_ext => '.exe', - cc => 'cl', - extra_cflags => $flags, - extra_clean => '*.pdb', - @_ - ); -} - -sub c2o_rule { - qq|.c.obj:\n\t\$(CC) \$(CFLAGS) -c \$< -Fo\$@|; -} - -sub build_link_command { - my ( $self, %args ) = @_; - my $objects = join( " ", @{ $args{objects} } ); - return "link -nologo $objects /OUT:$args{target}"; -} - -sub pathify { shift->winnify(@_) } -sub clean_rule { shift->clean_rule_win } -sub meld_rule { shift->meld_rule_win } -sub charmony_h_rule { shift->charmony_h_rule_win } -sub test_rule { shift->test_rule_win } - -package Charmonizer::Build::Makefile::MinGW; -BEGIN { our @ISA = qw( Charmonizer::Build::Makefile ) } - -sub new { - my $class = shift; - return $class->SUPER::new( - filename => 'Makefile.MinGW', - obj_ext => '.o', - exe_ext => '.exe', - cc => 'gcc', - @_ - ); -} - -sub pathify { shift->winnify(@_) } -sub clean_rule { shift->clean_rule_win } -sub meld_rule { shift->meld_rule_win } -sub charmony_h_rule { shift->charmony_h_rule_win } -sub test_rule { shift->test_rule_win } - -### actual script follows -package main; - -my $makefile_posix = Charmonizer::Build::Makefile::Posix->new( dir => '.' ); -my $makefile_msvc = Charmonizer::Build::Makefile::MSVC->new( dir => '.' ); -my $makefile_mingw = Charmonizer::Build::Makefile::MinGW->new( dir => '.' ); -$makefile_posix->gen_makefile; -$makefile_msvc->gen_makefile; -$makefile_mingw->gen_makefile; - -__END__ - -=head1 NAME - -gen_charmonizer_makefiles.pl - -=head1 SYNOPSIS - - gen_charmonizer_makefiles.pl - keeps the Makefiles in sync with the live tree. - -=head1 DESCRIPTION - -Be sure to run this code from the charmonizer subdirectory (where the -existing Makefiles live). - http://git-wip-us.apache.org/repos/asf/lucy-charmonizer/blob/6adc7977/regen_charmonizer.pl ---------------------------------------------------------------------- diff --git a/regen_charmonizer.pl b/regen_charmonizer.pl new file mode 100755 index 0000000..c39b58a --- /dev/null +++ b/regen_charmonizer.pl @@ -0,0 +1,36 @@ +#!/usr/bin/perl + +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You 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. + +use strict; +use warnings; + +use FindBin qw( $Bin ); +use File::Spec::Functions qw( catfile ); + +# Execute from the root of the Charmonizer repository. +chdir $Bin; + +my $MELD_EXE = catfile( 'buildbin', 'meld.pl' ); +die("Couldn't find meld.pl at $MELD_EXE") + if !-e $MELD_EXE; + +my $main = catfile(qw( tests charmonizer.main )); +my $out = $main; +$out =~ s/\.main/.c/ or die "no match"; +unlink $out; +system( $MELD_EXE, '--probes=', "--files=$main", "--out=$out" ); + http://git-wip-us.apache.org/repos/asf/lucy-charmonizer/blob/6adc7977/samples/configure ---------------------------------------------------------------------- diff --git a/samples/configure b/samples/configure deleted file mode 100755 index ba1281f..0000000 --- a/samples/configure +++ /dev/null @@ -1,47 +0,0 @@ -#!/bin/sh - -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You 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. - -probe_clang() { clang -v; } -probe_gcc() { gcc -v; } - -if [ -z "$CC" ]; then - case $(uname) in - Darwin*) compilers="clang gcc";; - *) compilers="gcc clang";; - esac - - for compiler in $compilers; do - if probe_$compiler >/dev/null 2>&1; then - CC=$compiler - break - fi - done - - if [ -z "$CC" ]; then - CC=cc - fi -fi - -echo "Using C compiler '$CC'" - -command="$CC charmonizer.c -o charmonizer" -echo $command -$command || exit - -echo Running charmonizer -./charmonizer --cc=$CC --enable-c --enable-makefile "$@" - http://git-wip-us.apache.org/repos/asf/lucy-charmonizer/blob/6adc7977/samples/configure.bat ---------------------------------------------------------------------- diff --git a/samples/configure.bat b/samples/configure.bat deleted file mode 100644 index cf65d36..0000000 --- a/samples/configure.bat +++ /dev/null @@ -1,46 +0,0 @@ -@echo off - -rem Licensed to the Apache Software Foundation (ASF) under one or more -rem contributor license agreements. See the NOTICE file distributed with -rem this work for additional information regarding copyright ownership. -rem The ASF licenses this file to You under the Apache License, Version 2.0 -rem (the "License"); you may not use this file except in compliance with -rem the License. You may obtain a copy of the License at -rem -rem http://www.apache.org/licenses/LICENSE-2.0 -rem -rem Unless required by applicable law or agreed to in writing, software -rem distributed under the License is distributed on an "AS IS" BASIS, -rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -rem See the License for the specific language governing permissions and -rem limitations under the License. - -setlocal -set CL= -cl >nul 2>nul -endlocal -if not errorlevel 1 goto found_cl - -gcc -v >nul 2>nul -if not errorlevel 1 goto found_gcc - -echo No C compiler found -exit /b 1 - -:found_cl -echo Using C compiler 'cl' -echo cl /nologo charmonizer.c -cl /nologo charmonizer.c -if errorlevel 1 exit /b 1 -echo Running charmonizer -charmonizer.exe --cc=cl --enable-c --enable-makefile %* -exit /b - -:found_gcc -echo Using C compiler 'gcc' -echo gcc charmonizer.c -o charmonizer.exe -gcc charmonizer.c -o charmonizer.exe -if errorlevel 1 exit /b 1 -echo Running charmonizer -charmonizer.exe --cc=gcc --enable-c --enable-makefile %* -exit /b http://git-wip-us.apache.org/repos/asf/lucy-charmonizer/blob/6adc7977/src/Charmonizer/Test.c ---------------------------------------------------------------------- diff --git a/src/Charmonizer/Test.c b/src/Charmonizer/Test.c deleted file mode 100644 index 868375b..0000000 --- a/src/Charmonizer/Test.c +++ /dev/null @@ -1,205 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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 <stdio.h> -#include <stdlib.h> -#include <string.h> -#include "Charmonizer/Test.h" - -struct chaz_TestBatch { - unsigned test_num; - unsigned num_tests; - unsigned num_passed; - unsigned num_failed; - unsigned num_skipped; -}; - -chaz_TestBatch* -chaz_Test_current = NULL; - -void -chaz_Test_init(void) { - /* Unbuffer stdout. */ - int check_val = setvbuf(stdout, NULL, _IONBF, 0); - if (check_val != 0) { - fprintf(stderr, "Failed when trying to unbuffer stdout\n"); - } -} - -chaz_TestBatch* -chaz_Test_new_batch(unsigned num_tests) { - chaz_TestBatch *batch = (chaz_TestBatch*)malloc(sizeof(chaz_TestBatch)); - if (!batch) { - fprintf(stderr, "Out of memory\n"); - return NULL; - } - - /* Assign. */ - batch->num_tests = num_tests; - - /* Initialize. */ - batch->test_num = 0; - batch->num_passed = 0; - batch->num_failed = 0; - batch->num_skipped = 0; - - return batch; -} - -chaz_TestBatch* -chaz_Test_start(unsigned num_tests) { - if (chaz_Test_current) { - fprintf(stderr, "Already started testing\n"); - return NULL; - } - chaz_Test_init(); - chaz_Test_current = chaz_Test_new_batch(num_tests); - CHAZ_TEST_PLAN(chaz_Test_current); - return chaz_Test_current; -} - -int -chaz_Test_finish(void) { - int remainder = chaz_Test_current->num_tests - - chaz_Test_current->num_passed - - chaz_Test_current->num_skipped; - free(chaz_Test_current); - chaz_Test_current = NULL; - return !remainder; -} - -void -chaz_Test_plan(chaz_TestBatch *batch) { - printf("1..%u\n", batch->num_tests); -} - -void -chaz_Test_ok(chaz_TestBatch *batch, int value, const char *message) { - /* Increment test number. */ - batch->test_num++; - - /* Test condition and pass or fail. */ - if (value) { - printf("ok %u - %s\n", batch->test_num, message); - batch->num_passed++; - } - else { - printf("not ok %u - %s\n", batch->test_num, message); - batch->num_failed++; - } -} - -void -chaz_Test_str_eq(chaz_TestBatch *batch, const char *got, - const char *expected, const char *message) { - /* Increment test number. */ - batch->test_num++; - - /* Test condition and pass or fail. */ - if (strcmp(expected, got) == 0) { - printf("ok %u - %s\n", batch->test_num, message); - batch->num_passed++; - } - else { - printf("not ok %u - Expected '%s', got '%s'\n # %s\n", - batch->test_num, expected, got, message); - batch->num_failed++; - } -} - - -void -chaz_Test_pass(chaz_TestBatch *batch, const char *message) { - /* Increment test number. */ - batch->test_num++; - - /* Indicate pass, update pass counter. */ - printf("ok %u - %s\n", batch->test_num, message); - batch->num_passed++; -} - -void -chaz_Test_fail(chaz_TestBatch *batch, const char *message) { - /* Increment test number. */ - batch->test_num++; - - /* Indicate failure, update pass counter. */ - printf("not ok %u - %s\n", batch->test_num, message); - batch->num_failed++; -} - -void -chaz_Test_long_eq(chaz_TestBatch *batch, long got, long expected, - const char *message) { - /* Increment test number. */ - batch->test_num++; - - if (expected == got) { - printf("ok %u - %s\n", batch->test_num, message); - batch->num_passed++; - } - else { - printf("not ok %u - Expected '%ld', got '%ld'\n # %s", - batch->test_num, expected, got, message); - batch->num_failed++; - } -} - -void -chaz_Test_double_eq(chaz_TestBatch *batch, double got, double expected, - double slop, const char *message) { - double diff = expected - got; - if (diff < 0) { - diff = 0 - diff; - } - - /* Increment test number. */ - batch->test_num++; - - /* Evaluate condition and pass or fail. */ - if (diff < slop) { - printf("ok %u - %s\n", batch->test_num, message); - batch->num_passed++; - } - else { - printf("not ok %u - Expected '%f', got '%f'\n # %s\n", - batch->test_num, expected, got, message); - batch->num_failed++; - } -} - -void -chaz_Test_skip(chaz_TestBatch *batch, const char *message) { - /* Increment test number. */ - batch->test_num++; - - /* Indicate that test is being skipped, update pass counter. */ - printf("ok %u # SKIP %s\n", batch->test_num, message); - batch->num_skipped++; -} - -void -chaz_Test_skip_remaining(chaz_TestBatch *batch, const char *message) { - unsigned remaining = batch->num_tests - batch->test_num; - - /* Indicate that tests are being skipped, update skip counter. */ - printf("# Skipping all %u remaining tests: %s\n", remaining, message); - while (batch->test_num < batch->num_tests) { - chaz_Test_skip(batch, ""); - } -} - - http://git-wip-us.apache.org/repos/asf/lucy-charmonizer/blob/6adc7977/src/Charmonizer/Test.h ---------------------------------------------------------------------- diff --git a/src/Charmonizer/Test.h b/src/Charmonizer/Test.h deleted file mode 100644 index d876c38..0000000 --- a/src/Charmonizer/Test.h +++ /dev/null @@ -1,140 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -/* Charmonizer/Test.h - test Charmonizer's output. - */ - -#ifndef H_CHAZ_TEST -#define H_CHAZ_TEST - -#ifdef __cplusplus -extern "C" { -#endif - -#include "Charmonizer/Core/Defines.h" - -typedef struct chaz_TestBatch chaz_TestBatch; - -/* Begin a test run. - */ -chaz_TestBatch* -chaz_Test_start(unsigned num_tests); - -/* End a test run. Returns true if all tests were run and there were no - * failures, false otherwise. - */ -int -chaz_Test_finish(void); - -/* Unbuffer stdout. Perform any other setup needed. - */ -void -chaz_Test_init(void); - -/* Constructor for TestBatch. - */ -chaz_TestBatch* -chaz_Test_new_batch(unsigned num_tests); - -#define CHAZ_TEST_PLAN chaz_Test_plan -void -chaz_Test_plan(chaz_TestBatch *batch); - -#define CHAZ_TEST_OK(_expression, _message) \ - chaz_Test_ok(chaz_Test_current, (_expression), (_message)) -void -chaz_Test_ok(chaz_TestBatch *batch, int expression, const char *message); - -#define CHAZ_TEST_STR_EQ(_got, _expected, _message) \ - chaz_Test_str_eq(chaz_Test_current, (_got), (_expected), (_message)) -void -chaz_Test_str_eq(chaz_TestBatch *batch, const char *got, - const char *expected, const char *message); - -#define CHAZ_TEST_PASS(_message) \ - chaz_Test_pass(chaz_Test_current, (_message)) -void -chaz_Test_pass(chaz_TestBatch *batch, const char *message); - -#define CHAZ_TEST_FAIL(_message) \ - chaz_Test_fail(chaz_Test_current, (_message)) -void -chaz_Test_fail(chaz_TestBatch *batch, const char *message); - -#define CHAZ_TEST_LONG_EQ(_got, _expected, _message) \ - chaz_Test_long_eq(chaz_Test_current, (_got), (_expected), (_message)) -void -chaz_Test_long_eq(chaz_TestBatch *batch, long got, long expected, - const char *message); - -#define CHAZ_TEST_DOUBLE_EQ(_got, _expected, _slop, _message) \ - chaz_Test_double_eq(chaz_Test_current, (_got), (_expected), (_slop), \ - (_message)) -void -chaz_Test_double_eq(chaz_TestBatch *batch, double got, double expected, - double slop, const char *message); - -/* Print a message indicating that a test was skipped and update batch. - */ -#define CHAZ_TEST_SKIP(_message) \ - chaz_Test_skip(chaz_Test_current, (_message)) -void -chaz_Test_skip(chaz_TestBatch *batch, const char *message); - -/* Print a message indicating that all remaining tests will be skipped and - * then call SKIP once for each. - */ -#define CHAZ_TEST_SKIP_REMAINING(_message) \ - chaz_Test_skip_remaining(chaz_Test_current, (_message)) -void -chaz_Test_skip_remaining(chaz_TestBatch* batch, const char *message); - -/* Global TestBatch implicitly accessed by testing macros. */ -extern chaz_TestBatch *chaz_Test_current; - -#ifdef CHAZ_USE_SHORT_NAMES - #define Test_start chaz_Test_start - #define Test_finish chaz_Test_finish - #define OK CHAZ_TEST_OK - #define STR_EQ CHAZ_TEST_STR_EQ - #define LONG_EQ CHAZ_TEST_LONG_EQ - #define DOUBLE_EQ CHAZ_TEST_DOUBLE_EQ - #define PASS CHAZ_TEST_PASS - #define FAIL CHAZ_TEST_FAIL - #define SKIP CHAZ_TEST_SKIP - #define SKIP_REMAINING CHAZ_TEST_SKIP_REMAINING - #define TestBatch chaz_TestBatch - #define Test_init chaz_Test_init - #define Test_new_batch chaz_Test_new_batch - #define Test_plan chaz_Test_plan - #define PLAN CHAZ_TEST_PLAN - #define Test_str_eq chaz_Test_str_eq - #define Test_long_eq chaz_Test_long_eq - #define Test_double_eq chaz_Test_double_eq - #define Test_pass chaz_Test_pass - #define Test_fail chaz_Test_fail - #define Test_skip chaz_Test_skip - #define Test_skip_remaining chaz_Test_skip_remaining -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* H_CHAZ_TEST */ - - - http://git-wip-us.apache.org/repos/asf/lucy-charmonizer/blob/6adc7977/src/Charmonizer/Test/TestDirManip.c ---------------------------------------------------------------------- diff --git a/src/Charmonizer/Test/TestDirManip.c b/src/Charmonizer/Test/TestDirManip.c deleted file mode 100644 index 626f5af..0000000 --- a/src/Charmonizer/Test/TestDirManip.c +++ /dev/null @@ -1,71 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -#define CHAZ_USE_SHORT_NAMES - -#include "Charmonizer/Test.h" -#include <stdio.h> -#include <string.h> -#include "charmony.h" -#ifdef HAS_DIRENT_H - #include <dirent.h> -#endif -#ifdef HAS_SYS_STAT_H - #include <sys/stat.h> -#endif -#ifdef HAS_SYS_TYPES_H - #include <sys/stat.h> -#endif -#ifdef HAS_UNISTD_H - #include <unistd.h> -#endif -#ifdef HAS_DIRECT_H - #include <direct.h> -#endif - -static void -S_run_tests(void) { - LONG_EQ(0, makedir("_chaz_test_dir", 0777), "makedir"); - LONG_EQ(0, makedir("_chaz_test_dir" DIR_SEP "deep", 0777), - "makedir with DIR_SEP"); - LONG_EQ(0, rmdir("_chaz_test_dir" DIR_SEP "deep"), "rmdir with DIR_SEP"); - LONG_EQ(0, rmdir("_chaz_test_dir"), "rmdir"); -#ifdef CHY_HAS_DIRENT_D_NAMLEN - { - struct dirent entry; - entry.d_namlen = 5; - LONG_EQ(5, entry.d_namlen, "d_namlen"); - } -#else - SKIP("no d_namlen member on this platform"); -#endif -#ifdef CHY_HAS_DIRENT_D_TYPE - { - struct dirent entry; - entry.d_type = 5; - LONG_EQ(5, entry.d_type, "d_type"); - } -#else - SKIP("no d_type member on this platform"); -#endif -} - -int main(int argc, char **argv) { - Test_start(6); - S_run_tests(); - return !Test_finish(); -} - http://git-wip-us.apache.org/repos/asf/lucy-charmonizer/blob/6adc7977/src/Charmonizer/Test/TestFuncMacro.c ---------------------------------------------------------------------- diff --git a/src/Charmonizer/Test/TestFuncMacro.c b/src/Charmonizer/Test/TestFuncMacro.c deleted file mode 100644 index dded9bb..0000000 --- a/src/Charmonizer/Test/TestFuncMacro.c +++ /dev/null @@ -1,63 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -#define CHAZ_USE_SHORT_NAMES - -#include "charmony.h" -#include <string.h> -#include "Charmonizer/Test.h" - -#ifdef INLINE -static INLINE const char* S_inline_function() { - return "inline works"; -} -#endif - -static void -S_run_tests(void) { - -#ifdef HAS_FUNC_MACRO - STR_EQ(FUNC_MACRO, "S_run_tests", "FUNC_MACRO"); -#else - SKIP("no FUNC_MACRO"); -#endif - -#ifdef HAS_ISO_FUNC_MACRO - STR_EQ(__func__, "S_run_tests", "HAS_ISO_FUNC_MACRO"); -#else - SKIP("no ISO_FUNC_MACRO"); -#endif - -#ifdef HAS_GNUC_FUNC_MACRO - STR_EQ(__FUNCTION__, "S_run_tests", "HAS_GNUC_FUNC_MACRO"); -#else - SKIP("no GNUC_FUNC_MACRO"); -#endif - -#ifdef INLINE - PASS(S_inline_function()); -#else - SKIP("no INLINE functions"); -#endif -} - - -int main(int argc, char **argv) { - Test_start(4); - S_run_tests(); - return !Test_finish(); -} - http://git-wip-us.apache.org/repos/asf/lucy-charmonizer/blob/6adc7977/src/Charmonizer/Test/TestHeaders.c ---------------------------------------------------------------------- diff --git a/src/Charmonizer/Test/TestHeaders.c b/src/Charmonizer/Test/TestHeaders.c deleted file mode 100644 index 210b7f6..0000000 --- a/src/Charmonizer/Test/TestHeaders.c +++ /dev/null @@ -1,164 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -#define CHAZ_USE_SHORT_NAMES - -#include "charmony.h" -#include <string.h> -#include "Charmonizer/Test.h" - -#ifdef HAS_ASSERT_H - #include <assert.h> -#endif -#ifdef HAS_CTYPE_H - #include <ctype.h> -#endif -#ifdef HAS_ERRNO_H - #include <errno.h> -#endif -#ifdef HAS_FLOAT_H - #include <float.h> -#endif -#ifdef HAS_LIMITS_H - #include <limits.h> -#endif -#ifdef HAS_LOCALE_H - #include <locale.h> -#endif -#ifdef HAS_MATH_H - #include <math.h> -#endif -#ifdef HAS_SETJMP_H - #include <setjmp.h> -#endif -#ifdef HAS_SIGNAL_H - #include <signal.h> -#endif -#ifdef HAS_STDARG_H - #include <stdarg.h> -#endif -#ifdef HAS_STDDEF_H - #include <stddef.h> -#endif -#ifdef HAS_STDIO_H - #include <stdio.h> -#endif -#ifdef HAS_STDLIB_H - #include <stdlib.h> -#endif -#ifdef HAS_STRING_H - #include <string.h> -#endif -#ifdef HAS_TIME_H - #include <time.h> -#endif - -#ifdef HAS_CPIO_H - #include <cpio.h> -#endif -#ifdef HAS_DIRENT_H - #include <dirent.h> -#endif -#ifdef HAS_FCNTL_H - #include <fcntl.h> -#endif -#ifdef HAS_GRP_H - #include <grp.h> -#endif -#ifdef HAS_PWD_H - #include <pwd.h> -#endif -#ifdef HAS_SYS_STAT_H - #include <sys/stat.h> -#endif -#ifdef HAS_SYS_TIMES_H - #include <sys/times.h> -#endif -#ifdef HAS_SYS_TYPES_H - #include <sys/types.h> -#endif -#ifdef HAS_SYS_UTSNAME_H - #include <sys/utsname.h> -#endif -#ifdef HAS_WAIT_H - #include <wait.h> -#endif -#ifdef HAS_TAR_H - #include <tar.h> -#endif -#ifdef HAS_TERMIOS_H - #include <termios.h> -#endif -#ifdef HAS_UNISTD_H - #include <unistd.h> -#endif -#ifdef HAS_UTIME_H - #include <utime.h> -#endif - -#if defined(HAS_C89) || defined(HAS_C90) - #include <assert.h> - #include <ctype.h> - #include <errno.h> - #include <float.h> - #include <limits.h> - #include <locale.h> - #include <math.h> - #include <setjmp.h> - #include <signal.h> - #include <stdarg.h> - #include <stddef.h> - #include <stdio.h> - #include <stdlib.h> - #include <string.h> - #include <time.h> -#endif - -#ifdef HAS_POSIX - #include <cpio.h> - #include <dirent.h> - #include <fcntl.h> - #include <grp.h> - #include <pwd.h> - #include <sys/stat.h> - #include <sys/times.h> - #include <sys/types.h> - #include <sys/utsname.h> - #include <sys/wait.h> - #include <tar.h> - #include <termios.h> - #include <unistd.h> - #include <utime.h> -#endif - -static void -S_run_tests(void) { - PASS("Compiled successfully with all detected headers"); - - /* Don't bother checking all -- just use stdio as an example. */ -#ifdef HAS_STDIO_H - PASS("stdio.h should have been detected"); -#else - FAIL("stdio.h should have been detected"); -#endif -} - -int main(int argc, char **argv) { - Test_start(2); - S_run_tests(); - return !Test_finish(); -} - http://git-wip-us.apache.org/repos/asf/lucy-charmonizer/blob/6adc7977/src/Charmonizer/Test/TestIntegers.c ---------------------------------------------------------------------- diff --git a/src/Charmonizer/Test/TestIntegers.c b/src/Charmonizer/Test/TestIntegers.c deleted file mode 100644 index 32cf9aa..0000000 --- a/src/Charmonizer/Test/TestIntegers.c +++ /dev/null @@ -1,127 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -#define CHAZ_USE_SHORT_NAMES -#define CHY_EMPLOY_BOOLEANS -#define CHY_EMPLOY_INTEGERTYPES -#define CHY_EMPLOY_INTEGERLITERALS -#define CHY_EMPLOY_INTEGERFORMATSTRINGS - -#include "Charmonizer/Test.h" -#include "charmony.h" -#include <stdio.h> -#include <string.h> - -static void -S_run_tests(TestBatch *batch) { - { - long one = 1; - long big_endian = !(*((char *)(&one))); -#ifdef BIG_END - OK(big_endian, "BIG_END"); -#else - #if defined(LITTLE_END) - OK(!big_endian, "LITTLE_END"); - #else - FAIL("Either BIG_END or LITTLE_END should be defined"); - #endif -#endif - } - - LONG_EQ(SIZEOF_CHAR, sizeof(char), "SIZEOF_CHAR"); - LONG_EQ(SIZEOF_SHORT, sizeof(short), "SIZEOF_SHORT"); - LONG_EQ(SIZEOF_INT, sizeof(int), "SIZEOF_INT"); - LONG_EQ(SIZEOF_LONG, sizeof(long), "SIZEOF_LONG"); - LONG_EQ(SIZEOF_PTR, sizeof(void*), "SIZEOF_PTR"); - -#ifdef HAS_LONG_LONG - LONG_EQ(SIZEOF_LONG_LONG, sizeof(long long), - "HAS_LONG_LONG and SIZEOF_LONG_LONG"); -#else - SKIP("No 'long long' type"); -#endif - - { - bool the_truth = true; - OK(the_truth, "bool true"); - OK(!false, "false is false"); - } -#ifdef HAS_INT8_T - { - int8_t foo = -100; - uint8_t bar = 200; - LONG_EQ(foo, -100, "int8_t is signed"); - LONG_EQ(bar, 200, "uint8_t is unsigned"); - LONG_EQ(sizeof(int8_t), 1, "i8_t is 1 byte"); - LONG_EQ(sizeof(uint8_t), 1, "u8_t is 1 byte"); - LONG_EQ(INT8_MAX, 127, "INT8_MAX"); - LONG_EQ(INT8_MIN, -128, "INT8_MIN"); - LONG_EQ(UINT8_MAX, 255, "UINT8_MAX"); - } -#endif -#ifdef HAS_INT16_T - { - int16_t foo = -100; - uint16_t bar = 30000; - LONG_EQ(foo, -100, "int16_t is signed"); - LONG_EQ(bar, 30000, "uint16_t is unsigned"); - LONG_EQ(sizeof(int16_t), 2, "int16_t is 2 bytes"); - LONG_EQ(sizeof(uint16_t), 2, "uint16_t is 2 bytes"); - LONG_EQ(INT16_MAX, 32767, "INT16_MAX"); - LONG_EQ(INT16_MIN, -32768, "INT16_MIN"); - LONG_EQ(UINT16_MAX, 65535, "UINT16_MAX"); - } -#endif -#ifdef HAS_INT32_T - { - int32_t foo = -100; - uint32_t bar = 4000000000UL; - OK((foo == -100), "int32_t is signed"); - OK((bar == 4000000000UL), "uint32_t is unsigned"); - OK((sizeof(int32_t) == 4), "int32_t is 4 bytes"); - OK((sizeof(uint32_t) == 4), "uint32_t is 4 bytes"); - OK((INT32_MAX == INT32_C(2147483647)), "INT32_MAX"); - /* The (-2147483647 - 1) avoids a compiler warning. */ - OK((INT32_MIN == -INT32_C(2147483647) - 1), "INT32_MIN"); - OK((UINT32_MAX == UINT32_C(4294967295)), "UINT32_MAX"); - } -#endif -#ifdef HAS_INT64_T - { - char buf[100]; - int64_t foo = -100; - uint64_t bar = UINT64_C(18000000000000000000); - OK((foo == -100), "int64_t is signed"); - OK((bar == UINT64_C(18000000000000000000)), "uint64_t is unsigned"); - OK((sizeof(int64_t) == 8), "int64_t is 8 bytes"); - OK((sizeof(uint64_t) == 8), "uint64_t is 8 bytes"); - OK((INT64_MAX == INT64_C(0x7FFFFFFFFFFFFFFF)), "INT64_MAX"); - OK((INT64_MIN == -INT64_C(0x7FFFFFFFFFFFFFFF) - 1), "INT64_MIN"); - OK((UINT64_MAX == UINT64_C(0xFFFFFFFFFFFFFFFF)), "UINT64_MAX"); - sprintf(buf, "%"PRId64, foo); - STR_EQ(buf, "-100", "PRId64"); - sprintf(buf, "%"PRIu64, bar); - STR_EQ(buf, "18000000000000000000", "PRIu64"); - } -#endif -} - -int main(int argc, char **argv) { - TestBatch *batch = Test_start(39); - S_run_tests(batch); - return !Test_finish(); -} - http://git-wip-us.apache.org/repos/asf/lucy-charmonizer/blob/6adc7977/src/Charmonizer/Test/TestLargeFiles.c ---------------------------------------------------------------------- diff --git a/src/Charmonizer/Test/TestLargeFiles.c b/src/Charmonizer/Test/TestLargeFiles.c deleted file mode 100644 index 5127229..0000000 --- a/src/Charmonizer/Test/TestLargeFiles.c +++ /dev/null @@ -1,281 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -#define CHAZ_USE_SHORT_NAMES -#define CHY_EMPLOY_INTEGERLITERALS - -#include "charmony.h" -#include <string.h> -#include <errno.h> - -#ifdef CHAZ_HAS_SYS_TYPES_H - #include <sys/types.h> -#endif -#ifdef CHAZ_HAS_FCNTL_H - #include <fcntl.h> /* open, fcntl flags */ -#endif -#ifdef CHY_HAS_UNISTD_H - #include <unistd.h> /* close */ -#endif -#ifdef CHAZ_HAS_IO_H - #include <io.h> -#endif - -#include <stdio.h> -#include "Charmonizer/Test.h" - -#if (defined(HAS_64BIT_STDIO) \ - && defined(CHAZ_HAS_STAT_ST_SIZE) \ - && defined(CHAZ_HAS_STAT_ST_BLOCKS)) -#define STAT_TESTS_ENABLED - -#include <sys/stat.h> - -/* Determine whether we can use sparse files. - */ -static int -S_check_sparse_files(void); - -/* Helper for check_sparse_files(). - */ -static int -S_test_sparse_file(long offset, struct stat *st); - -/* See if trying to write a 5 GB file in a subprocess bombs out. If it - * doesn't, then the test suite can safely verify large file support. - */ -static int -S_can_create_big_files(void); - -#endif /* criteria for defining STAT_TESTS_ENABLED */ - -#ifdef O_LARGEFILE - #define LARGEFILE_OPEN_FLAG O_LARGEFILE -#else - #define LARGEFILE_OPEN_FLAG 0 -#endif - -static void -S_run_tests(void) { - FILE *fh; - off64_t offset; - int check_val; - char check_char; - int fd; - - /* A little over 4 GB, and a little over 2 GB. */ - off64_t gb4_plus = ((off64_t)0x7FFFFFFF << 1) + 100; - off64_t gb2_plus = (off64_t)0x7FFFFFFF + 200; - - LONG_EQ(sizeof(off64_t), 8, "off64_t type has 8 bytes"); - -#ifndef HAS_64BIT_STDIO - SKIP_REMAINING("No stdio large file support"); - return; -#endif -#ifndef STAT_TESTS_ENABLED - SKIP_REMAINING("Need stat with st_size and st_blocks"); - return; -#else - /* Check for sparse files. */ - if (!S_check_sparse_files()) { - SKIP_REMAINING("Can't verify large file support " - "without sparse files"); - return; - } - if (!S_can_create_big_files()) { - SKIP_REMAINING("Unsafe to create 5GB sparse files on this system"); - return; - } - - fh = fopen64("_charm_large_file_test", "w+"); - if (fh == NULL) { - SKIP_REMAINING("Failed to open file"); - return; - } - - check_val = fseeko64(fh, gb4_plus, SEEK_SET); - LONG_EQ(check_val, 0, "fseeko64 above 4 GB"); - - offset = ftello64(fh); - OK((offset == gb4_plus), "ftello64 above 4 GB"); - - check_val = fprintf(fh, "X"); - LONG_EQ(check_val, 1, "print above 4 GB"); - - check_val = fseeko64(fh, gb2_plus, SEEK_SET); - LONG_EQ(check_val, 0, "fseeko64 above 2 GB"); - - offset = ftello64(fh); - OK((offset == gb2_plus), "ftello64 above 2 GB"); - - check_val = fseeko64(fh, -1, SEEK_END); - LONG_EQ(check_val, 0, "seek to near end"); - - check_char = fgetc(fh); - LONG_EQ(check_char, 'X', "read value after multiple seeks"); - - check_val = fclose(fh); - LONG_EQ(check_val, 0, "fclose succeeds after all that"); - - /* Truncate, just in case the call to remove fails. */ - fh = fopen64("_charm_large_file_test", "w+"); - if (fh != NULL) { - fclose(fh); - } - remove("_charm_large_file_test"); - -#ifndef HAS_64BIT_LSEEK - SKIP_REMAINING("No 64-bit lseek"); - return; -#else - fd = open("_charm_large_file_test", - O_RDWR | O_CREAT | LARGEFILE_OPEN_FLAG, 0666); - if (fd == -1) { - FAIL("open failed"); - SKIP_REMAINING("open failed"); - return; - } - - offset = lseek64(fd, gb4_plus, SEEK_SET); - OK(offset == gb4_plus, "lseek64 above 4 GB"); - - offset = lseek64(fd, 0, SEEK_CUR); - OK(offset == gb4_plus, "lseek64 in place above 4 GB"); - - check_val = write(fd, "X", 1); - LONG_EQ(check_val, 1, "write() above 4 GB"); - - offset = lseek64(fd, gb2_plus, SEEK_SET); - OK(offset == gb2_plus, "lseek64 above 2 GB"); - - offset = lseek64(fd, 0, SEEK_CUR); - OK((offset == gb2_plus), "lseek64 in place above 2 GB"); - - offset = lseek64(fd, -1, SEEK_END); - OK(offset == gb4_plus, "seek to near end"); - - check_val = read(fd, &check_char, 1); - LONG_EQ(check_val, 1, "read() after multiple lseek64 calls"); - LONG_EQ(check_char, 'X', - "read() correct data after multiple lseek64 calls"); -#ifdef HAS_64BIT_PREAD - check_char = 0; - check_val = pread64(fd, &check_char, 1, gb4_plus); - LONG_EQ(check_val, 1, "pread64"); - LONG_EQ(check_char, 'X', "pread64() correct data"); -#else - SKIP("no pread64"); - SKIP("no pread64"); -#endif - - check_val = close(fd); - LONG_EQ(check_val, 0, "close succeeds after all that"); -#endif - - /* Truncate, just in case the call to remove fails. */ - fh = fopen64("_charm_large_file_test", "w+"); - if (fh != NULL) { - fclose(fh); - } - remove("_charm_large_file_test"); -#endif /* STAT_TESTS_ENABLED */ -} - -#ifdef STAT_TESTS_ENABLED - -static int -S_check_sparse_files(void) { - struct stat st_a, st_b; - - /* Write and stat a 1 MB file and a 2 MB file, both of them sparse. */ - if (!S_test_sparse_file(1000000, &st_a)) { return false; } - if (!S_test_sparse_file(2000000, &st_b)) { return false; } - if (st_a.st_size != 1000001 || st_b.st_size != 2000001) { - return false; - } - - /* See if two files with very different lengths have the same block size. */ - return st_a.st_blocks == st_b.st_blocks ? true : false; -} - -static int -S_test_sparse_file(long offset, struct stat *st) { - FILE *sparse_fh; - int result = false; - - /* Make sure the file's not there, then open. */ - remove("_charm_sparse"); - if ((sparse_fh = fopen64("_charm_sparse", "w+")) == NULL) { - return false; - } - - /* Seek fh to [offset], write a byte, close file. */ - if ((fseeko64(sparse_fh, offset, SEEK_SET)) != -1) { - if ((fprintf(sparse_fh, "X")) == 1) { - result = true; - } - } - if (fclose(sparse_fh)) { - result = false; - } - - /* Stat the file. */ - stat("_charm_sparse", st); - - remove("_charm_sparse"); - return result; -} - -static int -S_can_create_big_files(void) { - int result = 0; - FILE *fh = fopen64("_charm_large_file_test", "w+"); - if (!fh) { - return false; - } - else { - /* Bail unless seek succeeds. */ - int64_t check_seek = fseeko64(fh, INT64_C(5000000000), SEEK_SET); - if (check_seek != -1) { - /* Bail unless we write successfully. */ - if (fprintf(fh, "X") == 1) { - result = true; - } - } - if (fclose(fh)) { - result = false; - } - } - - /* Truncate, just in case the call to remove fails. */ - fh = fopen64("_charm_large_file_test", "w"); - if (fh != NULL) { - fclose(fh); - } - remove("_charm_large_file_test"); - - return result; -} - -#endif /* STAT_TESTS_ENABLED */ - -int main(int argc, char **argv) { - Test_start(20); - S_run_tests(); - return !Test_finish(); -} - http://git-wip-us.apache.org/repos/asf/lucy-charmonizer/blob/6adc7977/src/Charmonizer/Test/TestUnusedVars.c ---------------------------------------------------------------------- diff --git a/src/Charmonizer/Test/TestUnusedVars.c b/src/Charmonizer/Test/TestUnusedVars.c deleted file mode 100644 index 09c3b04..0000000 --- a/src/Charmonizer/Test/TestUnusedVars.c +++ /dev/null @@ -1,42 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -#define CHAZ_USE_SHORT_NAMES - -#include "charmony.h" -#include "Charmonizer/Test.h" - -static void -S_run_tests(void) { -#ifdef UNUSED_VAR - PASS("UNUSED_VAR macro is defined"); -#else - FAIL("UNUSED_VAR macro is defined"); -#endif - -#ifdef UNREACHABLE_RETURN - PASS("UNREACHABLE_RETURN macro is defined"); -#else - FAIL("UNREACHABLE_RETURN macro is defined"); -#endif -} - -int main(int argc, char **argv) { - Test_start(2); - S_run_tests(); - return !Test_finish(); -} - http://git-wip-us.apache.org/repos/asf/lucy-charmonizer/blob/6adc7977/src/Charmonizer/Test/TestVariadicMacros.c ---------------------------------------------------------------------- diff --git a/src/Charmonizer/Test/TestVariadicMacros.c b/src/Charmonizer/Test/TestVariadicMacros.c deleted file mode 100644 index 4bfadfb..0000000 --- a/src/Charmonizer/Test/TestVariadicMacros.c +++ /dev/null @@ -1,69 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -#define CHAZ_USE_SHORT_NAMES - -#include "charmony.h" -#include <string.h> -#include <stdio.h> -#include "Charmonizer/Test.h" - -static void -S_run_tests(void) { - char buf[10]; - int really_has_var_macs = false; - -#if defined(HAS_ISO_VARIADIC_MACROS) || defined(HAS_GNUC_VARIADIC_MACROS) - #ifdef HAS_VARIADIC_MACROS - PASS("#defines agree"); - #else - FAIL(0, "#defines agree"); - #endif -#else - SKIP_REMAINING("No variadic macro support"); - return; -#endif - - -#ifdef HAS_ISO_VARIADIC_MACROS - #define ISO_TEST(buffer, fmt, ...) \ - sprintf(buffer, fmt, __VA_ARGS__) - really_has_var_macs = true; - ISO_TEST(buf, "%s", "iso"); - STR_EQ(buf, "iso", "ISO variadic macros work"); -#else - SKIP("No ISO variadic macros"); -#endif - -#ifdef HAS_GNUC_VARIADIC_MACROS - #define GNU_TEST(buffer, fmt, args...) \ - sprintf(buffer, fmt, ##args ) - really_has_var_macs = true; - GNU_TEST(buf, "%s", "gnu"); - STR_EQ(buf, "gnu", "GNUC variadic macros work"); -#else - SKIP("No GNUC variadic macros"); -#endif - - OK(really_has_var_macs, "either ISO or GNUC"); -} - -int main(int argc, char **argv) { - Test_start(4); - S_run_tests(); - return !Test_finish(); -} - http://git-wip-us.apache.org/repos/asf/lucy-charmonizer/blob/6adc7977/tests/.gitignore ---------------------------------------------------------------------- diff --git a/tests/.gitignore b/tests/.gitignore new file mode 100644 index 0000000..7c3a5f0 --- /dev/null +++ b/tests/.gitignore @@ -0,0 +1,4 @@ +/Makefile +/charmonizer +/libchaztest.* +/tests/test
