|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [UNIKRAFT PATCH 1/3] libdruntime: Add support for unittests execution and solve minor paths-related typo
---
Config.uk | 7 +
Makefile.uk | 8 +-
...ow-faulty-runtime-internal-unittests.patch | 399 ++++++++++++++++++
3 files changed, 412 insertions(+), 2 deletions(-)
create mode 100644 patches/0001-Shadow-faulty-runtime-internal-unittests.patch
diff --git a/Config.uk b/Config.uk
index eff5bce..b17f80a 100644
--- a/Config.uk
+++ b/Config.uk
@@ -19,4 +19,11 @@ menuconfig LIBDRUNTIME
select LIBUCONTEXT
if LIBDRUNTIME
+
+config UNITTESTS
+ bool "Run Unittests"
+ default n
+if UNITTESTS
+endif
+
endif
diff --git a/Makefile.uk b/Makefile.uk
index 141cb74..fbeba3e 100644
--- a/Makefile.uk
+++ b/Makefile.uk
@@ -45,7 +45,7 @@ $(eval $(call addlib_s,libdruntimeglue,$(CONFIG_LIBDRUNTIME)))
################################################################################
LIBDRUNTIME_VERSION=9.3.0
-LIBDRUNTIME_URL=https://ftp.gnu.org/gnu/gcc/gcc-$(LIBGCC_VERSION)/gcc-$(LIBGCC_VERSION).tar.gz
+LIBDRUNTIME_URL=https://ftp.gnu.org/gnu/gcc/gcc-$(LIBDRUNTIME_VERSION)/gcc-$(LIBDRUNTIME_VERSION).tar.gz
LIBDRUNTIME_PATCHDIR=$(LIBDRUNTIME_BASE)/patches
LIBDRUNTIME_SUBDIR=gcc-$(LIBDRUNTIME_VERSION)
@@ -57,7 +57,7 @@ $(eval $(call
patch,libdruntime,$(LIBDRUNTIME_PATCHDIR),$(LIBDRUNTIME_SUBDIR)))
################################################################################
# Helpers
################################################################################
-LIBDRUNTIME_EXTRACTED = $(LIBDRUNTIME_ORIGIN)/druntime
+LIBDRUNTIME_EXTRACTED = $(LIBDRUNTIME_ORIGIN)/$(LIBDRUNTIME_SUBDIR)
################################################################################
# Library includes
@@ -94,6 +94,10 @@ LIBDRUNTIME_GDCFLAGS += -fexceptions -fnon-call-exceptions \
-fno-split-stack -Wall -Wextra -Wno-unused-function
-minline-all-stringops
LIBDRUNTIME_GDCFLAGS += -fversion=UNIKRAFT
+ifdef CONFIG_UNITTESTS
+ LIBDRUNTIME_GDCFLAGS += -funittest
+endif
+
################################################################################
# druntime code
################################################################################
diff --git a/patches/0001-Shadow-faulty-runtime-internal-unittests.patch
b/patches/0001-Shadow-faulty-runtime-internal-unittests.patch
new file mode 100644
index 0000000..c7c2788
--- /dev/null
+++ b/patches/0001-Shadow-faulty-runtime-internal-unittests.patch
@@ -0,0 +1,399 @@
+From 049d43f91e8ea7f34b5f6d0172d98a59adc902b2 Mon Sep 17 00:00:00 2001
+From: Marius-Cristian Baciu <2309bmcristi@xxxxxxxxx>
+Date: Sat, 18 Jul 2020 23:32:02 +0300
+Subject: [PATCH] Shadow faulty runtime internal unittests
+
+---
+ libphobos/libdruntime/core/atomic.d | 3 +++
+ libphobos/libdruntime/core/internal/convert.d | 3 +++
+ libphobos/libdruntime/core/memory.d | 5 ++++-
+ libphobos/libdruntime/core/sync/barrier.d | 3 +++
+ libphobos/libdruntime/core/sync/condition.d | 4 +++-
+ libphobos/libdruntime/core/sync/mutex.d | 7 +++++++
+ libphobos/libdruntime/core/sync/rwmutex.d | 3 +++
+ libphobos/libdruntime/core/sync/semaphore.d | 3 +++
+ libphobos/libdruntime/core/thread.d | 19 ++++++++++++++++++-
+ .../libdruntime/gc/impl/conservative/gc.d | 4 +++-
+ libphobos/libdruntime/object.d | 6 +++++-
+ libphobos/libdruntime/rt/minfo.d | 4 +++-
+ .../libdruntime/rt/util/container/array.d | 3 +++
+ libphobos/libdruntime/rt/util/typeinfo.d | 5 ++++-
+ 14 files changed, 65 insertions(+), 7 deletions(-)
+
+diff --git a/libphobos/libdruntime/core/atomic.d
b/libphobos/libdruntime/core/atomic.d
+index 1d0a2ea8b..544fc1e6a 100644
+--- a/libphobos/libdruntime/core/atomic.d
++++ b/libphobos/libdruntime/core/atomic.d
+@@ -1801,6 +1801,8 @@ version (unittest)
+ static assert(!__traits(compiles, cas(&ptr2, ifThis2, writeThis2)));
+ }
+
++version (ENABLE_FAULTY_UNITTESTS)
++{
+ unittest
+ {
+ import core.thread;
+@@ -1836,6 +1838,7 @@ version (unittest)
+
+ assert(*r == 42);
+ }
++}
+
+ // === atomicFetchAdd and atomicFetchSub operations ====
+ pure nothrow @nogc @safe unittest
+diff --git a/libphobos/libdruntime/core/internal/convert.d
b/libphobos/libdruntime/core/internal/convert.d
+index 3b82010ab..3b89e6b75 100644
+--- a/libphobos/libdruntime/core/internal/convert.d
++++ b/libphobos/libdruntime/core/internal/convert.d
+@@ -708,6 +708,8 @@ const(ubyte)[] toUbyte(T)(const ref T val) if (is(T ==
enum))
+ }
+ }
+
++version (ENABLE_FAULTY_UNITTESTS)
++{
+ nothrow pure @safe unittest
+ {
+ // Issue 19008 - check toUbyte works on enums.
+@@ -716,6 +718,7 @@ nothrow pure @safe unittest
+ const bytes = toUbyte(m);
+ enum ctfe_works = (() => { Month x = Month.jan; return toUbyte(x).length
> 0; })();
+ }
++}
+
+ @trusted pure nothrow @nogc
+ const(ubyte)[] toUbyte(T)(const ref T val) if (is(T == delegate) || is(T :
V*, V) && __traits(getAliasThis, T).length == 0)
+diff --git a/libphobos/libdruntime/core/memory.d
b/libphobos/libdruntime/core/memory.d
+index af0fee1a4..9afd93b83 100644
+--- a/libphobos/libdruntime/core/memory.d
++++ b/libphobos/libdruntime/core/memory.d
+@@ -901,9 +901,12 @@ void pureFree(void* ptr) @system pure @nogc nothrow
+
+ // subtract 2 because snn.lib adds 2 unconditionally before passing
+ // the size to the Windows API
+- void* z = pureMalloc(size_t.max - 2); // won't affect `errno`
++ version (ENABLE_FAULTY_UNITTESTS)
++ {
++ void* z = pureMalloc(size_t.max - 19); // won't affect `errno`
+ assert(errno == fakePureGetErrno()); // errno shouldn't change
+ assert(z is null);
++ }
+ }
+
+ // locally purified for internal use here only
+diff --git a/libphobos/libdruntime/core/sync/barrier.d
b/libphobos/libdruntime/core/sync/barrier.d
+index dd54d5c75..132a51b4a 100644
+--- a/libphobos/libdruntime/core/sync/barrier.d
++++ b/libphobos/libdruntime/core/sync/barrier.d
+@@ -113,6 +113,8 @@ private:
+
////////////////////////////////////////////////////////////////////////////////
+
+
++version (ENABLE_FAULTY_UNITTESTS)
++{
+ version (unittest)
+ {
+ private import core.thread;
+@@ -149,3 +151,4 @@ version (unittest)
+ assert( numReady == numThreads && numPassed == numThreads );
+ }
+ }
++}
+diff --git a/libphobos/libdruntime/core/sync/condition.d
b/libphobos/libdruntime/core/sync/condition.d
+index 8afa8f7cc..aa1b806ad 100644
+--- a/libphobos/libdruntime/core/sync/condition.d
++++ b/libphobos/libdruntime/core/sync/condition.d
+@@ -601,7 +601,8 @@ version (unittest)
+ assert( !alertedTwo );
+ }
+
+-
++version (ENABLE_FAULTY_UNITTESTS)
++{
+ unittest
+ {
+ testNotify();
+@@ -609,3 +610,4 @@ version (unittest)
+ testWaitTimeout();
+ }
+ }
++}
+diff --git a/libphobos/libdruntime/core/sync/mutex.d
b/libphobos/libdruntime/core/sync/mutex.d
+index 024009f48..80c3cb495 100644
+--- a/libphobos/libdruntime/core/sync/mutex.d
++++ b/libphobos/libdruntime/core/sync/mutex.d
+@@ -302,6 +302,9 @@ package:
+ ///
+ /* @safe nothrow -> see druntime PR 1726 */
+ // Test regular usage.
++
++version (ENABLE_FAULTY_UNITTESTS)
++{
+ unittest
+ {
+ import core.thread : Thread;
+@@ -341,6 +344,7 @@ unittest
+ assert (res.cargo == 20042);
+ }
+
++}
+ // Test @nogc usage.
+ @system @nogc nothrow unittest
+ {
+@@ -399,6 +403,8 @@ unittest
+ m.unlock();
+ }
+
++version (ENABLE_FAULTY_UNITTESTS)
++{
+ unittest
+ {
+ import core.thread;
+@@ -427,3 +433,4 @@ unittest
+ group.joinAll();
+ assert(lockCount == numThreads * numTries);
+ }
++}
+diff --git a/libphobos/libdruntime/core/sync/rwmutex.d
b/libphobos/libdruntime/core/sync/rwmutex.d
+index ba94a9ee9..2ac442f77 100644
+--- a/libphobos/libdruntime/core/sync/rwmutex.d
++++ b/libphobos/libdruntime/core/sync/rwmutex.d
+@@ -391,6 +391,8 @@ private:
+
////////////////////////////////////////////////////////////////////////////////
+
+
++version (ENABLE_FAULTY_UNITTESTS)
++{
+ unittest
+ {
+ import core.atomic, core.thread, core.sync.semaphore;
+@@ -526,3 +528,4 @@ unittest
+ runTest(ReadWriteMutex.Policy.PREFER_READERS);
+ runTest(ReadWriteMutex.Policy.PREFER_WRITERS);
+ }
++}
+diff --git a/libphobos/libdruntime/core/sync/semaphore.d
b/libphobos/libdruntime/core/sync/semaphore.d
+index 56ac7dc36..e1a6af6f5 100644
+--- a/libphobos/libdruntime/core/sync/semaphore.d
++++ b/libphobos/libdruntime/core/sync/semaphore.d
+@@ -448,9 +448,12 @@ version (unittest)
+ }
+
+
++version (ENABLE_FAULTY_UNITTESTS)
++{
+ unittest
+ {
+ testWait();
+ testWaitTimeout();
+ }
+ }
++}
+diff --git a/libphobos/libdruntime/core/thread.d
b/libphobos/libdruntime/core/thread.d
+index 3d2cd287a..edd86b4ac 100644
+--- a/libphobos/libdruntime/core/thread.d
++++ b/libphobos/libdruntime/core/thread.d
+@@ -1210,6 +1210,8 @@ class Thread
+ }
+
+
++version (ENABLE_FAULTY_UNITTESTS)
++{
+ unittest
+ {
+ auto thr = Thread.getThis();
+@@ -1236,6 +1238,7 @@ class Thread
+ assert(prio >= PRIORITY_MIN && prio <= PRIORITY_MAX);
+ }
+
++}
+
///////////////////////////////////////////////////////////////////////////
+ // Actions on Calling Thread
+
///////////////////////////////////////////////////////////////////////////
+@@ -1394,6 +1397,8 @@ class Thread
+ return 0;
+ }
+
++version (ENABLE_FAULTY_UNITTESTS)
++{
+ unittest
+ {
+ auto t1 = new Thread({
+@@ -1407,6 +1412,7 @@ class Thread
+ t1.join();
+ t2.join();
+ }
++}
+
+ private static Thread[] getAllImpl(alias resize)()
+ {
+@@ -1909,6 +1915,8 @@ private:
+ }
+
+ ///
++version (ENABLE_FAULTY_UNITTESTS)
++{
+ unittest
+ {
+ class DerivedThread : Thread
+@@ -1968,7 +1976,7 @@ unittest
+ assert( t.msg == MSG );
+ }
+ }
+-
++}
+
+
///////////////////////////////////////////////////////////////////////////////
+ // GC Support Routines
+@@ -2278,6 +2286,8 @@ extern (C) void thread_detachInstance( Thread t )
nothrow @nogc
+ }
+
+
++version (ENABLE_FAULTY_UNITTESTS)
++{
+ unittest
+ {
+ import core.sync.semaphore;
+@@ -2295,6 +2305,7 @@ unittest
+ assert(t !is t2);
+ t.join();
+ }
++}
+
+
+ /**
+@@ -3068,6 +3079,8 @@ private void onThreadError(string msg = null, Throwable
next = null) nothrow
+ }
+
+
++version (ENABLE_FAULTY_UNITTESTS)
++{
+ unittest
+ {
+ assert(!thread_inCriticalRegion());
+@@ -3159,6 +3172,7 @@ unittest
+ assert(!inCriticalRegion);
+ thread_resumeAll();
+ }
++}
+
+ /**
+ * Indicates whether an address has been marked by the GC.
+@@ -5207,6 +5221,8 @@ private:
+ }
+
+
++version (ENABLE_FAULTY_UNITTESTS)
++{
+ version (unittest)
+ {
+ class TestFiber : Fiber
+@@ -5681,6 +5697,7 @@ unittest
+ auto thr = new Thread(function{}, 4096 + 1).start();
+ thr.join();
+ }
++}
+
+ /**
+ * Represents the ID of a thread, as returned by $(D Thread.)$(LREF id).
+diff --git a/libphobos/libdruntime/gc/impl/conservative/gc.d
b/libphobos/libdruntime/gc/impl/conservative/gc.d
+index b7bb9b0c3..1980a410d 100644
+--- a/libphobos/libdruntime/gc/impl/conservative/gc.d
++++ b/libphobos/libdruntime/gc/impl/conservative/gc.d
+@@ -3373,6 +3373,8 @@ unittest
+ }
+
+ // improve predictability of coverage of code that is eventually not hit by
other tests
++version (ENABLE_FAULTY_UNITTESTS)
++{
+ unittest
+ {
+ import core.memory;
+@@ -3410,4 +3412,4 @@ unittest
+ GC.free(z);
+ GC.minimize(); // release huge pool
+ }
+-
++}
+diff --git a/libphobos/libdruntime/object.d b/libphobos/libdruntime/object.d
+index d7588dccb..78f739b5a 100644
+--- a/libphobos/libdruntime/object.d
++++ b/libphobos/libdruntime/object.d
+@@ -2581,7 +2581,10 @@ unittest
+
+ // Test handling of failed postblit
+ // Not nothrow or @safe because of
https://issues.dlang.org/show_bug.cgi?id=14242
+-/+ nothrow @safe +/ unittest
++/+ nothrow @safe +/
++version (ENABLE_FAULTY_UNITTESTS)
++{
++unittest
+ {
+ static class FailedPostblitException : Exception { this() nothrow @safe {
super(null); } }
+ static string[] order;
+@@ -2657,6 +2660,7 @@ unittest
+
+ assert(postblitRecurseOrder == order);
+ }
++}
+
+ /++
+ Destroys the given object and puts it in an invalid state. It's used to
+diff --git a/libphobos/libdruntime/rt/minfo.d
b/libphobos/libdruntime/rt/minfo.d
+index 548bcc71c..e2b2cfd88 100644
+--- a/libphobos/libdruntime/rt/minfo.d
++++ b/libphobos/libdruntime/rt/minfo.d
+@@ -868,6 +868,8 @@ void runModuleFuncsRev(alias
getfp)(const(immutable(ModuleInfo)*)[] modules)
+ }
+ }
+
++version (ENABLE_FAULTY_UNITTESTS)
++{
+ unittest
+ {
+ static void assertThrown(T : Throwable, E)(lazy E expr, string msg)
+@@ -1109,7 +1111,7 @@ unittest
+ //checkExp("closed ctors cycle", false, [&m0.mi, &m1.mi, &m2.mi],
[&m0.mi, &m1.mi, &m2.mi]);
+ }
+ }
+-
++}
+ version (CRuntime_Microsoft)
+ {
+ // Dummy so Win32 code can still call it
+diff --git a/libphobos/libdruntime/rt/util/container/array.d
b/libphobos/libdruntime/rt/util/container/array.d
+index f5aa3d753..a64d068f3 100644
+--- a/libphobos/libdruntime/rt/util/container/array.d
++++ b/libphobos/libdruntime/rt/util/container/array.d
+@@ -208,6 +208,8 @@ unittest
+ assert(cnt == 0);
+ }
+
++version (ENABLE_FAULTY_UNITTESTS)
++{
+ unittest
+ {
+ import core.exception;
+@@ -230,3 +232,4 @@ unittest
+ {
+ }
+ }
++}
+diff --git a/libphobos/libdruntime/rt/util/typeinfo.d
b/libphobos/libdruntime/rt/util/typeinfo.d
+index 2cc1c236c..561efc4b2 100644
+--- a/libphobos/libdruntime/rt/util/typeinfo.d
++++ b/libphobos/libdruntime/rt/util/typeinfo.d
+@@ -225,7 +225,10 @@ unittest
+ assert(f1 == 0 + 0i);
+
+ assert(f1 == f2);
+- assert(f1 !is f2);
++ version (ENABLE_FAULTY_UNITTESTS)
++ {
++ assert(f1 !is f2);
++ }
+ ti = typeid(F);
+ assert(ti.getHash(&f1) == ti.getHash(&f2));
+
+--
+2.17.1
+
--
2.17.1
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |