Skip to content
This repository has been archived by the owner on Oct 12, 2022. It is now read-only.

Commit

Permalink
Add tests for "Out of memory exception"
Browse files Browse the repository at this point in the history
  • Loading branch information
Burgos committed Oct 21, 2016
1 parent 5835ce9 commit 393fd03
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 1 deletion.
2 changes: 1 addition & 1 deletion posix.mak
Expand Up @@ -197,7 +197,7 @@ $(DRUNTIME): $(OBJS) $(SRCS)
UT_MODULES:=$(patsubst src/%.d,$(ROOT)/unittest/%,$(SRCS))
HAS_ADDITIONAL_TESTS:=$(shell test -d test && echo 1)
ifeq ($(HAS_ADDITIONAL_TESTS),1)
ADDITIONAL_TESTS:=test/init_fini test/exceptions test/coverage test/profile test/cycles
ADDITIONAL_TESTS:=test/init_fini test/exceptions test/coverage test/profile test/cycles test/allocations
ADDITIONAL_TESTS+=$(if $(SHARED),test/shared,)
endif

Expand Down
23 changes: 23 additions & 0 deletions test/allocations/Makefile
@@ -0,0 +1,23 @@
include ../common.mak

TESTS:=overflow_from_zero overflow_from_existing

DIFF:=diff
SED:=sed

.PHONY: all clean
all: $(addprefix $(ROOT)/,$(addsuffix .done,$(TESTS)))

$(ROOT)/overflow_from_zero.done: STDERR_EXP="Memory allocation failed"
$(ROOT)/overflow_from_existing.done: STDERR_EXP="Memory allocation failed"
$(ROOT)/%.done: $(ROOT)/%
@echo Testing $*
$(NEGATE) $(QUIET)$(TIMELIMIT)$(ROOT)/$* $(RUN_ARGS) 2>&1 1>/dev/null | head -n 1 | grep -qF $(STDERR_EXP)
@touch $@

$(ROOT)/unittest_assert: DFLAGS+=-unittest
$(ROOT)/%: $(SRC)/%.d
$(QUIET)$(DMD) $(DFLAGS) -of$@ $<

clean:
rm -rf $(GENERATED)
6 changes: 6 additions & 0 deletions test/allocations/src/overflow_from_existing.d
@@ -0,0 +1,6 @@
void main()
{
void[] buffer;
buffer.length = 1;
buffer.length = size_t.max;
}
6 changes: 6 additions & 0 deletions test/allocations/src/overflow_from_zero.d
@@ -0,0 +1,6 @@
void main()
{
void[] buffer;
buffer.length = 1;
buffer.length = size_t.max;
}

0 comments on commit 393fd03

Please sign in to comment.