Changes in / [6609050:18cc83c] in mainline


Ignore:
Files:
73 added
11 edited

Legend:

Unmodified
Added
Removed
  • .bzrignore

    r6609050 r18cc83c  
    2121kernel/generic/src/debug/real_map.bin
    2222uspace/app/bdsh/bdsh
     23uspace/app/bdsh/test-bdsh
    2324uspace/app/bithenge/bithenge
    2425uspace/app/blkdump/blkdump
     
    184185uspace/dist/srv/udf
    185186uspace/dist/srv/udp
     187uspace/dist/test/*
    186188uspace/drv/audio/hdaudio/hdaudio
    187189uspace/drv/audio/sb16/sb16
     
    221223uspace/lib/c/arch/amd64/_link.ld
    222224uspace/lib/c/arch/amd64/include/libarch/common.h
     225uspace/lib/c/test-libc
     226uspace/lib/pcut/test-libpcut-*
    223227uspace/lib/posix/collisions.list
    224228uspace/lib/posix/redefs-hide-libc.xargs
    225229uspace/lib/posix/redefs-show-posix.xargs
    226230uspace/lib/posix/include/libc
     231uspace/lib/posix/test-libposix
     232uspace/lib/uri/test-liburi
    227233uspace/srv/audio/hound/hound
    228234uspace/srv/bd/file_bd/file_bd
  • HelenOS.config

    r6609050 r18cc83c  
    600600! CONFIG_WRITE_CORE_FILES (n/y)
    601601
     602% Include userspace unit tests (PCUT)
     603! CONFIG_PCUT_TESTS (n/y)
     604
     605% Include PCUT self-tests
     606! CONFIG_PCUT_SELF_TESTS (n/y)
     607
    602608% Include development files (headers, libraries)
    603609! CONFIG_DEVEL_FILES (n/y)
  • boot/Makefile

    r6609050 r18cc83c  
    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
     87ifeq ($(CONFIG_PCUT_SELF_TESTS),y)
     88        echo "echo Running all PCUT self-tests..." >"$(DIST_PATH)/test/run_pcut"
     89        echo "<html><head><title>Results of PCUT self-tests on HelenOS</title></head><body>" >"$(DIST_PATH)/test/pcut.html"
     90        echo "<h1>Results of PCUT self-tests on HelenOS</h1><ul>" >>"$(DIST_PATH)/test/pcut.html"
     91        for file in $(USPACE_PATH)/lib/pcut/test-libpcut-*; do \
     92                file2=`basename $$file`; \
     93                name=`echo "$$file2" | sed 's/test-libpcut-//'`; \
     94                cp "$$file" "$(DIST_PATH)/test/" ; \
     95                echo "echo ' ->' $$name" >>"$(DIST_PATH)/test/run_pcut"; \
     96                echo "/test/$$file2 | to /test/$$file2.out" >>"$(DIST_PATH)/test/run_pcut"; \
     97                echo "cat /test/$$file2.out" >>"$(DIST_PATH)/test/run_pcut"; \
     98                echo "cp -f /test/$$file2.out /data/web/result-$$file2.txt" >>"$(DIST_PATH)/test/run_pcut"; \
     99                echo "<li><a href=\"result-$$file2.txt\">$$name</a></li>" >>"$(DIST_PATH)/test/pcut.html"; \
     100        done
     101        echo "cp -f /test/pcut.html /data/web/pcut.html" >>"$(DIST_PATH)/test/run_pcut"
     102        echo "</ul></body></html>" >>"$(DIST_PATH)/test/pcut.html"
     103endif
     104
    70105        for drv in $(RD_DRVS) ; do \
    71106                drv_dir="`dirname "$$drv"`" ; \
     
    100135        rm -rf $(USPACE_PATH)/dist/inc/*
    101136        rm -f $(USPACE_PATH)/dist/app/*
     137        rm -f $(USPACE_PATH)/dist/test/*
    102138        rm -f $(USPACE_PATH)/dist/cfg/net/*
  • boot/Makefile.common

    r6609050 r18cc83c  
    222222        $(USPACE_PATH)/app/fontviewer/fontviewer
    223223
     224RD_TESTS = \
     225        $(USPACE_PATH)/lib/c/test-libc \
     226        $(USPACE_PATH)/lib/posix/test-libposix \
     227        $(USPACE_PATH)/lib/uri/test-liburi \
     228        $(USPACE_PATH)/app/bdsh/test-bdsh
     229
     230
    224231COMPONENTS = \
    225232        $(KERNEL_PATH)/kernel.bin \
  • uspace/Makefile

    r6609050 r18cc83c  
    233233        lib/usbvirt \
    234234        lib/pcm \
     235        lib/pcut \
    235236        lib/bithenge \
    236237        lib/posix \
     
    242243LIBN_BUILD = $(addsuffix .build,$(LIBN))
    243244BUILDS := $(addsuffix .build,$(DIRS))
     245BUILDS_TESTS := $(addsuffix .build-test,$(DIRS) $(LIBS) lib/c)
    244246
    245247CLEANS := $(addsuffix .clean,$(DIRS)) $(addsuffix .clean,$(LIBN)) $(addsuffix .clean,$(LIBS)) $(addsuffix .clean,$(LIBC))
     
    247249.PHONY: all $(LIBC_BUILD) $(LIBS_BUILD) $(LIBN_BUILD) $(BUILDS) $(CLEANS) clean
    248250
    249 all: $(BUILDS)
     251all: $(BUILDS) $(BUILDS_TESTS)
     252
     253$(BUILDS_TESTS): $(BUILDS)
     254        $(MAKE) -C $(basename $@) all-test PRECHECK=$(PRECHECK)
    250255
    251256clean: $(CLEANS)
  • uspace/Makefile.common

    r6609050 r18cc83c  
    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
     
    201203endif
    202204
     205# PCUT-based unit tests
     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
     210        EXTRA_CLEAN += $(TEST_OUTPUT) $(TEST_OUTPUT).map
     211ifneq ($(LIBRARY),)
     212        TEST_OUTPUT_LIBS += $(OUTPUT)
     213endif
     214        TEST_OUTPUT_LIBS += $(TEST_LIBS)
     215endif
     216
    203217.PHONY: all clean
    204218
    205219all: $(VERSION_DEF) $(COMMON_MAKEFILE) $(CONFIG_MAKEFILE) $(CONFIG_HEADER) $(LIBS) $(OUTPUT) $(LOUTPUT) $(EXTRA_OUTPUT)
    206220        -[ -f $(DEPEND) ] && cp -a $(DEPEND) $(DEPEND_PREV)
     221
     222all-test: $(TEST_OUTPUT)
    207223
    208224clean:
     
    295311OBJECTS := $(addsuffix .o,$(basename $(SOURCES)))
    296312LOBJECTS := $(addsuffix .lo,$(basename $(SOURCES)))
     313TEST_OBJECTS := $(addsuffix .test.o,$(basename $(TEST_SOURCES)))
    297314
    298315ifneq ($(BINARY),)
     
    339356endif
    340357
     358ifneq ($(TEST_OUTPUT),)
     359$(TEST_OUTPUT): $(LINKER_SCRIPT) $(TEST_OBJECTS) $(TEST_OUTPUT_LIBS)
     360        $(LD) -n $(LFLAGS) -T $(LINKER_SCRIPT) -M -Map $(TEST_OUTPUT).map -o $@ $(TEST_OBJECTS) $(TEST_OUTPUT_LIBS) $(LIBS) $(BASE_LIBS)
     361ifeq ($(CONFIG_STRIP_BINARIES),y)
     362        $(STRIP) $(TEST_OUTPUT)
     363endif
     364endif
     365
    341366%.o: %.S $(DEPEND)
    342367        $(GCC) $(DEFS) $(GCC_CFLAGS) -D__ASM__ -c $< -o $@
     
    357382endif
    358383
     384%.test.o: %.c $(DEPEND)
     385        $(CC) $(DEFS) $(CFLAGS) $(TEST_CFLAGS) -c $< -o $@
     386ifeq ($(PRECHECK),y)
     387        $(JOBFILE) $(JOB) $< $@ cc core $(DEFS) $(CFLAGS)
     388endif
     389
    359390%.lo: %.S $(DEPEND)
    360391        $(CC) $(DEFS) $(LIB_CFLAGS) -D__ASM__ -c $< -o $@
     
    376407
    377408$(DEPEND): $(PRE_DEPEND)
    378         makedepend -f - -- $(DEPEND_DEFS) $(CFLAGS) -- $(SOURCES) > $@ 2> /dev/null
     409        makedepend -f - -- $(DEPEND_DEFS) $(CFLAGS) -- $(SOURCES) $(TEST_SOURCES) > $@ 2> /dev/null
    379410        -[ -f $(DEPEND_PREV) ] && diff -q $(DEPEND_PREV) $@ && mv -f $(DEPEND_PREV) $@
    380411
  • uspace/app/bdsh/Makefile

    r6609050 r18cc83c  
    6565        tok.c
    6666
     67TEST_SOURCES = \
     68        tok.c \
     69        test/toktest.c
     70
    6771include $(USPACE_PREFIX)/Makefile.common
  • uspace/lib/c/Makefile

    r6609050 r18cc83c  
    165165        $(ARCH_SOURCES)
    166166
     167TEST_SOURCES = \
     168        test/main.c \
     169        test/sprintf.c
     170
    167171include $(USPACE_PREFIX)/Makefile.common
    168172
  • uspace/lib/posix/Makefile

    r6609050 r18cc83c  
    7979        source/unistd.c
    8080
     81TEST_SOURCES = \
     82        test/main.c \
     83        test/scanf.c
     84
    8185include $(USPACE_PREFIX)/Makefile.common
    8286
  • uspace/lib/posix/source/stdio/scanf.c

    r6609050 r18cc83c  
    12201220}
    12211221
    1222 // FIXME: put the testcases to the app/tester after scanf is included into libc
    1223 
    1224 #if 0
    1225 
    1226 //#include <stdio.h>
    1227 //#include <malloc.h>
    1228 //#include <string.h>
    1229 
    1230 #define test_val(fmt, exp_val, act_val) \
    1231         if (exp_val == act_val) { \
    1232                 printf("succ, expected "fmt", actual "fmt"\n", exp_val, act_val); \
    1233         } else { \
    1234                 printf("fail, expected "fmt", actual "fmt"\n", exp_val, act_val); \
    1235                 ++fail; \
    1236         }
    1237 
    1238 #define test_str(fmt, exp_str, act_str) \
    1239         if (posix_strcmp(exp_str, act_str) == 0) { \
    1240                 printf("succ, expected "fmt", actual "fmt"\n", exp_str, act_str); \
    1241         } else { \
    1242                 printf("fail, expected "fmt", actual "fmt"\n", exp_str, act_str); \
    1243                 ++fail; \
    1244         }
    1245 
    1246 void __posix_scanf_test(void);
    1247 void __posix_scanf_test(void)
    1248 {
    1249         int fail = 0;
    1250 
    1251         int ret;
    1252 
    1253         unsigned char uhh;
    1254         signed char shh;
    1255         unsigned short uh;
    1256         short sh;
    1257         unsigned udef;
    1258         int sdef;
    1259         unsigned long ul;
    1260         long sl;
    1261         unsigned long long ull;
    1262         long long sll;
    1263         void *p;
    1264        
    1265         float f;
    1266         double d;
    1267         long double ld;
    1268 
    1269         char str[20];
    1270         char seq[20];
    1271         char scanset[20];
    1272 
    1273         char *pstr;
    1274         char *pseq;
    1275         char *pscanset;
    1276        
    1277         ret = posix_sscanf(
    1278             "\n j tt % \t -121314 98765 aqw 0765 0x77 0xABCDEF88 -99 884",
    1279             " j tt %%%3hhd%1hhu%3hd %3hu%u aqw%n %lo%llx %p %li %lld",
    1280             &shh, &uhh, &sh, &uh, &udef, &sdef, &ul, &ull, &p, &sl, &sll);
    1281         test_val("%d", -12, shh);
    1282         test_val("%u", 1, uhh);
    1283         test_val("%d", 314, sh);
    1284         test_val("%u", 987, uh);
    1285         test_val("%u", 65, udef);
    1286         test_val("%d", 28, sdef);
    1287         test_val("%lo", (unsigned long) 0765, ul);
    1288         test_val("%llx", (unsigned long long) 0x77, ull);
    1289         test_val("%p", (void *) 0xABCDEF88, p);
    1290         test_val("%ld", (long) -99, sl);
    1291         test_val("%lld", (long long) 884, sll);
    1292         test_val("%d", 10, ret);
    1293 
    1294         ret = posix_sscanf(
    1295             "\n \t\t1.0 -0x555.AP10 1234.5678e12",
    1296             "%f %lf %Lf",
    1297             &f, &d, &ld);
    1298         test_val("%f", 1.0, f);
    1299         test_val("%lf", (double) -0x555.AP10, d);
    1300         test_val("%Lf", (long double) 1234.5678e12, ld);
    1301         test_val("%d", 3, ret);
    1302          
    1303         ret = posix_sscanf(
    1304             "\n\n\thello world    \n",
    1305             "%5s %ms",
    1306             str, &pstr);
    1307         test_str("%s", "hello", str);
    1308         test_str("%s", "world", pstr);
    1309         test_val("%d", 2, ret);
    1310         free(pstr);
    1311 
    1312         ret = posix_sscanf(
    1313             "\n\n\thello world    \n",
    1314             " %5c %mc",
    1315             seq, &pseq);
    1316         seq[5] = '\0';
    1317         pseq[1] = '\0';
    1318         test_str("%s", "hello", seq);
    1319         test_str("%s", "w", pseq);
    1320         test_val("%d", 2, ret);
    1321         free(pseq);
    1322 
    1323         ret = posix_sscanf(
    1324             "\n\n\th-e-l-l-o world-]    \n",
    1325             " %9[-eh-o] %m[^]-]",
    1326             scanset, &pscanset);
    1327         test_str("%s", "h-e-l-l-o", scanset);
    1328         test_str("%s", "world", pscanset);
    1329         test_val("%d", 2, ret);
    1330         free(pscanset);
    1331 
    1332         printf("Failed: %d\n", fail);
    1333 }
    1334 
    1335 #endif
    1336 
    13371222/** @}
    13381223 */
  • uspace/lib/uri/Makefile

    r6609050 r18cc83c  
    3636        uri.c
    3737
     38TEST_SOURCES = \
     39        test/main.c \
     40        test/parser.c
     41
    3842include $(USPACE_PREFIX)/Makefile.common
Note: See TracChangeset for help on using the changeset viewer.