Changeset 01579ad in mainline


Ignore:
Timestamp:
2014-04-11T08:10:18Z (10 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
2bff9860
Parents:
9a5abb78
Message:

Start work on PCUT integration

PCUT is a simple library for (hopefully) easier unit testing.
See https://github.com/vhotspur/pcut for more details.

Files:
52 added
5 edited

Legend:

Unmodified
Added
Removed
  • HelenOS.config

    r9a5abb78 r01579ad  
    612612! CONFIG_WRITE_CORE_FILES (n/y)
    613613
     614% Build userspace unit tests (PCUT)
     615! CONFIG_PCUT_TESTS (n/y)
     616
    614617% Include development files (headers, libraries)
    615618! CONFIG_DEVEL_FILES (n/y)
  • boot/Makefile

    r9a5abb78 r01579ad  
    6868                cp "$$file" "$(DIST_PATH)/app/" ; \
    6969        done
     70ifeq ($(CONFIG_PCUT_TESTS),y)
     71        echo "echo Running all tests..." >"$(DIST_PATH)/test/run_all"
     72        echo "<html><head><title>HelenOS test results</title></head><body>" >"$(DIST_PATH)/test/test.html"
     73        echo "<h1>HelenOS test results</h1><ul>" >>"$(DIST_PATH)/test/test.html"
     74        for file in $(RD_TESTS) ; do \
     75                file2=`basename $$file`; \
     76                cp "$$file" "$(DIST_PATH)/test/" ; \
     77                echo "echo ' ->' $$file2" >>"$(DIST_PATH)/test/run_all"; \
     78                echo "/test/$$file2 | to /test/$$file2.out" >>"$(DIST_PATH)/test/run_all"; \
     79                echo "cat /test/$$file2.out" >>"$(DIST_PATH)/test/run_all"; \
     80                echo "cp -f /test/$$file2.out /data/web/result-$$file2.txt" >>"$(DIST_PATH)/test/run_all"; \
     81                echo "<li><a href=\"result-$$file2.txt\">$$file2</a></li>" >>"$(DIST_PATH)/test/test.html"; \
     82        done
     83        echo "cp -f /test/test.html /data/web/test.html" >>"$(DIST_PATH)/test/run_all"
     84        echo "</ul></body></html>" >>"$(DIST_PATH)/test/test.html"
     85endif
     86
    7087        for drv in $(RD_DRVS) ; do \
    7188                drv_dir="`dirname "$$drv"`" ; \
     
    100117        rm -rf $(USPACE_PATH)/dist/inc/*
    101118        rm -f $(USPACE_PATH)/dist/app/*
     119        rm -f $(USPACE_PATH)/dist/test/*
    102120        rm -f $(USPACE_PATH)/dist/cfg/net/*
  • boot/Makefile.common

    r9a5abb78 r01579ad  
    237237endif
    238238
     239RD_TESTS = \
     240
     241
    239242COMPONENTS = \
    240243        $(KERNEL_PATH)/kernel.bin \
  • uspace/Makefile

    r9a5abb78 r01579ad  
    247247        lib/gpt
    248248
     249ifeq ($(CONFIG_PCUT_TESTS),y)
     250        LIBS += lib/pcut
     251endif
     252
    249253LIBC_BUILD = $(addsuffix .build,$(LIBC))
    250254LIBS_BUILD = $(addsuffix .build,$(LIBS))
    251255LIBN_BUILD = $(addsuffix .build,$(LIBN))
    252256BUILDS := $(addsuffix .build,$(DIRS))
     257BUILDS_TESTS := $(addsuffix .build-test,$(DIRS) $(LIBS) lib/c)
    253258
    254259CLEANS := $(addsuffix .clean,$(DIRS)) $(addsuffix .clean,$(LIBN)) $(addsuffix .clean,$(LIBS)) $(addsuffix .clean,$(LIBC))
     
    256261.PHONY: all $(LIBC_BUILD) $(LIBS_BUILD) $(LIBN_BUILD) $(BUILDS) $(CLEANS) clean
    257262
    258 all: $(BUILDS)
     263all: $(BUILDS) $(BUILDS_TESTS)
     264
     265$(BUILDS_TESTS): $(BUILDS)
     266        $(MAKE) -C $(basename $@) all-test PRECHECK=$(PRECHECK)
    259267
    260268clean: $(CLEANS)
  • uspace/Makefile.common

    r9a5abb78 r01579ad  
    7878        JOB = $(BINARY).job
    7979        OUTPUT = $(BINARY)
     80        TEST_BINARY = test-$(BINARY)
    8081        EXTRA_OUTPUT += $(BINARY).disasm
    8182        EXTRA_CLEAN += $(BINARY).map
     
    8586        JOB = $(LIBRARY).job
    8687        OUTPUT = $(LIBRARY).a
     88        TEST_BINARY = test-$(LIBRARY)
    8789endif
    8890
     
    200202endif
    201203
     204# PCUT-based unit tests
     205ifeq ($(CONFIG_PCUT_TESTS),y)
     206ifneq ($(TEST_SOURCES),)
     207        TEST_OUTPUT = $(TEST_BINARY)
     208        TEST_CFLAGS = -I$(LIB_PREFIX)/pcut/include -D__helenos__
     209        TEST_OUTPUT_LIBS = $(LIB_PREFIX)/pcut/libpcut.a
     210ifneq ($(LIBRARY),)
     211        TEST_OUTPUT_LIBS += $(OUTPUT)
     212endif
     213        TEST_OUTPUT_LIBS += $(TEST_LIBS)
     214endif
     215endif
     216
    202217.PHONY: all clean
    203218
    204219all: $(VERSION_DEF) $(COMMON_MAKEFILE) $(CONFIG_MAKEFILE) $(CONFIG_HEADER) $(LIBS) $(OUTPUT) $(LOUTPUT) $(EXTRA_OUTPUT)
    205220        -[ -f $(DEPEND) ] && cp -a $(DEPEND) $(DEPEND_PREV)
     221
     222all-test: $(TEST_OUTPUT)
    206223
    207224clean:
     
    294311OBJECTS := $(addsuffix .o,$(basename $(SOURCES)))
    295312LOBJECTS := $(addsuffix .lo,$(basename $(SOURCES)))
     313TEST_OBJECTS := $(addsuffix .test.o,$(basename $(TEST_SOURCES)))
    296314
    297315ifneq ($(BINARY),)
     
    338356endif
    339357
     358ifeq ($(CONFIG_PCUT_TESTS),y)
     359ifneq ($(TEST_OUTPUT),)
     360$(TEST_OUTPUT): $(LINKER_SCRIPT) $(TEST_OBJECTS) $(TEST_OUTPUT_LIBS)
     361        $(LD) -n $(LFLAGS) -T $(LINKER_SCRIPT) -M -Map $(TEST_OUTPUT).map -o $@ $(TEST_OBJECTS) $(TEST_OUTPUT_LIBS) $(LIBS) $(BASE_LIBS)
     362ifeq ($(CONFIG_STRIP_BINARIES),y)
     363        $(STRIP) $(TEST_OUTPUT)
     364endif
     365endif
     366endif
     367
    340368%.o: %.S $(DEPEND)
    341369        $(GCC) $(DEFS) $(GCC_CFLAGS) -D__ASM__ -c $< -o $@
     
    356384endif
    357385
     386%.test.o: %.c $(DEPEND)
     387        $(CC) $(DEFS) $(CFLAGS) $(TEST_CFLAGS) -c $< -o $@
     388ifeq ($(PRECHECK),y)
     389        $(JOBFILE) $(JOB) $< $@ cc core $(DEFS) $(CFLAGS)
     390endif
     391
    358392%.lo: %.S $(DEPEND)
    359393        $(CC) $(DEFS) $(LIB_CFLAGS) -D__ASM__ -c $< -o $@
     
    375409
    376410$(DEPEND): $(PRE_DEPEND)
    377         makedepend -f - -- $(DEPEND_DEFS) $(CFLAGS) -- $(SOURCES) > $@ 2> /dev/null
     411        makedepend -f - -- $(DEPEND_DEFS) $(CFLAGS) -- $(SOURCES) $(TEST_SOURCES) > $@ 2> /dev/null
    378412        -[ -f $(DEPEND_PREV) ] && diff -q $(DEPEND_PREV) $@ && mv -f $(DEPEND_PREV) $@
    379413
Note: See TracChangeset for help on using the changeset viewer.