]> xenbits.xensource.com Git - unikraft/libs/ruby.git/commitdiff
tests: Build tests
authorCostin Lupu <costin.lupu@cs.pub.ro>
Mon, 16 Dec 2019 13:47:50 +0000 (15:47 +0200)
committerCostin Lupu <costin.lupu@cs.pub.ro>
Mon, 16 Dec 2019 13:54:35 +0000 (15:54 +0200)
The Ruby unit testing depends on both extensions and encodings. We currently
add support for running only the time and file tests. Enabling the rest of the
tests is subject of further work.

Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>
Reviewed-by: Stefan Teodorescu <stefanl.teodorescu@gmail.com>
Config.uk
Makefile.uk
generated/ext/extinit.c

index 56f2b6b569d78498e8e7c7f93de9125b781850f5..e47eee3184482ace298bbe9129773b241136f3d6 100644 (file)
--- a/Config.uk
+++ b/Config.uk
@@ -128,4 +128,11 @@ config LIBRUBY_ENC
        depends on !LIBRUBY_MINI
        default y
 
+config LIBRUBY_TEST
+       bool "Enable unit testing"
+       depends on !LIBRUBY_MINI
+       depends on LIBRUBY_EXT
+       depends on LIBRUBY_ENC
+       default y
+
 endif
index 84c9aac97e359f74325bdf923677f8b0abdbe3ea..ef258bec4471b1156821ddf43a3130477eccb43f 100644 (file)
@@ -41,6 +41,7 @@
 $(eval $(call addlib_s,libruby,$(CONFIG_LIBRUBY)))
 $(eval $(call addlib_s,libruby_ext,$(CONFIG_LIBRUBY_EXT)))
 $(eval $(call addlib_s,libruby_enc,$(CONFIG_LIBRUBY_ENC)))
+$(eval $(call addlib_s,libruby_test,$(CONFIG_LIBRUBY_TEST)))
 
 ################################################################################
 # Sources
@@ -542,6 +543,31 @@ LIBRUBY_ENC_SRCS-y += $(LIBRUBY_SRC)/enc/trans/single_byte.c
 LIBRUBY_ENC_SRCS-y += $(LIBRUBY_SRC)/enc/trans/utf8_mac.c
 LIBRUBY_ENC_SRCS-y += $(LIBRUBY_SRC)/enc/trans/utf_16_32.c
 
+################################################################################
+# Unit testing
+################################################################################
+LIBRUBY_TEST_CFLAGS-y += $(LIBRUBY_CINCLUDES-y)
+LIBRUBY_TEST_CFLAGS-y += $(LIBRUBY_SUPPRESS_FLAGS)
+LIBRUBY_TEST_CFLAGS-y += -DRUBY_EXTCONF_H=\"extconf.h\"
+
+$(LIBRUBY_SRC)/ext/-test-/file/init_file.c: $(LIBRUBY_SRC)/ext/-test-/file/init.c
+       ln -s $< $@
+LIBRUBY_TEST_SRCS-y += $(LIBRUBY_SRC)/ext/-test-/file/init_file.c
+LIBRUBY_TEST_INIT_FILE_FLAGS-y += -I$(LIBRUBY_SRC)/ext/-test-/file
+LIBRUBY_TEST_SRCS-y += $(LIBRUBY_SRC)/ext/-test-/file/fs.c
+LIBRUBY_TEST_FS_FLAGS-y += -I$(LIBRUBY_SRC)/ext/-test-/file
+LIBRUBY_TEST_SRCS-y += $(LIBRUBY_SRC)/ext/-test-/file/stat.c
+LIBRUBY_TEST_STAT_FLAGS-y += -I$(LIBRUBY_SRC)/ext/-test-/file
+
+$(LIBRUBY_SRC)/ext/-test-/time/init_time.c: $(LIBRUBY_SRC)/ext/-test-/time/init.c
+       ln -s $< $@
+LIBRUBY_TEST_SRCS-y += $(LIBRUBY_SRC)/ext/-test-/time/init_time.c
+LIBRUBY_TEST_INIT_TIME_FLAGS-y += -I$(LIBRUBY_SRC)/ext/-test-/time
+LIBRUBY_TEST_SRCS-y += $(LIBRUBY_SRC)/ext/-test-/time/leap_second.c
+LIBRUBY_TEST_LEAP_SECOND_FLAGS-y += -I$(LIBRUBY_SRC)/ext/-test-/time
+LIBRUBY_TEST_SRCS-y += $(LIBRUBY_SRC)/ext/-test-/time/new.c
+LIBRUBY_TEST_NEW_FLAGS-y += -I$(LIBRUBY_SRC)/ext/-test-/time
+
 ################################################################################
 # Prepare rules
 ################################################################################
@@ -562,3 +588,19 @@ $(LIBRUBY_BUILD)/.build: $(LIBRUBY_BUILD)/.configured
 
 UK_PREPARE += $(LIBRUBY_BUILD)/.build
 
+ifeq ($(CONFIG_LIBRUBY_TEST),y)
+# Customize config: configure stack size
+$(APP_BASE)/.config.orig: $(APP_BASE)/.config
+       $(call verbose_cmd,CONFIG,libruby: $(notdir $@), \
+               cp $(APP_BASE)/.config $@ && \
+               sed -i 's/^CONFIG_STACK_SIZE_PAGE_ORDER=.*$$/CONFIG_STACK_SIZE_PAGE_ORDER=10/g' $(APP_BASE)/.config)
+
+# We need a bigger stack for tests
+LIBRUBY_TEST_PREPARED_DEPS = \
+       $(APP_BASE)/.config.orig \
+
+$(LIBRUBY_TEST_BUILD)/.prepared: $(LIBRUBY_TEST_PREPARED_DEPS)
+
+UK_PREPARE += $(LIBRUBY_TEST_BUILD)/.prepared
+endif
+
index 7bc41965e63cbd2738a8f17b0a51793a046e5b99..1a5ba7e6c97cd0a9c79e1aa7478332a3aa941754 100644 (file)
@@ -100,4 +100,10 @@ void Init_ext(void)
 #if CONFIG_LIBRUBY_EXT_SDBM
     init(Init_sdbm, "sdbm");
 #endif
+
+#if CONFIG_LIBRUBY_TEST
+    /* TODO add more tests */
+    init(Init_file, "-test-/file");
+    init(Init_time, "-test-/time");
+#endif
 }