Changeset 90152a4 for tests


Ignore:
Timestamp:
Aug 27, 2018, 4:40:34 PM (7 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
ADT, arm-eh, ast-experimental, cleanup-dtors, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
b7c89aa
Parents:
f9feab8 (diff), 305581d (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' into cleanup-dtors

Location:
tests
Files:
87 added
202 moved

Legend:

Unmodified
Added
Removed
  • tests/.expect/alloc-ERROR.txt

    rf9feab8 r90152a4  
    1 alloc.c:259:1 error: No reasonable alternatives for expression Applying untyped:
     1alloc.c:265:1 error: No reasonable alternatives for expression Applying untyped:
     2  Name: ?=?
     3...to:
     4  Name: p
     5  Applying untyped:
     6    Name: realloc
     7  ...to:
     8    Name: stp
     9    Applying untyped:
     10      Name: ?*?
     11    ...to:
     12      Name: dim
     13      Sizeof Expression on: Applying untyped:
     14          Name: *?
     15        ...to:
     16          Name: stp
     17
     18
     19
     20
     21alloc.c:266:1 error: No reasonable alternatives for expression Applying untyped:
    222  Name: ?=?
    323...to:
     
    1939
    2040
    21 alloc.c:260:1 error: No reasonable alternatives for expression Applying untyped:
     41alloc.c:267:1 error: No reasonable alternatives for expression Applying untyped:
    2242  Name: ?=?
    2343...to:
     
    3050
    3151
    32 alloc.c:261:1 error: No reasonable alternatives for expression Applying untyped:
     52alloc.c:268:1 error: No reasonable alternatives for expression Applying untyped:
    3353  Name: ?=?
    3454...to:
  • tests/.expect/declarationErrors.txt

    rf9feab8 r90152a4  
    1717
    1818
    19 declarationErrors.c:22:1 error: duplicate static in declaration of x6: static const volatile instance of type Int
     19declarationErrors.c:22:1 error: duplicate static in declaration of x6: static const volatile Int
    2020
    2121declarationErrors.c:24:1 error: duplicate const in declaration of f01: static inline function
  • tests/.expect/io2.txt

    rf9feab8 r90152a4  
    1 9 6 28 0 7 1 2
    2 1 2 3
    3 123
    4 123
    5 
    6 opening delimiters
    7 x (1 x [2 x {3 x =4 x $5 x £6 x ¥7 x ¡8 x ¿9 x «10
    8 
    9 closing delimiters
    10 1, x 2. x 3; x 4! x 5? x 6% x 7¢ x 8» x 9) x 10] x 11} x
    11 
    12 opening/closing delimiters
    13 x`1`x'2'x"3"x:4:x 5 x   6       x
    14 7
    15 x
    16 8
    17 x
    18 9
    19 x
    20 10
    21 x
    22 
    23 override opening/closing delimiters
    24 x ( 1 ) x 2 , x 3 :x: 4
    25 
    261input bacis types
    272
    283output basic types
     4false
    295A 23 93
    3061 2 3 4 5 6 7 8
  • tests/.expect/math1.txt

    rf9feab8 r90152a4  
    99exp2:2 2 2
    1010expm1:1.71828 1.71828182845905 1.71828182845904524
    11 pow:1 1 1 0.273957+0.583701i 0.273957253830121+0.583700758758615i 0.273957253830121071+0.583700758758614627i
     11pow:1 1 1 0.273957+0.583701i 0.273957253830121+0.583700758758615i -0.638110484918098871+0.705394566961838155i
    1212\ 16 256
    1313\ 912673 256 64 -64 0.015625 -0.015625 18.3791736799526 0.264715-1.1922i
    14 log:0 0 0 0.346574+0.785398i 0.346573590279973+0.785398163397448i 0.346573590279972655+0.78539816339744831i
    15 log2:3 3 3
    16 log10:2 2 2
    17 log1p:0.693147 0.693147180559945 0.693147180559945309
    18 ilogb:0 0 0
    19 logb:3 3 3
    20 sqrt:1 1 1 1.09868+0.45509i 1.09868411346781+0.455089860562227i 1.09868411346780997+0.455089860562227341i
    21 cbrt:3 3 3
    22 hypot:1.41421 1.4142135623731 1.41421356237309505
  • tests/.expect/math3.txt

    rf9feab8 r90152a4  
    1 sin:0.841471 0.841470984807897 0.841470984807896507 1.29846+0.634964i 1.29845758141598+0.634963914784736i 1.29845758141597729+0.634963914784736108i
    2 cos:0.540302 0.54030230586814 0.540302305868139717 0.83373-0.988898i 0.833730025131149-0.988897705762865i 0.833730025131149049-0.988897705762865096i
    3 tan:1.55741 1.5574077246549 1.55740772465490223 0.271753+1.08392i 0.271752585319512+1.08392332733869i 0.271752585319511717+1.08392332733869454i
    4 asin:1.5708 1.5707963267949 1.57079632679489662 0.666239+1.06128i 0.666239432492515+1.06127506190504i 0.666239432492515255+1.06127506190503565i
    5 acos:0 0 0 0.904557-1.06128i 0.904556894302381-1.06127506190504i 0.904556894302381364-1.06127506190503565i
    6 atan:0.785398 0.785398163397448 0.78539816339744831 1.01722+0.402359i 1.01722196789785+0.402359478108525i 1.01722196789785137+0.402359478108525094i
    7 atan2:0.785398 0.785398163397448 0.78539816339744831 atan:0.785398 0.785398163397448 0.78539816339744831
    81sinh:1.1752 1.1752011936438 1.17520119364380146 0.634964+1.29846i 0.634963914784736+1.29845758141598i 0.634963914784736108+1.29845758141597729i
    92cosh:1.54308 1.54308063481524 1.54308063481524378 0.83373+0.988898i 0.833730025131149+0.988897705762865i 0.833730025131149049+0.988897705762865096i
  • tests/.expect/references.txt

    rf9feab8 r90152a4  
    4413 1 12
    5514 14
     6x = 6 ; x2 = 789
     7x = 6 ; x2 = 999
     8x = 12345 ; x2 = 999
     9x = 22222 ; x2 = 999
    610Default constructing a Y
    711Copy constructing a Y
     
    2832Destructing a Y
    2933Destructing a Y
     343 3
     353
     363
     373 9 { 1, 7 }, [1, 2, 3]
    3038Destructing a Y
    3139Destructing a Y
  • tests/.expect/sum.txt

    rf9feab8 r90152a4  
    44sum from 0.5 to 1.5 is 9.5, check 9.5
    55sum from 5 to 15 is 95 95, check 95 95
     6sum from 5 to 15 is 95, check 95
  • tests/.expect/user_literals.txt

    rf9feab8 r90152a4  
    1111.0714285714286
    2 11.07225
     215
    3311.0714285714286
     424.8
     511.248
    4611.0714285714286
    5 11.0714285714286
    6 22.0457142857143
     728.0657142857143
    78secs 1
    89secs 23
     
    2223_thingy_ 10
    2324secs abc
    24 mins
    25 hours abc
    26 _A_ abc
    2725_thingy_ abc
  • tests/.gitignore

    rf9feab8 r90152a4  
    11.out/
    22.err/
     3.type
  • tests/Makefile.in

    rf9feab8 r90152a4  
    1717######################## -*- Mode: Makefile-Automake -*- ######################
    1818###############################################################################
    19 
    2019VPATH = @srcdir@
    2120am__is_gnu_make = { \
     
    9291build_triplet = @build@
    9392host_triplet = @host@
    94 noinst_PROGRAMS = fstream_test$(EXEEXT) vector_test$(EXEEXT) \
    95         avl_test$(EXEEXT) Bench$(EXEEXT)
    96 subdir = src/examples
     93EXTRA_PROGRAMS = fstream_test$(EXEEXT) avl_test$(EXEEXT)
     94subdir = tests
    9795ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
    98 am__aclocal_m4_deps = $(top_srcdir)/configure.ac
     96am__aclocal_m4_deps = $(top_srcdir)/automake/cfa.m4 \
     97        $(top_srcdir)/configure.ac
    9998am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
    10099        $(ACLOCAL_M4)
     
    102101mkinstalldirs = $(install_sh) -d
    103102CONFIG_HEADER = $(top_builddir)/config.h
    104 CONFIG_CLEAN_FILES =
    105 CONFIG_CLEAN_VPATH_FILES =
    106 PROGRAMS = $(noinst_PROGRAMS)
    107 Bench_SOURCES = Bench.c
    108 Bench_OBJECTS = Bench.$(OBJEXT)
    109 Bench_LDADD = $(LDADD)
     103CONFIG_CLEAN_FILES = config.py
     104CONFIG_CLEAN_VPATH_FILES = test.py
    110105am__dirstamp = $(am__leading_dot)dirstamp
    111106am_avl_test_OBJECTS = avltree/avl_test.$(OBJEXT) \
     
    118113fstream_test_OBJECTS = $(am_fstream_test_OBJECTS)
    119114fstream_test_LDADD = $(LDADD)
    120 am_vector_test_OBJECTS = vector_int.$(OBJEXT) array.$(OBJEXT) \
    121         vector_test.$(OBJEXT)
    122 vector_test_OBJECTS = $(am_vector_test_OBJECTS)
    123 vector_test_LDADD = $(LDADD)
    124115AM_V_P = $(am__v_P_@AM_V@)
    125116am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
     
    150141am__v_CCLD_0 = @echo "  CCLD    " $@;
    151142am__v_CCLD_1 =
    152 SOURCES = Bench.c $(avl_test_SOURCES) $(fstream_test_SOURCES) \
    153         $(vector_test_SOURCES)
    154 DIST_SOURCES = Bench.c $(avl_test_SOURCES) $(fstream_test_SOURCES) \
    155         $(vector_test_SOURCES)
     143SOURCES = $(avl_test_SOURCES) $(fstream_test_SOURCES)
     144DIST_SOURCES = $(avl_test_SOURCES) $(fstream_test_SOURCES)
    156145am__can_run_installinfo = \
    157146  case $$AM_UPDATE_INFO_DIR in \
     
    178167ETAGS = etags
    179168CTAGS = ctags
    180 am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/automake/depcomp
     169am__DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/config.py.in \
     170        $(srcdir)/test.py $(top_srcdir)/automake/depcomp
    181171DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
    182172ACLOCAL = @ACLOCAL@
     
    189179AWK = @AWK@
    190180BACKEND_CC = @BACKEND_CC@
    191 CC = @CFA_BINDIR@/@CFA_NAME@
     181BUILD_IN_TREE_FLAGS = @BUILD_IN_TREE_FLAGS@
     182CC = @CFACC@
    192183CCAS = @CCAS@
    193184CCASDEPMODE = @CCASDEPMODE@
    194185CCASFLAGS = @CCASFLAGS@
    195186CCDEPMODE = @CCDEPMODE@
     187CFACC = @CFACC@
     188CFACPP = @CFACPP@
    196189CFA_BACKEND_CC = @CFA_BACKEND_CC@
    197190CFA_BINDIR = @CFA_BINDIR@
     
    201194CFA_NAME = @CFA_NAME@
    202195CFA_PREFIX = @CFA_PREFIX@
    203 
    204 # applies to both programs
    205 CFLAGS =
     196CFLAGS = @CFLAGS@
    206197CPP = @CPP@
    207198CPPFLAGS = @CPPFLAGS@
     
    212203DEFS = @DEFS@
    213204DEPDIR = @DEPDIR@
     205DRIVER_DIR = @DRIVER_DIR@
    214206ECHO_C = @ECHO_C@
    215207ECHO_N = @ECHO_N@
     
    218210EXEEXT = @EXEEXT@
    219211GREP = @GREP@
     212HOST_FLAGS = @HOST_FLAGS@
    220213INSTALL = @INSTALL@
    221214INSTALL_DATA = @INSTALL_DATA@
     
    227220LEXLIB = @LEXLIB@
    228221LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
     222LIBCFA_TARGET_DIRS = @LIBCFA_TARGET_DIRS@
     223LIBCFA_TARGET_MAKEFILES = @LIBCFA_TARGET_MAKEFILES@
    229224LIBOBJS = @LIBOBJS@
    230225LIBS = @LIBS@
    231226LTLIBOBJS = @LTLIBOBJS@
    232 MACHINE_TYPE = @MACHINE_TYPE@
    233 MAINT = @MAINT@
    234227MAKEINFO = @MAKEINFO@
    235228MKDIR_P = @MKDIR_P@
     
    247240SHELL = @SHELL@
    248241STRIP = @STRIP@
     242TARGET_HOSTS = @TARGET_HOSTS@
    249243VERSION = @VERSION@
    250244YACC = @YACC@
     
    302296top_builddir = @top_builddir@
    303297top_srcdir = @top_srcdir@
    304 AM_CFLAGS = -g -Wall -Wno-unused-function -O2
     298AUTOMAKE_OPTIONS = foreign    # do not require all the GNU file names
     299debug = yes
     300installed = no
     301quick_test = avl_test operators numericConstants expression enum array typeof cast raii/dtor-early-exit raii/init_once attributes
     302concurrent =
     303TEST_PY = python ${builddir}/test.py
     304
     305# applies to both programs
     306AM_CFLAGS = $(if $(test), 2> $(test), ) -g -Wall -Wno-unused-function \
     307        -quiet @CFA_FLAGS@ -DIN_DIR="${srcdir}/.in/" ${DEBUG_FLAGS} \
     308        ${INSTALL_FLAGS} ${ARCH_FLAGS}
     309PRETTY_PATH = cd ${srcdir} &&
    305310fstream_test_SOURCES = fstream_test.c
    306 vector_test_SOURCES = vector_int.c array.c vector_test.c
    307311avl_test_SOURCES = avltree/avl_test.c avltree/avl0.c avltree/avl1.c avltree/avl2.c avltree/avl3.c avltree/avl4.c avltree/avl-private.c
    308312all: all-am
    309313
    310314.SUFFIXES:
    311 .SUFFIXES: .c .o .obj
    312 $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
     315.SUFFIXES: .c .o .obj .validate
     316$(srcdir)/Makefile.in: $(srcdir)/Makefile.am  $(am__configure_deps)
    313317        @for dep in $?; do \
    314318          case '$(am__configure_deps)' in \
     
    319323          esac; \
    320324        done; \
    321         echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/examples/Makefile'; \
     325        echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign tests/Makefile'; \
    322326        $(am__cd) $(top_srcdir) && \
    323           $(AUTOMAKE) --foreign src/examples/Makefile
     327          $(AUTOMAKE) --foreign tests/Makefile
    324328Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
    325329        @case '$?' in \
     
    334338        cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
    335339
    336 $(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
     340$(top_srcdir)/configure: $(am__configure_deps)
    337341        cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
    338 $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
     342$(ACLOCAL_M4): $(am__aclocal_m4_deps)
    339343        cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
    340344$(am__aclocal_m4_deps):
    341 
    342 clean-noinstPROGRAMS:
    343         -test -z "$(noinst_PROGRAMS)" || rm -f $(noinst_PROGRAMS)
     345config.py: $(top_builddir)/config.status $(srcdir)/config.py.in
     346        cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
    344347avltree/$(am__dirstamp):
    345348        @$(MKDIR_P) avltree
     
    371374        $(AM_V_CCLD)$(LINK) $(fstream_test_OBJECTS) $(fstream_test_LDADD) $(LIBS)
    372375
    373 vector_test$(EXEEXT): $(vector_test_OBJECTS) $(vector_test_DEPENDENCIES) $(EXTRA_vector_test_DEPENDENCIES)
    374         @rm -f vector_test$(EXEEXT)
    375         $(AM_V_CCLD)$(LINK) $(vector_test_OBJECTS) $(vector_test_LDADD) $(LIBS)
    376 
    377376mostlyclean-compile:
    378377        -rm -f *.$(OBJEXT)
     
    382381        -rm -f *.tab.c
    383382
    384 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Bench.Po@am__quote@
    385 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/array.Po@am__quote@
    386383@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fstream_test.Po@am__quote@
    387 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vector_int.Po@am__quote@
    388 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vector_test.Po@am__quote@
    389384@AMDEP_TRUE@@am__include@ @am__quote@avltree/$(DEPDIR)/avl-private.Po@am__quote@
    390385@AMDEP_TRUE@@am__include@ @am__quote@avltree/$(DEPDIR)/avl0.Po@am__quote@
     
    495490check-am: all-am
    496491check: check-am
    497 all-am: Makefile $(PROGRAMS)
     492all-am: Makefile all-local
    498493installdirs:
    499494install: install-am
     
    531526clean: clean-am
    532527
    533 clean-am: clean-generic clean-noinstPROGRAMS mostlyclean-am
     528clean-am: clean-generic clean-local mostlyclean-am
    534529
    535530distclean: distclean-am
     
    600595.MAKE: install-am install-strip
    601596
    602 .PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \
    603         clean-noinstPROGRAMS cscopelist-am ctags ctags-am distclean \
    604         distclean-compile distclean-generic distclean-tags distdir dvi \
    605         dvi-am html html-am info info-am install install-am \
    606         install-data install-data-am install-dvi install-dvi-am \
    607         install-exec install-exec-am install-html install-html-am \
    608         install-info install-info-am install-man install-pdf \
    609         install-pdf-am install-ps install-ps-am install-strip \
    610         installcheck installcheck-am installdirs maintainer-clean \
    611         maintainer-clean-generic mostlyclean mostlyclean-compile \
    612         mostlyclean-generic pdf pdf-am ps ps-am tags tags-am uninstall \
    613         uninstall-am
     597.PHONY: CTAGS GTAGS TAGS all all-am all-local check check-am clean \
     598        clean-generic clean-local cscopelist-am ctags ctags-am \
     599        distclean distclean-compile distclean-generic distclean-tags \
     600        distdir dvi dvi-am html html-am info info-am install \
     601        install-am install-data install-data-am install-dvi \
     602        install-dvi-am install-exec install-exec-am install-html \
     603        install-html-am install-info install-info-am install-man \
     604        install-pdf install-pdf-am install-ps install-ps-am \
     605        install-strip installcheck installcheck-am installdirs \
     606        maintainer-clean maintainer-clean-generic mostlyclean \
     607        mostlyclean-compile mostlyclean-generic pdf pdf-am ps ps-am \
     608        tags tags-am uninstall uninstall-am
    614609
    615610.PRECIOUS: Makefile
    616611
    617612
    618 Bench : Bench.c
    619         @for ccflags in "-debug" "-nodebug"; do \
    620                 echo ${CC} ${AM_CFLAGS} ${CFLAGS} $${ccflags} -lrt Bench.c;\
    621                 ${CC} ${AM_CFLAGS} ${CFLAGS} $${ccflags} -lrt Bench.c;\
    622                 ./a.out ; \
    623         done ; \
    624         rm -f ./a.out ;
     613.PHONY: list .validate
     614.INTERMEDIATE: .validate .validate.c
     615
     616#----------------------------------------------------------------------------------------------------------------
     617all-local :
     618        @+${TEST_PY} --debug=${debug}  --install=${installed} ${concurrent} ${quick_test}
     619
     620all-tests :
     621        @+${TEST_PY} --all --debug=${debug}  --install=${installed} ${concurrent}               # '@' => do not echo command (SILENT), '+' => allows recursive make from within python program
     622
     623clean-local :
     624        rm -f ${EXTRA_PROGRAMS}
     625
     626list :
     627        @+${TEST_PY} --list ${concurrent}
     628
     629.validate: .validate.c
     630        $(COMPILE) .validate.c -fsyntax-only -Wall -Wextra -Werror
     631
     632.validate.c:
     633        @echo "int main() { return 0; }" > ${@}
     634
     635concurrency :
     636        @+${TEST_PY} --debug=${debug}  --install=${installed} -Iconcurrent
     637
     638#----------------------------------------------------------------------------------------------------------------
     639# implicit rule so not all test require a rule
     640% : %.c $(CC)
     641        $(PRETTY_PATH) $(COMPILE) $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@})
     642
     643declarationSpecifier: declarationSpecifier.c $(CC)
     644        $(PRETTY_PATH) $(COMPILE) -CFA -XCFA -p $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@})
     645
     646gccExtensions : gccExtensions.c $(CC)
     647        $(PRETTY_PATH) $(COMPILE) -CFA -XCFA -p $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@})
     648
     649extension : extension.c $(CC)
     650        $(PRETTY_PATH) $(COMPILE) -CFA -XCFA -p $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@})
     651
     652attributes : attributes.c $(CC)
     653        $(PRETTY_PATH) $(COMPILE) -CFA -XCFA -p $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@})
     654
     655functions: functions.c $(CC)
     656        $(PRETTY_PATH) $(COMPILE) -CFA -XCFA -p $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@})
     657
     658KRfunctions : KRfunctions.c $(CC)
     659        $(PRETTY_PATH) $(COMPILE) -CFA -XCFA -p $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@})
     660
     661sched-ext-parse : sched-ext-parse.c $(CC)
     662        $(PRETTY_PATH) $(COMPILE) -CFA -XCFA -p $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@})
     663
     664gmp : gmp.c $(CC)
     665        $(PRETTY_PATH) $(COMPILE) -lgmp $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@})
     666
     667#builtins
     668builtins/sync: builtins/sync.c $(CC)
     669        $(PRETTY_PATH) $(COMPILE) $(shell realpath --relative-to=${srcdir} ${<}) 2> $(abspath ${@}) -fsyntax-only
     670
     671#------------------------------------------------------------------------------
     672#To make errors path independent we need to cd into the correct directories
     673completeTypeError : completeTypeError.c $(CC)
     674        $(PRETTY_PATH) $(COMPILE) -DERR1 $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@})
     675
     676typedefRedef-ERR1: typedefRedef.c $(CC)
     677        $(PRETTY_PATH) $(COMPILE) -DERR1 $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@})
     678
     679alloc-ERROR: alloc.c $(CC)
     680        $(PRETTY_PATH) $(COMPILE) -DERR1 $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@})
     681
     682fallthrough-ERROR: fallthrough.c $(CC)
     683        $(PRETTY_PATH) $(COMPILE) -DERR1 $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@})
     684
     685nested-types-ERR1: nested-types.c $(CC)
     686        $(PRETTY_PATH) $(COMPILE) -DERR1 $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@})
     687
     688nested-types-ERR2: nested-types.c $(CC)
     689        $(PRETTY_PATH) $(COMPILE) -DERR2 $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@})
     690
     691# Constructor/destructor tests
     692raii/dtor-early-exit-ERR1: raii/dtor-early-exit.c $(CC)
     693        $(PRETTY_PATH) $(COMPILE) -DERR1 $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@})
     694
     695raii/dtor-early-exit-ERR2: raii/dtor-early-exit.c $(CC)
     696        $(PRETTY_PATH) $(COMPILE) -DERR2 $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@})
     697
     698raii/memberCtors-ERR1: raii/memberCtors.c $(CC)
     699        $(PRETTY_PATH) $(COMPILE) -DERR1 $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@})
     700
     701raii/ctor-autogen-ERR1: raii/ctor-autogen.c $(CC)
     702        $(PRETTY_PATH) $(COMPILE) -DERR1 $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@})
     703
     704# Warnings
     705warnings/self-assignment: warnings/self-assignment.c $(CC)
     706        $(PRETTY_PATH) $(COMPILE) $(shell realpath --relative-to=${srcdir} ${<}) 2> $(abspath ${@}) -fsyntax-only
    625707
    626708# Tell versions [3.59,3.63) of GNU make to not export all variables.
  • tests/abs.c

    rf9feab8 r90152a4  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // abs.c -- 
     7// abs.c --
    88//
    99// Author           : Peter A. Buhr
     
    1414//
    1515
    16 #include <fstream>
    17 #include <stdlib>                                                                               // abs
     16#include <fstream.hfa>
     17#include <stdlib.hfa>                                                                           // abs
    1818
    1919int main( void ) {
  • tests/alloc.c

    rf9feab8 r90152a4  
    1010// Created On       : Wed Feb  3 07:56:22 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Jul 20 16:01:10 2017
    13 // Update Count     : 318
     12// Last Modified On : Thu Aug  9 06:21:35 2018
     13// Update Count     : 337
    1414//
    1515
     
    1818#include <stdint.h>                                                                             // uintptr_t
    1919#include <stdlib.h>                                                                             // posix_memalign
    20 #include <fstream>
    21 #include <stdlib>                                                                                       // access C malloc, realloc
     20#include <fstream.hfa>
     21#include <stdlib.hfa>                                                                           // access C malloc, realloc
    2222
    2323int * foo( int * p, int c ) { return p; }
     
    2727int main( void ) {
    2828        size_t dim = 10;
     29        char fill = '\xff';
    2930        int * p;
    30         char fill = '\1';
    3131
    3232        // allocation, non-array types
    3333
    34         p = (int *)(void *)malloc( sizeof(*p) );                   // C malloc, type unsafe
     34        // int & r = malloc();
     35        // r = 0xdeadbeef;
     36        // printf( "C   malloc %#x\n", r );
     37        // free( &r );
     38
     39        p = (int *)malloc( sizeof(*p) );                                        // C malloc, type unsafe
    3540        *p = 0xdeadbeef;
    3641        printf( "C   malloc %#x\n", *p );
     
    4954        p = alloc( fill );                                  // CFA alloc, fill
    5055        printf( "CFA alloc, fill %08x\n", *p );
     56        free( p );
    5157
    5258
     
    5460        printf( "\n" );
    5561
    56         p = (int *)calloc( dim, sizeof( *p ) );                    // C array calloc, type unsafe
     62        p = (int *)calloc( dim, sizeof( *p ) );                         // C array calloc, type unsafe
    5763        printf( "C   array calloc, fill 0\n" );
    58         for ( int i = 0; i < dim; i += 1 ) { printf( "%#x ", p[i] ); }
     64        for ( i; dim ) { printf( "%#x ", p[i] ); }
    5965        printf( "\n" );
    6066        free( p );
     
    6268        p = calloc( dim );                                  // CFA array calloc, type safe
    6369        printf( "CFA array calloc, fill 0\n" );
    64         for ( int i = 0; i < dim; i += 1 ) { printf( "%#x ", p[i] ); }
     70        for ( i; dim ) { printf( "%#x ", p[i] ); }
    6571        printf( "\n" );
    6672        free( p );
    6773
    6874        p = alloc( dim );                                   // CFA array alloc, type safe
    69         for ( int i = 0; i < dim; i += 1 ) { p[i] = 0xdeadbeef; }
     75        for ( i; dim ) { p[i] = 0xdeadbeef; }
    7076        printf( "CFA array alloc, no fill\n" );
    71         for ( int i = 0; i < dim; i += 1 ) { printf( "%#x ", p[i] ); }
     77        for ( i; dim ) { printf( "%#x ", p[i] ); }
    7278        printf( "\n" );
    7379        free( p );
    7480
    7581        p = alloc( 2 * dim, fill );                         // CFA array alloc, fill
    76         printf( "CFA array alloc, fill %#x\n", fill );
    77         for ( int i = 0; i < 2 * dim; i += 1 ) { printf( "%#x ", p[i] ); }
     82        printf( "CFA array alloc, fill %#hhx\n", fill );
     83        for ( i; 2 * dim ) { printf( "%#x ", p[i] ); }
    7884        printf( "\n" );
    7985        // do not free
     
    8389        printf( "\n" );
    8490
    85         p = (int *)(void *)realloc( p, dim * sizeof(*p) );         // C realloc
    86         for ( int i = 0; i < dim; i += 1 ) { p[i] = 0xdeadbeef; }
     91        p = (int *)realloc( p, dim * sizeof(*p) );                      // C realloc
     92        for ( i; dim ) { p[i] = 0xdeadbeef; }
    8793        printf( "C   realloc\n" );
    88         for ( int i = 0; i < dim; i += 1 ) { printf( "%#x ", p[i] ); }
     94        for ( i; dim ) { printf( "%#x ", p[i] ); }
    8995        printf( "\n" );
    9096
    9197        p = realloc( p, 2 * dim * sizeof(*p) );             // CFA realloc
    92         for ( int i = dim; i < 2 * dim; i += 1 ) { p[i] = 0x1010101; }
     98        for ( i; dim ~ 2 * dim ) { p[i] = 0x1010101; }
    9399        printf( "CFA realloc\n" );
    94         for ( int i = 0; i < 2 * dim; i += 1 ) { printf( "%#x ", p[i] ); }
     100        for ( i; 2 * dim ) { printf( "%#x ", p[i] ); }
    95101        printf( "\n" );
    96102        // do not free
     
    101107
    102108        p = alloc( p, dim );                                // CFA resize array alloc
    103         for ( int i = 0; i < dim; i += 1 ) { p[i] = 0xdeadbeef; }
     109        for ( i; dim ) { p[i] = 0xdeadbeef; }
    104110        printf( "CFA resize alloc\n" );
    105         for ( int i = 0; i < dim; i += 1 ) { printf( "%#x ", p[i] ); }
     111        for ( i; dim ) { printf( "%#x ", p[i] ); }
    106112        printf( "\n" );
    107113
    108114        p = alloc( p, 2 * dim );                            // CFA resize array alloc
    109         for ( int i = dim; i < 2 * dim; i += 1 ) { p[i] = 0x1010101; }
     115        for ( i; dim ~ 2 * dim ) { p[i] = 0x1010101; }
    110116        printf( "CFA resize array alloc\n" );
    111         for ( int i = 0; i < 2 * dim; i += 1 ) { printf( "%#x ", p[i] ); }
     117        for ( i; 2 * dim ) { printf( "%#x ", p[i] ); }
    112118        printf( "\n" );
    113119
    114120        p = alloc( p, dim );                                // CFA array alloc
    115121        printf( "CFA resize array alloc\n" );
    116         for ( int i = 0; i < dim; i += 1 ) { printf( "%#x ", p[i] ); }
     122        for ( i; dim ) { printf( "%#x ", p[i] ); }
    117123        printf( "\n" );
    118124
     
    122128        p = alloc( p, dim, fill );                          // CFA array alloc, fill
    123129        printf( "CFA resize array alloc, fill\n" );
    124         for ( int i = 0; i < dim; i += 1 ) { printf( "%#x ", p[i] ); }
     130        for ( i; dim ) { printf( "%#x ", p[i] ); }
    125131        printf( "\n" );
    126132
    127133        p = alloc( p, 2 * dim, fill );                      // CFA array alloc, fill
    128134        printf( "CFA resize array alloc, fill\n" );
    129         for ( int i = 0; i < 2 * dim; i += 1 ) { printf( "%#x ", p[i] ); }
     135        for ( i; 2 * dim ) { printf( "%#x ", p[i] ); }
    130136        printf( "\n" );
    131137
    132138        p = alloc( p, dim, fill );                          // CFA array alloc, fill
    133139        printf( "CFA resize array alloc, fill\n" );
    134         for ( int i = 0; i < dim; i += 1 ) { printf( "%#x ", p[i] );; }
     140        for ( i; dim ) { printf( "%#x ", p[i] );; }
    135141        printf( "\n" );
    136142        free( p );
     
    187193        stp = align_alloc( Alignment, dim );                // CFA array memalign
    188194        assert( (uintptr_t)stp % Alignment == 0 );
    189         for ( int i = 0; i < dim; i += 1 ) { stp[i] = (Struct){ 42, 42.5 }; }
     195        for ( i; dim ) { stp[i] = (Struct){ 42, 42.5 }; }
    190196        printf( "CFA array align_alloc\n" );
    191         for ( int i = 0; i < dim; i += 1 ) { printf( "%d %g, ", stp[i].x, stp[i].y ); }
     197        for ( i; dim ) { printf( "%d %g, ", stp[i].x, stp[i].y ); }
    192198        printf( "\n" );
    193199        free( stp );
     
    196202        assert( (uintptr_t)stp % Alignment == 0 );
    197203        printf( "CFA array align_alloc, fill\n" );
    198         for ( int i = 0; i < dim; i += 1 ) { printf( "%#x %a, ", stp[i].x, stp[i].y ); }
     204        for ( i; dim ) { printf( "%#x %a, ", stp[i].x, stp[i].y ); }
    199205        printf( "\n" );
    200206        free( stp );
     
    213219        printf( "\n" );
    214220
    215         memset( sta, dim, fill );                           // CFA array memset, type safe
     221        amemset( sta, fill, dim );                                                      // CFA array memset, type safe
    216222        printf( "CFA array memset\n" );
    217         for ( int i = 0; i < dim; i += 1 ) { printf( "%#x %a, ", sta[i].x, sta[i].y ); }
    218         printf( "\n" );
    219 
    220         memcpy( sta1, sta, dim );                           // CFA array memcpy, type safe
    221         printf( "CFA memcpy\n" );
    222         for ( int i = 0; i < dim; i += 1 ) { printf( "%#x %a, ", sta1[i].x, sta1[i].y ); }
     223        for ( i; dim ) { printf( "%#x %a, ", sta[i].x, sta[i].y ); }
     224        printf( "\n" );
     225
     226        amemcpy( sta1, sta, dim );                                                      // CFA array memcpy, type safe
     227        printf( "CFA array memcpy\n" );
     228        for ( i; dim ) { printf( "%#x %a, ", sta1[i].x, sta1[i].y ); }
    223229        printf( "\n" );
    224230
     
    235241        stp = anew( dim, 42, 42.5 );
    236242        printf( "CFA array new initialize\n" );
    237         for ( int i = 0; i < dim; i += 1 ) { printf( "%d %g, ", stp[i].x, stp[i].y ); }
     243        for ( i; dim ) { printf( "%d %g, ", stp[i].x, stp[i].y ); }
    238244        printf( "\n" );
    239245        stp1 = anew( dim, 42, 42.5 );
    240         for ( int i = 0; i < dim; i += 1 ) { printf( "%d %g, ", stp1[i].x, stp1[i].y ); }
     246        for ( i; dim ) { printf( "%d %g, ", stp1[i].x, stp1[i].y ); }
    241247        printf( "\n" );
    242248        adelete( dim, stp, dim, stp1 );
     
    254260        free( p );
    255261
     262#ifdef ERR1
    256263        stp = malloc();
    257264        printf( "\nSHOULD FAIL\n" );
    258 #ifdef ERR1
    259         p = alloc( stp, dim * sizeof(*stp) );
     265        p = realloc( stp, dim * sizeof( *stp ) );
     266        p = alloc( stp, dim * sizeof( *stp ) );
    260267        p = memset( stp, 10 );
    261268        p = memcpy( &st1, &st );
  • tests/attributes.c

    rf9feab8 r90152a4  
    1010// Created On       : Mon Feb  6 16:07:02 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Jul 21 23:05:52 2017
    13 // Update Count     : 3
     12// Last Modified On : Thu Jul 19 13:50:51 2018
     13// Update Count     : 15
    1414//
    1515
     
    2929enum __attribute__(( packed )) Agn3 { E2 };
    3030#ifdef __CFA__
    31 struct __attribute__(( unused )) ( int ) {};
    32 struct __attribute__(( unused )) ( int ) {};
     31struct __attribute__(( unused )) {} ( int );
     32struct __attribute__(( unused )) Agn4 {} ( int );
    3333#endif // __CFA__
    3434
     
    4242    __attribute__(( unused )) int f5 __attribute__(( unused ));
    4343    __attribute__(( used )) int f6 __attribute__(( packed )), f7 __attribute__(( unused )) __attribute__(( unused )), __attribute__(( used )) f8 __attribute__(( unused ));
    44     int __attribute__(( unused ));
    4544    int ( ( * (f9) __attribute__(( unused )) ) __attribute__(( unused )) );
    4645};
     
    149148struct Vad {
    150149    int __attribute__(( unused ));
    151     int __attribute__(( unused )) * __attribute__(( unused ));
    152     int __attribute__(( unused )) [10] __attribute__(( unused ));
    153     int __attribute__(( unused )) (*)() __attribute__(( unused ));
     150    int __attribute__(( unused )) :4;
     151    int __attribute__(( unused )) :4, __attribute__(( unused )) :6;
    154152};
    155153
  • tests/avltree/avl1.c

    rf9feab8 r90152a4  
    11#include "avl.h"
    22// #include "cwrap.h"
    3 #include <stdlib>
     3#include <stdlib.hfa>
    44
    55forall(otype K | Comparable(K), otype V)
  • tests/avltree/avl3.c

    rf9feab8 r90152a4  
    11#include "avl.h"
    22#include "avl-private.h"
    3 #include <stdlib>
     3#include <stdlib.hfa>
    44
    55// swaps the data within two tree nodes
  • tests/avltree/avl_test.c

    rf9feab8 r90152a4  
    11#include "avl.h"
    22#include "avl-private.h"
    3 #include <stdlib>
     3#include <stdlib.hfa>
    44
    55extern "C" {
  • tests/complex.c

    rf9feab8 r90152a4  
    1 // 
     1//
    22// Cforall Version 1.0.0 Copyright (C) 2017 University of Waterloo
    33//
    44// The contents of this file are covered under the licence agreement in the
    55// file "LICENCE" distributed with Cforall.
    6 // 
    7 // complex.c -- 
    8 // 
     6//
     7// complex.c --
     8//
    99// Author           : Peter A. Buhr
    1010// Created On       : Wed May 24 22:07:31 2017
     
    1212// Last Modified On : Wed May 24 22:08:01 2017
    1313// Update Count     : 1
    14 // 
     14//
    1515
    1616#include <stdio.h>
    1717#include <complex.h>
    1818#ifdef __CFA__
    19 #include <fstream>
     19#include <fstream.hfa>
    2020#endif // __CFA
    2121
  • tests/concurrent/monitor.c

    rf9feab8 r90152a4  
    1 #include <fstream>
    2 #include <kernel>
    3 #include <monitor>
    4 #include <thread>
     1#include <fstream.hfa>
     2#include <kernel.hfa>
     3#include <monitor.hfa>
     4#include <thread.hfa>
    55
    66monitor global_t {
  • tests/concurrent/multi-monitor.c

    rf9feab8 r90152a4  
    1 #include <fstream>
    2 #include <kernel>
    3 #include <monitor>
    4 #include <thread>
     1#include <fstream.hfa>
     2#include <kernel.hfa>
     3#include <monitor.hfa>
     4#include <thread.hfa>
    55
    66static int global12, global23, global13;
  • tests/concurrent/preempt.c

    rf9feab8 r90152a4  
    1 #include <kernel>
    2 #include <thread>
     1#include <kernel.hfa>hfa>
     2#include <thread.hfa>
     3#include <time.hfa>
     4
     5#include "long_tests.h"
    36
    47#ifndef PREEMPTION_RATE
    5 #define PREEMPTION_RATE 10_000ul
     8#define PREEMPTION_RATE 10`ms
    69#endif
    710
    8 unsigned int default_preemption() {
     11Duration default_preemption() {
    912        return PREEMPTION_RATE;
    1013}
     14
     15#ifdef TEST_LONG
     16static const unsigned long N = 30_000ul;
     17#else
     18static const unsigned long N = 500ul;
     19#endif
     20
     21extern void __cfaabi_check_preemption();
    1122
    1223static volatile int counter = 0;
     
    2132
    2233void main(worker_t & this) {
    23         while(counter < 1000) {
     34        while(TEST(counter < N)) {
     35                __cfaabi_check_preemption();
    2436                if( (counter % 7) == this.value ) {
     37                        __cfaabi_check_preemption();
    2538                        int next = __atomic_add_fetch_4(&counter, 1, __ATOMIC_SEQ_CST);
     39                        __cfaabi_check_preemption();
    2640                        if( (next % 100) == 0 ) printf("%d\n", (int)next);
     41                        __cfaabi_check_preemption();
    2742                }
     43                __cfaabi_check_preemption();
     44                KICK_WATCHDOG;
    2845        }
    2946}
  • tests/concurrent/signal/block.c

    rf9feab8 r90152a4  
    77
    88
    9 #include <fstream>
    10 #include <kernel>
    11 #include <monitor>
    12 #include <stdlib>
    13 #include <thread>
     9#include <fstream.hfa>
     10#include <kernel.hfa>hfa>
     11#include <monitor.hfa>
     12#include <stdlib.hfa>
     13#include <thread.hfa>
     14#include <time.hfa>
    1415
    15 #include <time.h>
    16 
    17 static const unsigned long N = 5_000ul;
     16#include "long_tests.h"
    1817
    1918#ifndef PREEMPTION_RATE
    20 #define PREEMPTION_RATE 10_000ul
     19#define PREEMPTION_RATE 10`ms
    2120#endif
    2221
    23 unsigned int default_preemption() {
     22Duration default_preemption() {
    2423        return PREEMPTION_RATE;
    2524}
     25
     26#ifdef TEST_LONG
     27static const unsigned long N = 150_000ul;
     28#else
     29static const unsigned long N = 5_000ul;
     30#endif
    2631
    2732enum state_t { WAITED, SIGNAL, BARGE };
     
    3742}
    3843
    39 void ^?{} ( global_data_t & this ) {}
     44void ^?{} ( global_data_t & mutex this ) {}
    4045
    4146global_data_t globalA, globalB;
     
    4752//------------------------------------------------------------------------------
    4853void wait_op( global_data_t & mutex a, global_data_t & mutex b, unsigned i ) {
    49         wait( cond, (uintptr_t)this_thread );
     54    wait( cond, (uintptr_t)active_thread() );
    5055
    5156        yield( random( 10 ) );
     
    5661        }
    5762
    58         a.last_thread = b.last_thread = this_thread;
     63        a.last_thread = b.last_thread = active_thread();
    5964
    6065        yield( random( 10 ) );
     
    6368thread Waiter {};
    6469void main( Waiter & this ) {
    65         for( int i = 0; i < N; i++ ) {
     70        for( int i = 0; TEST(i < N); i++ ) {
    6671                wait_op( globalA, globalB, i );
     72                KICK_WATCHDOG;
    6773        }
    6874}
     
    7278        yield( random( 10 ) );
    7379
    74         [a.last_thread, b.last_thread, a.last_signaller, b.last_signaller] = this_thread;
     80        [a.last_thread, b.last_thread, a.last_signaller, b.last_signaller] = active_thread();
    7581
    7682        if( !is_empty( cond ) ) {
     
    102108//------------------------------------------------------------------------------
    103109void barge_op( global_data_t & mutex a ) {
    104         a.last_thread = this_thread;
     110        a.last_thread = active_thread();
    105111}
    106112
     
    118124
    119125int main(int argc, char* argv[]) {
    120         random_seed( time( NULL ) );
     126        srandom( time( NULL ) );
    121127        done = false;
    122128        processor p;
  • tests/concurrent/signal/disjoint.c

    rf9feab8 r90152a4  
    1 #include <fstream>
    2 #include <kernel>
    3 #include <monitor>
    4 #include <thread>
     1#include <fstream.hfa>
     2#include <kernel.hfa>hfa>
     3#include <monitor.hfa>
     4#include <thread.hfa>
     5#include <time.hfa>
    56
    6 #include <time.h>
    7 
    8 static const unsigned long N = 10_000ul;
     7#include "long_tests.h"
    98
    109#ifndef PREEMPTION_RATE
    11 #define PREEMPTION_RATE 10_000ul
     10#define PREEMPTION_RATE 10`ms
    1211#endif
    1312
    14 unsigned int default_preemption() {
     13Duration default_preemption() {
    1514        return PREEMPTION_RATE;
    1615}
     16
     17#ifdef TEST_LONG
     18static const unsigned long N = 300_000ul;
     19#else
     20static const unsigned long N = 10_000ul;
     21#endif
    1722
    1823enum state_t { WAIT, SIGNAL, BARGE };
     
    2328monitor global_data_t;
    2429void ?{}( global_data_t & this );
    25 void ^?{} ( global_data_t & this );
     30void ^?{} ( global_data_t & mutex this );
    2631
    2732monitor global_data_t {
     
    3944}
    4045
    41 void ^?{} ( global_data_t & this ) {}
     46void ^?{} ( global_data_t & mutex this ) {}
    4247
    4348//------------------------------------------------------------------------------
     
    6469        }
    6570
    66         d.counter++;
     71        #if !defined(TEST_FOREVER)
     72                d.counter++;
     73                if( (d.counter % 1000) == 0 ) sout | d.counter | endl;
     74        #endif
    6775
    68         if( (d.counter % 1000) == 0 ) sout | d.counter | endl;
    69 
    70         return d.counter < N;
     76        return TEST(d.counter < N);
    7177}
    7278
     
    7480
    7581void main( Waiter & this ) {
    76         while( wait( mut, data ) ) { yield(); }
     82        while( wait( mut, data ) ) { KICK_WATCHDOG; yield(); }
    7783}
    7884
     
    9197
    9298        //This is technically a mutual exclusion violation but the mutex monitor protects us
    93         bool running = data.counter < N && data.counter > 0;
     99        bool running = TEST(data.counter < N) && data.counter > 0;
    94100        if( data.state != SIGNAL && running ) {
    95101                sout | "ERROR Eager signal" | data.state | endl;
     
    109115// Main loop
    110116int main(int argc, char* argv[]) {
    111         random_seed( time( NULL ) );
     117        srandom( time( NULL ) );
    112118        all_done = false;
    113119        processor p;
  • tests/concurrent/signal/wait.c

    rf9feab8 r90152a4  
    55
    66
    7 #include <fstream>
    8 #include <kernel>
    9 #include <monitor>
    10 #include <stdlib>
    11 #include <thread>
     7#include <fstream.hfa>
     8#include <kernel.hfa>hfa>
     9#include <monitor.hfa>
     10#include <stdlib.hfa>
     11#include <thread.hfa>
     12#include <time.hfa>
    1213
    13 #include <time.h>
    14 
    15 static const unsigned long N = 2_500ul;
     14#define __kick_rate 12000ul
     15#include "long_tests.h"
    1616
    1717#ifndef PREEMPTION_RATE
    18 #define PREEMPTION_RATE 10_000ul
     18#define PREEMPTION_RATE 10`ms
    1919#endif
    2020
    21 unsigned int default_preemption() {
     21Duration default_preemption() {
    2222        return PREEMPTION_RATE;
    2323}
     24
     25#ifdef TEST_LONG
     26static const unsigned long N = 375_000ul;
     27#else
     28static const unsigned long N = 2_500ul;
     29#endif
    2430
    2531monitor global_t {};
     
    8793// Waiter ABC
    8894void main( WaiterABC & this ) {
    89         for( int i = 0; i < N; i++ ) {
     95        for( int i = 0; TEST(i < N); i++ ) {
    9096                wait( condABC, globalA, globalB, globalC );
     97                KICK_WATCHDOG;
    9198        }
    9299
     
    97104// Waiter AB
    98105void main( WaiterAB & this ) {
    99         for( int i = 0; i < N; i++ ) {
     106        for( int i = 0; TEST(i < N); i++ ) {
    100107                wait( condAB , globalA, globalB );
     108                KICK_WATCHDOG;
    101109        }
    102110
     
    107115// Waiter AC
    108116void main( WaiterAC & this ) {
    109         for( int i = 0; i < N; i++ ) {
     117        for( int i = 0; TEST(i < N); i++ ) {
    110118                wait( condAC , globalA, globalC );
     119                KICK_WATCHDOG;
    111120        }
    112121
     
    117126// Waiter BC
    118127void main( WaiterBC & this ) {
    119         for( int i = 0; i < N; i++ ) {
     128        for( int i = 0; TEST(i < N); i++ ) {
    120129                wait( condBC , globalB, globalC );
     130                KICK_WATCHDOG;
    121131        }
    122132
     
    127137// Main
    128138int main(int argc, char* argv[]) {
    129         random_seed( time( NULL ) );
     139        srandom( time( NULL ) );
    130140        waiter_left = 4;
    131141        processor p[2];
  • tests/concurrent/thread.c

    rf9feab8 r90152a4  
    1 #include <fstream>
    2 #include <kernel>
    3 #include <stdlib>
    4 #include <thread>
     1#include <fstream.hfa>
     2#include <kernel.hfa>
     3#include <stdlib.hfa>
     4#include <thread.hfa>
    55
    66thread First  { semaphore* lock; };
    77thread Second { semaphore* lock; };
    88
    9 void ?{}( First & this, semaphore & lock ) { this.lock = &lock; }
    10 void ?{}( Second & this, semaphore & lock ) { this.lock = &lock; }
     9void ?{}( First  & this, semaphore & lock ) { ((thread&)this){"Thread 1"}; this.lock = &lock; }
     10void ?{}( Second & this, semaphore & lock ) { ((thread&)this){"Thread 2"}; this.lock = &lock; }
    1111
    1212void main(First& this) {
  • tests/concurrent/waitfor/barge.c

    rf9feab8 r90152a4  
    66//---------------------------------------------------------
    77
    8 #include <fstream>
    9 #include <kernel>
    10 #include <monitor>
    11 #include <stdlib>
    12 #include <thread>
     8#include <fstream.hfa>
     9#include <kernel.hfa>
     10#include <monitor.hfa>
     11#include <stdlib.hfa>
     12#include <thread.hfa>
    1313
    1414#include <stdbool.h>
  • tests/concurrent/waitfor/dtor.c

    rf9feab8 r90152a4  
    44//---------------------------------------------------------
    55
    6 #include <fstream>
    7 #include <kernel>
    8 #include <monitor>
    9 #include <stdlib>
    10 #include <thread>
     6#include <fstream.hfa>
     7#include <kernel.hfa>
     8#include <monitor.hfa>
     9#include <stdlib.hfa>
     10#include <thread.hfa>
    1111
    1212#include <stdbool.h>
  • tests/concurrent/waitfor/else.c

    rf9feab8 r90152a4  
    1 #include <fstream>
    2 #include <monitor>
     1#include <fstream.hfa>
     2#include <monitor.hfa>
    33
    44#include <stdbool.h>
  • tests/concurrent/waitfor/parse.c

    rf9feab8 r90152a4  
    88//----------------------------------------------------------------------------------------
    99
    10 #include <monitor>
     10#include <monitor.hfa>
    1111
    1212monitor M {};
  • tests/concurrent/waitfor/recurse.c

    rf9feab8 r90152a4  
    44//-----------------------------------------------------------------
    55
    6 #include <fstream>
    7 #include <kernel>
    8 #include <monitor>
    9 #include <stdlib>
    10 #include <thread>
     6#include <fstream.hfa>
     7#include <kernel.hfa>
     8#include <monitor.hfa>
     9#include <stdlib.hfa>
     10#include <thread.hfa>
    1111
    1212#include <stdbool.h>
     
    131131
    132132int main() {
    133         random_seed( time(NULL) );
     133        srandom( time(NULL) );
    134134        sout | "Starting" | endl;
    135135        {
  • tests/concurrent/waitfor/simple.c

    rf9feab8 r90152a4  
    1 #include <fstream>
    2 #include <kernel>
    3 #include <monitor>
    4 #include <stdlib>
    5 #include <thread>
     1#include <fstream.hfa>
     2#include <kernel.hfa>
     3#include <monitor.hfa>
     4#include <stdlib.hfa>
     5#include <thread.hfa>
    66
    77#include <time.h>
     
    1010
    1111#ifndef PREEMPTION_RATE
    12 #define PREEMPTION_RATE 10_000ul
     12#define PREEMPTION_RATE 10`ms
    1313#endif
    1414
    15 unsigned int default_preemption() {
     15Duration default_preemption() {
    1616        return PREEMPTION_RATE;
    1717}
     
    7474int main(int argc, char* argv[]) {
    7575        done = false;
    76         random_seed( time( NULL ) );
     76        srandom( time( NULL ) );
    7777        printf("%p\n", &globalA);
    7878        sout | "Starting" | endl;
  • tests/concurrent/waitfor/statment.c

    rf9feab8 r90152a4  
    1 #include <fstream>
    2 #include <kernel>
    3 #include <monitor>
    4 #include <thread>
     1#include <fstream.hfa>
     2#include <kernel.hfa>
     3#include <monitor.hfa>
     4#include <thread.hfa>
    55
    66#include <stdbool.h>
  • tests/concurrent/waitfor/when.c

    rf9feab8 r90152a4  
    44//-----------------------------------------------------------------
    55
    6 #include <fstream>
    7 #include <kernel>
    8 #include <monitor>
    9 #include <stdlib>
    10 #include <thread>
     6#include <fstream.hfa>
     7#include <kernel.hfa>
     8#include <monitor.hfa>
     9#include <stdlib.hfa>
     10#include <thread.hfa>
    1111
    1212#include <stdbool.h>
     
    7777
    7878int main() {
    79         random_seed( time(NULL) );
     79        srandom( time(NULL) );
    8080        sout | "Starting" | endl;
    8181        {
  • tests/coroutine/.in/fmtLines.txt

    rf9feab8 r90152a4  
    1 // 
     1//
    22// Cforall Version 1.0.0 Copyright (C) 2017 University of Waterloo
    33//
    44// The contents of this file are covered under the licence agreement in the
    55// file "LICENCE" distributed with Cforall.
    6 // 
    7 // fmtLines.cc -- 
    8 // 
     6//
     7// fmtLines.cc --
     8//
    99// Author           : Peter A. Buhr
    1010// Created On       : Sun Sep 17 21:56:15 2017
     
    1212// Last Modified On : Mon Sep 18 11:35:57 2017
    1313// Update Count     : 31
    14 // 
     14//
    1515
    16 #include <fstream>
    17 #include <coroutine>
     16#include <fstream.hfa>
     17#include <coroutine.hfa>
    1818
    1919coroutine Format {
  • tests/coroutine/fibonacci.c

    rf9feab8 r90152a4  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // fibonacci.c --
     7// fibonacci.c -- 3-state finite-state machine
    88//
    99// Author           : Thierry Delisle
    1010// Created On       : Thu Jun  8 07:29:37 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun Sep 17 21:38:15 2017
    13 // Update Count     : 7
     12// Last Modified On : Sat Aug 18 11:21:58 2018
     13// Update Count     : 24
    1414//
    1515
    16 #include <fstream>
    17 #include <coroutine>
     16#include <fstream.hfa>
     17#include <coroutine.hfa>
    1818
    19 coroutine Fibonacci {
    20         int fn;                                                                                         // used for communication
    21 };
     19coroutine Fibonacci { int fn; };                                                // used for communication
    2220
    23 void ?{}( Fibonacci & this ) {
    24         this.fn = 0;
    25 }
    26 
    27 void main( Fibonacci & this ) {
     21void main( Fibonacci & fib ) with( fib ) {                              // called on first resume
    2822        int fn1, fn2;                                                                           // retained between resumes
    29         this.fn = 0;                                                                            // case 0
    30         fn1 = this.fn;
     23        fn = 0;  fn1 = fn;                                                                      // 1st case
    3124        suspend();                                                                                      // restart last resume
    32 
    33         this.fn = 1;                                                                            // case 1
    34         fn2 = fn1;  fn1 = this.fn;
     25        fn = 1;  fn2 = fn1;  fn1 = fn;                                          // 2nd case
    3526        suspend();                                                                                      // restart last resume
    36 
    37         for ( ;; ) {                                                                            // general case
    38                 this.fn = fn1 + fn2;
    39                 fn2 = fn1;  fn1 = this.fn;
     27        for () {
     28                fn = fn1 + fn2;  fn2 = fn1;  fn1 = fn;                  // general case
    4029                suspend();                                                                              // restart last resume
    4130        } // for
    4231}
    4332
    44 int next( Fibonacci & this ) {
    45         resume( this );                                                                         // restart last suspend
    46         return this.fn;
     33int next( Fibonacci & fib ) with( fib ) {
     34        resume( fib );                                                                          // restart last suspend
     35        return fn;
    4736}
    4837
    4938int main() {
    5039        Fibonacci f1, f2;
    51         for ( int i = 1; i <= 10; i += 1 ) {
     40        for ( 10 ) {                                                                            // print N Fibonacci values
    5241                sout | next( f1 ) | next( f2 ) | endl;
    5342        } // for
  • tests/coroutine/pingpong.c

    rf9feab8 r90152a4  
    1 // 
     1//
    22// Cforall Version 1.0.0 Copyright (C) 2017 University of Waterloo
    33//
    44// The contents of this file are covered under the licence agreement in the
    55// file "LICENCE" distributed with Cforall.
    6 // 
    7 // pingpong.c -- 
    8 // 
     6//
     7// pingpong.c --
     8//
    99// Author           : Peter A. Buhr
    1010// Created On       : Wed Sep 20 11:55:23 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Sep 20 13:41:39 2017
    13 // Update Count     : 26
    14 // 
     12// Last Modified On : Sat Aug 18 11:31:11 2018
     13// Update Count     : 28
     14//
    1515
    16 #include <coroutine>
    17 #include <fstream>
     16#include <coroutine.hfa>
     17#include <fstream.hfa>
    1818
    1919coroutine PingPong {
     
    3939}
    4040void main( PingPong & pingpong ) {                                              // ping's starter ::main, pong's starter ping
    41         for ( unsigned int i = 0; i < pingpong.N; i += 1 ) {
     41        for ( pingpong.N ) {                                                            // N ping-pongs
    4242                sout | pingpong.name | endl;
    4343                cycle( *pingpong.part );
  • tests/coroutine/prodcons.c

    rf9feab8 r90152a4  
    1 // 
     1//
    22// Cforall Version 1.0.0 Copyright (C) 2017 University of Waterloo
    33//
    44// The contents of this file are covered under the licence agreement in the
    55// file "LICENCE" distributed with Cforall.
    6 // 
    7 // prodcons.c -- 
    8 // 
     6//
     7// prodcons.c --
     8//
    99// Author           : Peter A. Buhr
    1010// Created On       : Mon Sep 18 12:23:39 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Oct 30 23:06:05 2017
    13 // Update Count     : 42
    14 // 
     12// Last Modified On : Sat Aug 18 12:55:10 2018
     13// Update Count     : 51
     14//
    1515
    16 #include <fstream>
    17 #include <coroutine>
    18 #include <stdlib>                                                                               // random
     16#include <fstream.hfa>
     17#include <coroutine.hfa>
     18#include <stdlib.hfa>                                                                   // random
    1919#include <unistd.h>                                                                             // getpid
    2020
     
    2424
    2525coroutine Prod {
    26         Cons *c;
     26        Cons * c;
    2727        int N, money, receipt;
    2828};
    29 void main( Prod & prod ) {                                                              // starter ::main
     29void main( Prod & prod ) with( prod ) {                                 // starter ::main
    3030        // 1st resume starts here
    31         for ( int i = 0; i < prod.N; i += 1 ) {
     31        for ( i; N ) {                                                                          // N pairs of values
    3232                int p1 = random( 100 );
    3333                int p2 = random( 100 );
    3434                sout | p1 | " " | p2 | endl;
    35                 int status = delivery( *prod.c, p1, p2 );
    36                 sout | " $" | prod.money | endl;
     35                int status = delivery( *c, p1, p2 );
     36                sout | " $" | money | endl;
    3737                sout | status | endl;
    38                 prod.receipt += 1;
     38                receipt += 1;
    3939        }
    40         stop( *prod.c );
     40        stop( *c );
    4141        sout | "prod stops" | endl;
    4242}
     
    6464}
    6565void ^?{}( Cons & cons ) {}
    66 void main( Cons & cons ) {                                                              // starter prod
     66void main( Cons & cons ) with( cons ) {                                 // starter prod
    6767        // 1st resume starts here
    6868        int money = 1, receipt;
    69         for ( ; ! cons.done; ) {
    70                 sout | cons.p1 | " " | cons.p2 | endl;
     69        for ( ; ! done; ) {
     70                sout | p1 | " " | p2 | endl;
    7171                sout | " $" | money | endl;
    72                 cons.status += 1;
    73                 receipt = payment( *cons.p, money );
     72                status += 1;
     73                receipt = payment( *p, money );
    7474                sout | " #" | receipt | endl;
    7575                money += 1;
     
    9090        Prod prod;
    9191        Cons cons = { prod };
    92         random_seed( /* getpid() */ 103 );                                      // fixed seed for testing
     92        srandom( /* getpid() */ 103 );                                          // fixed seed for testing
    9393        start( prod, 5, cons );
    9494        sout | "main stops" | endl;
  • tests/div.c

    rf9feab8 r90152a4  
    1 // 
     1//
    22// Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
    33//
    44// The contents of this file are covered under the licence agreement in the
    55// file "LICENCE" distributed with Cforall.
    6 // 
    7 // div.c -- 
    8 // 
     6//
     7// div.c --
     8//
    99// Author           : Peter A. Buhr
    1010// Created On       : Tue Aug  8 16:28:43 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Aug 30 07:56:28 2017
    13 // Update Count     : 17
    14 // 
     12// Last Modified On : Thu Dec  7 09:06:52 2017
     13// Update Count     : 18
     14//
    1515
    16 #include <fstream>
    17 #include <stdlib>                                                                               // div
     16#include <fstream.hfa>
     17#include <stdlib.hfa>                                                                           // div
    1818
    1919struct T { int i; };
    2020T ?/?( T t1, T t2 ) { return t1.i / t2.i; }
    2121T ?%?( T t1, T t2 ) { return t1.i % t2.i; }
    22 ofstream * ?|?( ofstream * os, T t ) { return os | t.i; }
     22ofstream & ?|?( ofstream & os, T t ) { return os | t.i; }
    2323
    2424int main( void ) {
  • tests/except-2.c

    rf9feab8 r90152a4  
    22
    33
    4 #include <stdlib>
     4#include <stdlib.hfa>
    55#include "except-mac.h"
    66
  • tests/fstream_test.c

    rf9feab8 r90152a4  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // fstream_test.c -- 
     7// fstream_test.c --
    88//
    99// Author           : Peter A. Buhr
     
    1414//
    1515
    16 #include <fstream>
     16#include <fstream.hfa>
    1717
    1818int main( void ) {
  • tests/function-operator.c

    rf9feab8 r90152a4  
    99// Author           : Rob Schluntz
    1010// Created On       : Fri Aug 25 15:21:11 2017
    11 // Last Modified By : Rob Schluntz
    12 // Last Modified On : Fri Aug 25 15:31:29 2017
    13 // Update Count     : 2
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Thu Aug  2 09:27:53 2018
     13// Update Count     : 8
    1414//
    1515
    16 #include <fstream>
    17 #include <stdlib>
     16#include <fstream.hfa>
     17#include <stdlib.hfa>
    1818
    1919#define length(array) (sizeof((array))/sizeof((array)[0]))
     
    3434forall(otype Tin, dtype Input | Iterator(Input, Tin), otype Tout, dtype Output | Iterator(Output, Tout) | Assignable(Tout, Tin))
    3535Output copy(Input first, Input last, Output result) {
    36   while (first != last) {
    37     *result = *first;
    38     ++result; ++first;
    39   }
    40   return result;
     36        while (first != last) {
     37                *result = *first;
     38                ++result; ++first;
     39        }
     40        return result;
    4141}
    4242
     
    4444forall(otype Tin, dtype Input | Iterator(Input, Tin), otype Tout, dtype Output | Iterator(Output, Tout), otype FuncRet, dtype Func | { FuncRet ?()(Func *, Tin); } | Assignable(Tout, FuncRet))
    4545Output transform (Input first, Input last, Output result, Func * op) {
    46   while (first != last) {
    47     *result = op(*first);
    48     ++result; ++first;
    49   }
    50   return result;
     46        while (first != last) {
     47                *result = op(*first);
     48                ++result; ++first;
     49        }
     50        return result;
    5151}
    5252
     
    5454forall(dtype Iter, otype T | Iterator(Iter, T), otype Pred | { int ?()(Pred, T); })
    5555Iter find_if (Iter first, Iter last, Pred pred) {
    56   while (first != last) {
    57     if (pred(*first)) return first;
    58     ++first;
    59   }
    60   return last;
     56        while (first != last) {
     57                if (pred(*first)) return first;
     58                ++first;
     59        }
     60        return last;
    6161}
    6262
     
    6464forall(otype Generator, otype GenRet | { GenRet ?()(Generator &); }, dtype Iter, otype T| Iterator(Iter, T) | Assignable(T, GenRet))
    6565void generate(Iter first, Iter last, Generator & gen) {
    66   int i = 0;
    67   while (first != last) {
    68     *first = gen();
    69     ++first;
    70   }
     66        int i = 0;
     67        while (first != last) {
     68                *first = gen();
     69                ++first;
     70        }
    7171}
    7272
     
    7878// TODO: abstract over os type with ostream trait; resolver is currently too slow for this to be reasonable, but it does work.
    7979struct os_wrapper {
    80   ofstream * out;
     80        ofstream * out;
    8181};
    8282
    8383// TODO: abstract over (os, T)
    8484os_wrapper ?=?(os_wrapper & wrapper, int x) {
    85   wrapper.out | x | endl;
    86   return wrapper;
     85        *wrapper.out | x | endl;
     86        return wrapper;
    8787}
    8888
    89 struct ostream_iterator {
    90   os_wrapper * out;
    91 };
     89        struct ostream_iterator {
     90                os_wrapper * out;
     91        };
    9292void ?{}(ostream_iterator & iter, ofstream * out) {
    93   iter.out = new(out);
     93        iter.out = new(out);
    9494}
    9595// no destructor, memory leak. This is necessary for this to work at the moment, since
     
    9898// implement Iterator
    9999os_wrapper & *?(ostream_iterator iter) {
    100   return *iter.out;
     100        return *iter.out;
    101101}
    102102ostream_iterator ++?(ostream_iterator & iter) {
    103   // nothing to do
    104   return iter;
     103        // nothing to do
     104        return iter;
    105105}
    106106int ?!=?(ostream_iterator i1, ostream_iterator i2) {
    107   return i1.out->out != i2.out->out;
     107        return i1.out->out != i2.out->out;
    108108}
    109109
     
    132132forall(otype Return, ttype Args)
    133133struct function {
    134   Return (*f)(Args);
     134        Return (*f)(Args);
    135135};
    136136// TODO: missing adapter in these functions
     
    148148
    149149        // copy for output
    150         ostream_iterator out_iter = { sout };
     150        ostream_iterator out_iter = { &sout };
    151151        copy(begin(x), end(x), out_iter);
    152152        copy(begin(y), end(y), out_iter);
     
    168168        transform(begin(x), end(x), begin(x), &times2);
    169169        copy(begin(x), end(x), out_iter);
     170
     171        // REMOVE WHEN ?* PROBLEM FIXED.
     172        delete(out_iter.out);
    170173}
    171174
  • tests/functions.c

    rf9feab8 r90152a4  
    1 // 
     1//
    22// Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
    33//
    44// The contents of this file are covered under the licence agreement in the
    55// file "LICENCE" distributed with Cforall.
    6 // 
    7 // functions.c -- 
    8 // 
     6//
     7// functions.c --
     8//
    99// Author           : Peter A. Buhr
    1010// Created On       : Wed Aug 17 08:39:58 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Nov 27 18:08:54 2017
    13 // Update Count     : 11
    14 // 
     12// Last Modified On : Wed Jan 17 22:44:12 2018
     13// Update Count     : 12
     14//
    1515
    1616// ANSI function definitions
     
    2525        void g(void)
    2626        ) {
    27         (*g)();
     27        (* g)();
    2828        g();
    2929        g = h;
     
    3232int f1() {}
    3333int (f2()) {}
    34 int (*f3())() {}
    35 int *((f4())) {}
    36 int ((*f5()))() {}
    37 int *f6() {}
    38 int *(f7)() {}
    39 int **f8() {}
    40 int * const *(f9)() {}
    41 int (*f10())[] {}
    42 int (*f11())[][3] {}
    43 int ((*f12())[])[3] {}
     34int (* f3())() {}
     35int * ((f4())) {}
     36int ((* f5()))() {}
     37int * f6() {}
     38int * (f7)() {}
     39int ** f8() {}
     40int * const * (f9)() {}
     41int (* f10())[] {}
     42int (* f11())[][3] {}
     43int ((* f12())[])[3] {}
    4444
    4545// "implicit int" otype specifier (not ANSI)
     
    5050extern const fII4( int i ) {}
    5151
    52 *fII5() {}
    53 const *fII6() {}
    54 const long *fII7() {}
    55 static const long *fII8() {}
    56 const static long *fII9() {}
     52* fII5() {}
     53const * fII6() {}
     54const long * fII7() {}
     55static const long * fII8() {}
     56const static long * fII9() {}
    5757
    5858// K&R function definitions
     
    117117        [int](int)
    118118        ) {
    119         int (*(*pc)[][10])[][3];
     119        int (* (* pc)[][10])[][3];
    120120        * [][10] * [][3] int p;
    121121        * [] * [int](int) p;
    122122}
    123123
    124 static const int *f1() {}
    125 static [ const int ] f2() {}
     124static const int * f1() {}
     125static [ * const int ] f2() {}
    126126static inline [ const * int ] f3() {}
    127127static inline [ const [ * int, int ] ] f4() {}
     
    133133        int (),
    134134
    135         int *(),
    136         int **(),
    137         int * const *(),
     135        int * (),
     136        int ** (),
     137        int * const * (),
    138138        int * const * const (),
    139139
     
    141141        int ([10]),
    142142
    143         int *([]),
    144         int *([10]),
    145         int **([]),
    146         int **([10]),
    147         int * const *([]),
    148         int * const *([10]),
     143        int * ([]),
     144        int * ([10]),
     145        int ** ([]),
     146        int ** ([10]),
     147        int * const * ([]),
     148        int * const * ([10]),
    149149        int * const * const ([]),
    150150        int * const * const ([10])
     
    154154        int (),
    155155
    156         int *(),
    157         int **(),
    158         int * const *(),
     156        int * (),
     157        int ** (),
     158        int * const * (),
    159159        int * const * const (),
    160160
     
    162162        int ([10]),
    163163
    164         int *([]),
    165         int *([10]),
    166         int **([]),
    167         int **([10]),
    168         int * const *([]),
    169         int * const *([10]),
     164        int * ([]),
     165        int * ([10]),
     166        int ** ([]),
     167        int ** ([10]),
     168        int * const * ([]),
     169        int * const * ([10]),
    170170        int * const * const ([]),
    171171        int * const * const ([10])
     
    175175typedef int T;
    176176
    177 int f( T (*f), T t ) {
     177int f( T (* f), T t ) {
    178178        T (T);
    179179}
     
    184184//int (f[])() {}
    185185//int f[]() {}
    186 //int ((*f15())())[] {}
     186//int ((* f15())())[] {}
    187187
    188188// Local Variables: //
  • tests/genericUnion.c

    rf9feab8 r90152a4  
    1 #include <limits>
     1#include <limits.hfa>
    22
    33forall(otype T)
  • tests/gmp.c

    rf9feab8 r90152a4  
    1 // 
     1//
    22// Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
    33//
    44// The contents of this file are covered under the licence agreement in the
    55// file "LICENCE" distributed with Cforall.
    6 // 
    7 // gmp.c -- 
    8 // 
     6//
     7// gmp.c --
     8//
    99// Author           : Peter A. Buhr
    1010// Created On       : Tue Apr 19 08:55:51 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Sep 28 18:33:51 2017
    13 // Update Count     : 555
    14 // 
     12// Last Modified On : Sat Aug 18 12:43:13 2018
     13// Update Count     : 556
     14//
    1515
    1616// NOTE: UBUNTU DOES NOT SUPPORT GMP MULTILIB, SO ONLY 64-BIT GMP IS TESTED.
    1717
    18 #include <gmp>
     18#include <gmp.hfa>
    1919
    2020int main( void ) {
     
    8989        fn = 1; fn2 = fn1; fn1 = fn;                                            // 2nd case
    9090        sout | 1 | fn | endl;
    91         for ( unsigned int i = 2; i <= 200; i += 1 ) {
     91        for ( i; 2u ~= 200 ) {
    9292                fn = fn1 + fn2; fn2 = fn1; fn1 = fn;                    // general case
    9393                sout | i | fn | endl;
     
    9999        Int fact = 1;                                                                           // 1st case
    100100        sout | (int)0 | fact | endl;
    101         for ( unsigned int i = 1; i <= 40; i += 1 ) {
     101        for ( i; 1u ~= 40u ) {
    102102                fact *= i;                                                                              // general case
    103103                sout | i | fact | endl;
  • tests/hello.c

    rf9feab8 r90152a4  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // hello.c -- 
     7// hello.c --
    88//
    99// Author           : Peter A. Buhr
     
    1414//
    1515
    16 #include <fstream>
     16#include <fstream.hfa>
    1717
    1818int main() {
  • tests/identFuncDeclarator.c

    rf9feab8 r90152a4  
    1010// Created On       : Wed Aug 17 08:36:34 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Aug 17 08:37:06 2016
    13 // Update Count     : 1
     12// Last Modified On : Wed Jan 17 22:39:13 2018
     13// Update Count     : 2
    1414//
    1515
     
    1818        int (f2);
    1919
    20         int *f3;
    21         int **f4;
    22         int * const *f5;
     20        int * f3;
     21        int ** f4;
     22        int * const * f5;
    2323        int * const * const f6;
    2424
    25         int *(f7);
    26         int **(f8);
    27         int * const *(f9);
     25        int * (f7);
     26        int ** (f8);
     27        int * const * (f9);
    2828        int * const * const (f10);
    2929
    30         int (*f11);
    31         int (**f12);
    32         int (* const *f13);
     30        int (* f11);
     31        int (** f12);
     32        int (* const * f13);
    3333        int (* const * const f14);
    3434
     
    3838        int (f18[10]);
    3939
    40         int *f19[2];
    41         int *f20[10];
    42         int **f21[2];
    43         int **f22[10];
    44         int * const *f23[2];
    45         int * const *f24[10];
     40        int * f19[2];
     41        int * f20[10];
     42        int ** f21[2];
     43        int ** f22[10];
     44        int * const * f23[2];
     45        int * const * f24[10];
    4646        int * const * const f25[2];
    4747        int * const * const f26[10];
    4848
    49         int *(f27[2]);
    50         int *(f28[10]);
    51         int **(f29[2]);
    52         int **(f30[10]);
    53         int * const *(f31[2]);
    54         int * const *(f32[10]);
     49        int * (f27[2]);
     50        int * (f28[10]);
     51        int ** (f29[2]);
     52        int ** (f30[10]);
     53        int * const * (f31[2]);
     54        int * const * (f32[10]);
    5555        int * const * const (f33[2]);
    5656        int * const * const (f34[10]);
    5757
    58         int (*f35[2]);
    59         int (*f36[10]);
    60         int (**f37[2]);
    61         int (**f38[10]);
    62         int (* const *f39[2]);
    63         int (* const *f40[10]);
     58        int (* f35[2]);
     59        int (* f36[10]);
     60        int (** f37[2]);
     61        int (** f38[10]);
     62        int (* const * f39[2]);
     63        int (* const * f40[10]);
    6464        int (* const * const f41[2]);
    6565        int (* const * const f42[10]);
     
    7272        int ((f48[3]))[3];
    7373
    74         int *f49[2][3];
    75         int *f50[3][3];
    76         int **f51[2][3];
    77         int **f52[3][3];
    78         int * const *f53[2][3];
    79         int * const *f54[3][3];
     74        int * f49[2][3];
     75        int * f50[3][3];
     76        int ** f51[2][3];
     77        int ** f52[3][3];
     78        int * const * f53[2][3];
     79        int * const * f54[3][3];
    8080        int * const * const f55[2][3];
    8181        int * const * const f56[3][3];
    8282
    83         int (*f57[2][3]);
    84         int (*f58[3][3]);
    85         int (**f59[2][3]);
    86         int (**f60[3][3]);
    87         int (* const *f61[2][3]);
    88         int (* const *f62[3][3]);
     83        int (* f57[2][3]);
     84        int (* f58[3][3]);
     85        int (** f59[2][3]);
     86        int (** f60[3][3]);
     87        int (* const * f61[2][3]);
     88        int (* const * f62[3][3]);
    8989        int (* const * const f63[2][3]);
    9090        int (* const * const f64[3][3]);
     
    9393        int (f66)(int);
    9494
    95         int *f67(int);
    96         int **f68(int);
    97         int * const *f69(int);
     95        int * f67(int);
     96        int ** f68(int);
     97        int * const * f69(int);
    9898        int * const * const f70(int);
    9999
    100         int *(f71)(int);
    101         int **(f72)(int);
    102         int * const *(f73)(int);
     100        int * (f71)(int);
     101        int ** (f72)(int);
     102        int * const * (f73)(int);
    103103        int * const * const (f74)(int);
    104104
    105         int (*f75)(int);
    106         int (**f76)(int);
    107         int (* const *f77)(int);
     105        int (* f75)(int);
     106        int (** f76)(int);
     107        int (* const * f77)(int);
    108108        int (* const * const f78)(int);
    109109
    110         int (*(*f79)(int))();
    111         int (*(* const f80)(int))();
     110        int (* (* f79)(int))();
     111        int (* (* const f80)(int))();
    112112        int (* const(* const f81)(int))();
    113113}
  • tests/identParamDeclarator.c

    rf9feab8 r90152a4  
    1010// Created On       : Wed Aug 17 08:37:56 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Aug 17 08:38:42 2016
    13 // Update Count     : 1
     12// Last Modified On : Wed Jan 17 22:36:11 2018
     13// Update Count     : 2
    1414//
    1515
    16 int fred(
     16int fred (
    1717        int f1,
    1818        int (f2),
     
    157157    );
    158158
    159 //Dummy main
    160 int main(int argc, char const *argv[])
    161 {
     159int main( int argc, char const *argv[] ) {                              // dummy main
    162160        return 0;
    163161}
  • tests/identity.c

    rf9feab8 r90152a4  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // identity.c -- 
     7// identity.c --
    88//
    99// Author           : Peter A. Buhr
     
    1414//
    1515
    16 #include <fstream>
     16#include <fstream.hfa>
    1717
    1818forall( otype T )
  • tests/ifwhileCtl.c

    rf9feab8 r90152a4  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // ifcond.c --
     7// ifwhileCtl.c --
    88//
    99// Author           : Peter A. Buhr
    1010// Created On       : Sat Aug 26 10:13:11 2017
    11 // Last Modified By : Rob Schluntz
    12 // Last Modified On : Fri Sep 01 15:22:19 2017
    13 // Update Count     : 14
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Wed Jun  6 17:15:09 2018
     13// Update Count     : 21
    1414//
    1515
    16 #include <fstream>
     16#include <fstream.hfa>
    1717
    1818int f( int r ) { return r; }
     
    4040                sout | "x != y incorrect" | endl;
    4141        } // if
     42
     43        if ( struct S { int i; } s = { 3 }; s.i < 4 ) {
     44                S s1;
     45                sout | "s.i < 4 correct" | endl;
     46        } else {
     47                S s1;
     48                sout | "s.i >= 4 incorrect" | endl;
     49        } // if
     50
     51        while ( int x = 1 ) {
     52                sout | "x != 0 correct" | endl;
     53                break;
     54        } // while
     55
     56        while ( int x = 4, y = 0 ) {
     57                sout | "x != 0 && y != 0 incorrect" | endl;
     58        } // while
     59
     60        while ( int x = 5, y = f( x ); x == y ) {
     61                sout | "x == y correct" | endl;
     62                break;
     63        } // while
     64
     65        while ( struct S { int i; } s = { 3 }; s.i < 4 ) {
     66                S s1;
     67                sout | "s.i < 4 correct" | endl;
     68                break;
     69        } // while
    4270} // main
    4371
    4472// Local Variables: //
    4573// tab-width: 4 //
    46 // compile-command: "cfa ifcond.c" //
     74// compile-command: "cfa ifwhileCtl.c" //
    4775// End: //
  • tests/io2.c

    rf9feab8 r90152a4  
    1 // 
     1//
    22// Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
    33//
    44// The contents of this file are covered under the licence agreement in the
    55// file "LICENCE" distributed with Cforall.
    6 // 
    7 // io.c --
    8 // 
     6//
     7// io2.c --
     8//
    99// Author           : Peter A. Buhr
    1010// Created On       : Wed Mar  2 16:56:02 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Sep 11 08:53:41 2017
    13 // Update Count     : 81
    14 // 
     12// Last Modified On : Thu May 24 21:17:41 2018
     13// Update Count     : 103
     14//
    1515
    16 #include <fstream>
     16#include <fstream.hfa>
     17
     18 #define xstr(s) str(s)
     19#define str(s) #s
    1720
    1821int main() {
    19         char c;                                                                                         // basic types
     22        _Bool b;                                                                                        // basic types
     23        char c;
    2024        signed char sc;
    2125        unsigned char usc;
     
    3741        char s1[size], s2[size];
    3842
    39         int x = 3, y = 5, z = 7;
    40         sout | x * 3 | y + 1 | z << 2 | x == y | (x | y) | (x || y) | (x > z ? 1 : 2) | endl;
    41         sout | 1 | 2 | 3 | endl;
    42         sout | '1' | '2' | '3' | endl;
    43         sout | 1 | "" | 2 | "" | 3 | endl;
    44         sout | endl;
    45 
    46         sout | "opening delimiters" | endl;
    47         sout
    48                 | "x (" | 1
    49                 | "x [" | 2
    50                 | "x {" | 3
    51                 | "x =" | 4
    52                 | "x $" | 5
    53                 | "x £" | 6
    54                 | "x ¥" | 7
    55                 | "x ¡" | 8
    56                 | "x ¿" | 9
    57                 | "x «" | 10
    58                 | endl | endl;
    59 
    60         sout | "closing delimiters" | endl;
    61         sout
    62                 | 1 | ", x"
    63                 | 2 | ". x"
    64                 | 3 | "; x"
    65                 | 4 | "! x"
    66                 | 5 | "? x"
    67                 | 6 | "% x"
    68                 | 7 | "¢ x"
    69                 | 8 | "» x"
    70                 | 9 | ") x"
    71                 | 10 | "] x"
    72                 | 11 | "} x"
    73                 | endl | endl;
    74 
    75         sout | "opening/closing delimiters" | endl;
    76         sout
    77                 | "x`" | 1 | "`x'" | 2
    78                 | "'x\"" | 3 | "\"x:" | 4
    79                 | ":x " | 5 | " x\t" | 6
    80                 | "\tx\f" | 7 | "\fx\v" | 8
    81                 | "\vx\n" | 9 | "\nx\r" | 10
    82                 | "\rx"
    83                 | endl | endl;
    84 
    85         sout | "override opening/closing delimiters" | endl;
    86         sout | "x ( " | 1 | " ) x" | 2 | " , x" | 3 | " :x: " | 4 | endl;
    87         sout | endl;
    88 
    89         ifstream in;                                                                            // create / open file
    90         open( &in, "io.data", "r" );
     43        ifstream in = { xstr(IN_DIR) "io.data" };                                               // create / open file
    9144
    9245        sout | "input bacis types" | endl;
    93         &in | c | sc | usc                                                                      // character
    94                 | si | usi | i | ui | li | uli | lli | ulli             // integral
    95                 | f | d | ld                                                                    // floating point
    96                 | fc | dc | ldc                                                                 // floating-point complex
    97                 | cstr( s1 ) | cstr( s2, size );                                // C string, length unchecked and checked
     46        in       | b                                                                                    // boolean
     47                 | c | sc | usc                                                                 // character
     48                 | si | usi | i | ui | li | uli | lli | ulli    // integral
     49                 | f | d | ld                                                                   // floating point
     50                 | fc | dc | ldc                                                                // floating-point complex
     51                 | cstr( s1 ) | cstr( s2, size );                               // C string, length unchecked and checked
    9852        sout | endl;
    9953
    10054        sout | "output basic types" | endl;
    101         sout | c | ' ' | sc | ' ' | usc | endl                          // character
    102                 | si | usi | i | ui | li | uli | lli | ulli | endl // integral
    103                 | f | d | ld | endl                                                             // floating point
    104                 | fc | dc | ldc | endl;                                                 // complex
     55        sout | b | endl                                                                         // boolean
     56                 | c | ' ' | sc | ' ' | usc | endl                              // character
     57                 | si | usi | i | ui | li | uli | lli | ulli | endl // integral
     58                 | f | d | ld | endl                                                    // floating point
     59                 | fc | dc | ldc | endl;                                                // complex
    10560        sout | endl;
    10661
     
    11267        sout | "toggle separator" | endl;
    11368        sout | f | "" | d | "" | ld | endl                                      // floating point without separator
    114                 | sepDisable | fc | dc | ldc | endl                             // complex without separator
    115                 | fc | sepOn | dc | ldc | endl                                  // local separator add
    116                 | sepEnable | fc | dc | ldc | endl                              // complex with separator
    117                 | fc | sepOff | dc | ldc | endl                                 // local separator removal
    118                 | s1 | sepOff | s2 | endl                                               // local separator removal
    119                 | s1 | "" | s2 | endl;                                                  // local separator removal
     69                 | sepDisable | fc | dc | ldc | endl                    // complex without separator
     70                 | fc | sepOn | dc | ldc | endl                                 // local separator add
     71                 | sepEnable | fc | dc | ldc | endl                             // complex with separator
     72                 | fc | sepOff | dc | ldc | endl                                // local separator removal
     73                 | s1 | sepOff | s2 | endl                                              // local separator removal
     74                 | s1 | "" | s2 | endl;                                                 // local separator removal
    12075        sout | endl;
    12176
     
    12580        sout | " to \"" | sep | "\"" | endl;
    12681        sout | f | d | ld | endl
    127                 | fc | dc | ldc | endl
    128                 | s1 | s2 | endl
    129                 | t1 | t2 | endl;                                                               // print tuple
     82                 | fc | dc | ldc | endl
     83                 | s1 | s2 | endl
     84                 | t1 | t2 | endl;                                                              // print tuple
    13085        sout | endl;
    13186        sout | "from \"" | sep | "\" ";
     
    13388        sout | "to \"" | sep | "\"" | endl;
    13489        sout | f | d | ld | endl
    135                 | fc | dc | ldc | endl
    136                 | s1 | s2 | endl
    137                 | t1 | t2 | endl;                                                               // print tuple
     90                 | fc | dc | ldc | endl
     91                 | s1 | s2 | endl
     92                 | t1 | t2 | endl;                                                              // print tuple
    13893        sout | endl;
    13994
     
    179134// Local Variables: //
    180135// tab-width: 4 //
    181 // compile-command: "cfa io.c" //
     136// compile-command: "cfa io2.c" //
    182137// End: //
  • tests/labelledExit.c

    rf9feab8 r90152a4  
    1010// Created On       : Wed Aug 10 07:29:39 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Aug 10 07:30:15 2016
    13 // Update Count     : 1
     12// Last Modified On : Thu Aug 16 08:55:39 2018
     13// Update Count     : 3
    1414//
    1515
     
    6060        }
    6161
    62   D: for ( ;; ) {
     62  D: for () {
    6363                break D;
    6464                continue D;
     
    6767  Z : i += 1;
    6868        goto Z;
    69   X: Y: for ( ;; ) {
     69  X: Y: for () {
    7070                i += 1;
    7171                if ( i > 5 ) continue X;
     
    7474                break;
    7575        }
    76   XX: for ( ;; ) {
    77           YY: for ( ;; ) {
    78                   ZZ: for ( ;; ) {
     76  XX: for () {
     77          YY: for () {
     78                  ZZ: for () {
    7979                                i += 1;
    8080                                if ( i > 5 ) continue XX;
     
    8989        }
    9090
    91         for ( ;; ) ;
     91        for () ;
    9292        for ( int i = 0 ;; ) ;
    9393        for (  ; i < 0; ) ;
     
    9797  L20: L21: L22: L23: L24: L25: L26: L27: L28: L29:
    9898  L31: L32: L33: L34:
    99         for ( ;; ) {
     99        for () {
    100100                break L0;
    101101        }
  • tests/literals.c

    rf9feab8 r90152a4  
    1 // 
     1//
    22// Cforall Version 1.0.0 Copyright (C) 2017 University of Waterloo
    33//
    44// The contents of this file are covered under the licence agreement in the
    55// file "LICENCE" distributed with Cforall.
    6 // 
    7 // literals.c -- 
    8 // 
     6//
     7// literals.c --
     8//
    99// Author           : Peter A. Buhr
    1010// Created On       : Sat Sep  9 16:34:38 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Sep 25 20:26:00 2017
    13 // Update Count     : 132
    14 // 
     12// Last Modified On : Sun Jul  1 15:12:15 2018
     13// Update Count     : 137
     14//
    1515
    1616#ifdef __CFA__
    1717#include <stdint.h>
    18 #include <fstream>
     18#include <fstream.hfa>
    1919
    2020void f( char v ) { sout | "char " | v | endl; }
     
    3131// integer literals
    3232
     33        // binary
     34         0b01101011;   0b01101011u;   0b01101011l;   0b01101011ll;   0b01101011ul;   0b01101011lu;   0b01101011ull;   0b01101011llu;
     35        +0b01101011;  +0b01101011u;  +0b01101011l;  +0b01101011ll;  +0b01101011ul;  +0b01101011lu;  +0b01101011ull;  +0b01101011llu;
     36        -0b01101011;  -0b01101011u;  -0b01101011l;  -0b01101011ll;  -0b01101011ul;  -0b01101011lu;  -0b01101011ull;  -0b01101011llu;
     37
    3338        // octal
    3439         01234567;   01234567u;   01234567l;   01234567ll;   01234567ul;   01234567lu;   01234567ull;   01234567llu;
     
    149154// fixed-size length
    150155
     156        // binary
     157         0b01101011_l8;   0b01101011_l16;   0b01101011_l32;   0b01101011_l64;   0b01101011_l8u;   0b01101011_ul16;   0b01101011_l32u;   0b01101011_ul64;
     158        +0b01101011_l8;  +0b01101011_l16;  +0b01101011_l32;  +0b01101011_l64;  +0b01101011_l8u;  +0b01101011_ul16;  +0b01101011_l32u;  +0b01101011_ul64;
     159        -0b01101011_l8;  -0b01101011_l16;  -0b01101011_l32;  -0b01101011_l64;  -0b01101011_l8u;  -0b01101011_ul16;  -0b01101011_l32u;  -0b01101011_ul64;
     160
     161#ifdef __LP64__ // 64-bit processor
     162        0b01101011_l128;   0b01101011_ul128;
     163        +0b01101011_l128;  +0b01101011_ul128;
     164        -0b01101011_l128;  -0b01101011_ul128;
     165#endif // __LP64__
     166
    151167        // octal
    152          01234567_l8;   01234567_l16;   01234567_l32;   01234567_l64;   01234567_l128;   01234567_l8u;   01234567_ul16;   01234567_l32u;   01234567_ul64;   01234567_ul128;
    153         +01234567_l8;  +01234567_l16;  +01234567_l32;  +01234567_l64;  +01234567_l128;  +01234567_l8u;  +01234567_ul16;  +01234567_l32u;  +01234567_ul64;  +01234567_ul128;
    154         -01234567_l8;  -01234567_l16;  -01234567_l32;  -01234567_l64;  -01234567_l128;  -01234567_l8u;  -01234567_ul16;  -01234567_l32u;  -01234567_ul64;  -01234567_ul128;
     168         01234567_l8;   01234567_l16;   01234567_l32;   01234567_l64;   01234567_l8u;   01234567_ul16;   01234567_l32u;   01234567_ul64;
     169        +01234567_l8;  +01234567_l16;  +01234567_l32;  +01234567_l64;  +01234567_l8u;  +01234567_ul16;  +01234567_l32u;  +01234567_ul64;
     170        -01234567_l8;  -01234567_l16;  -01234567_l32;  -01234567_l64;  -01234567_l8u;  -01234567_ul16;  -01234567_l32u;  -01234567_ul64;
     171
     172#ifdef __LP64__ // 64-bit processor
     173        01234567_l128;   01234567_ul128;
     174        +01234567_l128;  +01234567_ul128;
     175        -01234567_l128;  -01234567_ul128;
     176#endif // __LP64__
    155177
    156178        // decimal
    157          1234567890L8;   1234567890L16;   1234567890l32;   1234567890l64;   1234567890l128;   1234567890UL8;   1234567890L16U;   1234567890Ul32;   1234567890l64u;   1234567890l128u;
    158         +1234567890L8;  +1234567890L16;  +1234567890l32;  +1234567890l64;  +1234567890l128;  +1234567890UL8;  +1234567890L16U;  +1234567890Ul32;  +1234567890l64u;  +1234567890l128u;
    159         -1234567890L8;  -1234567890L16;  -1234567890l32;  -1234567890l64;  -1234567890l128;  -1234567890UL8;  -1234567890L16U;  -1234567890Ul32;  -1234567890l64u;  -1234567890l128u;
     179         1234567890L8;   1234567890L16;   1234567890l32;   1234567890l64;   1234567890UL8;   1234567890L16U;   1234567890Ul32;   1234567890l64u;
     180        +1234567890L8;  +1234567890L16;  +1234567890l32;  +1234567890l64;  +1234567890UL8;  +1234567890L16U;  +1234567890Ul32;  +1234567890l64u;
     181        -1234567890L8;  -1234567890L16;  -1234567890l32;  -1234567890l64;  -1234567890UL8;  -1234567890L16U;  -1234567890Ul32;  -1234567890l64u;
     182
     183#ifdef __LP64__ // 64-bit processor
     184        1234567890l128;   1234567890l128u;
     185        +1234567890l128;  +1234567890l128u;
     186        -1234567890l128;  -1234567890l128u;
     187#endif // __LP64__
    160188
    161189        // hexadecimal
     
    193221        -0123456789.0123456789E+09L32;  -0123456789.0123456789E+09L64;  -0123456789.0123456789E+09L80;  -0123456789.0123456789E+09L128;
    194222         0123456789.0123456789E-09L32;   0123456789.0123456789E-09L64;   0123456789.0123456789E-09L80;   0123456789.0123456789E-09L128;
    195        
     223
    196224         0x0123456789.p09l32;   0x0123456789.p09l64;   0x0123456789.p09l80;   0x0123456789.p09l128;
    197225        +0x0123456789.p09l32;  +0x0123456789.p09l64;  +0x0123456789.p09l80;  +0x0123456789.p09l128;
  • tests/math1.c

    rf9feab8 r90152a4  
    1 // 
     1//
    22// Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
    33//
    44// The contents of this file are covered under the licence agreement in the
    55// file "LICENCE" distributed with Cforall.
    6 // 
    7 // math1.c -- 
    8 // 
     6//
     7// math1.c --
     8//
    99// Author           : Peter A. Buhr
    1010// Created On       : Fri Apr 22 14:59:21 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Aug 11 15:16:41 2017
    13 // Update Count     : 84
    14 // 
     12// Last Modified On : Thu May 24 21:01:15 2018
     13// Update Count     : 85
     14//
    1515
    16 #include <fstream>
    17 #include <math>
     16#include <fstream.hfa>
     17#include <math.hfa>
    1818
    1919int main( void ) {
     
    4141        sout | "exp2:" | exp2( 1.0F ) | exp2( 1.0D ) | exp2( 1.0L ) | endl;
    4242        sout | "expm1:" | expm1( 1.0F ) | expm1( 1.0D ) | expm1( 1.0L ) | endl;
    43         sout | "pow:" | pow( 1.0F, 1.0F ) | pow( 1.0D, 1.0D ) | pow( 1.0L, 1.0L ) | pow( 1.0F+1.0FI, 1.0F+1.0FI ) | pow( 1.0D+1.0DI, 1.0D+1.0DI ) | pow( 1.0DL+1.0LI, 1.0DL+1.0LI ) | endl;
     43        sout | "pow:" | pow( 1.0F, 1.0F ) | pow( 1.0D, 1.0D ) | pow( 1.0L, 1.0L ) | pow( 1.0F+1.0FI, 1.0F+1.0FI ) | pow( 1.0D+1.0DI, 1.0D+1.0DI ) | pow( 1.5DL+1.5LI, 1.5DL+1.5LI ) | endl;
    4444
    4545        int b = 4;
     
    4848    sout | "\\" | b | b \ e | endl;
    4949    sout | "\\" | 'a' \ 3u | 2 \ 8u | 4 \ 3u | -4 \ 3u | 4 \ -3 | -4 \ -3 | 4.0 \ 2.1 | (1.0f+2.0fi) \ (3.0f+2.0fi) | endl;
    50 
    51         //---------------------- Logarithm ----------------------
    52 
    53         sout | "log:" | log( 1.0F ) | log( 1.0D ) | log( 1.0L ) | log( 1.0F+1.0FI ) | log( 1.0D+1.0DI ) | log( 1.0DL+1.0LI ) | endl;
    54         sout | "log2:" | log2( 8.0F ) | log2( 8.0D ) | log2( 8.0L ) | endl;
    55         sout | "log10:" | log10( 100.0F ) | log10( 100.0D ) | log10( 100.0L ) | endl;
    56         sout | "log1p:" | log1p( 1.0F ) | log1p( 1.0D ) | log1p( 1.0L ) | endl;
    57         sout | "ilogb:" | ilogb( 1.0F ) | ilogb( 1.0D ) | ilogb( 1.0L ) | endl;
    58         sout | "logb:" | logb( 8.0F ) | logb( 8.0D ) | logb( 8.0L ) | endl;
    59 
    60         sout | "sqrt:" | sqrt( 1.0F ) | sqrt( 1.0D ) | sqrt( 1.0L ) | sqrt( 1.0F+1.0FI ) | sqrt( 1.0D+1.0DI ) | sqrt( 1.0DL+1.0LI ) | endl;
    61         sout | "cbrt:" | cbrt( 27.0F ) | cbrt( 27.0D ) | cbrt( 27.0L ) | endl;
    62         sout | "hypot:" | hypot( 1.0F, -1.0F ) | hypot( 1.0D, -1.0D ) | hypot( 1.0L, -1.0L ) | endl;
    6350} // main
    6451
  • tests/math3.c

    rf9feab8 r90152a4  
    1 // 
     1//
    22// Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
    33//
    44// The contents of this file are covered under the licence agreement in the
    55// file "LICENCE" distributed with Cforall.
    6 // 
    7 // math2.c --
    8 // 
     6//
     7// math3.c --
     8//
    99// Author           : Peter A. Buhr
    1010// Created On       : Fri Apr 22 14:59:21 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Aug 11 15:40:04 2017
    13 // Update Count     : 81
    14 // 
     12// Last Modified On : Thu May 24 21:06:12 2018
     13// Update Count     : 82
     14//
    1515
    16 #include <fstream>
    17 #include <math>
     16#include <fstream.hfa>
     17#include <math.hfa>
    1818
    1919int main( void ) {
     
    2121        double d;
    2222        long double l;
    23 
    24         //---------------------- Trigonometric ----------------------
    25 
    26         sout | "sin:" | sin( 1.0F ) | sin( 1.0D ) | sin( 1.0L ) | sin( 1.0F+1.0FI ) | sin( 1.0D+1.0DI ) | sin( 1.0DL+1.0LI ) | endl;
    27         sout | "cos:" | cos( 1.0F ) | cos( 1.0D ) | cos( 1.0L ) | cos( 1.0F+1.0FI ) | cos( 1.0D+1.0DI ) | cos( 1.0DL+1.0LI ) | endl;
    28         sout | "tan:" | tan( 1.0F ) | tan( 1.0D ) | tan( 1.0L ) | tan( 1.0F+1.0FI ) | tan( 1.0D+1.0DI ) | tan( 1.0DL+1.0LI ) | endl;
    29         sout | "asin:" | asin( 1.0F ) | asin( 1.0D ) | asin( 1.0L ) | asin( 1.0F+1.0FI ) | asin( 1.0D+1.0DI ) | asin( 1.0DL+1.0LI ) | endl;
    30         sout | "acos:" | acos( 1.0F ) | acos( 1.0D ) | acos( 1.0L ) | acos( 1.0F+1.0FI ) | acos( 1.0D+1.0DI ) | acos( 1.0DL+1.0LI ) | endl;
    31         sout | "atan:" | atan( 1.0F ) | atan( 1.0D ) | atan( 1.0L ) | atan( 1.0F+1.0FI ) | atan( 1.0D+1.0DI ) | atan( 1.0DL+1.0LI ) | endl;
    32         sout | "atan2:" | atan2( 1.0F, 1.0F ) | atan2( 1.0D, 1.0D ) | atan2( 1.0L, 1.0L );
    33         sout | "atan:" | atan( 1.0F, 1.0F ) | atan( 1.0D, 1.0D ) | atan( 1.0L, 1.0L ) | endl;
    3423
    3524        //---------------------- Hyperbolic ----------------------
     
    5948// Local Variables: //
    6049// tab-width: 4 //
    61 // compile-command: "cfa math2.c" //
     50// compile-command: "cfa math3.c" //
    6251// End: //
  • tests/math4.c

    rf9feab8 r90152a4  
    1 // 
     1//
    22// Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
    33//
    44// The contents of this file are covered under the licence agreement in the
    55// file "LICENCE" distributed with Cforall.
    6 // 
    7 // math3.c --
    8 // 
     6//
     7// math4.c --
     8//
    99// Author           : Peter A. Buhr
    10 // Created On       : Fri Apr 22 14:59:21 2016
     10// Created On       : Thu May 24 20:56:54 2018
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Aug 11 15:40:03 2017
    13 // Update Count     : 81
    14 // 
     12// Last Modified On : Thu May 24 20:58:06 2018
     13// Update Count     : 2
     14//
    1515
    16 #include <fstream>
    17 #include <math>
     16#include <fstream.hfa>
     17#include <math.hfa>
    1818
    1919int main( void ) {
  • tests/maybe.c

    rf9feab8 r90152a4  
    1515
    1616#include <assert.h>
    17 #include <containers/maybe>
     17#include <containers/maybe.hfa>
    1818
    1919void checkPredicates() {
  • tests/minmax.c

    rf9feab8 r90152a4  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // minmax.c -- 
     7// minmax.c --
    88//
    9 // Author           : Richard C. Bilson
     9// Author           : Peter A. Buhr
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Feb 29 23:45:16 2016
    13 // Update Count     : 49
     12// Last Modified On : Tue Apr 10 17:29:09 2018
     13// Update Count     : 50
    1414//
    1515
    16 #include <fstream>
    17 #include <stdlib>                                                                               // min, max
     16#include <fstream.hfa>
     17#include <stdlib.hfa>                                                                           // min, max
    1818
    1919int main( void ) {
  • tests/operators.c

    rf9feab8 r90152a4  
    2727        a(b);
    2828        a + b;
    29         struct accumulator ?+?; // why not, eh?
    30         a + b;
    3129}
    3230
  • tests/preempt_longrun/Makefile.in

    rf9feab8 r90152a4  
    9191build_triplet = @build@
    9292host_triplet = @host@
    93 subdir = src/tests/preempt_longrun
     93subdir = tests/preempt_longrun
    9494ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
    95 am__aclocal_m4_deps = $(top_srcdir)/configure.ac
     95am__aclocal_m4_deps = $(top_srcdir)/automake/cfa.m4 \
     96        $(top_srcdir)/configure.ac
    9697am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
    9798        $(ACLOCAL_M4)
     
    337338AWK = @AWK@
    338339BACKEND_CC = @BACKEND_CC@
    339 CC = @CFA_BINDIR@/@CFA_NAME@
     340BUILD_IN_TREE_FLAGS = @BUILD_IN_TREE_FLAGS@
     341CC = @CFACC@
    340342CCAS = @CCAS@
    341343CCASDEPMODE = @CCASDEPMODE@
    342344CCASFLAGS = @CCASFLAGS@
    343345CCDEPMODE = @CCDEPMODE@
     346CFACC = @CFACC@
     347CFACPP = @CFACPP@
    344348CFA_BACKEND_CC = @CFA_BACKEND_CC@
    345349CFA_BINDIR = @CFA_BINDIR@
     
    358362DEFS = @DEFS@
    359363DEPDIR = @DEPDIR@
     364DRIVER_DIR = @DRIVER_DIR@
    360365ECHO_C = @ECHO_C@
    361366ECHO_N = @ECHO_N@
     
    364369EXEEXT = @EXEEXT@
    365370GREP = @GREP@
     371HOST_FLAGS = @HOST_FLAGS@
    366372INSTALL = @INSTALL@
    367373INSTALL_DATA = @INSTALL_DATA@
     
    373379LEXLIB = @LEXLIB@
    374380LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
     381LIBCFA_TARGET_DIRS = @LIBCFA_TARGET_DIRS@
     382LIBCFA_TARGET_MAKEFILES = @LIBCFA_TARGET_MAKEFILES@
    375383LIBOBJS = @LIBOBJS@
    376384LIBS = @LIBS@
    377385LTLIBOBJS = @LTLIBOBJS@
    378 MACHINE_TYPE = @MACHINE_TYPE@
    379 MAINT = @MAINT@
    380386MAKEINFO = @MAKEINFO@
    381387MKDIR_P = @MKDIR_P@
     
    393399SHELL = @SHELL@
    394400STRIP = @STRIP@
     401TARGET_HOSTS = @TARGET_HOSTS@
    395402VERSION = @VERSION@
    396403YACC = @YACC@
     
    448455top_builddir = @top_builddir@
    449456top_srcdir = @top_srcdir@
     457AUTOMAKE_OPTIONS = foreign    # do not require all the GNU file names
    450458repeats = 10
    451459max_time = 600
    452 preempt = 1_000ul
    453 REPEAT = ${abs_top_srcdir}/tools/repeat -s
    454 BUILD_FLAGS = -g -Wall -Wno-unused-function -quiet @CFA_FLAGS@ -debug -O2 -DPREEMPTION_RATE=${preempt}
    455 TESTS = block create disjoint enter enter3 processor stack wait yield
     460preempt = 10ul\`ms
     461debug = -debug
     462type = LONG
     463REPEAT = ${abs_top_srcdir}/tools/repeat
     464WATCHDOG = ${abs_top_srcdir}/tools/watchdog
     465TIME = /usr/bin/time -f "%E"
     466
     467# $(shell ./update-type $(type))
     468# ./update-type $(type)
     469UPDATED_TYPE = $(shell ./update-type $(type))
     470BUILD_FLAGS = -g -Wall -Wno-unused-function -quiet @CFA_FLAGS@ -O2 -DPREEMPTION_RATE=${preempt} -I.. -I. -DTEST_$(shell cat .type | tr a-z A-Z)
     471TESTS = block coroutine create disjoint enter enter3 processor stack wait yield
    456472all: all-am
    457473
    458474.SUFFIXES:
    459475.SUFFIXES: .log .test .test$(EXEEXT) .trs
    460 $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
     476$(srcdir)/Makefile.in: $(srcdir)/Makefile.am  $(am__configure_deps)
    461477        @for dep in $?; do \
    462478          case '$(am__configure_deps)' in \
     
    467483          esac; \
    468484        done; \
    469         echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/tests/preempt_longrun/Makefile'; \
     485        echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign tests/preempt_longrun/Makefile'; \
    470486        $(am__cd) $(top_srcdir) && \
    471           $(AUTOMAKE) --foreign src/tests/preempt_longrun/Makefile
     487          $(AUTOMAKE) --foreign tests/preempt_longrun/Makefile
    472488Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
    473489        @case '$?' in \
     
    482498        cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
    483499
    484 $(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
     500$(top_srcdir)/configure: $(am__configure_deps)
    485501        cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
    486 $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
     502$(ACLOCAL_M4): $(am__aclocal_m4_deps)
    487503        cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
    488504$(am__aclocal_m4_deps):
     
    642658        $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
    643659        "$$tst" $(AM_TESTS_FD_REDIRECT)
     660coroutine.log: coroutine
     661        @p='coroutine'; \
     662        b='coroutine'; \
     663        $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
     664        --log-file $$b.log --trs-file $$b.trs \
     665        $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
     666        "$$tst" $(AM_TESTS_FD_REDIRECT)
    644667create.log: create
    645668        @p='create'; \
     
    864887
    865888
    866 .INTERMEDIATE: ${TESTS}
     889# .INTERMEDIATE: ${TESTS}
    867890
    868891all-local: ${TESTS:=.run}
    869892
     893runall : ${TESTS:=.run}
     894        @ echo "All programs terminated normally"
     895
     896watchall : ${TESTS:=.watch}
     897        @ echo "All programs terminated normally"
     898
     899compileall : ${TESTS}
     900        @ echo "Compiled"
     901
    870902clean-local:
    871         rm -f ${TESTS}
    872 
    873 % : %.c ${CC}
    874         ${AM_V_GEN}${CC} ${CFLAGS} ${<} -o ${@}
    875 
    876 %.run : %
    877         @ time ${REPEAT} $(repeats) timeout ${max_time} ./${<}
     903        rm -f ${TESTS} core* out.log .type
     904
     905% : %.c ${CC} ${UPDATED_TYPE}
     906        ${AM_V_GEN}${CC} ${CFLAGS} ${<} $(debug) -o ${@}
     907
     908%.run : % ${REPEAT}
     909        @ time ${REPEAT} -r out.log -i -s $(repeats) timeout ${max_time} ./${<}
    878910        @ rm ${<}
    879911        @ echo -e "${<}: SUCCESS\n"
     912
     913%.watch : % ${WATCHDOG}
     914        @ time ${WATCHDOG} ./${<}
     915        @ rm ${<}
     916        @ echo -e "${<}: SUCCESS\n"
     917
     918%.time : % ${REPEAT}
     919        @ ${REPEAT} -i -s -- $(repeats) $(TIME) -a -o times.log ./${<}
     920        @ rm ${<}
     921        @ echo -e "${<}: SUCCESS\n"
     922
     923${REPEAT}: ${abs_top_srcdir}/tools/Makefile
     924        @+make -C ${abs_top_srcdir}/tools/
     925
     926${WATCHDOG}: ${abs_top_srcdir}/tools/Makefile
     927        @+make -C ${abs_top_srcdir}/tools/
    880928
    881929# Tell versions [3.59,3.63) of GNU make to not export all variables.
  • tests/pybin/tools.py

    rf9feab8 r90152a4  
    99import stat
    1010import sys
     11import fileinput
    1112
    1213from pybin import settings
     
    3435                return proc.returncode, out
    3536
     37def is_ascii(fname):
     38        if settings.dry_run:
     39                print("is_ascii: %s" % fname)
     40                return True
     41
     42        if not os.path.isfile(fname):
     43                return False
     44
     45        code, out = sh("file %s" % fname, print2stdout = False)
     46        if code != 0:
     47                return False
     48
     49        match = re.search(".*: (.*)", out)
     50
     51        if not match:
     52                return False
     53
     54        return match.group(1).startswith("ASCII text")
     55
    3656# Remove 1 or more files silently
    3757def rm( files ):
    38         try:
     58        if isinstance( files, basestring ):
     59                sh("rm -f %s > /dev/null 2>&1" % files )
     60        else:
    3961                for file in files:
    4062                        sh("rm -f %s > /dev/null 2>&1" % file )
    41         except TypeError:
    42                 sh("rm -f %s > /dev/null 2>&1" % files )
     63
     64# Create 1 or more directory
     65def mkdir( files ):
     66        if isinstance( files, basestring ):
     67                sh("mkdir -p %s" % os.path.dirname(files) )
     68        else:
     69                for file in files:
     70                        sh("mkdir -p %s" % os.path.dirname(file) )
     71
    4372
    4473def chdir( dest = __main__.__file__ ):
     
    5079def diff( lhs, rhs ):
    5180        # diff the output of the files
    52         diff_cmd = ("diff --ignore-all-space "
     81        diff_cmd = ("diff --ignore-all-space --text "
    5382                                "--ignore-blank-lines "
    5483                                "--old-group-format='\t\tmissing lines :\n"
     
    76105                '-s' if silent else '',
    77106                test_param,
     107                settings.arch.flags,
    78108                settings.debug.flags,
     109                settings.install.flags,
    79110                flags,
    80111                target,
     
    83114        return sh(cmd)
    84115
     116def which(program):
     117    import os
     118    def is_exe(fpath):
     119        return os.path.isfile(fpath) and os.access(fpath, os.X_OK)
     120
     121    fpath, fname = os.path.split(program)
     122    if fpath:
     123        if is_exe(program):
     124            return program
     125    else:
     126        for path in os.environ["PATH"].split(os.pathsep):
     127            exe_file = os.path.join(path, program)
     128            if is_exe(exe_file):
     129                return exe_file
     130
     131    return None
    85132################################################################################
    86133#               file handling
     
    89136# helper function to replace patterns in a file
    90137def file_replace(fname, pat, s_after):
    91     # first, see if the pattern is even in the file.
    92     with open(fname) as f:
    93         if not any(re.search(pat, line) for line in f):
    94             return # pattern does not occur in file so we are done.
    95 
    96     # pattern is in the file, so perform replace operation.
    97     with open(fname) as f:
    98         out_fname = fname + ".tmp"
    99         out = open(out_fname, "w")
    100         for line in f:
    101             out.write(re.sub(pat, s_after, line))
    102         out.close()
    103         os.rename(out_fname, fname)
     138        if settings.dry_run:
     139                print("replacing '%s' with '%s' in %s" % (pat, s_after, fname))
     140                return
     141
     142        file = fileinput.FileInput(fname, inplace=True, backup='.bak')
     143        for line in file:
     144                print(line.replace(pat, s_after), end='')
     145        file.close()
    104146
    105147# helper function to check if a files contains only a specific string
     
    124166# transform path to canonical form
    125167def canonicalPath(path):
    126         return os.path.join('.', os.path.normpath(path) )
     168        abspath = os.path.abspath(__main__.__file__)
     169        dname = os.path.dirname(abspath)
     170        return os.path.join(dname, os.path.normpath(path) )
    127171
    128172# compare path even if form is different
     
    135179                for name in names:
    136180                        path = os.path.join(dirname, name)
    137 
    138181                        op( path )
    139182
    140183        # Start the walk
    141         os.path.walk('.', step, '')
     184        dname = settings.SRCDIR
     185        os.path.walk(dname, step, '')
    142186
    143187################################################################################
    144188#               system
    145189################################################################################
    146 
    147 # parses the Makefile to find the machine type (32-bit / 64-bit)
    148 def getMachineType():
    149         sh('echo "void ?{}(int&a,int b){}int main(){return 0;}" > .dummy.c')
    150         ret, out = make('.dummy', silent = True)
    151 
    152         if ret != 0:
    153                 print("Failed to identify architecture:")
    154                 print(out)
    155                 print("Stopping")
    156                 rm( (".dummy.c",".dummy") )
    157                 sys.exit(1)
    158 
    159         _, out = sh("file .dummy", print2stdout=False)
    160         rm( (".dummy.c",".dummy") )
    161 
    162         if settings.dry_run :
    163                 return 'x64'
    164 
    165         return re.search(r"[^,]+,([^,]+),", out).group(1).strip()
    166 
    167190# count number of jobs to create
    168191def jobCount( options, tests ):
    169192        # check if the user already passed in a number of jobs for multi-threading
    170         make_flags = os.environ.get('MAKEFLAGS')
    171         make_jobs_fds = re.search("--jobserver-(auth|fds)=\s*([0-9]+),([0-9]+)", make_flags) if make_flags else None
    172         if make_jobs_fds :
    173                 tokens = os.read(int(make_jobs_fds.group(2)), 1024)
    174                 options.jobs = len(tokens)
    175                 os.write(int(make_jobs_fds.group(3)), tokens)
     193        if not options.jobs:
     194                make_flags = os.environ.get('MAKEFLAGS')
     195                force = bool(make_flags)
     196                make_jobs_fds = re.search("--jobserver-(auth|fds)=\s*([0-9]+),([0-9]+)", make_flags) if make_flags else None
     197                if make_jobs_fds :
     198                        tokens = os.read(int(make_jobs_fds.group(2)), 1024)
     199                        options.jobs = len(tokens)
     200                        os.write(int(make_jobs_fds.group(3)), tokens)
     201                else :
     202                        options.jobs = multiprocessing.cpu_count()
    176203        else :
    177                 options.jobs = multiprocessing.cpu_count()
     204                force = True
    178205
    179206        # make sure we have a valid number of jobs that corresponds to user input
     
    182209                sys.exit(1)
    183210
    184         return min( options.jobs, len(tests) ), True if make_flags else False
     211        return min( options.jobs, len(tests) ), force
    185212
    186213# setup a proper processor pool with correct signal handling
     
    215242        return False
    216243
    217 
    218 settings.set_machine_default( getMachineType )
     244def fancy_print(text):
     245        column = which('column')
     246        if column:
     247                cmd = "%s 2> /dev/null" % column
     248                print(cmd)
     249                proc = Popen(cmd, stdin=PIPE, stderr=None, shell=True)
     250                proc.communicate(input=text)
     251        else:
     252                print(text)
  • tests/quoted_keyword.c

    rf9feab8 r90152a4  
    1414//
    1515
    16 #include <fstream>
     16#include <fstream.hfa>
    1717
    1818struct {
  • tests/raii/dtor-early-exit.c

    rf9feab8 r90152a4  
    1010// Created On       : Wed Aug 17 08:26:25 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Aug 17 08:29:37 2016
    13 // Update Count     : 2
    14 //
    15 
    16 #include <fstream>
    17 #include <stdlib>
    18 extern "C" {
    19 #define false ((int)0)  // until stdbool.h works
    20 #define assert(cond) if (! (cond)) { sout | "Assertion failed: (" | #cond | ") at " __FILE__ | ":" | __LINE__ | endl; abort(); }
    21 }
     12// Last Modified On : Sat Aug 11 07:58:39 2018
     13// Update Count     : 8
     14//
     15
     16#include <fstream.hfa>
     17#include <stdlib.hfa>
     18#include <assert.h>
    2219
    2320struct A {
  • tests/raii/globals.c

    rf9feab8 r90152a4  
    1 #include <fstream>
     1#include <fstream.hfa>
    22
    33struct value_t {
  • tests/random.c

    rf9feab8 r90152a4  
    1 // 
     1//
    22// Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
    33//
    44// The contents of this file are covered under the licence agreement in the
    55// file "LICENCE" distributed with Cforall.
    6 // 
    7 // random.c -- 
    8 // 
     6//
     7// random.c --
     8//
    99// Author           : Peter A. Buhr
    1010// Created On       : Tue Jul  5 21:29:30 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Oct 30 23:06:49 2017
    13 // Update Count     : 6
    14 // 
     12// Last Modified On : Tue Jan  2 12:19:34 2018
     13// Update Count     : 19
     14//
    1515
    16 #include <fstream>
    17 #include <stdlib>                                                                               // random
     16#include <fstream.hfa>
     17#include <stdlib.hfa>                                                                           // random
    1818#include <unistd.h>                                                                             // getpid
    1919
    2020int main() {
    21         //srandom( getpid() );                                                          // set random seed
    22         random_seed( 1003 );                                                            // fixed seed for repeatable tests
     21        // srandom( getpid() );                                                         // set random seed
     22        srandom( 1003 );                                                                        // fixed seed for repeatable tests
    2323
    2424        // test polymorphic calls to random and stream
    2525        char c = random();
    2626        sout | c | endl;
     27        c = random( 'A' );
     28        sout | c | endl;
     29        c = random( 'A', 'Z' );
     30        sout | c | endl;
     31
    2732        int i = random();
    2833    sout | i | endl;
     34        i = random( 10 );
     35    sout | i | endl;
     36        i = random( -10, 20 );
     37    sout | i | endl;
     38
    2939        unsigned int ui = random();
    3040    sout | ui | endl;
     41        ui = random( 10u );
     42    sout | ui | endl;
     43        ui = random( 10u, 20u );
     44    sout | ui | endl;
     45
    3146        long int li = random();
    3247    sout | li | endl;
     48        li = random( 10l );
     49    sout | li | endl;
     50        li = random( -10l, 20l );
     51    sout | li | endl;
     52
    3353        unsigned long int uli = random();
    3454    sout | uli | endl;
     55        uli = random( 10ul );
     56    sout | uli | endl;
     57        uli = random( 10ul, 20ul );
     58    sout | uli | endl;
     59
    3560    float f = random();
    3661    sout | f | endl;
     62
    3763    double d = random();
    3864    sout | d | endl;
     65
    3966    float _Complex fc = random();
    4067    sout | fc | endl;
     68
    4169    double _Complex dc = random();
    4270    sout | dc | endl;
     71
    4372    long double _Complex ldc = random();
    4473    sout | ldc | endl;
  • tests/rational.c

    rf9feab8 r90152a4  
    1414//
    1515
    16 #include <rational>
    17 #include <limits>
    18 #include <stdlib>
    19 #include <fstream>
     16#include <rational.hfa>
     17#include <limits.hfa>
     18#include <stdlib.hfa>
     19#include <fstream.hfa>
    2020
    2121// UNNECESSARY, FIX ME
  • tests/references.c

    rf9feab8 r90152a4  
    4646
    4747int main() {
    48         int x = 123456, *p1 = &x, **p2 = &p1, ***p3 = &p2,
     48        int x = 123456, x2 = 789, *p1 = &x, **p2 = &p1, ***p3 = &p2,
    4949                &r1 = x,    &&r2 = r1,   &&&r3 = r2;
    5050        ***p3 = 3;                          // change x
     
    5252        *p3 = &p1;                          // change p2
    5353        int y = 0, z = 11, & ar[3] = { x, y, z };    // initialize array of references
     54        // &ar[1] = &z;                        // change reference array element
     55        // typeof( ar[1] ) p = 3;              // is int, i.e., the type of referenced object
     56        // typeof( &ar[1] ) q = &x;            // is int *, i.e., the type of pointer
     57        // _Static_assert( sizeof( ar[1] ) == sizeof( int ), "Array type should be int." );   // is true, i.e., the size of referenced object
     58        // _Static_assert( sizeof( &ar[1] ) == sizeof( int *), "Address of array should be int *." ); // is true, i.e., the size of a reference
    5459
     60        ((int*&)&r3) = &x;                  // change r1, (&*)**r3
     61        x = 3;
    5562        // test that basic reference properties are true - r1 should be an alias for x
    5663        printf("%d %d %d\n", x, r1, &x == &r1);
     
    6875        printf("%d %d\n", r1, x);
    6976
     77        r3 = 6;                               // change x, ***r3
     78        printf("x = %d ; x2 = %d\n", x, x2);  // check that x was changed
     79        &r3 = &x2;                            // change r1 to refer to x2, (&*)**r3
     80        r3 = 999;                             // modify x2
     81        printf("x = %d ; x2 = %d\n", x, x2);  // check that x2 was changed
     82        ((int**&)&&r3) = p2;                  // change r2, (&(&*)*)*r3, ensure explicit cast to reference works
     83        r3 = 12345;                           // modify x
     84        printf("x = %d ; x2 = %d\n", x, x2);  // check that x was changed
     85        &&&r3 = p3;                           // change r3 to p3, (&(&(&*)*)*)r3
     86        ((int&)r3) = 22222;                   // modify x, ensure explicit cast to reference works
     87        printf("x = %d ; x2 = %d\n", x, x2);  // check that x was changed
     88
    7089        // test that reference members are not implicitly constructed/destructed/assigned
    7190        X x1, x2 = x1;
     
    7695        &z1.r = &z1r;
    7796        &z2.r = &z2r;
     97
    7898        z1 = z2;
     99
     100        // test rvalue-to-reference conversion
     101        {
     102                struct S { double x, y; };
     103                void f( int & i, int & j, S & s, int v[] ) {
     104                        printf("%d %d { %g, %g }, [%d, %d, %d]\n", i, j, s.[x, y], v[0], v[1], v[2]);
     105                }
     106                void g(int & i) { printf("%d\n", i); }
     107                void h(int &&& i) { printf("%d\n", i); }
     108
     109                int &&& r = 3;  // rvalue to reference
     110                int i = r;
     111                printf("%d %d\n", i, r);  // both 3
     112
     113                g( 3 );          // rvalue to reference
     114                h( (int &&&)3 ); // rvalue to reference
     115
     116                int a = 5, b = 4;
     117                f( 3, a + b, (S){ 1.0, 7.0 }, (int [3]){ 1, 2, 3 } ); // two rvalue to reference
     118        }
    79119}
    80120
     
    82122// tab-width: 4 //
    83123// End: //
    84 
  • tests/result.c

    rf9feab8 r90152a4  
    1515
    1616#include <assert.h>
    17 #include <containers/result>
     17#include <containers/result.hfa>
    1818
    1919void checkPredicates() {
  • tests/searchsort.c

    rf9feab8 r90152a4  
    1 // 
     1//
    22// Cforall Version 1.0.0 Copyright (C) 2015 University of Waterloo
    33//
    44// The contents of this file are covered under the licence agreement in the
    55// file "LICENCE" distributed with Cforall.
    6 // 
    7 // searchsort.c -- 
    8 // 
     6//
     7// searchsort.c --
     8//
    99// Author           : Peter A. Buhr
    1010// Created On       : Thu Feb  4 18:17:50 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun Apr  2 11:29:30 2017
    13 // Update Count     : 76
    14 // 
     12// Last Modified On : Thu Aug  9 07:54:57 2018
     13// Update Count     : 101
     14//
    1515
    16 #include <fstream>
    17 #include <stdlib>                                                                               // bsearch, qsort
     16#include <fstream.hfa>
     17#include <stdlib.hfa>                                                                           // bsearch, qsort
    1818#include <stdlib.h>                                                                             // C version of bsearch
    1919
     
    2424        int iarr[size];
    2525
    26         for ( unsigned int i = 0; i < size; i += 1 ) {
     26        for ( i; 0u ~ size ) {
    2727                iarr[i] = size - i;
    2828                sout | iarr[i] | ", ";
     
    3232        // ascending sort/search by changing < to >
    3333        qsort( iarr, size );
    34         for ( unsigned int i = 0; i < size; i += 1 ) {
     34        for ( i; 0u ~ size ) {
    3535                sout | iarr[i] | ", ";
    3636        } // for
    3737        sout | endl;
    38         for ( unsigned int i = 0; i < size; i += 1 ) {          // C version
     38        for ( i; 0u ~ size ) {          // C version
    3939                int key = size - i;
    40                 int *v = bsearch( &key, iarr, size, sizeof( iarr[0] ), comp );
    41                 sout | *v | ", ";
     40                int * v = bsearch( &key, iarr, size, sizeof( iarr[0] ), comp );
     41                sout | key | ':' | *v | ", ";
    4242        } // for
    4343        sout | endl;
    44         for ( unsigned int i = 0; i < size; i += 1 ) {
    45                 int *v = bsearch( size - i, iarr, size );
    46                 sout | *v | ", ";
     44
     45        for ( i; 0u ~ size ) {
     46                int * v = bsearch( size - i, iarr, size );
     47                sout | size - i | ':' | *v | ", ";
    4748        } // for
    4849        sout | endl;
    49         for ( unsigned int i = 0; i < size; i += 1 ) {
     50        for ( i; 0u ~ size ) {
    5051                unsigned int posn = bsearch( size - i, iarr, size );
    51                 sout | iarr[posn] | ", ";
     52                sout | size - i | ':' | iarr[posn] | ", ";
    5253        } // for
    5354        sout | endl | endl;
    5455
    5556        // descending sort/search by changing < to >
    56         for ( unsigned int i = 0; i < size; i += 1 ) {
     57        for ( i; 0u ~ size ) {
    5758                iarr[i] = i + 1;
    5859                sout | iarr[i] | ", ";
     
    6263                int ?<?( int x, int y ) { return x > y; }
    6364                qsort( iarr, size );
    64                 for ( unsigned int i = 0; i < size; i += 1 ) {
     65                for ( i; 0u ~ size ) {
    6566                        sout | iarr[i] | ", ";
    6667                } // for
    6768                sout | endl;
    68                 for ( unsigned int i = 0; i < size; i += 1 ) {
    69                         int *v = bsearch( size - i, iarr, size );
    70                         sout | *v | ", ";
     69                for ( i; 0u ~ size ) {
     70                        int * v = bsearch( size - i, iarr, size );
     71                        sout | size - i | ':' | *v | ", ";
    7172                } // for
    7273                sout | endl;
    73                 for ( unsigned int i = 0; i < size; i += 1 ) {
     74                for ( i; 0u ~ size ) {
    7475                        unsigned int posn = bsearch( size - i, iarr, size );
    75                         sout | iarr[posn] | ", ";
     76                        sout | size - i | ':' | iarr[posn] | ", ";
    7677                } // for
    7778        }
     
    7980
    8081        double darr[size];
    81         for ( unsigned int i = 0; i < size; i += 1 ) {
     82        for ( i; 0u ~ size ) {
    8283                darr[i] = size - i + 0.5;
    8384                sout | darr[i] | ", ";
     
    8586        sout | endl;
    8687        qsort( darr, size );
    87         for ( unsigned int i = 0; i < size; i += 1 ) {
     88        for ( i; 0u ~ size ) {
    8889                sout | darr[i] | ", ";
    8990        } // for
    9091        sout | endl;
    91         for ( unsigned int i = 0; i < size; i += 1 ) {
    92                 double *v = bsearch( size - i + 0.5, darr, size );
    93                 sout | *v | ", ";
     92        for ( i; 0u ~ size ) {
     93                double * v = bsearch( size - i + 0.5, darr, size );
     94                sout | size - i + 0.5 | ':' | *v | ", ";
    9495        } // for
    9596        sout | endl;
    96         for ( unsigned int i = 0; i < size; i += 1 ) {
     97        for ( i; 0u ~ size ) {
    9798                unsigned int posn = bsearch( size - i + 0.5, darr, size );
    98                 sout | darr[posn] | ", ";
     99                sout | size - i + 0.5 | ':' | darr[posn] | ", ";
    99100        } // for
    100101        sout | endl | endl;
     
    102103        struct S { int i, j; } sarr[size];
    103104        int ?<?( S t1, S t2 ) { return t1.i < t2.i && t1.j < t2.j; }
    104         ofstream * ?|?( ofstream * os, S v ) { return os | v.i | ' ' | v.j; }
    105         for ( unsigned int i = 0; i < size; i += 1 ) {
     105        ofstream & ?|?( ofstream & os, S v ) { return os | v.i | ' ' | v.j; }
     106        for ( i; 0u ~ size ) {
    106107                sarr[i].i = size - i;
    107108                sarr[i].j = size - i + 1;
     
    110111        sout | endl;
    111112        qsort( sarr, size );
    112         for ( unsigned int i = 0; i < size; i += 1 ) {
     113        for ( i; 0u ~ size ) {
    113114                sout | sarr[i] | ", ";
    114115        } // for
    115116        sout | endl;
    116         for ( unsigned int i = 0; i < size; i += 1 ) {
     117        for ( i; 0u ~ size ) {
    117118                S temp = { size - i, size - i + 1 };
    118                 S *v = bsearch( temp, sarr, size );
    119                 sout | *v | ", ";
     119                S * v = bsearch( temp, sarr, size );
     120                sout | temp | ':' | *v | ", ";
    120121        } // for
    121122        sout | endl;
    122         for ( unsigned int i = 0; i < size; i += 1 ) {
     123        for ( i; 0u ~ size ) {
    123124                S temp = { size - i, size - i + 1 };
    124125                unsigned int posn = bsearch( temp, sarr, size );
    125                 sout | sarr[posn] | ", ";
     126                sout | temp | ':' | sarr[posn] | ", ";
    126127        } // for
    127128        sout | endl | endl;
     129        {
     130                unsigned int getKey( const S & s ) { return s.j; }
     131                for ( i; 0u ~ size ) {
     132                        sout | sarr[i] | ", ";
     133                } // for
     134                sout | endl;
     135                for ( i; 0u ~ size ) {
     136                        S * v = bsearch( size - i + 1, sarr, size );
     137                        sout | size - i + 1 | ':' | *v | ", ";
     138                } // for
     139                sout | endl;
     140                for ( i; 0u ~ size ) {
     141                        unsigned int posn = bsearch( size - i + 1, sarr, size );
     142                        sout | size - i + 1 | ':' | sarr[posn] | ", ";
     143                } // for
     144                sout | endl | endl;
     145        }
    128146} // main
    129147
  • tests/shortCircuit.c

    rf9feab8 r90152a4  
    2222}
    2323
    24 #include <fstream>
     24#include <fstream.hfa>
    2525
    2626struct test_t {
  • tests/sum.c

    rf9feab8 r90152a4  
    1111// Created On       : Wed May 27 17:56:53 2015
    1212// Last Modified By : Peter A. Buhr
    13 // Last Modified On : Sun Oct 29 10:29:12 2017
    14 // Update Count     : 260
     13// Last Modified On : Thu Aug  2 08:03:09 2018
     14// Update Count     : 279
    1515//
    1616
    17 #include <fstream>
     17#include <fstream.hfa>
     18#include <stdlib.hfa>
    1819
    19 void ?{}( int & c, zero_t ) { c = 0; }
     20void ?{}( int & c, zero_t ) { c = 0; }                                  // not in prelude
    2021
    2122trait sumable( otype T ) {
    22         void ?{}( T &, zero_t );                                                        // constructor from 0 literal
     23        void ?{}( T &, zero_t );                                                        // 0 literal constructor
    2324        T ?+?( T, T );                                                                          // assortment of additions
    2425        T ?+=?( T &, T );
     
    2829
    2930forall( otype T | sumable( T ) )                                                // use trait
    30 T sum( unsigned int n, T a[] ) {
    31         T total = 0;                                                                            // instantiate T, select 0
    32         for ( unsigned int i = 0; i < n; i += 1 )
    33                 total += a[i];                                                                  // select +
     31T sum( size_t size, T a[] ) {
     32        T total = 0;                                                                            // initialize by 0 constructor
     33        for ( size_t i = 0; i < size; i += 1 )
     34                total += a[i];                                                                  // select appropriate +
    3435        return total;
    3536} // sum
     
    5556        } // for
    5657        sout | "sum from" | low | "to" | High | "is"
    57                 | sum( size, (unsigned char *)a ) | ", check" | (int)s | endl;
     58                 | sum( size, (unsigned char *)a ) | ", check" | (int)s | endl;
    5859
    5960        int s = 0, a[size], v = low;
     
    6364        } // for
    6465        sout | "sum from" | low | "to" | High | "is"
    65                 | sum( size, (int *)a ) | ", check" | (int)s | endl;
     66                 | sum( size, (int *)a ) | ", check" | (int)s | endl;
    6667
    6768        float s = 0.0f, a[size], v = low / 10.0f;
     
    7172        } // for
    7273        sout | "sum from" | low / 10.0f | "to" | High / 10.0f | "is"
    73                 | sum( size, (float *)a ) | ", check" | (float)s | endl;
     74                 | sum( size, (float *)a ) | ", check" | (float)s | endl;
    7475
    7576        double s = 0.0, a[size], v = low / 10.0;
     
    7980        } // for
    8081        sout | "sum from" | low / 10.0 | "to" | High / 10.0 | "is"
    81                 | sum( size, (double *)a ) | ", check" | (double)s | endl;
     82                 | sum( size, (double *)a ) | ", check" | (double)s | endl;
    8283
    8384        struct S { int i, j; };
    8485        void ?{}( S & s ) { s.[i, j] = 0; }
    85         void ?{}( S & s, int i, int j ) { s.[i,j] = [i, j]; }
    86         void ?{}( S & s, zero_t ) { s.[i,j] = 0; }
    87         void ?{}( S & s, one_t ) { s.[i,j] = 1; }
     86        void ?{}( S & s, int i ) { s.[i, j] = [i, 0]; }
     87        void ?{}( S & s, int i, int j ) { s.[i, j] = [i, j]; }
     88        void ?{}( S & s, zero_t ) { s.[i, j] = 0; }
     89        void ?{}( S & s, one_t ) { s.[i, j] = 1; }
    8890        S ?+?( S t1, S t2 ) { return (S){ t1.i + t2.i, t1.j + t2.j }; }
    8991        S ?+=?( S & t1, S t2 ) { t1 = t1 + t2; return t1; }
    9092        S ++?( S & t ) { t += (S){1}; return t; }
    9193        S ?++( S & t ) { S temp = t; t += (S){1}; return temp; }
    92         ofstream * ?|?( ofstream * os, S v ) { return os | v.i | v.j; }
     94        ofstream & ?|?( ofstream & os, S v ) { return os | v.i | v.j; }
    9395
    9496        S s = (S){0}, a[size], v = { low, low };
     
    98100        } // for
    99101        sout | "sum from" | low | "to" | High | "is"
    100                 | sum( size, (S *)a ) | ", check" | (S)s | endl;
     102                 | sum( size, (S *)a ) | ", check" | (S)s | endl;
     103
     104        forall( otype Impl | sumable( Impl ) )
     105        struct GS {
     106                Impl * x, * y;
     107        };
     108        GS(int) gs;
     109        gs.x = anew( size );                                                            // create array storage for field
     110        s = 0; v = low;
     111        for ( int i = 0; i < size; i += 1, v += 1 ) {
     112                s += (int)v;
     113                gs.x[i] = (int)v;                                                               // set field array in generic type
     114        } // for
     115        sout | "sum from" | low | "to" | High | "is"
     116                 | sum( size, gs.x ) | ", check" | (int)s | endl; // add field array in generic type
     117        delete( gs.x );
    101118} // main
    102119
  • tests/swap.c

    rf9feab8 r90152a4  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // swap.c -- 
     7// swap.c --
    88//
    99// Author           : Peter A. Buhr
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Aug 23 20:34:45 2017
    13 // Update Count     : 70
     12// Last Modified On : Thu Dec  7 09:13:13 2017
     13// Update Count     : 71
    1414//
    1515
    16 #include <fstream>
    17 #include <stdlib>                                                                               // swap
     16#include <fstream.hfa>
     17#include <stdlib.hfa>                                                                           // swap
    1818
    1919int main( void ) {
     
    8484
    8585        struct S { int i, j; } s1 = { 1, 2 }, s2 = { 2, 1 };
    86         ofstream * ?|?( ofstream * os, S s ) { return os | s.i | s.j; }
     86        ofstream & ?|?( ofstream & os, S s ) { return os | s.i | s.j; }
    8787        sout | "struct S\t\t" | s1 | "," | s2 | "\t\tswap ";
    8888        swap( s1, s2 );
  • tests/switch.c

    rf9feab8 r90152a4  
    1010// Created On       : Tue Jul 12 06:50:22 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Aug 26 10:14:21 2017
    13 // Update Count     : 33
     12// Last Modified On : Thu Mar  8 07:33:05 2018
     13// Update Count     : 36
    1414//
    1515
     
    8787                S s;
    8888          case 19:
    89           case 'A' ... 'Z':
    90           case 0 ... 6:
     89          case 'A'...'Z':
     90          case 0 ...6:                                                                          // space required, or lexed as decimal point
    9191          case 20, 30, 40:
    9292                i = 3;
     
    9696          case 8~10:
    9797                f( 3 );
    98                 fallthru
     98                fallthru;
    9999          case 'd':
    100100                j = 5;
  • tests/test.py

    rf9feab8 r90152a4  
    99import re
    1010import sys
     11import time
    1112
    1213################################################################################
     
    1819
    1920        def matchTest(path):
    20                 match = re.search("(\.[\w\/\-_]*)\/.expect\/([\w\-_]+)(\.[\w\-_]+)?\.txt", path)
     21                match = re.search("%s\/([\w\/\-_]*).expect\/([\w\-_]+)(\.[\w\-_]+)?\.txt" % settings.SRCDIR, path)
    2122                if match :
    2223                        test = Test()
     
    4243        if includes:
    4344                test_list = [x for x in test_list if
    44                         x.path.startswith( tuple(includes) )
     45                        x.target().startswith( tuple(includes) )
    4546                ]
    4647
     
    4849        if excludes:
    4950                test_list = [x for x in test_list if not
    50                         x.path.startswith( tuple(excludes) )
     51                        x.target().startswith( tuple(excludes) )
    5152                ]
    5253
     
    6162        if options.regenerate_expected :
    6263                for testname in options.tests :
     64                        testname = canonicalPath( testname )
    6365                        if Test.valid_name(testname):
    64                                 found = [test for test in allTests if test.target() == testname]
     66                                found = [test for test in allTests if canonicalPath( test.target() ) == testname]
    6567                                tests.append( found[0] if len(found) == 1 else Test.from_target(testname) )
    6668                        else :
     
    7779                                print('ERROR: No expected file for test %s, ignoring it' % testname, file=sys.stderr)
    7880
    79         # make sure we have at least some test to run
    80         if not tests :
    81                 print('ERROR: No valid test to run', file=sys.stderr)
    82                 sys.exit(1)
    83 
    8481        return tests
    8582
     
    8885        # create a parser with the arguments for the tests script
    8986        parser = argparse.ArgumentParser(description='Script which runs cforall tests')
    90         parser.add_argument('--debug', help='Run all tests in debug or release', type=yes_no, default='no')
     87        parser.add_argument('--debug', help='Run all tests in debug or release', type=yes_no, default='yes')
     88        parser.add_argument('--install', help='Run all tests based on installed binaries or tree binaries', type=yes_no, default='no')
    9189        parser.add_argument('--arch', help='Test for specific architecture', type=str, default='')
     90        parser.add_argument('--timeout', help='Maximum duration in seconds after a single test is considered to have timed out', type=int, default=60)
     91        parser.add_argument('--global-timeout', help='Maximum cumulative duration in seconds after the ALL tests are considered to have timed out', type=int, default=7200)
    9292        parser.add_argument('--dry-run', help='Don\'t run the tests, only output the commands', action='store_true')
    9393        parser.add_argument('--list', help='List all test available', action='store_true')
    9494        parser.add_argument('--all', help='Run all test available', action='store_true')
    9595        parser.add_argument('--regenerate-expected', help='Regenerate the .expect by running the specified tets, can be used with --all option', action='store_true')
    96         parser.add_argument('-j', '--jobs', help='Number of tests to run simultaneously', type=int, default='8')
     96        parser.add_argument('-j', '--jobs', help='Number of tests to run simultaneously', type=int)
    9797        parser.add_argument('--list-comp', help='List all valide arguments', action='store_true')
    9898        parser.add_argument('-I','--include', help='Directory of test to include, can be used multiple time, All  if omitted', action='append')
     
    100100        parser.add_argument('tests', metavar='test', type=str, nargs='*', help='a list of tests to run')
    101101
    102         options =  parser.parse_args()
     102        try:
     103                options =  parser.parse_args()
     104        except:
     105                print('ERROR: invalid arguments', file=sys.stderr)
     106                parser.print_help(sys.stderr)
     107                sys.exit(1)
    103108
    104109        # script must have at least some tests to run or be listing
     
    119124#               running test functions
    120125################################################################################
     126# fix the absolute paths in the output
     127def fixoutput( fname ):
     128        if not is_ascii(fname):
     129                return
     130
     131        file_replace(fname, "%s/" % settings.SRCDIR, "")
     132
     133
    121134# logic to run a single test and return the result (No handling of printing or other test framework logic)
    122135def run_single_test(test):
    123136
    124137        # find the output file based on the test name and options flag
     138        exe_file = test.target_executable();
    125139        out_file = test.target_output()
    126140        err_file = test.error_log()
     
    131145        test.prepare()
    132146
    133         # remove any outputs from the previous tests to prevent side effects
    134         rm( (out_file, err_file, test.target()) )
    135 
    136147        # build, skipping to next test on error
     148        before = time.time()
    137149        make_ret, _ = make( test.target(),
    138150                redirects  = "2> %s 1> /dev/null" % out_file,
    139151                error_file = err_file
    140152        )
     153        after = time.time()
     154
     155        comp_dur = after - before
     156
     157        run_dur = None
    141158
    142159        # if the make command succeds continue otherwise skip to diff
    143160        if make_ret == 0 or settings.dry_run:
    144                 if settings.dry_run or fileIsExecutable(test.target()) :
     161                before = time.time()
     162                if settings.dry_run or fileIsExecutable(exe_file) :
    145163                        # run test
    146                         retcode, _ = sh("timeout 60 %s > %s 2>&1" % (test.target(), out_file), input = in_file)
     164                        retcode, _ = sh("timeout %d %s > %s 2>&1" % (settings.timeout.single, exe_file, out_file), input = in_file)
    147165                else :
    148166                        # simply cat the result into the output
    149                         retcode, _ = sh("cat %s > %s" % (test.target(), out_file))
     167                        retcode, _ = sh("cat %s > %s" % (exe_file, out_file))
     168
     169                after = time.time()
     170                run_dur = after - before
    150171        else:
    151172                retcode, _ = sh("mv %s %s" % (err_file, out_file))
     
    153174
    154175        if retcode == 0:
     176                # fixoutput(out_file)
    155177                if settings.generating :
    156178                        # if we are ounly generating the output we still need to check that the test actually exists
     
    173195        sh("rm -f %s > /dev/null 2>&1" % test.target())
    174196
    175         return retcode, error
     197        return retcode, error, [comp_dur, run_dur]
    176198
    177199# run a single test and handle the errors, outputs, printing, exception handling, etc.
     
    182204                name_txt = "%20s  " % t.name
    183205
    184                 retcode, error = run_single_test(t)
     206                retcode, error, duration = run_single_test(t)
    185207
    186208                # update output based on current action
    187                 result_txt = TestResult.toString( retcode )
     209                result_txt = TestResult.toString( retcode, duration )
    188210
    189211                #print result with error if needed
     
    214236                        tests,
    215237                        chunksize = 1
    216                 ).get(7200)
     238                ).get(settings.timeout.total)
    217239        except KeyboardInterrupt:
    218240                pool.terminate()
     
    234256################################################################################
    235257if __name__ == "__main__":
    236         #always run from same folder
    237         chdir()
    238258
    239259        # parse the command line arguments
     
    254274                tests = validTests( options )
    255275
     276        # make sure we have at least some test to run
     277        if not tests :
     278                print('ERROR: No valid test to run', file=sys.stderr)
     279                sys.exit(1)
     280
     281
    256282        # sort the test alphabetically for convenience
    257283        tests.sort(key=lambda t: (t.arch if t.arch else '') + t.target())
     
    259285        # users may want to simply list the tests
    260286        if options.list_comp :
    261                 print("-h --help --debug --dry-run --list --arch --all --regenerate-expected -j --jobs ", end='')
     287                print("-h --help --debug --dry-run --list --arch --all --regenerate-expected --install --timeout --global-timeout -j --jobs ", end='')
    262288                print(" ".join(map(lambda t: "%s" % (t.target()), tests)))
    263289
    264290        elif options.list :
    265291                print("Listing for %s:%s"% (settings.arch.string, settings.debug.string))
    266                 print("\n".join(map(lambda t: "%s" % (t.toString()), tests)))
     292                fancy_print("\n".join(map(lambda t: "%s" % (t.toString()), tests)))
    267293
    268294        else :
     295                # check the build configuration works
     296                settings.validate()
     297
    269298                options.jobs, forceJobs = jobCount( options, tests )
    270299                settings.updateMakeCmd(forceJobs, options.jobs)
  • tests/tuple/tupleAssign.c

    rf9feab8 r90152a4  
    1414//
    1515
    16 #include <fstream>
     16#include <fstream.hfa>
    1717
    1818int main() {
     
    4848                        int z;
    4949                } x;
    50                 X ?=?(X & x, double d) {}
     50                X ?=?(X & x, double d) { return x; }
    5151                [int, double, int] t;
    5252
  • tests/tuple/tupleVariadic.c

    rf9feab8 r90152a4  
    99// Author           : Rob Schluntz
    1010// Created On       : Fri Dec 16 10:25:35 2016
    11 // Last Modified By : Rob Schluntz
    12 // Last Modified On : Fri Dec 21 14:42:48 2016
    13 // Update Count     : 2
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Thu Aug  2 09:24:04 2018
     13// Update Count     : 6
    1414//
     15
     16#include <stdlib.hfa>
    1517
    1618void func(void) {
     
    2830        printf("called process(double) %g\n", x);
    2931}
    30 
    31 forall( dtype T, ttype Params | sized(T) | { void ?{}(T &, Params); } )
    32 T * new(Params p);
    3332
    3433struct array {
     
    6867}
    6968
     69void ^?{}(array & a) {
     70        free(a.data);
     71}
     72
    7073// test use of a tuple argument
    7174[void] ?{}(array & a, [int, int, int, int] args) {
     
    9598}
    9699
     100forall(ttype T | { void foo(T); }) void bar(T x) {}
     101void foo(int) {}
     102
    97103int main() {
    98104        array * x0 = new();
     
    117123        func(3, 2.0, 111, 4.145);
    118124        printf("finished func\n");
     125
     126        {
     127                // T = [const int] -- this ensures that void(*)(int) satisfies void(*)(const int)
     128                const int x;
     129                bar(x);
     130        }
     131
     132        delete(ptr);
     133        delete(x4);
     134        delete(x3);
     135        delete(x2);
     136        delete(x1);
     137        delete(x0);
    119138}
    120139
     
    122141// tab-width: 4 //
    123142// End: //
    124 
  • tests/user_literals.c

    rf9feab8 r90152a4  
    1 // 
     1//
    22// Cforall Version 1.0.0 Copyright (C) 2017 University of Waterloo
    33//
    44// The contents of this file are covered under the licence agreement in the
    55// file "LICENCE" distributed with Cforall.
    6 // 
    7 // user_literals.c -- 
    8 // 
     6//
     7// user_literals.c --
     8//
    99// Author           : Peter A. Buhr
    1010// Created On       : Wed Sep  6 21:40:50 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Sep  9 08:31:32 2017
    13 // Update Count     : 48
    14 // 
     12// Last Modified On : Sun Apr 29 16:51:42 2018
     13// Update Count     : 54
     14//
    1515
    16 #include <fstream>
     16#include <fstream.hfa>
    1717#include <wchar.h>
    1818#include <uchar.h>
     
    3131
    3232
    33 struct Weight {
    34         double stones;
    35 };
    36 void ?{}( Weight & w ) { w.stones = 0; }                                // operations
     33struct Weight { double stones; };
     34void ?{}( Weight & w ) { w.stones = 0; }
    3735void ?{}( Weight & w, double w ) { w.stones = w; }
    38 Weight ?+?( Weight l, Weight r ) { return (Weight){ l.stones + r.stones }; }
    39 ofstream * ?|?( ofstream * os, Weight w ) { return os | w.stones; }
     36Weight ?+?( Weight l, Weight r ) {
     37        return (Weight){ l.stones + r.stones };
     38}
     39ofstream & ?|?( ofstream & os, Weight w ) { return os | w.stones; }
    4040
    4141Weight ?`st( double w ) { return (Weight){ w }; }               // backquote for user literals
    4242Weight ?`lb( double w ) { return (Weight){ w / 14.0 }; }
    43 Weight ?`kg( double w ) { return (Weight) { w * 0.1575}; }
    44 
     43Weight ?`kg( double w ) { return (Weight) { w * 0.16 }; }
    4544
    4645int main() {
    47         Weight w, hw = { 14 };                                                          // 14 stone
    48         w = 11`st + 1`lb;
     46        Weight w, heavy = { 20 };                                                       // 20 stone
     47        w = 155`lb;
     48        sout | w | endl;
     49        w = 0b_1111`st;
     50        sout | w | endl;
     51        w = 0_233`lb;                                                                           // octal weight (155)
     52        sout | w | endl;
     53        w = 0x_9b_u`kg;
    4954        sout | w | endl;
    5055        w = 70.3`kg;
    5156        sout | w | endl;
    52         w = 155`lb;
     57        w = 11`st + 1`lb;
    5358        sout | w | endl;
    54         w = 0x_9b_u`lb;                                                                         // hexadecimal unsigned weight (155)
    55         sout | w | endl;
    56         w = 0_233`lb;                                                                           // octal weight (155)
    57         sout | w | endl;
    58         w = 5`st + 8`kg + 25`lb + hw;
     59        w = 5`st + 8`kg + 25`lb + heavy;
    5960        sout | w | endl;
    6061
     
    8182
    8283        "abc"`s;
    83         u"abc"`m;
    84         U_"abc"`h;
    85         L"abc"`_A_;
     84//      u"abc"`m;
     85//      U_"abc"`h;
     86//      L"abc"`_A_;
    8687        u8_"abc"`__thingy_;
    8788} // main
  • tests/vector.c

    rf9feab8 r90152a4  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // libcfa_vector.c --
     7// vector.c --
    88//
    99// Author           : Thierry Delisle
    1010// Created On       : Mon Jul  4 23:36:19 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Jul  5 15:08:05 2016
    13 // Update Count     : 26
     12// Last Modified On : Thu Jan 18 17:08:08 2018
     13// Update Count     : 27
    1414//
    1515
    16 #include <fstream>
    17 #include <vector>
     16#include <fstream.hfa>
     17#include <vector.hfa>
    1818
    1919#undef assert
     
    6363// Local Variables: //
    6464// tab-width: 4 //
    65 // compile-command: "cfa libcfa_vector.c" //
     65// compile-command: "cfa vector.c" //
    6666// End: //
  • tests/virtualCast.c

    rf9feab8 r90152a4  
    99 */
    1010
    11 #include <stdlib>
     11#include <stdlib.hfa>
    1212#include <assert.h>
    1313
Note: See TracChangeset for help on using the changeset viewer.