diff options
| -rw-r--r-- | Makefile | 8 | ||||
| -rw-r--r-- | test/Makefile | 65 | ||||
| -rw-r--r-- | test/driver.c (renamed from tools/mrit/mrit.c) | 14 | ||||
| -rw-r--r-- | test/init_mrbtest.c (renamed from test/init_mritlib.c) | 7 | ||||
| -rw-r--r-- | test/t/_assert.rb (renamed from test/_assert.rb) | 0 | ||||
| -rw-r--r-- | test/t/array.rb (renamed from test/array.rb) | 0 | ||||
| -rw-r--r-- | test/t/time.rb (renamed from test/time.rb) | 0 | ||||
| -rw-r--r-- | tools/mrit/Makefile | 82 |
8 files changed, 63 insertions, 113 deletions
@@ -27,11 +27,10 @@ all : @$(MAKE) -C tools/mruby $(MAKE_FLAGS) @$(MAKE) -C tools/mirb $(MAKE_FLAGS) -# mruby iso test -.PHONY : mrit -mrit : +# mruby test +.PHONY : test +test : @$(MAKE) -C test $(MAKE_FLAGS) - @$(MAKE) -C tools/mrit $(MAKE_FLAGS) # clean up .PHONY : clean @@ -39,5 +38,4 @@ clean : @$(MAKE) clean -C src $(MAKE_FLAGS) @$(MAKE) clean -C tools/mruby $(MAKE_FLAGS) @$(MAKE) clean -C tools/mirb $(MAKE_FLAGS) - @$(MAKE) clean -C tools/mrit $(MAKE_FLAGS) @$(MAKE) clean -C test $(MAKE_FLAGS) diff --git a/test/Makefile b/test/Makefile index b7a6572c8..26c898704 100644 --- a/test/Makefile +++ b/test/Makefile @@ -4,15 +4,16 @@ # project-specific macros # extension of the executable-file is modifiable(.exe .out ...) BASEDIR = . -TARGET := mritlib +TARGET := mrbtest +LIBR := ../lib/libmruby.a MLIB := $(TARGET).o CLIB := $(TARGET).c +INIT := init_$(TARGET).c DLIB := $(TARGET).ctmp RLIB := $(TARGET).rbtmp -DEPLIB := $(TARGET).d -MRB1 := $(BASEDIR)/*.rb -MRBS := $(MRB1) -LIBR := ../lib/libmrit.a +DEPLIB := $(TARGET).d driver.d +MRBS := $(BASEDIR)/t/*.rb +OBJS := driver.o $(MLIB) # C compiler (gcc) CC = gcc @@ -32,28 +33,63 @@ else MAKE_FLAGS = CC='$(CC)' LL='$(LL)' ALL_CFLAGS='$(ALL_CFLAGS)' endif -# mruby compiler +# mruby compiler and test driver ifeq ($(OS),Windows_NT) MRBC = ../bin/mrbc.exe +EXE := $(TARGET).exe else MRBC = ../bin/mrbc +EXE := $(TARGET) +endif + +# libraries, includes +LIBS = -lm + +# compiler, linker (gcc) +CC = gcc +LL = gcc +YACC = bison +DEBUG_MODE = 1 +ifeq ($(DEBUG_MODE),1) +CFLAGS = -g -O3 +else +CFLAGS = -O3 +endif +ALL_CFLAGS = -Wall -Werror-implicit-function-declaration $(CFLAGS) +ifeq ($(OS),Windows_NT) + MAKE_FLAGS = CC=$(CC) LL=$(LL) ALL_CFLAGS="$(ALL_CFLAGS)" +else + MAKE_FLAGS = CC='$(CC)' LL='$(LL)' ALL_CFLAGS='$(ALL_CFLAGS)' endif ############################## # generic build targets, rules .PHONY : all -all : $(MRBC) $(MLIB) - $(AR) r $(LIBR) $(MLIB) +all : $(LIBR) $(EXE) @echo "make: built targets of `pwd`" -# Compile mrblib source -$(MLIB) : $(CLIB) - $(CC) $(ALL_CFLAGS) -MMD $(INCLUDES) -c $(CLIB) -o $(MLIB) +.PHONY : test +all : $(LIBR) $(EXE) + ./$(EXE) + +# executable constructed using linker from object files +$(EXE) : $(LIBR) $(OBJS) + $(LL) -o $@ $(CFLAGS) $(OBJS) $(LIBR) $(LIBS) + +-include $(OBJS:.o=.d) + +# objects compiled from source +$(OBJS) : %.o : %.c + $(CC) $(ALL_CFLAGS) -MMD $(INCLUDES) -c $< -o $@ + +# C library compile +$(LIBR) : + @$(MAKE) -C $(BASEDIR) $(MAKE_FLAGS) # Compile C source from merged mruby source -$(CLIB) : $(RLIB) $(MRBC) - $(MRBC) -Bmritlib_irep -o$(DLIB) $(RLIB); cat init_$(TARGET).c $(DLIB) > $@ +$(CLIB) : $(RLIB) $(MRBC) $(INIT) + $(MRBC) -Bmrbtest_irep -o$(DLIB) $(RLIB); cat $(INIT) $(DLIB) > $@ $(MRBC) : ../src/opcode.h ../src/codegen.c ../src/parse.y $(MAKE) -C ../tools/mrbc $(MAKE_FLAGS) @@ -66,5 +102,4 @@ $(RLIB) : $(MRBS) .PHONY : clean clean : @echo "make: removing targets, objects and depend files of `pwd`" - -rm -f $(MRBC) $(MLIB) $(CLIB) $(RLIB) $(DLIB) $(DEPLIB) $(LIBR) - + -rm -f $(MRBC) $(MLIB) $(CLIB) $(RLIB) $(DLIB) $(DEPLIB) $(OBJS) $(EXE) diff --git a/tools/mrit/mrit.c b/test/driver.c index 594ab012d..90fa6a6d0 100644 --- a/tools/mrit/mrit.c +++ b/test/driver.c @@ -1,10 +1,10 @@ /* -** mrit - Embeddable Ruby ISO Test +** mrbtest - Test for Embeddable Ruby ** -** This program verifies ISO/IEC 30170:2012 +** This program runs Ruby test programs in test/t directory ** against the current mruby implementation. */ - + #include <string.h> #include <mruby.h> @@ -13,12 +13,12 @@ #include <compile.h> void -mrb_init_mritlib(mrb_state *); +mrb_init_mrbtest(mrb_state *); /* Print a short remark for the user */ void print_hint(void) { - printf("mrit - Embeddable Ruby ISO Test\n"); + printf("mrbtest - Embeddable Ruby Test\n"); printf("\nThis is a very early version, please test and report errors.\n"); printf("Thanks :)\n\n"); } @@ -35,7 +35,7 @@ main(void) /* new interpreter instance */ mrb_interpreter = mrb_open(); - mrb_init_mritlib(mrb_interpreter); + mrb_init_mrbtest(mrb_interpreter); parser = mrb_parse_nstring_ext(mrb_interpreter, "report()", strlen("report()")); /* generate bytecode */ @@ -48,7 +48,7 @@ main(void) mrb_top_self(mrb_interpreter)); /* did an exception occur? */ if (mrb_interpreter->exc) { - mrb_p(mrb_interpreter, mrb_obj_value(mrb_interpreter->exc)); + mrb_p(mrb_interpreter, mrb_return_value); mrb_interpreter->exc = 0; } else { diff --git a/test/init_mritlib.c b/test/init_mrbtest.c index 73b926b87..5d977da34 100644 --- a/test/init_mritlib.c +++ b/test/init_mrbtest.c @@ -4,14 +4,13 @@ #include "mruby/string.h" #include "mruby/proc.h" -extern const char mritlib_irep[]; +extern const char mrbtest_irep[]; void -mrb_init_mritlib(mrb_state *mrb) +mrb_init_mrbtest(mrb_state *mrb) { - int n = mrb_read_irep(mrb, mritlib_irep); + int n = mrb_read_irep(mrb, mrbtest_irep); - extern mrb_value mrb_top_self(mrb_state *mrb); mrb_run(mrb, mrb_proc_new(mrb, mrb->irep[n]), mrb_top_self(mrb)); } diff --git a/test/_assert.rb b/test/t/_assert.rb index 91751f769..91751f769 100644 --- a/test/_assert.rb +++ b/test/t/_assert.rb diff --git a/test/array.rb b/test/t/array.rb index 3b65a80dd..3b65a80dd 100644 --- a/test/array.rb +++ b/test/t/array.rb diff --git a/test/time.rb b/test/t/time.rb index f33cdde0d..f33cdde0d 100644 --- a/test/time.rb +++ b/test/t/time.rb diff --git a/tools/mrit/Makefile b/tools/mrit/Makefile deleted file mode 100644 index af973d9de..000000000 --- a/tools/mrit/Makefile +++ /dev/null @@ -1,82 +0,0 @@ -# makefile discription. -# basic build file for mrit executable - -# project-specific macros -# extension of the executable-file is modifiable(.exe .out ...) -BASEDIR = ../../src -TARGET := ../../bin/mrit -LIBR := ../../lib/libmruby.a -LIBRIT := ../../lib/libmrit.a -ifeq ($(OS),Windows_NT) -EXE := $(TARGET).exe -else -EXE := $(TARGET) -endif -OBJ0 := $(patsubst %.c,%.o,$(wildcard $(BASEDIR)/../tools/mrit/*.c)) -#OBJ1 := $(patsubst %.c,%.o,$(filter-out $(EXCEPT1),$(wildcard $(BASEDIR)/*.c))) -#OBJ2 := $(patsubst %.c,%.o,$(wildcard $(BASEDIR)/ext/regex/*.c)) -#OBJ3 := $(patsubst %.c,%.o,$(wildcard $(BASEDIR)/ext/enc/*.c)) -OBJS := $(OBJ0) - -# ext libraries -#EXT1 := $(patsubst %.c,%.o,$(wildcard $(BASEDIR)/../ext/socket/*.c)) -EXTS := $(EXT1) - -# libraries, includes -LIBS = -lm -INCLUDES = -I$(BASEDIR) -I$(BASEDIR)/../include - -# compiler, linker (gcc) -CC = gcc -LL = gcc -YACC = bison -DEBUG_MODE = 1 -ifeq ($(DEBUG_MODE),1) -CFLAGS = -g -O3 -else -CFLAGS = -O3 -endif -ALL_CFLAGS = -Wall -Werror-implicit-function-declaration $(CFLAGS) -ifeq ($(OS),Windows_NT) - MAKE_FLAGS = CC=$(CC) LL=$(LL) ALL_CFLAGS="$(ALL_CFLAGS)" -else - MAKE_FLAGS = CC='$(CC)' LL='$(LL)' ALL_CFLAGS='$(ALL_CFLAGS)' -endif - -############################## -# generic build targets, rules - -.PHONY : all -all : $(LIBRIT) $(LIBR) $(EXE) - @echo "make: built targets of `pwd`" - -# executable constructed using linker from object files -$(EXE) : $(LIBRIT) $(LIBR) $(OBJS) $(EXTS) - $(LL) -o $@ $(CFLAGS) $(OBJS) $(LIBRIT) $(LIBR) $(EXTS) $(LIBS) - --include $(OBJS:.o=.d) - -# objects compiled from source -$(OBJS) : %.o : %.c - $(CC) $(ALL_CFLAGS) -MMD $(INCLUDES) -c $< -o $@ - -# C library compile -$(LIBR) : - @$(MAKE) -C $(BASEDIR) $(MAKE_FLAGS) -$(LIBRIT) : - @$(MAKE) -C $(BASEDIR) $(MAKE_FLAGS) - -# mrit library compile -# extend libraries complile -$(EXTS) : %.o : %.c - $(CC) $(ALL_CFLAGS) -MMD $(INCLUDES) -c $< -o $@ - -# clean up -.PHONY : clean #cleandep -clean : - $(MAKE) clean -C ../../test $(MAKE_FLAGS) - $(MAKE) clean -C ../../mrblib $(MAKE_FLAGS) - $(MAKE) clean -C ../mrbc $(MAKE_FLAGS) - @echo "make: removing targets, objects and depend files of `pwd`" - -rm -f $(EXE) $(OBJS) - -rm -f $(OBJS:.o=.d) |
